mirror of https://github.com/acidanthera/audk.git
OvmfPkg/MptScsiDxe: Set and restore PCI attributes
Enable the IO Space and Bus Mastering and restore the original values when the device is stopped. This is a standard procedure in PCI drivers. 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-10-nikita.leshchenko@oracle.com>
This commit is contained in:
parent
da8c0b8f4d
commit
ecdbdba636
|
@ -38,6 +38,7 @@ typedef struct {
|
||||||
EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
|
EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
|
||||||
UINT8 MaxTarget;
|
UINT8 MaxTarget;
|
||||||
EFI_PCI_IO_PROTOCOL *PciIo;
|
EFI_PCI_IO_PROTOCOL *PciIo;
|
||||||
|
UINT64 OriginalPciAttributes;
|
||||||
} MPT_SCSI_DEV;
|
} MPT_SCSI_DEV;
|
||||||
|
|
||||||
#define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \
|
#define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \
|
||||||
|
@ -335,6 +336,53 @@ MptScsiControllerStart (
|
||||||
goto FreePool;
|
goto FreePool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status = Dev->PciIo->Attributes (
|
||||||
|
Dev->PciIo,
|
||||||
|
EfiPciIoAttributeOperationGet,
|
||||||
|
0,
|
||||||
|
&Dev->OriginalPciAttributes
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto CloseProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Enable I/O Space & Bus-Mastering
|
||||||
|
//
|
||||||
|
Status = Dev->PciIo->Attributes (
|
||||||
|
Dev->PciIo,
|
||||||
|
EfiPciIoAttributeOperationEnable,
|
||||||
|
(EFI_PCI_IO_ATTRIBUTE_IO |
|
||||||
|
EFI_PCI_IO_ATTRIBUTE_BUS_MASTER),
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
goto CloseProtocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Signal device supports 64-bit DMA addresses
|
||||||
|
//
|
||||||
|
Status = Dev->PciIo->Attributes (
|
||||||
|
Dev->PciIo,
|
||||||
|
EfiPciIoAttributeOperationEnable,
|
||||||
|
EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// Warn user that device will only be using 32-bit DMA addresses.
|
||||||
|
//
|
||||||
|
// Note that this does not prevent the device/driver from working
|
||||||
|
// and therefore we only warn and continue as usual.
|
||||||
|
//
|
||||||
|
DEBUG ((
|
||||||
|
DEBUG_WARN,
|
||||||
|
"%a: failed to enable 64-bit DMA addresses\n",
|
||||||
|
__FUNCTION__
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Host adapter channel, doesn't exist
|
// Host adapter channel, doesn't exist
|
||||||
//
|
//
|
||||||
|
@ -359,11 +407,19 @@ MptScsiControllerStart (
|
||||||
&Dev->PassThru
|
&Dev->PassThru
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto CloseProtocol;
|
goto RestoreAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
RestoreAttributes:
|
||||||
|
Dev->PciIo->Attributes (
|
||||||
|
Dev->PciIo,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
Dev->OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
CloseProtocol:
|
CloseProtocol:
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
|
@ -415,6 +471,13 @@ MptScsiControllerStop (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dev->PciIo->Attributes (
|
||||||
|
Dev->PciIo,
|
||||||
|
EfiPciIoAttributeOperationSet,
|
||||||
|
Dev->OriginalPciAttributes,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
&gEfiPciIoProtocolGuid,
|
&gEfiPciIoProtocolGuid,
|
||||||
|
|
Loading…
Reference in New Issue