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.web12.14052.1585425533529938049 for ; Sat, 28 Mar 2020 12:58:53 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=uabd0WJu; 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 02SJnaRH014218; Sat, 28 Mar 2020 19:58:53 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=DKyKgGCpUiKaTPNeLIdcIYfkuQ3gXaea7OsfPC5Gu4Q=; b=uabd0WJulEi47BNKwAXFZXp1nQWst2bwto6wXQiQOZwrirWPNDDYFdMTO6PPZBEcp6xa xefW7sSJZmdLHXznGdicyyncknw3Ff++SLFAeMv69yV1xuxUdSiG3o0t3au2t3Thx2jz G2PeaoAwd9yznxgWY6vcy7lhByllVoAAn5RcukIDEnjyxfzX2+NUr7ZAQ79m0VKmvER2 GWt059Ii4mnjUyyhBwfEh9gfZX8pBInV9Ty+SHDC2oYWog6Pa/82ndh2ZbtU9kaYNLw1 YY5RSrJVGZ7FAe3H3DeZaRBlTIycZKlCnjcq6UvLOtVZ7gXR1/rO1wOHRVbn8vUI0hFU 7w== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 301x0qsj8g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:52 +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 02SJp92p050007; Sat, 28 Mar 2020 19:58:52 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 301xd210q3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:52 +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 02SJwpMo024977; Sat, 28 Mar 2020 19:58:51 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:51 -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 08/17] OvmfPkg/PvScsiDxe: Open PciIo protocol for later use Date: Sat, 28 Mar 2020 23:00:51 +0300 Message-Id: <20200328200100.60786-9-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 bulkscore=0 phishscore=0 suspectscore=0 mlxscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=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 will give us an exclusive access to the PciIo of this device after it was started and until it will be stopped. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon --- OvmfPkg/PvScsiDxe/PvScsi.c | 29 ++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 76fc1eb910f2..e0380d729b3c 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -412,11 +412,23 @@ PvScsiDriverBindingStart ( return EFI_OUT_OF_RESOURCES; } - Status = PvScsiInit (Dev); + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + (VOID **)&Dev->PciIo, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); if (EFI_ERROR (Status)) { goto FreePvScsi; } + Status = PvScsiInit (Dev); + if (EFI_ERROR (Status)) { + goto ClosePciIo; + } + // // Setup complete, attempt to export the driver instance's PassThru interface // @@ -436,6 +448,14 @@ PvScsiDriverBindingStart ( UninitDev: PvScsiUninit (Dev); +ClosePciIo: + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + FreePvScsi: FreePool (Dev); @@ -481,6 +501,13 @@ PvScsiDriverBindingStop ( PvScsiUninit (Dev); + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + FreePool (Dev); return EFI_SUCCESS; diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index dd3e0c68e6da..e1e5ae18ebf2 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -19,6 +19,7 @@ typedef struct { UINT32 Signature; + EFI_PCI_IO_PROTOCOL *PciIo; UINT8 MaxTarget; UINT8 MaxLun; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; -- 2.20.1