summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/MptScsiDxe
diff options
context:
space:
mode:
authorNikita Leshenko <nikita.leshchenko@oracle.com>2020-05-05 00:06:03 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-05-05 20:43:02 +0000
commitda8c0b8f4d2df23de249580a595afea76b5185fd (patch)
tree4721d6fd92adba84ecab138e2b1f4a17b226b7c6 /OvmfPkg/MptScsiDxe
parentf9941d31dd6f95ca7557d5a5f2c1874bd3bd0e14 (diff)
downloadedk2-da8c0b8f4d2df23de249580a595afea76b5185fd.tar.gz
edk2-da8c0b8f4d2df23de249580a595afea76b5185fd.tar.bz2
edk2-da8c0b8f4d2df23de249580a595afea76b5185fd.zip
OvmfPkg/MptScsiDxe: Open PciIo protocol for later use
This will give us an exclusive access to the PciIo of this device after it was started and until is will be stopped. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com> Reviewed-by: Liran Alon <liran.alon@oracle.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20200504210607.144434-9-nikita.leshchenko@oracle.com>
Diffstat (limited to 'OvmfPkg/MptScsiDxe')
-rw-r--r--OvmfPkg/MptScsiDxe/MptScsi.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c
index 66d57f1c85..3dfc78cf2e 100644
--- a/OvmfPkg/MptScsiDxe/MptScsi.c
+++ b/OvmfPkg/MptScsiDxe/MptScsi.c
@@ -37,6 +37,7 @@ typedef struct {
EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
UINT8 MaxTarget;
+ EFI_PCI_IO_PROTOCOL *PciIo;
} MPT_SCSI_DEV;
#define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \
@@ -322,6 +323,18 @@ MptScsiControllerStart (
Dev->MaxTarget = PcdGet8 (PcdMptScsiMaxTargetLimit);
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ &gEfiPciIoProtocolGuid,
+ (VOID **)&Dev->PciIo,
+ This->DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (EFI_ERROR (Status)) {
+ goto FreePool;
+ }
+
//
// Host adapter channel, doesn't exist
//
@@ -346,11 +359,19 @@ MptScsiControllerStart (
&Dev->PassThru
);
if (EFI_ERROR (Status)) {
- goto FreePool;
+ goto CloseProtocol;
}
return EFI_SUCCESS;
+CloseProtocol:
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+
FreePool:
FreePool (Dev);
@@ -394,6 +415,13 @@ MptScsiControllerStop (
return Status;
}
+ gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+
FreePool (Dev);
return Status;