From: "Nikita Leshenko" <nikita.leshchenko@oracle.com>
To: devel@edk2.groups.io
Cc: liran.alon@oracle.com, aaron.young@oracle.com,
jordan.l.justen@intel.com, lersek@redhat.com,
ard.biesheuvel@linaro.org,
Nikita Leshenko <nikita.leshchenko@oracle.com>
Subject: [PATCH v2 10/13] OvmfPkg/MptScsiDxe: Set and restore PCI attributes
Date: Wed, 26 Feb 2020 18:41:48 +0200 [thread overview]
Message-ID: <20200226164151.125182-11-nikita.leshchenko@oracle.com> (raw)
In-Reply-To: <20200226164151.125182-1-nikita.leshchenko@oracle.com>
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
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Aaron Young <aaron.young@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
---
OvmfPkg/MptScsiDxe/MptScsi.c | 44 ++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c
index 22001da763..f5f774e431 100644
--- a/OvmfPkg/MptScsiDxe/MptScsi.c
+++ b/OvmfPkg/MptScsiDxe/MptScsi.c
@@ -41,6 +41,7 @@ typedef struct {
EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru;
EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode;
EFI_PCI_IO_PROTOCOL *PciIo;
+ UINT64 OriginalPciAttributes;
} MPT_SCSI_DEV;
#define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \
@@ -263,6 +264,7 @@ MptScsiControllerStart (
{
EFI_STATUS Status;
MPT_SCSI_DEV *Dev;
+ BOOLEAN PciAttributesChanged;
Dev = AllocateZeroPool (sizeof (*Dev));
if (Dev == NULL) {
@@ -270,6 +272,7 @@ MptScsiControllerStart (
}
Dev->Signature = MPT_SCSI_DEV_SIGNATURE;
+ PciAttributesChanged = FALSE;
Status = gBS->OpenProtocol (
ControllerHandle,
@@ -283,6 +286,31 @@ MptScsiControllerStart (
goto Done;
}
+ Status = Dev->PciIo->Attributes (
+ Dev->PciIo,
+ EfiPciIoAttributeOperationGet,
+ 0,
+ &Dev->OriginalPciAttributes
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // 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 Done;
+ }
+ PciAttributesChanged = TRUE;
+
//
// Host adapter channel, doesn't exist
//
@@ -312,6 +340,15 @@ MptScsiControllerStart (
Done:
if (EFI_ERROR (Status)) {
+ if (PciAttributesChanged) {
+ Dev->PciIo->Attributes (
+ Dev->PciIo,
+ EfiPciIoAttributeOperationEnable,
+ Dev->OriginalPciAttributes,
+ NULL
+ );
+ }
+
if (Dev->PciIo) {
gBS->CloseProtocol (
ControllerHandle,
@@ -361,6 +398,13 @@ MptScsiControllerStop (
&Dev->PassThru
);
+ Dev->PciIo->Attributes (
+ Dev->PciIo,
+ EfiPciIoAttributeOperationEnable,
+ Dev->OriginalPciAttributes,
+ NULL
+ );
+
gBS->CloseProtocol (
ControllerHandle,
&gEfiPciIoProtocolGuid,
--
2.20.1
next prev parent reply other threads:[~2020-02-26 16:40 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 16:41 [PATCH v2 00/13] OvmfPkg: Support booting from Fusion-MPT SCSI controllers Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 01/13] OvmfPkg/MptScsiDxe: Create empty driver Nikita Leshenko
2020-02-28 8:12 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 02/13] OvmfPkg/MptScsiDxe: Install DriverBinding Protocol Nikita Leshenko
2020-02-28 8:16 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 03/13] OvmfPkg/MptScsiDxe: Report name of driver Nikita Leshenko
2020-02-28 8:17 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 04/13] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi Nikita Leshenko
2020-02-28 8:26 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 05/13] OvmfPkg/MptScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Nikita Leshenko
2020-02-28 8:35 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 06/13] OvmfPkg/MptScsiDxe: Report one Target and one LUN Nikita Leshenko
2020-02-28 8:41 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 07/13] OvmfPkg/MptScsiDxe: Build DevicePath for discovered devices Nikita Leshenko
2020-02-28 9:03 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 08/13] OvmfPkg/MptScsiDxe: Implement GetTargetLun Nikita Leshenko
2020-02-28 9:16 ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 09/13] OvmfPkg/MptScsiDxe: Open PciIo protocol for later use Nikita Leshenko
2020-02-28 9:50 ` Laszlo Ersek
2020-02-28 9:53 ` Laszlo Ersek
2020-02-26 16:41 ` Nikita Leshenko [this message]
2020-02-26 16:41 ` [PATCH v2 11/13] OvmfPkg/MptScsiDxe: Initialize hardware Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 12/13] OvmfPkg/MptScsiDxe: Implement the PassThru method Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 13/13] OvmfPkg/MptScsiDxe: Report multiple targets Nikita Leshenko
2020-02-27 9:52 ` [edk2-devel] [PATCH v2 00/13] OvmfPkg: Support booting from Fusion-MPT SCSI controllers Laszlo Ersek
2020-02-28 7:51 ` Laszlo Ersek
2020-02-28 8:06 ` Laszlo Ersek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200226164151.125182-11-nikita.leshchenko@oracle.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox