From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web12.12096.1594110507849558750 for ; Tue, 07 Jul 2020 01:28:28 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FHTVox3W; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594110507; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=693jdp7UDg4ilejfFHY/QLq7oDGlTlFUy2AGPPsFJJU=; b=FHTVox3WZezrvecnodkkJ72LG8ytafkG765e9rHr4ouIro+NutzrqGTkXTEyV7jifj9akH l9sS2s89t40sZcp+ks5zBydrYSWrTjRABMxtTw2J5YKQG5As/tDuO04f23ivtVzj7npnD1 0NAOWJOsoL2VWS8WhJYOwyBX0xcXcx0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-149-eH8QwPruO1qEZnNjAeTBWg-1; Tue, 07 Jul 2020 04:28:25 -0400 X-MC-Unique: eH8QwPruO1qEZnNjAeTBWg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 330FE1005510; Tue, 7 Jul 2020 08:28:24 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-90.ams2.redhat.com [10.36.114.90]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0081A60CC0; Tue, 7 Jul 2020 08:28:22 +0000 (UTC) Subject: Re: [PATCH 05/11] OvmfPkg/LsiScsiDxe: Install stubbed EXT_SCSI_PASS_THRU To: Gary Lin , devel@edk2.groups.io Cc: Jordan Justen , Ard Biesheuvel References: <20200701040448.14871-1-glin@suse.com> <20200701040448.14871-6-glin@suse.com> From: "Laszlo Ersek" Message-ID: Date: Tue, 7 Jul 2020 10:28:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200701040448.14871-6-glin@suse.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 07/01/20 06:04, Gary Lin wrote: > Partially implement LsiScsiControllerStart() and LsiScsiControllerStop() > to insert the scaffolding of EXT_SCSI_PASS_THRU functions. > > Cc: Jordan Justen > Cc: Laszlo Ersek > Cc: Ard Biesheuvel > Signed-off-by: Gary Lin > --- > OvmfPkg/LsiScsiDxe/LsiScsi.c | 171 +++++++++++++++++++++++++++++- > OvmfPkg/LsiScsiDxe/LsiScsi.h | 77 ++++++++++++++ > OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf | 3 + > 3 files changed, 250 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/LsiScsiDxe/LsiScsi.c b/OvmfPkg/LsiScsiDxe/LsiScsi.c > index 5bca85bd75eb..f633c6793298 100644 > --- a/OvmfPkg/LsiScsiDxe/LsiScsi.c > +++ b/OvmfPkg/LsiScsiDxe/LsiScsi.c > @@ -11,14 +11,105 @@ > > #include > #include > +#include > +#include > +#include > +#include > #include > #include > #include > #include > +#include > #include > > #include "LsiScsi.h" > > +// > +// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL > +// for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata C, > +// sections > +// - 14.1 SCSI Driver Model Overview, > +// - 14.7 Extended SCSI Pass Thru Protocol. > +// > + > +EFI_STATUS > +EFIAPI > +LsiScsiPassThru ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN UINT8 *Target, > + IN UINT64 Lun, > + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, > + IN EFI_EVENT Event OPTIONAL > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +EFI_STATUS > +EFIAPI > +LsiScsiGetNextTargetLun ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN OUT UINT8 **TargetPointer, > + IN OUT UINT64 *Lun > + ) > +{ > + return EFI_NOT_FOUND; > +} > + > +EFI_STATUS > +EFIAPI > +LsiScsiBuildDevicePath ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN UINT8 *Target, > + IN UINT64 Lun, > + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath > + ) > +{ > + return EFI_NOT_FOUND; > +} > + > +EFI_STATUS > +EFIAPI > +LsiScsiGetTargetLun ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, > + OUT UINT8 **TargetPointer, > + OUT UINT64 *Lun > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +EFI_STATUS > +EFIAPI > +LsiScsiResetChannel ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +EFI_STATUS > +EFIAPI > +LsiScsiResetTargetLun ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN UINT8 *Target, > + IN UINT64 Lun > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +EFI_STATUS > +EFIAPI > +LsiScsiGetNextTarget ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN OUT UINT8 **TargetPointer > + ) > +{ > + return EFI_NOT_FOUND; > +} > + > // > // Probe, start and stop functions of this driver, called by the DXE core for > // specific devices. > @@ -88,7 +179,49 @@ LsiScsiControllerStart ( > IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL > ) > { > + EFI_STATUS Status; > + LSI_SCSI_DEV *Dev; > + > + Dev = AllocateZeroPool (sizeof (*Dev)); > + if (Dev == NULL) { > + return EFI_OUT_OF_RESOURCES; > + } > + > + Dev->Signature = LSI_SCSI_DEV_SIGNATURE; > + > + // > + // Host adapter channel, doesn't exist > + // > + Dev->PassThruMode.AdapterId = MAX_UINT32; > + Dev->PassThruMode.Attributes = > + EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL | > + EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL; > + > + Dev->PassThru.Mode = &Dev->PassThruMode; > + Dev->PassThru.PassThru = &LsiScsiPassThru; > + Dev->PassThru.GetNextTargetLun = &LsiScsiGetNextTargetLun; > + Dev->PassThru.BuildDevicePath = &LsiScsiBuildDevicePath; > + Dev->PassThru.GetTargetLun = &LsiScsiGetTargetLun; > + Dev->PassThru.ResetChannel = &LsiScsiResetChannel; > + Dev->PassThru.ResetTargetLun = &LsiScsiResetTargetLun; > + Dev->PassThru.GetNextTarget = &LsiScsiGetNextTarget; > + > + Status = gBS->InstallProtocolInterface ( > + &ControllerHandle, > + &gEfiExtScsiPassThruProtocolGuid, > + EFI_NATIVE_INTERFACE, > + &Dev->PassThru > + ); > + if (EFI_ERROR (Status)) { > + goto FreePool; > + } > + > return EFI_SUCCESS; > + > +FreePool: > + FreePool (Dev); > + > + return Status; > } > > EFI_STATUS > @@ -100,7 +233,43 @@ LsiScsiControllerStop ( > IN EFI_HANDLE *ChildHandleBuffer > ) > { > - return EFI_SUCCESS; > + EFI_STATUS Status; > + EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru; > + LSI_SCSI_DEV *Dev; > + > + Status = gBS->OpenProtocol ( > + ControllerHandle, > + &gEfiExtScsiPassThruProtocolGuid, > + (VOID **)&PassThru, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_GET_PROTOCOL // Lookup only > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Dev = LSI_SCSI_FROM_PASS_THRU (PassThru); > + > + Status = gBS->UninstallProtocolInterface ( > + ControllerHandle, > + &gEfiExtScsiPassThruProtocolGuid, > + &Dev->PassThru > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + gBS->CloseProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + ControllerHandle > + ); (1) This CloseProtocol() call does not belong in this patch. In this patch, the Start() function doesn't open the PCI IO protocol yet. Please move the CloseProtocol() call to the following patch: [PATCH 07/11] OvmfPkg/LsiScsiDxe: Open PciIo protocol and initialize the device with that: Reviewed-by: Laszlo Ersek Thanks Laszlo > + > + FreePool (Dev); > + > + return Status; > } > > // > diff --git a/OvmfPkg/LsiScsiDxe/LsiScsi.h b/OvmfPkg/LsiScsiDxe/LsiScsi.h > index 00db9ada12d2..fca1007f9b98 100644 > --- a/OvmfPkg/LsiScsiDxe/LsiScsi.h > +++ b/OvmfPkg/LsiScsiDxe/LsiScsi.h > @@ -12,6 +12,17 @@ > #ifndef _LSI_SCSI_DXE_H_ > #define _LSI_SCSI_DXE_H_ > > +typedef struct { > + UINT32 Signature; > + EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; > + EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; > +} LSI_SCSI_DEV; > + > +#define LSI_SCSI_DEV_SIGNATURE SIGNATURE_32 ('L','S','I','S') > + > +#define LSI_SCSI_FROM_PASS_THRU(PassThruPtr) \ > + CR (PassThruPtr, LSI_SCSI_DEV, PassThru, LSI_SCSI_DEV_SIGNATURE) > + > // > // Probe, start and stop functions of this driver, called by the DXE core for > // specific devices. > @@ -48,6 +59,72 @@ LsiScsiControllerStop ( > ); > > > +// > +// The next seven functions implement EFI_EXT_SCSI_PASS_THRU_PROTOCOL > +// for the LSI 53C895A SCSI Controller. Refer to UEFI Spec 2.3.1 + Errata C, > +// sections > +// - 14.1 SCSI Driver Model Overview, > +// - 14.7 Extended SCSI Pass Thru Protocol. > +// > + > +EFI_STATUS > +EFIAPI > +LsiScsiPassThru ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN UINT8 *Target, > + IN UINT64 Lun, > + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, > + IN EFI_EVENT Event OPTIONAL > + ); > + > +EFI_STATUS > +EFIAPI > +LsiScsiGetNextTargetLun ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN OUT UINT8 **TargetPointer, > + IN OUT UINT64 *Lun > + ); > + > +EFI_STATUS > +EFIAPI > +LsiScsiBuildDevicePath ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN UINT8 *Target, > + IN UINT64 Lun, > + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath > + ); > + > +EFI_STATUS > +EFIAPI > +LsiScsiGetTargetLun ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, > + OUT UINT8 **TargetPointer, > + OUT UINT64 *Lun > + ); > + > +EFI_STATUS > +EFIAPI > +LsiScsiResetChannel ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This > + ); > + > +EFI_STATUS > +EFIAPI > +LsiScsiResetTargetLun ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN UINT8 *Target, > + IN UINT64 Lun > + ); > + > +EFI_STATUS > +EFIAPI > +LsiScsiGetNextTarget ( > + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, > + IN OUT UINT8 **TargetPointer > + ); > + > + > // > // The purpose of the following scaffolding (EFI_COMPONENT_NAME_PROTOCOL and > // EFI_COMPONENT_NAME2_PROTOCOL implementation) is to format the driver's name > diff --git a/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf b/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf > index e86c626a61aa..8660513e2ffd 100644 > --- a/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf > +++ b/OvmfPkg/LsiScsiDxe/LsiScsiDxe.inf > @@ -26,9 +26,12 @@ [Packages] > > [LibraryClasses] > BaseLib > + BaseMemoryLib > + MemoryAllocationLib > UefiBootServicesTableLib > UefiDriverEntryPoint > UefiLib > > [Protocols] > + gEfiExtScsiPassThruProtocolGuid ## BY_START > gEfiPciIoProtocolGuid ## TO_START >