-
Notifications
You must be signed in to change notification settings - Fork 427
sync with the latest downstream viostor and vioscsi related changes #1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4cc1831
7b9c6bd
939cac4
0686f2c
410f21f
798b688
70c568d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1025,7 +1025,7 @@ VioScsiInterrupt(IN PVOID DeviceExtension) | |
| } | ||
| else | ||
| { | ||
| ProcessBuffer(DeviceExtension, QUEUE_TO_MESSAGE(VIRTIO_SCSI_REQUEST_QUEUE_0), InterruptLock); | ||
| ProcessQueue(DeviceExtension, QUEUE_TO_MESSAGE(VIRTIO_SCSI_REQUEST_QUEUE_0), TRUE); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1254,17 +1254,17 @@ VioScsiUnitControl(IN PVOID DeviceExtension, IN SCSI_UNIT_CONTROL_TYPE ControlTy | |
| break; | ||
| case ScsiUnitRemove: | ||
| case ScsiUnitSurpriseRemoval: | ||
| ULONG vq_req_idx; | ||
| PREQUEST_LIST element; | ||
| ULONG QueuNum; | ||
| ULONG MsgId; | ||
|
Comment on lines
+1257
to
+1258
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for typo -1 for renaming MsgId |
||
| STOR_LOCK_HANDLE LockHandle = {0}; | ||
| PVOID LockContext = NULL; // sanity check for LockMode = InterruptLock or StartIoLock | ||
| PSTOR_ADDR_BTL8 stor_addr = (PSTOR_ADDR_BTL8)Parameters; | ||
|
|
||
| for (vq_req_idx = 0; vq_req_idx < adaptExt->num_queues; vq_req_idx++) | ||
| for (index = 0; index < adaptExt->num_queues; index++) | ||
| { | ||
| element = &adaptExt->processing_srbs[vq_req_idx]; | ||
| LockContext = &adaptExt->dpc[vq_req_idx]; | ||
| StorPortAcquireSpinLock(DeviceExtension, DpcLock, LockContext, &LockHandle); | ||
| PREQUEST_LIST element = &adaptExt->processing_srbs[index]; | ||
| QueuNum = index + VIRTIO_SCSI_REQUEST_QUEUE_0; | ||
| MsgId = QUEUE_TO_MESSAGE(QueuNum); | ||
| VioScsiVQLock(DeviceExtension, MsgId, &LockHandle, FALSE); | ||
| if (!IsListEmpty(&element->srb_list)) | ||
| { | ||
| PLIST_ENTRY entry = element->srb_list.Flink; | ||
|
|
@@ -1276,6 +1276,7 @@ VioScsiUnitControl(IN PVOID DeviceExtension, IN SCSI_UNIT_CONTROL_TYPE ControlTy | |
| SRB_LUN(currSrb) == stor_addr->Lun) | ||
| { | ||
| SRB_SET_SRB_STATUS(currSrb, SRB_STATUS_NO_DEVICE); | ||
| SRB_SET_DATA_TRANSFER_LENGTH(currSrb, 0); | ||
| CompleteRequest(DeviceExtension, (PSRB_TYPE)currSrb); | ||
| RhelDbgPrint(TRACE_LEVEL_INFORMATION, | ||
| " Complete pending I/Os on Path %d Target %d Lun %d \n", | ||
|
|
@@ -1287,7 +1288,7 @@ VioScsiUnitControl(IN PVOID DeviceExtension, IN SCSI_UNIT_CONTROL_TYPE ControlTy | |
| entry = entry->Flink; | ||
| } | ||
| } | ||
| StorPortReleaseSpinLock(DeviceExtension, &LockHandle); | ||
| VioScsiVQUnlock(DeviceExtension, MsgId, &LockHandle, FALSE); | ||
| } | ||
| Status = ScsiUnitControlSuccess; | ||
| break; | ||
|
|
@@ -1326,6 +1327,7 @@ VioScsiBuildIo(IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb) | |
| (Lun >= adaptExt->scsi_config.max_lun) || adaptExt->bRemoved) | ||
| { | ||
| SRB_SET_SRB_STATUS(Srb, SRB_STATUS_NO_DEVICE); | ||
| SRB_SET_DATA_TRANSFER_LENGTH(Srb, 0); | ||
| StorPortNotification(RequestComplete, DeviceExtension, Srb); | ||
| return FALSE; | ||
| } | ||
|
|
@@ -1432,41 +1434,31 @@ VOID FORCEINLINE DispatchQueue(IN PVOID DeviceExtension, IN ULONG MessageId) | |
| EXIT_FN(); | ||
| return; | ||
| } | ||
| ProcessBuffer(DeviceExtension, MessageId, InterruptLock); | ||
| ProcessQueue(DeviceExtension, MessageId, TRUE); | ||
| EXIT_FN(); | ||
| } | ||
|
|
||
| VOID ProcessBuffer(IN PVOID DeviceExtension, IN ULONG MessageId, IN STOR_SPINLOCK LockMode) | ||
| VOID ProcessQueue(IN PVOID DeviceExtension, IN ULONG MessageID, IN BOOLEAN isr) | ||
| { | ||
| ULONG_PTR srbId; | ||
| unsigned int len; | ||
| PADAPTER_EXTENSION adaptExt = (PADAPTER_EXTENSION)DeviceExtension; | ||
| ULONG QueueNumber = MESSAGE_TO_QUEUE(MessageId); | ||
| STOR_LOCK_HANDLE LockHandle = {0}; | ||
| ULONG index = MESSAGE_TO_QUEUE(MessageID); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| STOR_LOCK_HANDLE queueLock = {0}; | ||
| struct virtqueue *vq; | ||
| PSRB_EXTENSION srbExt = NULL; | ||
| PREQUEST_LIST element; | ||
| ULONG vq_req_idx; | ||
| PVOID LockContext = NULL; // sanity check for LockMode = InterruptLock or StartIoLock | ||
|
|
||
| ENTER_FN(); | ||
|
|
||
| if (QueueNumber >= (adaptExt->num_queues + VIRTIO_SCSI_REQUEST_QUEUE_0)) | ||
| if (index >= (adaptExt->num_queues + VIRTIO_SCSI_REQUEST_QUEUE_0)) | ||
| { | ||
| RhelDbgPrint(TRACE_LEVEL_VERBOSE, | ||
| " Modulo assignment required for QueueNumber as it exceeds the number of virtqueues available.\n"); | ||
| QueueNumber %= adaptExt->num_queues; | ||
| index %= adaptExt->num_queues; | ||
| } | ||
| vq_req_idx = QueueNumber - VIRTIO_SCSI_REQUEST_QUEUE_0; | ||
| element = &adaptExt->processing_srbs[vq_req_idx]; | ||
|
|
||
| vq = adaptExt->vq[QueueNumber]; | ||
| PREQUEST_LIST element = &adaptExt->processing_srbs[index - VIRTIO_SCSI_REQUEST_QUEUE_0]; | ||
| vq = adaptExt->vq[index]; | ||
|
|
||
| if (LockMode == DpcLock) | ||
| { | ||
| LockContext = &adaptExt->dpc[vq_req_idx]; | ||
| } | ||
| StorPortAcquireSpinLock(DeviceExtension, LockMode, LockContext, &LockHandle); | ||
| VioScsiVQLock(DeviceExtension, MessageID, &queueLock, isr); | ||
|
|
||
| do | ||
| { | ||
|
|
@@ -1500,7 +1492,7 @@ VOID ProcessBuffer(IN PVOID DeviceExtension, IN ULONG MessageId, IN STOR_SPINLOC | |
| } | ||
| } while (!virtqueue_enable_cb(vq)); | ||
|
|
||
| StorPortReleaseSpinLock(DeviceExtension, &LockHandle); | ||
| VioScsiVQUnlock(DeviceExtension, MessageID, &queueLock, isr); | ||
|
|
||
| EXIT_FN(); | ||
| } | ||
|
|
@@ -1511,18 +1503,15 @@ VOID VioScsiCompleteDpcRoutine(IN PSTOR_DPC Dpc, IN PVOID Context, IN PVOID Syst | |
|
|
||
| ENTER_FN(); | ||
| MessageId = PtrToUlong(SystemArgument1); | ||
| ProcessBuffer(Context, MessageId, DpcLock); | ||
| ProcessQueue(Context, MessageId, FALSE); | ||
| EXIT_FN(); | ||
| } | ||
|
|
||
| VOID CompletePendingRequestsOnReset(IN PVOID DeviceExtension) | ||
| { | ||
| PADAPTER_EXTENSION adaptExt; | ||
| ULONG QueueNumber; | ||
| ULONG vq_req_idx; | ||
| PREQUEST_LIST element; | ||
| STOR_LOCK_HANDLE LockHandle = {0}; | ||
| PVOID LockContext = NULL; // sanity check for LockMode = InterruptLock or StartIoLock | ||
| ULONG QueueNum; | ||
| ULONG MsgId; | ||
|
Comment on lines
+1513
to
+1514
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| adaptExt = (PADAPTER_EXTENSION)DeviceExtension; | ||
|
|
||
|
|
@@ -1532,12 +1521,14 @@ VOID CompletePendingRequestsOnReset(IN PVOID DeviceExtension) | |
| StorPortPause(DeviceExtension, 10); | ||
| DeviceReset(DeviceExtension); | ||
|
|
||
| for (vq_req_idx = 0; vq_req_idx < adaptExt->num_queues; vq_req_idx++) | ||
| for (ULONG index = 0; index < adaptExt->num_queues; index++) | ||
| { | ||
| element = &adaptExt->processing_srbs[vq_req_idx]; | ||
| RhelDbgPrint(TRACE_LEVEL_FATAL, " queue %d cnt %d\n", vq_req_idx, element->srb_cnt); | ||
| LockContext = &adaptExt->dpc[vq_req_idx]; | ||
| StorPortAcquireSpinLock(DeviceExtension, DpcLock, LockContext, &LockHandle); | ||
| PREQUEST_LIST element = &adaptExt->processing_srbs[index]; | ||
| STOR_LOCK_HANDLE LockHandle = {0}; | ||
| RhelDbgPrint(TRACE_LEVEL_FATAL, " queue %d cnt %d\n", index, element->srb_cnt); | ||
| QueueNum = index + VIRTIO_SCSI_REQUEST_QUEUE_0; | ||
| MsgId = QUEUE_TO_MESSAGE(QueueNum); | ||
| VioScsiVQLock(DeviceExtension, MsgId, &LockHandle, FALSE); | ||
| while (!IsListEmpty(&element->srb_list)) | ||
| { | ||
| PLIST_ENTRY entry = RemoveHeadList(&element->srb_list); | ||
|
|
@@ -1548,6 +1539,7 @@ VOID CompletePendingRequestsOnReset(IN PVOID DeviceExtension) | |
| if (currSrb) | ||
| { | ||
| SRB_SET_SRB_STATUS(currSrb, SRB_STATUS_BUS_RESET); | ||
| SRB_SET_DATA_TRANSFER_LENGTH(currSrb, 0); | ||
| CompleteRequest(DeviceExtension, (PSRB_TYPE)currSrb); | ||
| element->srb_cnt--; | ||
| } | ||
|
|
@@ -1557,7 +1549,7 @@ VOID CompletePendingRequestsOnReset(IN PVOID DeviceExtension) | |
| { | ||
| element->srb_cnt = 0; | ||
| } | ||
| StorPortReleaseSpinLock(DeviceExtension, &LockHandle); | ||
| VioScsiVQUnlock(DeviceExtension, MsgId, &LockHandle, FALSE); | ||
| } | ||
| StorPortResume(DeviceExtension); | ||
| } | ||
|
|
@@ -1935,6 +1927,7 @@ VOID VioScsiIoControl(IN PVOID DeviceExtension, IN OUT PSRB_TYPE Srb) | |
| break; | ||
| default: | ||
| SRB_SET_SRB_STATUS(Srb, SRB_STATUS_INVALID_REQUEST); | ||
| SRB_SET_DATA_TRANSFER_LENGTH(Srb, 0); | ||
| RhelDbgPrint(TRACE_LEVEL_INFORMATION, " <--> Unsupport control code 0x%x\n", srbControl->ControlCode); | ||
| break; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
MessageIDparameter is unused in this function. Consider removing it from the function signature to improve code clarity. This change would also need to be applied to the function declaration invioscsi/helper.hand all call sites.