From nobody Tue Feb 10 03:38:10 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+58085+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+58085+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1587751071; cv=none; d=zohomail.com; s=zohoarc; b=Ex4LR2ULNxmLNgHGG4u5zPMkwSBllzszZslbGtnVjfI1D3MkO6iB9CIvG7/j0ZeaH8tlYwcvHoYIU79SaAazV4UYUSki1sWItxvMJcRKWvEy9KNeWsgt2iS77V379xVw02DeQs0/CmzxEmHSVuTScA/vTuxtNEtRE9etRyOjZco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1587751071; 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=EJbdWw8uMfuDp1JbuU+Y3MTCHMnHprAWqiabr5JL0GQ=; b=Opo+jBc0nxC78psLzBsyRik78zuvMhEctw5LMxajVZi9JNP5+kEIzRJIJgyv13NxiJDnZviMq0RiNgqXX8o8NGR88CD3dmok/blqGMnSTp2dyjRMMfzqDiv64MxlQStiM/nr/2hIcWeON6P5fHKmjWF7kAjPxFdP70S/ze3PgmY= 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+58085+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 158775107128635.3046529311913; Fri, 24 Apr 2020 10:57:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rIpGYY1788612x1ybbe6pnJu; Fri, 24 Apr 2020 10:57:50 -0700 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.2088.1587750997048263032 for ; Fri, 24 Apr 2020 10:56:37 -0700 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 03OHqjT6185258; Fri, 24 Apr 2020 17:56:33 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 30jvq52fb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:56:33 +0000 X-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03OHlexJ078242; Fri, 24 Apr 2020 17:56:32 GMT X-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 30k7qxk72p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 24 Apr 2020 17:56:32 +0000 X-Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 03OHuVp8029122; Fri, 24 Apr 2020 17:56:32 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 24 Apr 2020 10:56:31 -0700 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [edk2-devel] [PATCH v5 09/12] OvmfPkg/MptScsiDxe: Set and restore PCI attributes Date: Fri, 24 Apr 2020 20:59:24 +0300 Message-Id: <20200424175927.41210-10-nikita.leshchenko@oracle.com> In-Reply-To: <20200424175927.41210-1-nikita.leshchenko@oracle.com> References: <20200424175927.41210-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: rZsXhvHoix4e5ZMPZSpfd9C4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1587751070; bh=kTWOQVI5BM2/lwcGJgxymb6/SWnyc2aUbbc0V6DsUNY=; h=Cc:Date:From:Reply-To:Subject:To; b=VbxEElnsCdMAzgcqCyWTzu93XX/ZWz0lpSY0SY0HcXc24dyXF1L2Difme8LdzoAJZIv qTuwoDpoUuMv7vXWeWKMvZSAwCQz8ph9csnmDyM2wgldECZaEOPHhBn5qZqsVk0GRCmq0 AkI32aPf8iN2lVaX332ArOvDvk+kljXdM1s= 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 Signed-off-by: Nikita Leshenko Reviewed-by: Liran Alon Reviewed-by: Laszlo Ersek --- OvmfPkg/MptScsiDxe/MptScsi.c | 65 +++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index ed7fabf8b471..e88ac2867a75 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -37,6 +37,7 @@ typedef struct { EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; UINT8 MaxTarget; EFI_PCI_IO_PROTOCOL *PciIo; + UINT64 OriginalPciAttributes; } MPT_SCSI_DEV; =20 #define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \ @@ -334,6 +335,53 @@ MptScsiControllerStart ( goto FreePool; } =20 + Status =3D Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationGet, + 0, + &Dev->OriginalPciAttributes + ); + if (EFI_ERROR (Status)) { + goto CloseProtocol; + } + + // + // 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 CloseProtocol; + } + + // + // Signal device supports 64-bit DMA addresses + // + Status =3D 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 // @@ -358,11 +406,19 @@ MptScsiControllerStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto CloseProtocol; + goto RestoreAttributes; } =20 return EFI_SUCCESS; =20 +RestoreAttributes: + Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationSet, + Dev->OriginalPciAttributes, + NULL + ); + CloseProtocol: gBS->CloseProtocol ( ControllerHandle, @@ -414,6 +470,13 @@ MptScsiControllerStop ( return Status; } =20 + Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationSet, + 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 (#58085): https://edk2.groups.io/g/devel/message/58085 Mute This Topic: https://groups.io/mt/73247269/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-