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.15175.1585152475146236539 for ; Wed, 25 Mar 2020 09:07:55 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=akWNEjOU; 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 02PG3CQJ050192; Wed, 25 Mar 2020 16:07:54 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=akWNEjOUvP9yucHv840NrWanjUrWgAAnUEkwSO67hYjcqjn1z3M9UKhJs6kWDS8mG9cW eGsQJ853X7sxcBYYYwiRnd36qqIyPjRzkE0gWXn6A3Epoq69aLQcfN3cZXxPxXepJwFU 0c7MvJo0VsQvYSC21xJbMAhemsn/+grixuPcSPV8wFAsGhnNHtBt7IdI0NTZ8UDIWgnK NH2gvvuxeOlJkdtfI+KFWklKjedq4fWgv8Bs6539MvFfxiEO1mCg5kuzVe440f+nqoTY 8adPF6BG89gC8Chi5cTKUJfaYCTwR51Vt9uUo7UHIG3qjxFpoKavJP0nlBW56FHuwy1g 1A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2ywabrankd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:07:54 +0000 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 02PG7dds182034; Wed, 25 Mar 2020 16:07:54 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 3003gj0s5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:07:54 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02PG7rl2031720; Wed, 25 Mar 2020 16:07:53 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: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 v2 08/17] OvmfPkg/PvScsiDxe: Open PciIo protocol for later use Date: Wed, 25 Mar 2020 18:09:56 +0200 Message-Id: <20200325161005.16743-9-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 mlxscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 suspectscore=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 spamscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 priorityscore=1501 clxscore=1015 adultscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250128 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