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.web12.15180.1585152478434905991 for ; Wed, 25 Mar 2020 09:07:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=lTrF9z4G; 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 02PG3HXJ138183; Wed, 25 Mar 2020 16:07:58 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=er5EDQy/j0nncfGrCKjoYMf3MEX2uGexwI8aCiulHUA=; b=lTrF9z4G42+2tqhGpt7Op4ZoD6T2cEPBDt6GXCmn8xV/yJ/nf56hKebl68Eus0Qoc/g5 TPHnRScF8B15MsdZjWk8nT0flBH7RNmK7C3gj/rjloL61PTFmqC+lhU2EvCXu2tkW3ha bZQFWurHKSKfDisvG61aMLdpSX10EaASdQ5BVrdH/AciMchFR8jAzzEAhNyC1MTRNPRZ tt23riHsCvlYNyl7KQNnlVKw0UenetLrbAGFa4Y0Tb/4fQT8x9NTmxD+H9qdhQUPrbEG yw63fDYtMBqq3/BEMkQEafrqLdD452E9I6GJhuA5hp2tQ7LXoUQZtfA4gTydX1NxF0lI Iw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2ywavmanaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:07:57 +0000 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 02PG72Es035594; Wed, 25 Mar 2020 16:07:57 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 30073ahsy1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:07:57 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02PG7teh026973; Wed, 25 Mar 2020 16:07:56 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Mar 2020 09:07:55 -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 v2 09/17] OvmfPkg/PvScsiDxe: Backup/Restore PCI attributes on Init/UnInit Date: Wed, 25 Mar 2020 18:09:57 +0200 Message-Id: <20200325161005.16743-10-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200325161005.16743-1-liran.alon@oracle.com> References: <20200325161005.16743-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9571 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250129 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9571 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 bulkscore=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250128 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 Signed-off-by: Liran Alon --- OvmfPkg/PvScsiDxe/PvScsi.c | 54 +++++++++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index e0380d729b3c..5566b4cce467 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -283,18 +283,70 @@ PvScsiGetNextTarget ( return EFI_NOT_FOUND; } +STATIC +EFI_STATUS +PvScsiSetPciAttributes ( + IN OUT PVSCSI_DEV *Dev + ) +{ + EFI_STATUS Status; + + // + // Backup original PCI Attributes + // + Status = Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationGet, + 0, + &Dev->OriginalPciAttributes + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // TODO: Change PCI Attributes + // + + return EFI_SUCCESS; +} + +STATIC +VOID +PvScsiRestorePciAttributes ( + IN PVSCSI_DEV *Dev + ) +{ + Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationSet, + Dev->OriginalPciAttributes, + NULL + ); +} + 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 // @@ -333,7 +385,7 @@ PvScsiUninit ( IN OUT PVSCSI_DEV *Dev ) { - // Currently nothing to do here + PvScsiRestorePciAttributes (Dev); } // 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