A while loop in SCSIBusDriverBindingStart() is supposed to scan all the possible Puns in the SCSI channel by calling ScsiScanCreateDevice() for each of them. Therefore, we should not abort the loop even when one of the Puns is disconnected.
The following is one of the scenarios. SCSIBusDriverBindingStart() > ScsiScanCreateDevice() > DiscoverScsiDevice() > ScsiInquiryCommand() > ... > ParseResponse() When virtio-scsi returns VIRTIO_SCSI_S_BAD_TARGET, ParseResponse() in VirtioScsi.c will return EFI_TIMEOUT: case VIRTIO_SCSI_S_BAD_TARGET: // // This is non-intuitive but explicitly required by the // EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() specification for // disconnected (but otherwise valid) target / LUN addresses. // Packet->HostAdapterStatus = EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND; return EFI_TIMEOUT; This will eventually cause DiscoverScsiDevice() to return FALSE, which will cause ScsiScanCreateDevice() to return EFI_OUT_OF_RESOURCES: if (!DiscoverScsiDevice (ScsiIoDevice)) { Status = EFI_OUT_OF_RESOURCES; goto ErrorExit; } In sum, "disconnected (but otherwise valid) target / LUN addresses" can result in EFI_OUT_OF_RESOURCES and when this happens the while loop in SCSIBusDriverBindingStart() should continue, not abort. Without this fix, the loop can terminate prematurely with good devices not having a chance to be discovered. If this good device is the boot device, boot will fail. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Hao A Wu <hao.a...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Sivaparvathi chellaiah <sivaparvat...@ami.com> Signed-off-by: Yuan Yu <yua...@google.com> --- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c index fbe14c772496..2ed816da4abe 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c +++ b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c @@ -533,9 +533,6 @@ SCSIBusDriverBindingStart ( // then create handle and install scsi i/o protocol. // Status = ScsiScanCreateDevice (This, Controller, &ScsiTargetId, Lun, ScsiBusDev); - if (Status == EFI_OUT_OF_RESOURCES) { - goto ErrorExit; - } } return EFI_SUCCESS; -- 2.39.0.314.g84b9a713c41-goog -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98784): https://edk2.groups.io/g/devel/message/98784 Mute This Topic: https://groups.io/mt/96350422/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-