From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.14072.1585425535861117857 for ; Sat, 28 Mar 2020 12:58:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=O9GhRmWu; spf=pass (domain: oracle.com, ip: 156.151.31.86, mailfrom: liran.alon@oracle.com) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJnOVq014144; Sat, 28 Mar 2020 19:58:55 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=VasARcm6pSijiQMeEpJHRnXRMFMzVoFY1enGWzmRVMU=; b=O9GhRmWuXBCkOnrvOR3X83+7qIHGWY+jdfwD8DRVmEFZhE/d3Z6wxq5MZ+B9xRbiHwyV UiWzJxNyJkCkRgpV0motsZzsJ8QNMgsQ1F6bo912r3nd2Q7PIit7wWpYH3vPpkvkgc6/ 1NIm3UGBFk2KZpD4rH3y2plao5Q6mqhMywGoR77IzgGg/C/BPkgu2vo/AIo92baIpy0x voD9k/ECqryN65vRQLNuiN5i3zntW4FChSYSnS/mMUIDpxzwLUfBocaD9QLFQHN3amRZ JzqHG+mD+E8GKVPYZtmo8/bIA2C0wuJGW8MeoZw7xkAOJrmNCErXTlN3VtsSfIoJoC+S AA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 301x0qsj8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:55 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJorXr164786; Sat, 28 Mar 2020 19:58:55 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 301ups6h7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:54 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02SJwsZ9025056; Sat, 28 Mar 2020 19:58:54 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:53 -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 v3 09/17] OvmfPkg/PvScsiDxe: Backup/Restore PCI attributes on Init/UnInit Date: Sat, 28 Mar 2020 23:00:52 +0300 Message-Id: <20200328200100.60786-10-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 malwarescore=0 phishscore=0 mlxlogscore=999 adultscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280189 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 clxscore=1015 adultscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280189 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: Laszlo Ersek 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