From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web10.69834.1584370829017941145 for ; Mon, 16 Mar 2020 08:00:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=wTlAr9Qe; spf=pass (domain: oracle.com, ip: 141.146.126.78, mailfrom: liran.alon@oracle.com) 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 02GEqjxe149326; Mon, 16 Mar 2020 15:00:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=xSXc2QhxbeunqkejnNZzBFoYEP/x2CHDhzLmZpv+NEw=; b=wTlAr9QegmOqveIKwTOXKItpP0Ei9GHI9hvXc0N9IGO7yI9wPUf6gCuzUztY7WPR9/V9 51lfDntzNqaLoHiuyR9uAGFH+GdpVT0Kzd1r5beGqHTAq1Z5eGOmkrNDX3pGunXPCEr8 g5f1Yl3v0kk86WQMrHWF31q31EjBJtODwbKcCUr83dt5Qnh4NDyX0vO1FTwieEbsSbTx vI1o6yloZmnRUFSKTcFuMCYXI5prz7Bw0omb4Y6tDvP2eW+cwKYBlxFb1hAnhHfBK7Ud e8deAxiMTHbkxy6cokeGJIQQQJ2RsgKQr2DW5glsf+y8EE6VL3EXqn5SN3wFreELe5sY xQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2yrq7kqd8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:28 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02GEqXaw114389; Mon, 16 Mar 2020 15:00:28 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2ys8tpw9s3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:25 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02GF0PPd009289; Mon, 16 Mar 2020 15:00:25 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Mar 2020 08:00:25 -0700 From: "Liran Alon" To: devel@edk2.groups.io, lersek@redhat.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org, Liran Alon Subject: [PATCH 09/17] OvmfPkg/PvScsiDxe: Backup/Restore PCI attributes on Init/UnInit Date: Mon, 16 Mar 2020 17:01:05 +0200 Message-Id: <20200316150113.104630-10-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200316150113.104630-1-liran.alon@oracle.com> References: <20200316150113.104630-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9561 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003160072 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9561 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=999 priorityscore=1501 clxscore=1015 malwarescore=0 mlxscore=0 phishscore=0 impostorscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003160072 Content-Transfer-Encoding: 8bit This commit doesn't change semantics. It is done as a preparation for future commits which will modify PCI attributes. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon --- OvmfPkg/PvScsiDxe/PvScsi.c | 53 +++++++++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index b6a83d73cead..92e0f4a98965 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -281,18 +281,59 @@ PvScsiGetNextTarget ( return EFI_NOT_FOUND; } +STATIC +EFI_STATUS +PvScsiSetPCIAttributes ( + IN OUT PVSCSI_DEV *Dev + ) +{ + EFI_STATUS Status; + + // + // Set saved original PCI attirubtes to invalid value + // such that cleanup logic could determine if it should restore + // PCI attributes or not + // + Dev->OriginalPciAttributes = (UINT64)(-1); + + // + // Backup original PCI Attributes + // + Status = Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationGet, + 0, + &Dev->OriginalPciAttributes + ); + if (EFI_ERROR (Status)) { + return Status; + } + + return EFI_SUCCESS; +} + STATIC EFI_STATUS PvScsiInit ( IN OUT PVSCSI_DEV *Dev ) { + EFI_STATUS Status; + // // Init configuration // Dev->MaxTarget = PcdGet8 (PcdPvScsiMaxTargetLimit); Dev->MaxLun = PcdGet8 (PcdPvScsiMaxLunLimit); + // + // Set PCI Attributes + // + Status = PvScsiSetPCIAttributes (Dev); + if (EFI_ERROR (Status)) { + return Status; + } + // // Populate the exported interface's attributes // @@ -331,7 +372,17 @@ PvScsiUninit ( IN OUT PVSCSI_DEV *Dev ) { - // Currently nothing to do here + // + // Restore PCI Attributes + // + if (Dev->OriginalPciAttributes != (UINT64)(-1)) { + Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationSet, + Dev->OriginalPciAttributes, + NULL + ); + } } // diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index e1e5ae18ebf2..5f611dbbc98c 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -20,6 +20,7 @@ typedef struct { UINT32 Signature; EFI_PCI_IO_PROTOCOL *PciIo; + UINT64 OriginalPciAttributes; UINT8 MaxTarget; UINT8 MaxLun; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; -- 2.20.1