From nobody Tue Feb 10 06:58:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+54909+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54909+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1582739410; cv=none; d=zohomail.com; s=zohoarc; b=TKwr2YJ4Nhbwo3el0dUiNIrk7NwutJbKDaEHwIjRy1At03Ts/GYdtuZinin+OvcHxOlpElqi7CpenVvVJyuQvU8PwVMP8JpoW4LrJHaON0EgBuhOGYkmki+nVTsCEythZ55xWBUjGmh9yXWgXypUX8XMGt/A8LmI7n9EBn4mnhA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582739410; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qIV7ZgVVuw1pZQCh7nfzAC4CZYz9d+S5N5kSbTFfNQU=; b=mfTseXH8gKBsVW4renQDZyVOeNnKWvgA8XhIpOXvFlGMF5tn3KC77t9obprZ9cQGJETZHZKguc4JXGtmnLAuZFPDepr44luLyV3hFgG8sy9TAdPPkxfkq0Vf14L/SY1AylsucqpdQ5w1MNJP1e6oEN7ZidtauSw0gLQGapxMhEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54909+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 15827394104251021.6531440726425; Wed, 26 Feb 2020 09:50:10 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id FpIHYY1788612xy04VirtTIJ; Wed, 26 Feb 2020 09:50:09 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web12.10856.1582735243652730726 for ; Wed, 26 Feb 2020 08:40:43 -0800 X-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01QGNlCx060221; Wed, 26 Feb 2020 16:40:43 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2ydcsrmwab-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2020 16:40:43 +0000 X-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01QGMHd6015528; Wed, 26 Feb 2020 16:40:42 GMT X-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2ydcs5ffyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 26 Feb 2020 16:40:42 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 01QGefNP013199; Wed, 26 Feb 2020 16:40:41 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 26 Feb 2020 08:40:41 -0800 From: "Nikita Leshenko" 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 Subject: [edk2-devel] [PATCH v2 10/13] OvmfPkg/MptScsiDxe: Set and restore PCI attributes Date: Wed, 26 Feb 2020 18:41:48 +0200 Message-Id: <20200226164151.125182-11-nikita.leshchenko@oracle.com> In-Reply-To: <20200226164151.125182-1-nikita.leshchenko@oracle.com> References: <20200226164151.125182-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nikita.leshchenko@oracle.com X-Gm-Message-State: 9XyrRvxMz7lQk3iw5XoE43AWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1582739409; bh=qIGTbIbCXQlGZYpYn12VT1jiNuvqom6G38TKKTbZCkk=; h=Cc:Date:From:Reply-To:Subject:To; b=gES3Hw/KDqAuvgP/i/R2b5f0ElGTCMGJODE7tG1ZgdVKRI7jLbA/mtX2hNY1OX6o9/2 nZxX7PsvguQ89XxeDi+JiZ7Xw/pp+mwPy9q3aN/fiDPqWy2ZnH/hMmxgV3/Z7a+TMkIQy +ZOA+uerboqbfbR3HhmHTRj7yYaz4qUAT9I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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=3D2390 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Nikita Leshenko Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Aaron Young Reviewed-by: Liran Alon --- 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; =20 #define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \ @@ -263,6 +264,7 @@ MptScsiControllerStart ( { EFI_STATUS Status; MPT_SCSI_DEV *Dev; + BOOLEAN PciAttributesChanged; =20 Dev =3D AllocateZeroPool (sizeof (*Dev)); if (Dev =3D=3D NULL) { @@ -270,6 +272,7 @@ MptScsiControllerStart ( } =20 Dev->Signature =3D MPT_SCSI_DEV_SIGNATURE; + PciAttributesChanged =3D FALSE; =20 Status =3D gBS->OpenProtocol ( ControllerHandle, @@ -283,6 +286,31 @@ MptScsiControllerStart ( goto Done; } =20 + Status =3D Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationGet, + 0, + &Dev->OriginalPciAttributes + ); + if (EFI_ERROR (Status)) { + goto Done; + } + + // + // Enable I/O Space & Bus-Mastering + // + Status =3D 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 =3D TRUE; + // // Host adapter channel, doesn't exist // @@ -312,6 +340,15 @@ MptScsiControllerStart ( =20 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 ); =20 + Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationEnable, + Dev->OriginalPciAttributes, + NULL + ); + gBS->CloseProtocol ( ControllerHandle, &gEfiPciIoProtocolGuid, --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#54909): https://edk2.groups.io/g/devel/message/54909 Mute This Topic: https://groups.io/mt/71570010/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-