From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56534+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56534+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425517; cv=none; d=zohomail.com; s=zohoarc; b=fiMVHgxxSPl4Wp+jnjZDa5pE9KtOi99ZKZ8kB7C8G8GiAY2z41+fjQI98agCcTcOj6zB4P4Ys9ab/SjhhDIlo9++eOw643v/HSbaLzV/SUDMHHJNQfBVwZNKG9oe9swGIyRDYWyj+Cjb3+y5wsnriEBtiksXpUk0/pxPbd24rok= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425517; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=DezLvxaaE8gULddKFVDzKnwoJ1Ui3mG0R6iOF3FYt9U=; b=cXcR76mbbAimrnWzaDwvLHaGfO//F5AH9O1d01XxYcHpCXicM/grmuRzHlrlL/GitjyMnQ/eULdfRhmNUzDK8FZeu6zCzyzzM81kn1mlXUhsp6agFeky1rxXOFg/N7rgU8DoGG4zTdHtVgVHWsd5eemfXBjcbzgE2xbVZ6NewYs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56534+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425517690539.417839310464; Sat, 28 Mar 2020 12:58:37 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 7jbOYY1788612x8npVdktlu9; Sat, 28 Mar 2020 12:58:37 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.14039.1585425515993815847 for ; Sat, 28 Mar 2020 12:58:36 -0700 X-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 02SJnLkC014021; Sat, 28 Mar 2020 19:58:35 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 301x0qsj84-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:35 +0000 X-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 02SJoJF0071539; Sat, 28 Mar 2020 19:58:35 GMT X-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 301wwhmw1p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:35 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02SJwYGh008863; Sat, 28 Mar 2020 19:58:34 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:33 -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: [edk2-devel] [PATCH v3 01/17] OvmfPkg/PvScsiDxe: Create empty driver Date: Sat, 28 Mar 2020 23:00:44 +0300 Message-Id: <20200328200100.60786-2-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: vMH3VIb8uncqTXAxJN20nvH8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425517; bh=oYSBed/RwWrSTESQoodmJLBc3y2n8lSJBvA6VSKwuQk=; h=Cc:Date:From:Reply-To:Subject:To; b=lZIT7Vhuzj8SSIMiIGjg9XWs1/iZdflzVbS/HYNV64xR82Fl/xsd6PSf7XSLj83VJ7O zEcXQDYFO8ticNCZfJPOA76OUCG7jTHjqncgH/v6VEwTUHykxsBQYNucOt6gfwKKJCxpc mYWcOiFXYDZh3a5twV8JYkzWHWGlN+BPe6I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In preparation for support booting from PvScsi devices, create a basic scaffolding for a driver. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/OvmfPkgIa32.dsc | 8 ++++++++ OvmfPkg/OvmfPkgIa32.fdf | 3 +++ OvmfPkg/OvmfPkgIa32X64.dsc | 8 ++++++++ OvmfPkg/OvmfPkgIa32X64.fdf | 3 +++ OvmfPkg/OvmfPkgX64.dsc | 8 ++++++++ OvmfPkg/OvmfPkgX64.fdf | 3 +++ OvmfPkg/PvScsiDxe/PvScsi.c | 26 ++++++++++++++++++++++++++ OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 27 +++++++++++++++++++++++++++ 8 files changed, 86 insertions(+) create mode 100644 OvmfPkg/PvScsiDxe/PvScsi.c create mode 100644 OvmfPkg/PvScsiDxe/PvScsiDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 19728f20b34e..af985b4f7826 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -44,6 +44,11 @@ =20 !include NetworkPkg/NetworkDefines.dsc.inc =20 + # + # Device drivers + # + DEFINE PVSCSI_ENABLE =3D TRUE + # # Flash size selection. Setting FD_SIZE_IN_KB on the command line direct= ly to # one of the supported values, in place of any of the convenience macros= , is @@ -718,6 +723,9 @@ OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf OvmfPkg/XenBusDxe/XenBusDxe.inf OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +!if $(PVSCSI_ENABLE) =3D=3D TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf +!endif MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf index 63607551ed75..a442e133b952 100644 --- a/OvmfPkg/OvmfPkgIa32.fdf +++ b/OvmfPkg/OvmfPkgIa32.fdf @@ -227,6 +227,9 @@ INF OvmfPkg/VirtioRngDxe/VirtioRng.inf INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf INF OvmfPkg/XenBusDxe/XenBusDxe.inf INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +!if $(PVSCSI_ENABLE) =3D=3D TRUE +INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf +!endif =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootCon= figDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 3c0c229e3a72..267a83bf86e2 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -44,6 +44,11 @@ =20 !include NetworkPkg/NetworkDefines.dsc.inc =20 + # + # Device drivers + # + DEFINE PVSCSI_ENABLE =3D TRUE + # # Flash size selection. Setting FD_SIZE_IN_KB on the command line direct= ly to # one of the supported values, in place of any of the convenience macros= , is @@ -731,6 +736,9 @@ OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf OvmfPkg/XenBusDxe/XenBusDxe.inf OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +!if $(PVSCSI_ENABLE) =3D=3D TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf +!endif MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index 0488e5d95ffe..5fddaac2b0cb 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -228,6 +228,9 @@ INF OvmfPkg/VirtioRngDxe/VirtioRng.inf INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf INF OvmfPkg/XenBusDxe/XenBusDxe.inf INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +!if $(PVSCSI_ENABLE) =3D=3D TRUE +INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf +!endif =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootCon= figDxe.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index f6c1d8d228c6..98cc2a955c3e 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -44,6 +44,11 @@ =20 !include NetworkPkg/NetworkDefines.dsc.inc =20 + # + # Device drivers + # + DEFINE PVSCSI_ENABLE =3D TRUE + # # Flash size selection. Setting FD_SIZE_IN_KB on the command line direct= ly to # one of the supported values, in place of any of the convenience macros= , is @@ -729,6 +734,9 @@ OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf OvmfPkg/XenBusDxe/XenBusDxe.inf OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +!if $(PVSCSI_ENABLE) =3D=3D TRUE + OvmfPkg/PvScsiDxe/PvScsiDxe.inf +!endif MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntim= eDxe.inf MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 0488e5d95ffe..5fddaac2b0cb 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -228,6 +228,9 @@ INF OvmfPkg/VirtioRngDxe/VirtioRng.inf INF OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf INF OvmfPkg/XenBusDxe/XenBusDxe.inf INF OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf +!if $(PVSCSI_ENABLE) =3D=3D TRUE +INF OvmfPkg/PvScsiDxe/PvScsiDxe.inf +!endif =20 !if $(SECURE_BOOT_ENABLE) =3D=3D TRUE INF SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootCon= figDxe.inf diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c new file mode 100644 index 000000000000..1ae4de9869c1 --- /dev/null +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -0,0 +1,26 @@ +/** @file + + This driver produces Extended SCSI Pass Thru Protocol instances for + pvscsi devices. + + Copyright (C) 2020, Oracle and/or its affiliates. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +// +// Entry Point +// + +EFI_STATUS +EFIAPI +PvScsiEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return EFI_UNSUPPORTED; +} diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf new file mode 100644 index 000000000000..093cc0171338 --- /dev/null +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -0,0 +1,27 @@ +## @file +# +# This driver produces Extended SCSI Pass Thru Protocol instances for +# pvscsi devices. +# +# Copyright (C) 2020, Oracle and/or its affiliates. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION =3D 1.29 + BASE_NAME =3D PvScsiDxe + FILE_GUID =3D 30346B14-1580-4781-879D-BA0C55AE9BB2 + MODULE_TYPE =3D UEFI_DRIVER + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D PvScsiEntryPoint + +[Sources] + PvScsi.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + UefiDriverEntryPoint --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56534): https://edk2.groups.io/g/devel/message/56534 Mute This Topic: https://groups.io/mt/72617115/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56535+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56535+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425519; cv=none; d=zohomail.com; s=zohoarc; b=Vp0Fv0fNpywxSkrMsv/JEAaRWQBQo4z2fJEMpDBEMUWwDBgMtvvMfnSvAFh3UBx3YW5QvDQKJ+iyCdOTEOVHzOefoe4BSbzOjmES8UPBtkiYLwKWAVf391ekW1QVRJVexfRlUSRnSAi8qMabXmTK1R3QWbyubqjFiKBKMSquIi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425519; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=cFsWFNQRe4LxaRhdIar5zL/rvHs7vMIZsexZ2iN3Rzo=; b=ALayFHl9/GJ1/Y53d9nndKahW8WnzoEKcSneSFDJbR5OKFOBp60UahlBI8FxHfIUtavDQp7gDoOnWk99FTVezHNlegRQ6IlJbozx5dHIE91cHd26E0xU5nyOuN+ig1PEEkJKvXgVKoX2HheVcmvqSQpLaDLWaUpJJ5hq3843m2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56535+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425519439917.301560284924; Sat, 28 Mar 2020 12:58:39 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EvLhYY1788612xxUGnESBB3N; Sat, 28 Mar 2020 12:58:39 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.14112.1585425518501725114 for ; Sat, 28 Mar 2020 12:58:38 -0700 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJmQhi032615; Sat, 28 Mar 2020 19:58:38 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 301y7mhf80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:37 +0000 X-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 02SJontT164696; Sat, 28 Mar 2020 19:58:37 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 301ups6h1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:37 +0000 X-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 02SJwaUt024961; Sat, 28 Mar 2020 19:58:36 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:36 -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: [edk2-devel] [PATCH v3 02/17] OvmfPkg/PvScsiDxe: Install DriverBinding protocol Date: Sat, 28 Mar 2020 23:00:45 +0300 Message-Id: <20200328200100.60786-3-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: qYAdAodoSvgZmOJKDkAssfKlx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425519; bh=M3Ry+AoqVOxDpA0yFDvMJEwMcMkOohR/JC+z6qe/ugg=; h=Cc:Date:From:Reply-To:Subject:To; b=lS6741btz6g2q0bTEvKax8EhTtFSrYjUpCPfwv8soxhrtZuGXuhFgfDAzi/85wAXd5s YSeHS0k5DfcDfNdvLb4yvYWhLru1aeKJp47cqkxJsKIWzSVyNkk+3C/vyHRAa6hU7GVLj oVhuwxD5HUXKwNThbA1GegzNInzoq4H5UZg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In order to probe and connect to the PvScsi device we need this protocol. Currently it does nothing. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 66 ++++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 1 + 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 1ae4de9869c1..77b28b326784 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -9,8 +9,65 @@ =20 **/ =20 +#include #include =20 +// +// Higher versions will be used before lower, 0x10-0xffffffef is the versi= on +// range for IHV (Indie Hardware Vendors) +// +#define PVSCSI_BINDING_VERSION 0x10 + +// +// Driver Binding +// + +STATIC +EFI_STATUS +EFIAPI +PvScsiDriverBindingSupported ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiDriverBindingStart ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiDriverBindingStop ( + IN EFI_DRIVER_BINDING_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN UINTN NumberOfChildren, + IN EFI_HANDLE *ChildHandleBuffer + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC EFI_DRIVER_BINDING_PROTOCOL mPvScsiDriverBinding =3D { + &PvScsiDriverBindingSupported, + &PvScsiDriverBindingStart, + &PvScsiDriverBindingStop, + PVSCSI_BINDING_VERSION, + NULL, // ImageHandle, filled by EfiLibInstallDriverBindingComponentName2= () + NULL // DriverBindingHandle, filled as well +}; + // // Entry Point // @@ -22,5 +79,12 @@ PvScsiEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { - return EFI_UNSUPPORTED; + return EfiLibInstallDriverBindingComponentName2 ( + ImageHandle, + SystemTable, + &mPvScsiDriverBinding, + ImageHandle, + NULL, // TODO Component name + NULL // TODO Component name + ); } diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf index 093cc0171338..d1d0e963f96d 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -25,3 +25,4 @@ =20 [LibraryClasses] UefiDriverEntryPoint + UefiLib --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56535): https://edk2.groups.io/g/devel/message/56535 Mute This Topic: https://groups.io/mt/72617118/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56536+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56536+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425521; cv=none; d=zohomail.com; s=zohoarc; b=KMWVvw2rPPtnkzSR6r5NL/6wgdWqIVhWmoGsl0zhPBJVzynjL6AOYfZl/pBuskNzUybuAS2wjssiu+z8BYbPs1Mfz1CJFaHEdp7pD1AfOyhguHKaeH2iBB2V/M1+u4dHe/Lz/wiUhN1t52ha0cVDLQ1djcUuELlVlxCaW2FTdOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425521; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=s+kUCl8H7l+zO9gunSTFrM1UkbbcQZP2v1HOnCVp/JA=; b=NIajFYOvdd91MQ64xzPiVLKW5zdOMGlVXqeMFFK1fl7htr51uCKnrBcbX3TZhyEqwPngGaipdeSyFg0MVgez5Hw9uKZ1ZvuTVvbowDg1nU4us4tyxnZsRwDrLwsDaoGSSW8VcGpZRYcoSV3J1+TVFmlFYrVPsxm/l7pJYqOiTmw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56536+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425521528142.40592565429472; Sat, 28 Mar 2020 12:58:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id hhUGYY1788612xLR0gmkizCT; Sat, 28 Mar 2020 12:58:41 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.14066.1585425520688594484 for ; Sat, 28 Mar 2020 12:58:40 -0700 X-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 02SJnLkD014021; Sat, 28 Mar 2020 19:58:40 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 301x0qsj87-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:40 +0000 X-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 02SJnuGQ070946; Sat, 28 Mar 2020 19:58:40 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 301wwhmw7f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:39 +0000 X-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 02SJwddP024967; Sat, 28 Mar 2020 19:58:39 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:38 -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: [edk2-devel] [PATCH v3 03/17] OvmfPkg/PvScsiDxe: Report name of driver Date: Sat, 28 Mar 2020 23:00:46 +0300 Message-Id: <20200328200100.60786-4-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: CERp6KD3cLIAZG5YXFlaLXDZx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425521; bh=EuiEs0q1C9kmyA+hmp9sRSREHrFg/8hGnAeiq9kx41w=; h=Cc:Date:From:Reply-To:Subject:To; b=vVydQDAfZxVXDm9kx2lyrRblb85Dj+sMePKPj8s+DT8XuM0F/aXUk8p2NCZ2vbn2nsZ LQrocyTVVuRQHwa9zzTrRCIEdDM/Q2TwviKD9l9wgZiveal4xS/3Bfm9yr0cAcwU9AbUJ IMYGkj3/uWjZuXom5OdaRB5sed71Yb2fYw4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Install Component Name protocols to have a nice display name for the driver in places such as UEFI shell. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 59 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 77b28b326784..51b03f709040 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -68,6 +68,61 @@ STATIC EFI_DRIVER_BINDING_PROTOCOL mPvScsiDriverBinding = =3D { NULL // DriverBindingHandle, filled as well }; =20 +// +// Component Name +// + +STATIC EFI_UNICODE_STRING_TABLE mDriverNameTable[] =3D { + { "eng;en", L"PVSCSI Host Driver" }, + { NULL, NULL } +}; + +STATIC EFI_COMPONENT_NAME_PROTOCOL mComponentName; + +STATIC +EFI_STATUS +EFIAPI +PvScsiGetDriverName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName + ) +{ + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + mDriverNameTable, + DriverName, + (BOOLEAN)(This =3D=3D &mComponentName) // Iso639Language + ); +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiGetDeviceName ( + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE DeviceHandle, + IN EFI_HANDLE ChildHandle, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC EFI_COMPONENT_NAME_PROTOCOL mComponentName =3D { + &PvScsiGetDriverName, + &PvScsiGetDeviceName, + "eng" // SupportedLanguages, ISO 639-2 language codes +}; + +STATIC EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 =3D { + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) &PvScsiGetDriverName, + (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) &PvScsiGetDeviceName, + "en" // SupportedLanguages, RFC 4646 language codes +}; + // // Entry Point // @@ -84,7 +139,7 @@ PvScsiEntryPoint ( SystemTable, &mPvScsiDriverBinding, ImageHandle, - NULL, // TODO Component name - NULL // TODO Component name + &mComponentName, + &mComponentName2 ); } --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56536): https://edk2.groups.io/g/devel/message/56536 Mute This Topic: https://groups.io/mt/72617122/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56537+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56537+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425524; cv=none; d=zohomail.com; s=zohoarc; b=gAbDKl539wud2qpBiYO5qdJbrbbFVn7PWydECbDvDAj7EMSXZkPLfmtF0mEx1iurDh1dQWmyzWoSbdkfzCvv8FjJzbU3girM0GwXSoLg+8b98zfhm0BOqwyxaG4zM1k1w+asq1E8JTd3KC0PXt/p/ehiA+hqicbi2hjfQRGfmlk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425524; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=ThkS/BX7guScfwrkKQL66Jm6D+cZYryqdwdyCWW3E08=; b=YODP3xajt0UlE1Xe6i0LKGYZOO8+RKJZIDt5aO38HdX9G+AoEc9DI9i06XuwpOP2aymMRi5omwRROrtPGcgAN6sSEOWa+5DdwNx6iLLVu0sk7sqU85L/znfu0BQLyj9Bq5Wh1aI2owUA/VxNjCguxakegCW7zAIBhV+HmrTkpdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56537+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425524847238.59279415887238; Sat, 28 Mar 2020 12:58:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id HcLZYY1788612xQAzaORMzTl; Sat, 28 Mar 2020 12:58:44 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.14045.1585425523930958671 for ; Sat, 28 Mar 2020 12:58:44 -0700 X-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 02SJnMgp014025; Sat, 28 Mar 2020 19:58:43 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 301x0qsj88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:43 +0000 X-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 02SJo7Ye031409; Sat, 28 Mar 2020 19:58:42 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 301vm90pyd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:42 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJwgb3016973; Sat, 28 Mar 2020 19:58:42 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:41 -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: [edk2-devel] [PATCH v3 04/17] OvmfPkg/PvScsiDxe: Probe PCI devices and look for PvScsi Date: Sat, 28 Mar 2020 23:00:47 +0300 Message-Id: <20200328200100.60786-5-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: qjPSFSxegzOS7dKM54so9SDGx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425524; bh=nEgT4Ww27s9SHjK10IaYVYZ/TddQGS9CsaJ2/4xapD8=; h=Cc:Date:From:Reply-To:Subject:To; b=GiP3WZFEMcNyid73hKENZg3iww17UD9fMPieVK9LG8splDdPAIsa/HyFQ32Hh/Jr9I/ HfiiP4QvvYgzZbPQkVuwMb8hcvlR7Dofy4rMY2/tTOmcM4Ik3bkeTVNVqscPuSdUrB0Wn yQpldvjKKgXtpUWP5tkMIT2IylNc+csAYPA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" PvScsiControllerSupported() is called on handles passed in by the ConnectController() boot service and if the handle is the PVSCSI controller, the function would return success. A success return value will attach our driver to the device. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/Include/IndustryStandard/PvScsi.h | 21 ++++++++++ OvmfPkg/PvScsiDxe/PvScsi.c | 49 ++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 5 +++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 OvmfPkg/Include/IndustryStandard/PvScsi.h diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/In= dustryStandard/PvScsi.h new file mode 100644 index 000000000000..004c0af84989 --- /dev/null +++ b/OvmfPkg/Include/IndustryStandard/PvScsi.h @@ -0,0 +1,21 @@ +/** @file + + VMware PVSCSI Device specific type and macro definitions. + + Copyright (C) 2020, Oracle and/or its affiliates. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PVSCSI_H_ +#define __PVSCSI_H_ + +// +// Device offsets and constants +// + +#define PCI_VENDOR_ID_VMWARE (0x15ad) +#define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0) + +#endif // __PVSCSI_H_ diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 51b03f709040..9923a31d25d7 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -9,7 +9,11 @@ =20 **/ =20 +#include +#include +#include #include +#include #include =20 // @@ -31,7 +35,50 @@ PvScsiDriverBindingSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + EFI_PCI_IO_PROTOCOL *PciIo; + PCI_TYPE00 Pci; + + Status =3D gBS->OpenProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + (VOID **)&PciIo, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status =3D PciIo->Pci.Read ( + PciIo, + EfiPciIoWidthUint32, + 0, + sizeof (Pci) / sizeof (UINT32), + &Pci + ); + if (EFI_ERROR (Status)) { + goto Done; + } + + if ((Pci.Hdr.VendorId !=3D PCI_VENDOR_ID_VMWARE) || + (Pci.Hdr.DeviceId !=3D PCI_DEVICE_ID_VMWARE_PVSCSI)) { + Status =3D EFI_UNSUPPORTED; + goto Done; + } + + Status =3D EFI_SUCCESS; + +Done: + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + + return Status; } =20 STATIC diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf index d1d0e963f96d..c1f0663832ed 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -22,7 +22,12 @@ =20 [Packages] MdePkg/MdePkg.dec + OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib + +[Protocols] + gEfiPciIoProtocolGuid ## TO_START --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56537): https://edk2.groups.io/g/devel/message/56537 Mute This Topic: https://groups.io/mt/72617125/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56538+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56538+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425527; cv=none; d=zohomail.com; s=zohoarc; b=SrxuRbvmDshqyBQrmmhaIGrSsULv2lojpx9v0HKVQfyJby26p9p1JAdG68f0Tqoi3aTbNGpPpvgTMQTEyWBE3NF04DtfUebmU1gQ/cRgfy5HhIgHNPMvoHDt8jIcst3hYYB6Ks2nJ+MhEk8MfrQRXF8zRixOQ7QbkJvVXic39gY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425527; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=wGppvY+SYier6Rttf5SFKhvUly4RqeNO2k7I4mVppY4=; b=No1GIIE79Ti4/WVb4eceYd9IHfJMSJEkhP6xXO9CnsSJ40h1K7e6EV/2f0DfN1v7Aei268QpB+XmR6epURNT3sqntzG2wKIYm1KBQU9SBiRug1fI8U/kLKKIQgc7FP+EK/PSj9sXOtrEX8Bputb1jG9s/O4Y17pN3I+pkR1iMLo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56538+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425527526446.5600560861744; Sat, 28 Mar 2020 12:58:47 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id XjVoYY1788612xA0WLM3Z0sR; Sat, 28 Mar 2020 12:58:47 -0700 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web10.14119.1585425526720269128 for ; Sat, 28 Mar 2020 12:58:46 -0700 X-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 02SJnFWS029002; Sat, 28 Mar 2020 19:58:46 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 301xhkhgyt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:45 +0000 X-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 02SJonk1164673; Sat, 28 Mar 2020 19:58:45 GMT X-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 301ups6h4n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:45 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02SJwi5T008879; Sat, 28 Mar 2020 19:58:44 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:44 -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: [edk2-devel] [PATCH v3 05/17] OvmfPkg/PvScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Date: Sat, 28 Mar 2020 23:00:48 +0300 Message-Id: <20200328200100.60786-6-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: C6o7PXmTvzoWRPHrk6jBdnMAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425527; bh=DKWbZd12NUnIgg3XhsZVCPFEC/ZRF3yBfZxfKjJhdOk=; h=Cc:Date:From:Reply-To:Subject:To; b=s4BWS2Bu4OFkmEr3QSDMn3ByPdjkLNw4jaubPFFp/WyfkzweEs1uN/3Zlc9wkecRkXw iuBsDUkC1QQx18op3s7CuvyUGer+RfCq8AKKIcrIxdev6k7nH1ij9IpzqiQuVg6T53B5t LN+miV61HTRaZzm+7eEnmPygL4J4+lyUTLI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Support dynamic insertion and removal of the protocol. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 209 +++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 29 +++++ OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 6 +- 3 files changed, 241 insertions(+), 3 deletions(-) create mode 100644 OvmfPkg/PvScsiDxe/PvScsi.h diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 9923a31d25d7..04c08036b799 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -11,17 +11,156 @@ =20 #include #include +#include #include #include #include #include =20 +#include "PvScsi.h" + // // Higher versions will be used before lower, 0x10-0xffffffef is the versi= on // range for IHV (Indie Hardware Vendors) // #define PVSCSI_BINDING_VERSION 0x10 =20 +// +// Ext SCSI Pass Thru +// + +STATIC +EFI_STATUS +EFIAPI +PvScsiPassThru ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN UINT8 *Target, + IN UINT64 Lun, + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, + IN EFI_EVENT Event OPTIONAL + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiGetNextTargetLun ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN OUT UINT8 **Target, + IN OUT UINT64 *Lun + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiBuildDevicePath ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN UINT8 *Target, + IN UINT64 Lun, + IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiGetTargetLun ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, + OUT UINT8 **Target, + OUT UINT64 *Lun + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiResetChannel ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiResetTargetLun ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN UINT8 *Target, + IN UINT64 Lun + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +EFIAPI +PvScsiGetNextTarget ( + IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This, + IN OUT UINT8 **Target + ) +{ + return EFI_UNSUPPORTED; +} + +STATIC +EFI_STATUS +PvScsiInit ( + IN OUT PVSCSI_DEV *Dev + ) +{ + // + // Populate the exported interface's attributes + // + Dev->PassThru.Mode =3D &Dev->PassThruMode; + Dev->PassThru.PassThru =3D &PvScsiPassThru; + Dev->PassThru.GetNextTargetLun =3D &PvScsiGetNextTargetLun; + Dev->PassThru.BuildDevicePath =3D &PvScsiBuildDevicePath; + Dev->PassThru.GetTargetLun =3D &PvScsiGetTargetLun; + Dev->PassThru.ResetChannel =3D &PvScsiResetChannel; + Dev->PassThru.ResetTargetLun =3D &PvScsiResetTargetLun; + Dev->PassThru.GetNextTarget =3D &PvScsiGetNextTarget; + + // + // AdapterId is a target for which no handle will be created during bus = scan. + // Prevent any conflict with real devices. + // + Dev->PassThruMode.AdapterId =3D MAX_UINT32; + + // + // Set both physical and logical attributes for non-RAID SCSI channel + // + Dev->PassThruMode.Attributes =3D EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSI= CAL | + EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL; + + // + // No restriction on transfer buffer alignment + // + Dev->PassThruMode.IoAlign =3D 0; + + return EFI_SUCCESS; +} + +STATIC +VOID +PvScsiUninit ( + IN OUT PVSCSI_DEV *Dev + ) +{ + // Currently nothing to do here +} + // // Driver Binding // @@ -90,7 +229,42 @@ PvScsiDriverBindingStart ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL ) { - return EFI_UNSUPPORTED; + PVSCSI_DEV *Dev; + EFI_STATUS Status; + + Dev =3D (PVSCSI_DEV *) AllocateZeroPool (sizeof (*Dev)); + if (Dev =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Status =3D PvScsiInit (Dev); + if (EFI_ERROR (Status)) { + goto FreePvScsi; + } + + // + // Setup complete, attempt to export the driver instance's PassThru inte= rface + // + Dev->Signature =3D PVSCSI_SIG; + Status =3D gBS->InstallProtocolInterface ( + &ControllerHandle, + &gEfiExtScsiPassThruProtocolGuid, + EFI_NATIVE_INTERFACE, + &Dev->PassThru + ); + if (EFI_ERROR (Status)) { + goto UninitDev; + } + + return EFI_SUCCESS; + +UninitDev: + PvScsiUninit (Dev); + +FreePvScsi: + FreePool (Dev); + + return Status; } =20 STATIC @@ -103,7 +277,38 @@ PvScsiDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + EFI_EXT_SCSI_PASS_THRU_PROTOCOL *PassThru; + PVSCSI_DEV *Dev; + + Status =3D gBS->OpenProtocol ( + ControllerHandle, + &gEfiExtScsiPassThruProtocolGuid, + (VOID **)&PassThru, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_GET_PROTOCOL // Lookup only + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Dev =3D PVSCSI_FROM_PASS_THRU (PassThru); + + Status =3D gBS->UninstallProtocolInterface ( + ControllerHandle, + &gEfiExtScsiPassThruProtocolGuid, + &Dev->PassThru + ); + if (EFI_ERROR (Status)) { + return Status; + } + + PvScsiUninit (Dev); + + FreePool (Dev); + + return EFI_SUCCESS; } =20 STATIC EFI_DRIVER_BINDING_PROTOCOL mPvScsiDriverBinding =3D { diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h new file mode 100644 index 000000000000..3940b4c20019 --- /dev/null +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -0,0 +1,29 @@ +/** @file + + Internal definitions for the PVSCSI driver, which produces Extended SCSI + Pass Thru Protocol instances for pvscsi devices. + + Copyright (C) 2020, Oracle and/or its affiliates. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef __PVSCSI_DXE_H_ +#define __PVSCSI_DXE_H_ + +#include +#include + +#define PVSCSI_SIG SIGNATURE_32 ('P', 'S', 'C', 'S') + +typedef struct { + UINT32 Signature; + EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; + EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; +} PVSCSI_DEV; + +#define PVSCSI_FROM_PASS_THRU(PassThruPointer) \ + CR (PassThruPointer, PVSCSI_DEV, PassThru, PVSCSI_SIG) + +#endif // __PVSCSI_DXE_H_ diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf index c1f0663832ed..f4d452c6c3d2 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -19,15 +19,19 @@ =20 [Sources] PvScsi.c + PvScsi.h =20 [Packages] MdePkg/MdePkg.dec OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + DebugLib + MemoryAllocationLib UefiBootServicesTableLib UefiDriverEntryPoint UefiLib =20 [Protocols] - gEfiPciIoProtocolGuid ## TO_START + gEfiExtScsiPassThruProtocolGuid ## BY_START + gEfiPciIoProtocolGuid ## TO_START --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56538): https://edk2.groups.io/g/devel/message/56538 Mute This Topic: https://groups.io/mt/72617129/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56539+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56539+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425529; cv=none; d=zohomail.com; s=zohoarc; b=G63BZczj3FxXeMFBE/g3YUHRJMj/7e6/LvszGy2b6eBGS4xx62DuIpaFY2AFlZn7B7jyKu6m+hFn26snQE56mV8sqRFfEbM7d6M81+k6YZwWTKIhD5UIj8/VWw8G5QvV0uPM4BPUED0xvtoSqHnyBpziaeo96Gud32rk8uHSO9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425529; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4Vj8hcGcaa+LDS3RASDahORVNSt9jN8H5JwIVXBqQsA=; b=IrcJyEQrZE9e+hhqxAMnBr5Vi40e8VG8lZNlxzoUA2tnrLvjbZ6xXik5LqP5eaJpHcPqyB6AgnlNHXVk5adTNuDR4cB64qHKJILD9bUBhYe44j2U2UkbwKpch0Dcuk5/5jhKs2j6/7ZN0jk9pIU01WaIAPfhM5msBY9Vcx1WjD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56539+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425529586624.7052752173778; Sat, 28 Mar 2020 12:58:49 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KhhhYY1788612xBaunZOH8IJ; Sat, 28 Mar 2020 12:58:49 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web10.14120.1585425528785011826 for ; Sat, 28 Mar 2020 12:58:48 -0700 X-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 02SJwmSb104274; Sat, 28 Mar 2020 19:58:48 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 301x0qsj8e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:48 +0000 X-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 02SJoOk4071594; Sat, 28 Mar 2020 19:58:47 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 301wwhmwh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:47 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJwkgv017068; Sat, 28 Mar 2020 19:58:46 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:46 -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: [edk2-devel] [PATCH v3 06/17] OvmfPkg/PvScsiDxe: Report the number of targets and LUNs Date: Sat, 28 Mar 2020 23:00:49 +0300 Message-Id: <20200328200100.60786-7-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: 2YYsbwBZjaUZPifQ142cnChWx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425529; bh=Qv4KMRjCf5372cEJ9wzeQrS+zMhJQ5y3BjUPiOCHcjQ=; h=Cc:Date:From:Reply-To:Subject:To; b=GBCEJo+YntQmjrNIUcNjdAsFobQv60DgXJ5iQd43QIA9tS5jXTJCJmqBmtHR4fOiYK4 0WJpUvUYM34KkjWZGF1zvrMEpZURbOfjfjE1Bzel+G+zUGavy8hND60AVc/LkeMIORgER 3SqFMqT13rrzam3KTSjFFwJ9mlJh1x9Z57A= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Implement EXT_SCSI_PASS_THRU.GetNextTarget() and EXT_SCSI_PASS_THRU.GetNextTargetLun(). ScsiBusDxe scans all MaxTarget * MaxLun possible devices. This can take unnecessarily long for large number of targets. To deal with this, VirtioScsiDxe has defined PCDs to limit the MaxTarget & MaxLun to desired values which gives sufficient performance. It is very important in virtio-scsi as it can have very big MaxTarget & MaxLun. Even though a common PVSCSI device has a default MaxTarget=3D64 and MaxLun=3D0, we implement similar mechanism as virtio-scsi for completeness. This may be useful in the future when PVSCSI will have bigger values for MaxTarget and MaxLun. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/OvmfPkg.dec | 9 +++ OvmfPkg/PvScsiDxe/PvScsi.c | 122 +++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 2 + OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 5 ++ 4 files changed, 136 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 4c5b6511cb97..a04aee5c2cd4 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -121,6 +121,15 @@ gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6 gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7 =20 + ## Sets the *inclusive* number of targets and LUNs that PvScsi exposes f= or + # scan by ScsiBusDxe. + # As specified above for VirtioScsi, ScsiBusDxe scans all MaxTarget * M= axLun + # possible devices, which can take extremely long. Thus, the below cons= tants + # are used so that scanning the number of devices given by their product + # is still acceptably fast. + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxTargetLimit|64|UINT8|0x36 + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxLunLimit|0|UINT8|0x37 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase|0x0|UINT32|= 0x8 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize|0x0|UINT32|= 0x9 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize|0x0|UINT32|0xa diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 04c08036b799..7f51ada19a1a 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -11,6 +11,7 @@ =20 #include #include +#include #include #include #include @@ -25,6 +26,30 @@ // #define PVSCSI_BINDING_VERSION 0x10 =20 +// +// Ext SCSI Pass Thru utilities +// + +/** + Check if Target argument to EXT_SCSI_PASS_THRU.GetNextTarget() and + EXT_SCSI_PASS_THRU.GetNextTargetLun() is initialized +**/ +STATIC +BOOLEAN +IsTargetInitialized ( + IN UINT8 *Target + ) +{ + UINTN Idx; + + for (Idx =3D 0; Idx < TARGET_MAX_BYTES; ++Idx) { + if (Target[Idx] !=3D 0xFF) { + return TRUE; + } + } + return FALSE; +} + // // Ext SCSI Pass Thru // @@ -52,7 +77,54 @@ PvScsiGetNextTargetLun ( IN OUT UINT64 *Lun ) { - return EFI_UNSUPPORTED; + UINT8 *TargetPtr; + UINT8 LastTarget; + PVSCSI_DEV *Dev; + + if (Target =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // The Target input parameter is unnecessarily a pointer-to-pointer + // + TargetPtr =3D *Target; + + // + // If target not initialized, return first target & LUN + // + if (!IsTargetInitialized (TargetPtr)) { + ZeroMem (TargetPtr, TARGET_MAX_BYTES); + *Lun =3D 0; + return EFI_SUCCESS; + } + + // + // We only use first byte of target identifer + // + LastTarget =3D *TargetPtr; + + // + // Increment (target, LUN) pair if valid on input + // + Dev =3D PVSCSI_FROM_PASS_THRU (This); + if (LastTarget > Dev->MaxTarget || *Lun > Dev->MaxLun) { + return EFI_INVALID_PARAMETER; + } + + if (*Lun < Dev->MaxLun) { + ++*Lun; + return EFI_SUCCESS; + } + + if (LastTarget < Dev->MaxTarget) { + *Lun =3D 0; + ++LastTarget; + *TargetPtr =3D LastTarget; + return EFI_SUCCESS; + } + + return EFI_NOT_FOUND; } =20 STATIC @@ -111,7 +183,47 @@ PvScsiGetNextTarget ( IN OUT UINT8 **Target ) { - return EFI_UNSUPPORTED; + UINT8 *TargetPtr; + UINT8 LastTarget; + PVSCSI_DEV *Dev; + + if (Target =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // The Target input parameter is unnecessarily a pointer-to-pointer + // + TargetPtr =3D *Target; + + // + // If target not initialized, return first target + // + if (!IsTargetInitialized (TargetPtr)) { + ZeroMem (TargetPtr, TARGET_MAX_BYTES); + return EFI_SUCCESS; + } + + // + // We only use first byte of target identifer + // + LastTarget =3D *TargetPtr; + + // + // Increment target if valid on input + // + Dev =3D PVSCSI_FROM_PASS_THRU (This); + if (LastTarget > Dev->MaxTarget) { + return EFI_INVALID_PARAMETER; + } + + if (LastTarget < Dev->MaxTarget) { + ++LastTarget; + *TargetPtr =3D LastTarget; + return EFI_SUCCESS; + } + + return EFI_NOT_FOUND; } =20 STATIC @@ -120,6 +232,12 @@ PvScsiInit ( IN OUT PVSCSI_DEV *Dev ) { + // + // Init configuration + // + Dev->MaxTarget =3D PcdGet8 (PcdPvScsiMaxTargetLimit); + Dev->MaxLun =3D PcdGet8 (PcdPvScsiMaxLunLimit); + // // Populate the exported interface's attributes // diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index 3940b4c20019..dd3e0c68e6da 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -19,6 +19,8 @@ =20 typedef struct { UINT32 Signature; + UINT8 MaxTarget; + UINT8 MaxLun; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; } PVSCSI_DEV; diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf index f4d452c6c3d2..fcffc90d46c8 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -26,6 +26,7 @@ OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + BaseMemoryLib DebugLib MemoryAllocationLib UefiBootServicesTableLib @@ -35,3 +36,7 @@ [Protocols] gEfiExtScsiPassThruProtocolGuid ## BY_START gEfiPciIoProtocolGuid ## TO_START + +[Pcd] + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxLunLimit ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxTargetLimit ## CONSUMES --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56539): https://edk2.groups.io/g/devel/message/56539 Mute This Topic: https://groups.io/mt/72617130/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56540+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56540+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425531; cv=none; d=zohomail.com; s=zohoarc; b=MFDnbSfDDAGyEv3GhlEdALQO66e6Ozwcx4nBTJga8k9j4OO1+GOgk/qTAniWUWwsKiVAgK65T3x4BpJFn0EbtQtKB9beBqnHvead+cRyrrIPKjtuAHR1+OJ0/vA31Zv1EgaC1DG+XaNfDgELjpCG0wv5TQei4drj2vtOiQP+fZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425531; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=l5kR41eav7LYlPj58IoiPBJYq4PK5J07oXk+sDL3fjM=; b=AwprbZe8T/qJNAtHIGWDMSoiIlCOsOH25qTbCM48sZILX1hYwz7CmlgSDRARmycgrI8u8g0Fb0VNHcZIhuF4g4ZadhZgIQIIJ/7EWCYVeIZZUpvQfUGxB+F+SCsBd2BEJVFClVUH/MiAupzwJV9H/QhNpEC/dvmmaZKRaDr58l8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56540+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425531896282.7683697474622; Sat, 28 Mar 2020 12:58:51 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id L6wyYY1788612x3eNbLwlUEG; Sat, 28 Mar 2020 12:58:51 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web12.14051.1585425531011277631 for ; Sat, 28 Mar 2020 12:58:51 -0700 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJmQVY032604; Sat, 28 Mar 2020 19:58:50 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 301y7mhf8a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:50 +0000 X-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 02SJpwtp166287; Sat, 28 Mar 2020 19:58:50 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 301ups6h68-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:50 +0000 X-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 02SJwnnu024974; Sat, 28 Mar 2020 19:58:49 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:48 -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: [edk2-devel] [PATCH v3 07/17] OvmfPkg/PvScsiDxe: Translate Target & LUN to/from DevicePath Date: Sat, 28 Mar 2020 23:00:50 +0300 Message-Id: <20200328200100.60786-8-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: BACVgTUfnZh609zMyReSwOxKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425531; bh=PDt37W9F4sa8INLppiKKUVEZtL1ZDGCSVCy1ikHqbFU=; h=Cc:Date:From:Reply-To:Subject:To; b=w3P6bYIA3gb/ybEB5tIbxss33YgHa5MRmU7pFXNiK6f5fi9VR6POYNMr7yYZ1fpkmpb Io5aVdD1dObK1sKSfpJKaP5V+DQL927555PrRBUea+vn+QRneKXrgBKd/nYAMic8yhr4p j/R4iJJc7/0CbRjBfzhXvAEUwX2Eq8IUB6E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Implement EXT_SCSI_PASS_THRU.BuildDevicePath() and EXT_SCSI_PASS_THRU.GetTargetLun(). Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 61 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 7f51ada19a1a..76fc1eb910f2 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -137,7 +137,38 @@ PvScsiBuildDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ) { - return EFI_UNSUPPORTED; + UINT8 TargetValue; + PVSCSI_DEV *Dev; + SCSI_DEVICE_PATH *ScsiDevicePath; + + if (DevicePath =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + // + // We only use first byte of target identifer + // + TargetValue =3D *Target; + + Dev =3D PVSCSI_FROM_PASS_THRU (This); + if (TargetValue > Dev->MaxTarget || Lun > Dev->MaxLun) { + return EFI_NOT_FOUND; + } + + ScsiDevicePath =3D AllocatePool (sizeof (*ScsiDevicePath)); + if (ScsiDevicePath =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + ScsiDevicePath->Header.Type =3D MESSAGING_DEVICE_PATH; + ScsiDevicePath->Header.SubType =3D MSG_SCSI_DP; + ScsiDevicePath->Header.Length[0] =3D (UINT8)sizeof (*ScsiDevicePath); + ScsiDevicePath->Header.Length[1] =3D (UINT8)(sizeof (*ScsiDevicePath) >>= 8); + ScsiDevicePath->Pun =3D TargetValue; + ScsiDevicePath->Lun =3D (UINT16)Lun; + + *DevicePath =3D &ScsiDevicePath->Header; + return EFI_SUCCESS; } =20 STATIC @@ -150,7 +181,33 @@ PvScsiGetTargetLun ( OUT UINT64 *Lun ) { - return EFI_UNSUPPORTED; + SCSI_DEVICE_PATH *ScsiDevicePath; + PVSCSI_DEV *Dev; + + if (DevicePath =3D=3D NULL || Target =3D=3D NULL || *Target =3D=3D NULL = || Lun =3D=3D NULL) { + return EFI_INVALID_PARAMETER; + } + + if (DevicePath->Type !=3D MESSAGING_DEVICE_PATH || + DevicePath->SubType !=3D MSG_SCSI_DP) { + return EFI_UNSUPPORTED; + } + + ScsiDevicePath =3D (SCSI_DEVICE_PATH *)DevicePath; + Dev =3D PVSCSI_FROM_PASS_THRU (This); + if (ScsiDevicePath->Pun > Dev->MaxTarget || + ScsiDevicePath->Lun > Dev->MaxLun) { + return EFI_NOT_FOUND; + } + + // + // We only use first byte of target identifer + // + **Target =3D (UINT8)ScsiDevicePath->Pun; + ZeroMem (*Target + 1, TARGET_MAX_BYTES - 1); + *Lun =3D ScsiDevicePath->Lun; + + return EFI_SUCCESS; } =20 STATIC --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56540): https://edk2.groups.io/g/devel/message/56540 Mute This Topic: https://groups.io/mt/72617132/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56541+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56541+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425534; cv=none; d=zohomail.com; s=zohoarc; b=GCFXE4t6P+acdp3iUB1CrQTbOIrYcL/qGvHzpI1YtMxODj+M5Jezfm1BGVx1AzKDXB6go7qbANBjRv2vlnDY7cx6u5PKgVF3vlGxemVdazw9OdLyoRbZSo1GcDl+b1+osjx+f3okmkVmJVrnAjDnpIbqs4KpaKhr6RIRsIimGFw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=vHlLk7hRrAHx23o1EQmF8kZHa4WmffABvK8Fm5bcCQ8=; b=MfJgI0vBeE8hxifuL0J91SynlaBQQ3YAIk49WBG29y3yDuQS9SVX9qMOmdnCAJKoC83WL6g6WnVcKY/y1T/bV3+TzrKx7KtF8BPCht8ijv/WKeWKPBDoWOLlpy+4LiCx4fCzFc/c96AT4gZpuAhstTOimAaHXmJpZ8sLlpEuEr4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56541+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425534543872.5186143777887; Sat, 28 Mar 2020 12:58:54 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CIOOYY1788612xm8saFJVg5J; Sat, 28 Mar 2020 12:58:54 -0700 X-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 X-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 X-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 X-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 X-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 X-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 X-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: [edk2-devel] [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> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: bKGhQMxfCDflpI7u3r7wppQqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425534; bh=JLK4r0B9TbuD8wuSJ9CJiFNm3pIWyiBQp+MqSy74W1k=; h=Cc:Date:From:Reply-To:Subject:To; b=H7qcPFcNf3SITe+Cz9FUFxsECPFopyHszUlQp1PKV8ItQOuOkm17WvOaADmCAFkKA+Q YQRNZ2is8ikRqYoMcZnXyyGzrHVg6et2uuDgAX6p7phmpNsK4SU4VHVVXZqG6SfwOjpvk AZbNifLFkQYP/SFafk+pZ1Z4+qnkGRUT8SU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- 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; } =20 - Status =3D PvScsiInit (Dev); + Status =3D gBS->OpenProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + (VOID **)&Dev->PciIo, + This->DriverBindingHandle, + ControllerHandle, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); if (EFI_ERROR (Status)) { goto FreePvScsi; } =20 + Status =3D PvScsiInit (Dev); + if (EFI_ERROR (Status)) { + goto ClosePciIo; + } + // // Setup complete, attempt to export the driver instance's PassThru inte= rface // @@ -436,6 +448,14 @@ PvScsiDriverBindingStart ( UninitDev: PvScsiUninit (Dev); =20 +ClosePciIo: + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + FreePvScsi: FreePool (Dev); =20 @@ -481,6 +501,13 @@ PvScsiDriverBindingStop ( =20 PvScsiUninit (Dev); =20 + gBS->CloseProtocol ( + ControllerHandle, + &gEfiPciIoProtocolGuid, + This->DriverBindingHandle, + ControllerHandle + ); + FreePool (Dev); =20 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 @@ =20 typedef struct { UINT32 Signature; + EFI_PCI_IO_PROTOCOL *PciIo; UINT8 MaxTarget; UINT8 MaxLun; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56541): https://edk2.groups.io/g/devel/message/56541 Mute This Topic: https://groups.io/mt/72617133/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56542+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56542+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425536; cv=none; d=zohomail.com; s=zohoarc; b=bh1OOee4a0VfcIesxCCb3Z5oor47BcESfksjrIjLd9wmz0KZ2+PLeXtFrW2DgpICRNaH+ACR46p4doVXISaE3s7KQf1jvwyeRyiT44gK62IH4RnWCFosxVb/xe1KTWRayl17OcKWxlpj7mIhdfN81pADqAmajLh91NBQvYU9bgU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425536; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=NpTppFbUsjQP5+VR4Ix57SYyJfc1tyWxNRNC5yWu2Lk=; b=ljHSHDHgifQbvBgdaQrQR3+m7xgjIlrk5QCuO+SCgeqOQehnh89HpLVVczP9dJL7H4M93crbb13DZkd3gk6XXYrY6S6yBDVJrCpOS/07BOT3vvdRP2REnjbp4J9x/v6FSAkpICJCB0abDx46CJ+Rp7E+l0gEmiiE/ii0DGo58BI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56542+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425536750106.8755870571706; Sat, 28 Mar 2020 12:58:56 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 8G36YY1788612xYiAX19MVL4; Sat, 28 Mar 2020 12:58:56 -0700 X-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 X-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 X-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 X-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 X-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 X-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 X-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: [edk2-devel] [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> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: hrBHikDpQMbgyoGc8vJ9RRf5x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425536; bh=7ZRzqXBWE3N556GIcnCcqg+CnfXg8GW4ndIMUXMoBLU=; h=Cc:Date:From:Reply-To:Subject:To; b=TpRt0oP7xWFv4Tdeavs09n7wefbgm26/l7HCQ4drJ45sAX9OcdpSqyw+vN3HSQPgnW0 o1EMfcY+oGwY6u7BYCeUxdy0y1MUOGCTVcpuTBsMiiOQAlMo1S0PYybKLRHGL7sVj57+u WZRxlH1NyEQtLsqJCwlIDomIufN8mWL4aVc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" 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=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- 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; } =20 +STATIC +EFI_STATUS +PvScsiSetPciAttributes ( + IN OUT PVSCSI_DEV *Dev + ) +{ + EFI_STATUS Status; + + // + // Backup original PCI Attributes + // + Status =3D 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 =3D PcdGet8 (PcdPvScsiMaxTargetLimit); Dev->MaxLun =3D PcdGet8 (PcdPvScsiMaxLunLimit); =20 + // + // Set PCI Attributes + // + Status =3D 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); } =20 // 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; --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56542): https://edk2.groups.io/g/devel/message/56542 Mute This Topic: https://groups.io/mt/72617136/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56543+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56543+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425539; cv=none; d=zohomail.com; s=zohoarc; b=hgk27g8WwBpigGwResFhv2slMEKT1poUyPD1RXubTpwxRWUuO1telyDiTQcagNja9pbumrSojcqJvGJGuchuhZGeNXJZ5ImTnuGbFQk6X5ygwCA14bbSKpGnof14jS/CKmf3MPFSopnWAhpsqwNkp3b8a0roTdHy/HcF1JS1nlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425539; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=jeJVbw2NoyXRe6nmq3UmfoeFphRr3cELykt7ammbOZg=; b=MddUhiCgXZY01isbd3B+0MEYwNETQKKzA9GqO3kTGRf0GGg+q+g7vyOqFVEl/2PlKeLkl0A/StjRJ0BUNuKlV8fkcpEYSyybif0dpLMRVt7dccF8yjMk9XbiuS+q7ttbBdKu1bSs+9/mIShphOFrofzuuG/7J50WleUMwZknX7M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56543+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425539078248.21495325972262; Sat, 28 Mar 2020 12:58:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id JkywYY1788612x53fr9ItD8B; Sat, 28 Mar 2020 12:58:58 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.14127.1585425538272886956 for ; Sat, 28 Mar 2020 12:58:58 -0700 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJwv5U123616; Sat, 28 Mar 2020 19:58:57 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 301y7mhf8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:57 +0000 X-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 02SJo761031490; Sat, 28 Mar 2020 19:58:57 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 301vm90q4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:58:57 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJwutR017129; Sat, 28 Mar 2020 19:58:56 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:56 -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: [edk2-devel] [PATCH v3 10/17] OvmfPkg/PvScsiDxe: Enable MMIO-Space & Bus-Mastering in PCI attributes Date: Sat, 28 Mar 2020 23:00:53 +0300 Message-Id: <20200328200100.60786-11-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: InQkQka5mKvg6wF7eh5Q9IWgx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425538; bh=K4BJkq7ntjbqvXy/0EZ2q3ZHZsj04v+k4GqF/f6x85Q=; h=Cc:Date:From:Reply-To:Subject:To; b=Blcg1KgXpw7cZx6qQxoO+STfncADGM4zVybJGL5nJaHt43XglDOXBOkn6+TBeX3YS1w JdbRo7etUoXBS32H+qVehcPhCAcvAFlaWcwTb/P7hwIPJn5ntV4chqrbtThFBNjFgitSl mKcPFt43AdMh+spy1cvMaet7zm5/rOE4wNM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Enable MMIO-Space & Bus-Mastering PCI attributes when device is started. Note that original PCI attributes are restored when device is stopped. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 5566b4cce467..531bed4e5ab7 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -305,8 +305,18 @@ PvScsiSetPciAttributes ( } =20 // - // TODO: Change PCI Attributes + // Enable MMIO-Space & Bus-Mastering // + Status =3D Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationEnable, + (EFI_PCI_IO_ATTRIBUTE_MEMORY | + EFI_PCI_IO_ATTRIBUTE_BUS_MASTER), + NULL + ); + if (EFI_ERROR (Status)) { + return Status; + } =20 return EFI_SUCCESS; } --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56543): https://edk2.groups.io/g/devel/message/56543 Mute This Topic: https://groups.io/mt/72617138/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56544+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56544+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425542; cv=none; d=zohomail.com; s=zohoarc; b=V1KSDoGSMShTEvyaBWFECgKvD43gxvs2b7YK92lLI+w2g6elLG0mQI9icFVxGtDOBBev/PlwKgd5tH2lZIYgTYcRkqb4dhsHOOS3MkqAnt10TVq5NVcLgyrviCaSyOD9Krq0J+KMoo7BsTUS7KyQUWm/DFM/ut/3BCLJiPZLsQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425542; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=T2iKaT8f5DBGWnNxYicskngscMk5hzWxIT+Fn9B7ats=; b=Dgyu6FzoDBSICiuvj0Pl1CMSvV+hpZuya5cBtE4TxRCcN+nZCWqUjeUrZ/HYqw2cjRlMgoO5Q2ClLsABleQeHyQdt34f6UURoX0wLyUcXtCcKX1/y1/wyKXdffqpEf2hsJecp1cyDlBp5ScfIjK69ridnbVnJXbIHRTwtDjJc6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56544+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425542514165.47720814689148; Sat, 28 Mar 2020 12:59:02 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GK2IYY1788612xiTnaE5fOg3; Sat, 28 Mar 2020 12:59:02 -0700 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.14079.1585425541501068302 for ; Sat, 28 Mar 2020 12:59:01 -0700 X-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 02SJlFLw028015; Sat, 28 Mar 2020 19:59:01 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 301xhkhh02-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:00 +0000 X-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 02SJoKGJ031927; Sat, 28 Mar 2020 19:59:00 GMT X-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 301vm90q6b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:00 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJwxWZ007274; Sat, 28 Mar 2020 19:58:59 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:58:58 -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: [edk2-devel] [PATCH v3 11/17] OvmfPkg/PvScsiDxe: Define device interface structures and constants Date: Sat, 28 Mar 2020 23:00:54 +0300 Message-Id: <20200328200100.60786-12-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: ixntvQjbPdNxHw7SPC7l3zO1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425542; bh=r1zE8kZfAV8xD8f1Qsloug45CIrfnh/NYRxyYF0YVm0=; h=Cc:Date:From:Reply-To:Subject:To; b=dCnPSl5Z0wdQHQJdg/uH8d0pjIhaVSPTmS5vsI1Q2gEfHvZv/Mw49rg7x+wC/oQK+2A E1ngHG4+zSx3GzozP/NwhWKHAzcANAH9EjaXLzzznaRM9HuEJcpwtCkwidhhGuahPv6J8 bmJ0QxPSUQolgq7iDxOnD/IlP/eOuky1u8Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" These definitions will be used by the following commits to complete the implementation of PVSCSI device driver. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Acked-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/Include/IndustryStandard/PvScsi.h | 165 ++++++++++++++++++++++ 1 file changed, 165 insertions(+) diff --git a/OvmfPkg/Include/IndustryStandard/PvScsi.h b/OvmfPkg/Include/In= dustryStandard/PvScsi.h index 004c0af84989..a4d6634f3ba0 100644 --- a/OvmfPkg/Include/IndustryStandard/PvScsi.h +++ b/OvmfPkg/Include/IndustryStandard/PvScsi.h @@ -18,4 +18,169 @@ #define PCI_VENDOR_ID_VMWARE (0x15ad) #define PCI_DEVICE_ID_VMWARE_PVSCSI (0x07c0) =20 +// +// CDB (Command Descriptor Block) with size above this constant +// should be considered out-of-band +// +#define PVSCSI_CDB_MAX_SIZE (16) + +typedef enum { + PvScsiRegOffsetCommand =3D 0x0, + PvScsiRegOffsetCommandData =3D 0x4, + PvScsiRegOffsetCommandStatus =3D 0x8, + PvScsiRegOffsetLastSts0 =3D 0x100, + PvScsiRegOffsetLastSts1 =3D 0x104, + PvScsiRegOffsetLastSts2 =3D 0x108, + PvScsiRegOffsetLastSts3 =3D 0x10c, + PvScsiRegOffsetIntrStatus =3D 0x100c, + PvScsiRegOffsetIntrMask =3D 0x2010, + PvScsiRegOffsetKickNonRwIo =3D 0x3014, + PvScsiRegOffsetDebug =3D 0x3018, + PvScsiRegOffsetKickRwIo =3D 0x4018, +} PVSCSI_BAR0_OFFSETS; + +// +// Define Interrupt-Status register flags +// +#define PVSCSI_INTR_CMPL_0 BIT0 +#define PVSCSI_INTR_CMPL_1 BIT1 +#define PVSCSI_INTR_CMPL_MASK (PVSCSI_INTR_CMPL_0 | PVSCSI_INTR_CMPL_1) + +typedef enum { + PvScsiCmdFirst =3D 0, + PvScsiCmdAdapterReset =3D 1, + PvScsiCmdIssueScsi =3D 2, + PvScsiCmdSetupRings =3D 3, + PvScsiCmdResetBus =3D 4, + PvScsiCmdResetDevice =3D 5, + PvScsiCmdAbortCmd =3D 6, + PvScsiCmdConfig =3D 7, + PvScsiCmdSetupMsgRing =3D 8, + PvScsiCmdDeviceUnplug =3D 9, + PvScsiCmdLast =3D 10 +} PVSCSI_COMMANDS; + +#define PVSCSI_SETUP_RINGS_MAX_NUM_PAGES (32) + +#pragma pack (1) +typedef struct { + UINT32 ReqRingNumPages; + UINT32 CmpRingNumPages; + UINT64 RingsStatePPN; + UINT64 ReqRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES]; + UINT64 CmpRingPPNs[PVSCSI_SETUP_RINGS_MAX_NUM_PAGES]; +} PVSCSI_CMD_DESC_SETUP_RINGS; +#pragma pack () + +#define PVSCSI_MAX_CMD_DATA_WORDS \ + (sizeof (PVSCSI_CMD_DESC_SETUP_RINGS) / sizeof (UINT32)) + +#pragma pack (1) +typedef struct { + UINT32 ReqProdIdx; + UINT32 ReqConsIdx; + UINT32 ReqNumEntriesLog2; + + UINT32 CmpProdIdx; + UINT32 CmpConsIdx; + UINT32 CmpNumEntriesLog2; + + UINT8 Pad[104]; + + UINT32 MsgProdIdx; + UINT32 MsgConsIdx; + UINT32 MsgNumEntriesLog2; +} PVSCSI_RINGS_STATE; +#pragma pack () + +// +// Define PVSCSI request descriptor tags +// +#define PVSCSI_SIMPLE_QUEUE_TAG (0x20) + +// +// Define PVSCSI request descriptor flags +// +#define PVSCSI_FLAG_CMD_WITH_SG_LIST BIT0 +#define PVSCSI_FLAG_CMD_OUT_OF_BAND_CDB BIT1 +#define PVSCSI_FLAG_CMD_DIR_NONE BIT2 +#define PVSCSI_FLAG_CMD_DIR_TOHOST BIT3 +#define PVSCSI_FLAG_CMD_DIR_TODEVICE BIT4 + +#pragma pack (1) +typedef struct { + UINT64 Context; + UINT64 DataAddr; + UINT64 DataLen; + UINT64 SenseAddr; + UINT32 SenseLen; + UINT32 Flags; + UINT8 Cdb[16]; + UINT8 CdbLen; + UINT8 Lun[8]; + UINT8 Tag; + UINT8 Bus; + UINT8 Target; + UINT8 VcpuHint; + UINT8 Unused[59]; +} PVSCSI_RING_REQ_DESC; +#pragma pack () + +// +// Host adapter status/error codes +// +typedef enum { + PvScsiBtStatSuccess =3D 0x00, // CCB complete normally with no er= rors + PvScsiBtStatLinkedCommandCompleted =3D 0x0a, + PvScsiBtStatLinkedCommandCompletedWithFlag =3D 0x0b, + PvScsiBtStatDataUnderrun =3D 0x0c, + PvScsiBtStatSelTimeout =3D 0x11, // SCSI selection timeout + PvScsiBtStatDatarun =3D 0x12, // Data overrun/underrun + PvScsiBtStatBusFree =3D 0x13, // Unexpected bus free + PvScsiBtStatInvPhase =3D 0x14, // + // Invalid bus phase or sequence requ= ested + // by target + // + PvScsiBtStatLunMismatch =3D 0x17, // + // Linked CCB has different LUN from = first + // CCB + // + PvScsiBtStatSensFailed =3D 0x1b, // Auto request sense failed + PvScsiBtStatTagReject =3D 0x1c, // + // SCSI II tagged queueing message re= jected + // by target + // + PvScsiBtStatBadMsg =3D 0x1d, // + // Unsupported message received by th= e host + // adapter + // + PvScsiBtStatHaHardware =3D 0x20, // Host adapter hardware failed + PvScsiBtStatNoResponse =3D 0x21, // + // Target did not respond to SCSI ATN= sent + // a SCSI RST + // + PvScsiBtStatSentRst =3D 0x22, // Host adapter asserted a SCSI RST + PvScsiBtStatRecvRst =3D 0x23, // Other SCSI devices asserted a SC= SI RST + PvScsiBtStatDisconnect =3D 0x24, // + // Target device reconnected improper= ly + // (w/o tag) + // + PvScsiBtStatBusReset =3D 0x25, // Host adapter issued BUS device r= eset + PvScsiBtStatAbortQueue =3D 0x26, // Abort queue generated + PvScsiBtStatHaSoftware =3D 0x27, // Host adapter software error + PvScsiBtStatHaTimeout =3D 0x30, // Host adapter hardware timeout er= ror + PvScsiBtStatScsiParity =3D 0x34, // SCSI parity error detected +} PVSCSI_HOST_BUS_ADAPTER_STATUS; + +#pragma pack (1) +typedef struct { + UINT64 Context; + UINT64 DataLen; + UINT32 SenseLen; + UINT16 HostStatus; + UINT16 ScsiStatus; + UINT32 Pad[2]; +} PVSCSI_RING_CMP_DESC; +#pragma pack () + #endif // __PVSCSI_H_ --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56544): https://edk2.groups.io/g/devel/message/56544 Mute This Topic: https://groups.io/mt/72617141/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56545+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56545+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425546; cv=none; d=zohomail.com; s=zohoarc; b=D3jvQS0yQSF0PLw5lVNMQH00X2eJvf7fNTFqWz9xPENf75ux51qTLCRlIONEuP/dZKuRSolcKrxcYxf7UXUNuw0nUhM7JNkNlSIPCYe8GjXo7piBPWTCXvbhQHCTULDUXrLW0cofJkTsJ8VepTA15cg/x08uOQG/92qJ5AKcicw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425546; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=VYNmw3+H8LY9wxQzhYsw1in7C6Y42yatDE9UucJ8tt8=; b=VCDdUlLqQyvekJwQJ/IE4Fwr5ziCfcT87TyVuFN2XHhiKsGJ67fOp/AA6u8KUTHrHAn1Z0LDkzbE51la2uqsW0tO0BRA5STpZiqAD/m6cID3qknZcbPdOC+2tatUlRNGWMfFCQGrebyiPbuAUCnSFmOpussuWPNkTJ7hJtQvBrY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56545+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 158542554623693.74043742421884; Sat, 28 Mar 2020 12:59:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id fcVFYY1788612xl0aNc9jAzp; Sat, 28 Mar 2020 12:59:05 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.14081.1585425545041524695 for ; Sat, 28 Mar 2020 12:59:05 -0700 X-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 02SJnLcd014007; Sat, 28 Mar 2020 19:59:04 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 301x0qsj8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:04 +0000 X-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 02SJomAL164617; Sat, 28 Mar 2020 19:59:04 GMT X-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 301ups6hbc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:04 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJx3j3007284; Sat, 28 Mar 2020 19:59:03 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:01 -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: [edk2-devel] [PATCH v3 12/17] OvmfPkg/PvScsiDxe: Reset adapter on init Date: Sat, 28 Mar 2020 23:00:55 +0300 Message-Id: <20200328200100.60786-13-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: YnUw93kfAqrrW4HLPqib8w4bx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425545; bh=vFE7vbmPDaHXTz6j/odqYPtGQ71CPRY8YzF9NsJ0qII=; h=Cc:Date:From:Reply-To:Subject:To; b=Cx1ht2Q9aNY7ssPAY4o8vECP8KZRa1awFxehaVboGzm/Rqx7oWuAE8GmL4baXzZa8mH g0TqQ7xKwOMhchEFWAwVRnWQwE1jrpMcOc9TvNH3VGmCXaCSIcYixEWOaiJsJcuSlnbN9 jIyyi9lbj41KDlCO4pxzDK1cXKqHyDL0Vqc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The following commits will complete the implementation of device initialization. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 531bed4e5ab7..cf75884350ee 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -30,6 +30,107 @@ // Ext SCSI Pass Thru utilities // =20 +/** + Writes a 32-bit value into BAR0 using MMIO +**/ +STATIC +EFI_STATUS +PvScsiMmioWrite32 ( + IN CONST PVSCSI_DEV *Dev, + IN UINT64 Offset, + IN UINT32 Value + ) +{ + return Dev->PciIo->Mem.Write ( + Dev->PciIo, + EfiPciIoWidthUint32, + PCI_BAR_IDX0, + Offset, + 1, // Count + &Value + ); +} + +/** + Writes multiple words of data into BAR0 using MMIO +**/ +STATIC +EFI_STATUS +PvScsiMmioWrite32Multiple ( + IN CONST PVSCSI_DEV *Dev, + IN UINT64 Offset, + IN UINTN Count, + IN UINT32 *Words + ) +{ + return Dev->PciIo->Mem.Write ( + Dev->PciIo, + EfiPciIoWidthFifoUint32, + PCI_BAR_IDX0, + Offset, + Count, + Words + ); +} + +/** + Send a PVSCSI command to device. + + @param[in] Dev The pvscsi host device. + @param[in] Cmd The command to send to device. + @param[in] OPTIONAL DescWords An optional command descriptor (If com= mand + have a descriptor). The descriptor is + provided as an array of UINT32 words a= nd + is must be 32-bit aligned. + @param[in] DescWordsCount The number of words in command descrip= tor. + Caller must specify here 0 if DescWords + is not supplied (It is optional). In t= hat + case, DescWords is ignored. + + @return Status codes returned by Dev->PciIo->Mem.Write(). + +**/ +STATIC +EFI_STATUS +PvScsiWriteCmdDesc ( + IN CONST PVSCSI_DEV *Dev, + IN UINT32 Cmd, + IN UINT32 *DescWords OPTIONAL, + IN UINTN DescWordsCount + ) +{ + EFI_STATUS Status; + + if (DescWordsCount > PVSCSI_MAX_CMD_DATA_WORDS) { + return EFI_INVALID_PARAMETER; + } + + Status =3D PvScsiMmioWrite32 (Dev, PvScsiRegOffsetCommand, Cmd); + if (EFI_ERROR (Status)) { + return Status; + } + + if (DescWordsCount > 0) { + return PvScsiMmioWrite32Multiple ( + Dev, + PvScsiRegOffsetCommandData, + DescWordsCount, + DescWords + ); + } + + return EFI_SUCCESS; +} + +STATIC +EFI_STATUS +PvScsiResetAdapter ( + IN CONST PVSCSI_DEV *Dev + ) +{ + return PvScsiWriteCmdDesc (Dev, PvScsiCmdAdapterReset, NULL, 0); +} + /** Check if Target argument to EXT_SCSI_PASS_THRU.GetNextTarget() and EXT_SCSI_PASS_THRU.GetNextTargetLun() is initialized @@ -357,6 +458,14 @@ PvScsiInit ( return Status; } =20 + // + // Reset adapter + // + Status =3D PvScsiResetAdapter (Dev); + if (EFI_ERROR (Status)) { + goto RestorePciAttributes; + } + // // Populate the exported interface's attributes // @@ -387,6 +496,11 @@ PvScsiInit ( Dev->PassThruMode.IoAlign =3D 0; =20 return EFI_SUCCESS; + +RestorePciAttributes: + PvScsiRestorePciAttributes (Dev); + + return Status; } =20 STATIC --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56545): https://edk2.groups.io/g/devel/message/56545 Mute This Topic: https://groups.io/mt/72617145/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56546+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56546+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425548; cv=none; d=zohomail.com; s=zohoarc; b=WzatFsU+0ggoCANj8MmNXn9Krdkixl0dtARWrFU5tgEPWjW5gqzKYU2SKzOWv39gCKS6KOu1yxhCVd4AwVwlUIxebFdCH1OYU4WBgQzTIM41OiHTiCcnV2fpzFqlSje8spmlcp8QhYn9evfeJK2LiLFAtiCAqVX4dWpcCPkgoik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425548; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=tky7p+KHo0mZlAjvldK7yaXBRc3QnTS+C+lqbOiD60A=; b=XmfHP+KRn6lb2lO6Yp0iajtDUSkQDX+KdSaigLNkfM3rgNWtTroj4G7cCV/pYB+UnyWWtGQsE3B89k6Co5W7KmPAE9juwthSMmWkCa65WjI/kt0mkpHTEVMBrq41UVPnPjMnOfXyTvEkYknRqOJ05CRgOBnLIEDBctdL85VbXwE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56546+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425548271468.7206499053983; Sat, 28 Mar 2020 12:59:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SwaDYY1788612xHMkrrGLilk; Sat, 28 Mar 2020 12:59:07 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.14083.1585425547328295934 for ; Sat, 28 Mar 2020 12:59:07 -0700 X-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 02SJnKOS013982; Sat, 28 Mar 2020 19:59:07 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 301x0qsj8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:06 +0000 X-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 02SJom9R032737; Sat, 28 Mar 2020 19:59:06 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 301vm90q8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:06 +0000 X-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 02SJx5qj025080; Sat, 28 Mar 2020 19:59:05 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:05 -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: [edk2-devel] [PATCH v3 13/17] OvmfPkg/PvScsiDxe: Setup requests and completions rings Date: Sat, 28 Mar 2020 23:00:56 +0300 Message-Id: <20200328200100.60786-14-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: qYoduWkUORBSM2wwr2Io4dtOx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425547; bh=bA0CQNqiRTjv36h8nZ/w+6e5shN95qOuMmUSskDfgiI=; h=Cc:Date:From:Reply-To:Subject:To; b=H05z/a0v0FKimnTWSKTfOSaJEyNPtyT68YT4kigmWKiz+vtjGGbubPE20AE/7EjFXIz W5g8QTHbgL+vNghl5VInTKNadgPivAnZn2wRLxuV3AFHp7Z8MiEXcuAFt5d194CHqvqKG riy/Ozp/rWHwaoWlE8zwtgyFZW2ZGkElnzk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" These rings are shared memory buffers between host and device in which a cyclic buffer is managed to send request descriptors from host to device and receive completion descriptors from device to host. Note that because device may be constrained by IOMMU or guest may be run under AMD SEV, we make sure to map these rings to device by using PciIo->Map(). Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Signed-off-by: Liran Alon Reviewed-by: Laszlo Ersek Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 219 ++++++++++++++++++++++++++++++++ OvmfPkg/PvScsiDxe/PvScsi.h | 17 +++ OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 1 + 3 files changed, 237 insertions(+) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index cf75884350ee..c7d367e83a2d 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -11,11 +11,13 @@ =20 #include #include +#include #include #include #include #include #include +#include #include =20 #include "PvScsi.h" @@ -436,6 +438,207 @@ PvScsiRestorePciAttributes ( ); } =20 +STATIC +EFI_STATUS +PvScsiAllocateSharedPages ( + IN PVSCSI_DEV *Dev, + IN UINTN Pages, + OUT VOID **HostAddress, + OUT PVSCSI_DMA_DESC *DmaDesc + ) +{ + EFI_STATUS Status; + UINTN NumberOfBytes; + + Status =3D Dev->PciIo->AllocateBuffer ( + Dev->PciIo, + AllocateAnyPages, + EfiBootServicesData, + Pages, + HostAddress, + EFI_PCI_ATTRIBUTE_MEMORY_CACHED + ); + if (EFI_ERROR (Status)) { + return Status; + } + + NumberOfBytes =3D EFI_PAGES_TO_SIZE (Pages); + Status =3D Dev->PciIo->Map ( + Dev->PciIo, + EfiPciIoOperationBusMasterCommonBuffer, + *HostAddress, + &NumberOfBytes, + &DmaDesc->DeviceAddress, + &DmaDesc->Mapping + ); + if (EFI_ERROR (Status)) { + goto FreeBuffer; + } + + if (NumberOfBytes !=3D EFI_PAGES_TO_SIZE (Pages)) { + Status =3D EFI_OUT_OF_RESOURCES; + goto Unmap; + } + + return EFI_SUCCESS; + +Unmap: + Dev->PciIo->Unmap (Dev->PciIo, DmaDesc->Mapping); + +FreeBuffer: + Dev->PciIo->FreeBuffer (Dev->PciIo, Pages, *HostAddress); + + return Status; +} + +STATIC +VOID +PvScsiFreeSharedPages ( + IN PVSCSI_DEV *Dev, + IN UINTN Pages, + IN VOID *HostAddress, + IN PVSCSI_DMA_DESC *DmaDesc + ) +{ + Dev->PciIo->Unmap (Dev->PciIo, DmaDesc->Mapping); + Dev->PciIo->FreeBuffer (Dev->PciIo, Pages, HostAddress); +} + +STATIC +EFI_STATUS +PvScsiInitRings ( + IN OUT PVSCSI_DEV *Dev + ) +{ + EFI_STATUS Status; + union { + PVSCSI_CMD_DESC_SETUP_RINGS Cmd; + UINT32 Uint32; + } AlignedCmd; + PVSCSI_CMD_DESC_SETUP_RINGS *Cmd; + + Cmd =3D &AlignedCmd.Cmd; + + Status =3D PvScsiAllocateSharedPages ( + Dev, + 1, + (VOID **)&Dev->RingDesc.RingState, + &Dev->RingDesc.RingStateDmaDesc + ); + if (EFI_ERROR (Status)) { + return Status; + } + ZeroMem (Dev->RingDesc.RingState, EFI_PAGE_SIZE); + + Status =3D PvScsiAllocateSharedPages ( + Dev, + 1, + (VOID **)&Dev->RingDesc.RingReqs, + &Dev->RingDesc.RingReqsDmaDesc + ); + if (EFI_ERROR (Status)) { + goto FreeRingState; + } + ZeroMem (Dev->RingDesc.RingReqs, EFI_PAGE_SIZE); + + Status =3D PvScsiAllocateSharedPages ( + Dev, + 1, + (VOID **)&Dev->RingDesc.RingCmps, + &Dev->RingDesc.RingCmpsDmaDesc + ); + if (EFI_ERROR (Status)) { + goto FreeRingReqs; + } + ZeroMem (Dev->RingDesc.RingCmps, EFI_PAGE_SIZE); + + ZeroMem (Cmd, sizeof (*Cmd)); + Cmd->ReqRingNumPages =3D 1; + Cmd->CmpRingNumPages =3D 1; + Cmd->RingsStatePPN =3D RShiftU64 ( + Dev->RingDesc.RingStateDmaDesc.DeviceAddress, + EFI_PAGE_SHIFT + ); + Cmd->ReqRingPPNs[0] =3D RShiftU64 ( + Dev->RingDesc.RingReqsDmaDesc.DeviceAddress, + EFI_PAGE_SHIFT + ); + Cmd->CmpRingPPNs[0] =3D RShiftU64 ( + Dev->RingDesc.RingCmpsDmaDesc.DeviceAddress, + EFI_PAGE_SHIFT + ); + + STATIC_ASSERT ( + sizeof (*Cmd) % sizeof (UINT32) =3D=3D 0, + "Cmd must be multiple of 32-bit words" + ); + Status =3D PvScsiWriteCmdDesc ( + Dev, + PvScsiCmdSetupRings, + (UINT32 *)Cmd, + sizeof (*Cmd) / sizeof (UINT32) + ); + if (EFI_ERROR (Status)) { + goto FreeRingCmps; + } + + return EFI_SUCCESS; + +FreeRingCmps: + PvScsiFreeSharedPages ( + Dev, + 1, + Dev->RingDesc.RingCmps, + &Dev->RingDesc.RingCmpsDmaDesc + ); + +FreeRingReqs: + PvScsiFreeSharedPages ( + Dev, + 1, + Dev->RingDesc.RingReqs, + &Dev->RingDesc.RingReqsDmaDesc + ); + +FreeRingState: + PvScsiFreeSharedPages ( + Dev, + 1, + Dev->RingDesc.RingState, + &Dev->RingDesc.RingStateDmaDesc + ); + + return Status; +} + +STATIC +VOID +PvScsiFreeRings ( + IN OUT PVSCSI_DEV *Dev + ) +{ + PvScsiFreeSharedPages ( + Dev, + 1, + Dev->RingDesc.RingCmps, + &Dev->RingDesc.RingCmpsDmaDesc + ); + + PvScsiFreeSharedPages ( + Dev, + 1, + Dev->RingDesc.RingReqs, + &Dev->RingDesc.RingReqsDmaDesc + ); + + PvScsiFreeSharedPages ( + Dev, + 1, + Dev->RingDesc.RingState, + &Dev->RingDesc.RingStateDmaDesc + ); +} + STATIC EFI_STATUS PvScsiInit ( @@ -466,6 +669,14 @@ PvScsiInit ( goto RestorePciAttributes; } =20 + // + // Init PVSCSI rings + // + Status =3D PvScsiInitRings (Dev); + if (EFI_ERROR (Status)) { + goto RestorePciAttributes; + } + // // Populate the exported interface's attributes // @@ -509,6 +720,14 @@ PvScsiUninit ( IN OUT PVSCSI_DEV *Dev ) { + // + // Reset device to stop device usage of the rings. + // This is required to safely free the rings. + // + PvScsiResetAdapter (Dev); + + PvScsiFreeRings (Dev); + PvScsiRestorePciAttributes (Dev); } =20 diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index 5f611dbbc98c..6d23b6e1eccf 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -15,12 +15,29 @@ #include #include =20 +typedef struct { + EFI_PHYSICAL_ADDRESS DeviceAddress; + VOID *Mapping; +} PVSCSI_DMA_DESC; + +typedef struct { + PVSCSI_RINGS_STATE *RingState; + PVSCSI_DMA_DESC RingStateDmaDesc; + + PVSCSI_RING_REQ_DESC *RingReqs; + PVSCSI_DMA_DESC RingReqsDmaDesc; + + PVSCSI_RING_CMP_DESC *RingCmps; + PVSCSI_DMA_DESC RingCmpsDmaDesc; +} PVSCSI_RING_DESC; + #define PVSCSI_SIG SIGNATURE_32 ('P', 'S', 'C', 'S') =20 typedef struct { UINT32 Signature; EFI_PCI_IO_PROTOCOL *PciIo; UINT64 OriginalPciAttributes; + PVSCSI_RING_DESC RingDesc; UINT8 MaxTarget; UINT8 MaxLun; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf index fcffc90d46c8..6200533698fc 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -26,6 +26,7 @@ OvmfPkg/OvmfPkg.dec =20 [LibraryClasses] + BaseLib BaseMemoryLib DebugLib MemoryAllocationLib --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56546): https://edk2.groups.io/g/devel/message/56546 Mute This Topic: https://groups.io/mt/72617147/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56547+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56547+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425550; cv=none; d=zohomail.com; s=zohoarc; b=JUsCZ2QMiiQzjZ2ROO30elSF1v2BJ4OJ1TprVmpFiIxRRop2oWtYBubP6Nf3ECFGsLmArKWiCot2UQGX4Zq/2mx08N/Lk0KrFWqQUXcXgXeeN4KpspPap/vttx1zJfoIZt3VsQbqyyP7XX+rONMXF+lPkAfqBgyvbCelAt8uxqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425550; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=uTZXq+zjICwdSZPgxJIT/OqpN69SBi848Onp+x8gQyA=; b=bEcp008+MnUXQvBHcegOff3qhyTl9VE4X+DssdW1rdhsn1s2Qbf9/VeVN2yWl1q9FVqUzCDKP45bXaPPGUwkYFz4G5lOvq69IEHZvUiMljtRhfYc97ncXPCBxHCkxByE/PHK/AwsS+sLR++AqnCoNwE9hnUJzw+8OXH+zWXW3xI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56547+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425550573993.1240356508212; Sat, 28 Mar 2020 12:59:10 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VSf9YY1788612xPWSvbDmded; Sat, 28 Mar 2020 12:59:10 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.14133.1585425549698059737 for ; Sat, 28 Mar 2020 12:59:09 -0700 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJmRmd032626; Sat, 28 Mar 2020 19:59:09 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 301y7mhf90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:09 +0000 X-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 02SJo8rZ031560; Sat, 28 Mar 2020 19:59:08 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 301vm90q9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:08 +0000 X-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 02SJx87L025087; Sat, 28 Mar 2020 19:59:08 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:07 -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: [edk2-devel] [PATCH v3 14/17] OvmfPkg/PvScsiDxe: Introduce DMA communication buffer Date: Sat, 28 Mar 2020 23:00:57 +0300 Message-Id: <20200328200100.60786-15-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: YvpaGABBTurRP9eZaSbhCFzzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425550; bh=bWb59eS8bp/g2lUGWJc9Tg+BV82an04IEYLyqmWSmOk=; h=Cc:Date:From:Reply-To:Subject:To; b=BUuUR2FuCUvm2e0wnwU336+VCI8XxbOmSC/MrN0A+qsUKAooGSitWx7kMhoJyhBK6nr 9pAAuf62ZpueswCpZ7yRx9xORzDsuOrCzgGv2Kd+hkQzWoLuyz4dHQ5KHyjSu2y8S78Sh Y249nAYEm/5K8GEX7s3NrBK3qYCjVqjLvWA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In case device is constrained by IOMMU or guest is running under AMD SEV, input/output buffers provided to device (DataBuffer and SenseData) needs to be explicitly mapped to device by PciIo->Map(). To avoid the overhead of mapping/unmapping the DataBuffer and SenseData to the device for every SCSI requst (and to simplify code), introduce a single DMA communication buffer that will be mapped to device on initialization. When a SCSI request needs to be sent to device, the DataBuffer and SenseData will be copied from/to the DMA communication buffer as required. This will be done by the following commits. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Signed-off-by: Liran Alon Reviewed-by: Laszlo Ersek Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 60 ++++++++++++++++++++++++++++++-------- OvmfPkg/PvScsiDxe/PvScsi.h | 20 +++++++++++++ 2 files changed, 68 insertions(+), 12 deletions(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index c7d367e83a2d..6e350bb2d6e0 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -677,6 +677,19 @@ PvScsiInit ( goto RestorePciAttributes; } =20 + // + // Allocate DMA communication buffer + // + Status =3D PvScsiAllocateSharedPages ( + Dev, + EFI_SIZE_TO_PAGES (sizeof (*Dev->DmaBuf)), + (VOID **)&Dev->DmaBuf, + &Dev->DmaBufDmaDesc + ); + if (EFI_ERROR (Status)) { + goto FreeRings; + } + // // Populate the exported interface's attributes // @@ -708,18 +721,7 @@ PvScsiInit ( =20 return EFI_SUCCESS; =20 -RestorePciAttributes: - PvScsiRestorePciAttributes (Dev); - - return Status; -} - -STATIC -VOID -PvScsiUninit ( - IN OUT PVSCSI_DEV *Dev - ) -{ +FreeRings: // // Reset device to stop device usage of the rings. // This is required to safely free the rings. @@ -728,6 +730,40 @@ PvScsiUninit ( =20 PvScsiFreeRings (Dev); =20 +RestorePciAttributes: + PvScsiRestorePciAttributes (Dev); + + return Status; +} + +STATIC +VOID +PvScsiUninit ( + IN OUT PVSCSI_DEV *Dev + ) +{ + // + // Reset device to: + // - Make device stop processing all requests. + // - Stop device usage of the rings. + // + // This is required to safely free the DMA communication buffer + // and the rings. + // + PvScsiResetAdapter (Dev); + + // + // Free DMA communication buffer + // + PvScsiFreeSharedPages ( + Dev, + EFI_SIZE_TO_PAGES (sizeof (*Dev->DmaBuf)), + Dev->DmaBuf, + &Dev->DmaBufDmaDesc + ); + + PvScsiFreeRings (Dev); + PvScsiRestorePciAttributes (Dev); } =20 diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index 6d23b6e1eccf..fff12146dc75 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -31,6 +31,21 @@ typedef struct { PVSCSI_DMA_DESC RingCmpsDmaDesc; } PVSCSI_RING_DESC; =20 +typedef struct { + // + // As EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET.SenseDataLength is defi= ned + // as UINT8, defining here SenseData size to MAX_UINT8 will guarantee it + // cannot overflow when passed to device. + // + UINT8 SenseData[MAX_UINT8]; + // + // This size of the data is arbitrarily chosen. + // It seems to be sufficient for all I/O requests sent through + // EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() for common boot scenarios. + // + UINT8 Data[0x2000]; +} PVSCSI_DMA_BUFFER; + #define PVSCSI_SIG SIGNATURE_32 ('P', 'S', 'C', 'S') =20 typedef struct { @@ -38,6 +53,8 @@ typedef struct { EFI_PCI_IO_PROTOCOL *PciIo; UINT64 OriginalPciAttributes; PVSCSI_RING_DESC RingDesc; + PVSCSI_DMA_BUFFER *DmaBuf; + PVSCSI_DMA_DESC DmaBufDmaDesc; UINT8 MaxTarget; UINT8 MaxLun; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; @@ -47,4 +64,7 @@ typedef struct { #define PVSCSI_FROM_PASS_THRU(PassThruPointer) \ CR (PassThruPointer, PVSCSI_DEV, PassThru, PVSCSI_SIG) =20 +#define PVSCSI_DMA_BUF_DEV_ADDR(Dev, MemberName) \ + (Dev->DmaBufDmaDesc.DeviceAddress + OFFSET_OF(PVSCSI_DMA_BUFFER, MemberN= ame)) + #endif // __PVSCSI_DXE_H_ --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56547): https://edk2.groups.io/g/devel/message/56547 Mute This Topic: https://groups.io/mt/72617148/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56548+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56548+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425554; cv=none; d=zohomail.com; s=zohoarc; b=nEQE8RZjNI3eRz66CVNXNHOAmt022P8iyES61JY+FRyqm0Rn8L/ZvYQ2psfxumoltWJ78n5jAWIRUFtGxsadA/U8WIVHYJMuBZThn1+8rRXP9hyGj3/guL+e+LO6+WpsZ/rkBBasV2jlirbT5OCu/nkyemgNgasWn0Lv9JjhKLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425554; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=MmXNxYM8TYJslBp1lQxrWXNPDDrYp8v2ha5GSOCeF7Y=; b=Gb6zxdsafBefpT9Bswn6gXSTQr6KhF6JpR8dxRPgVL2ueidzAf4cnDNPvt/FcU/hclTT5iEOlWWTxcvJfEocsUls8uJ1Iktv3pHNI7TWAtIks89Vi0ATQ17CzTGcRCLjrWsC1sktCxfEXsQIxHBFTKAT68WLvA3Okcrztspqx6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56548+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425554481125.82831574806585; Sat, 28 Mar 2020 12:59:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id VLR1YY1788612xyUnknkTEGu; Sat, 28 Mar 2020 12:59:14 -0700 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web10.14137.1585425553444636349 for ; Sat, 28 Mar 2020 12:59:13 -0700 X-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 02SJlMbg028036; Sat, 28 Mar 2020 19:59:13 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 301xhkhh0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:12 +0000 X-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 02SJpfFd050786; Sat, 28 Mar 2020 19:59:12 GMT X-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 301xd211cp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:12 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02SJxB9b008998; Sat, 28 Mar 2020 19:59:11 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:10 -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: [edk2-devel] [PATCH v3 15/17] OvmfPkg/PvScsiDxe: Support sending SCSI request and receive response Date: Sat, 28 Mar 2020 23:00:58 +0300 Message-Id: <20200328200100.60786-16-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: KipRVKMKDeeb2bo1lImSIpKDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425554; bh=CEnfgxykg2+vGiBjvCNP3qMrBbDpOLExnhfbw6SZqbU=; h=Cc:Date:From:Reply-To:Subject:To; b=qJwBq72BFEP1M8CyRTMRENmtq/vW4Xz9xvWwDBESkHP/2rEA3UFch5qcG1xc5CiALCE gi1774bPUoYgOv681DOH+CMObuGKcFfccXs5x2a59NpVxYpNDYSDvH45Khff/5UAwkAuI 0DZmAEb6M75VTdcUZuM9OJdurFJYJC2417I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Implement EXT_SCSI_PASS_THRU.PassThru(). Machines should be able to boot after this commit. Tested with Ubuntu 16.04 guest. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Signed-off-by: Liran Alon Reviewed-by: Laszlo Ersek Reviewed-by: Nikita Leshenko --- OvmfPkg/OvmfPkg.dec | 6 + OvmfPkg/PvScsiDxe/PvScsi.c | 456 +++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + OvmfPkg/PvScsiDxe/PvScsiDxe.inf | 5 +- 4 files changed, 465 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index a04aee5c2cd4..ff49ec0e9e6a 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -130,6 +130,12 @@ gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxTargetLimit|64|UINT8|0x36 gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxLunLimit|0|UINT8|0x37 =20 + ## After PvScsiDxe sends a SCSI request to the device, it waits for + # the request completion in a polling loop. + # This constant defines how many micro-seconds to wait between each + # polling loop iteration. + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiWaitForCmpStallInUsecs|5|UINT32|0x38 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase|0x0|UINT32|= 0x8 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize|0x0|UINT32|= 0x9 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFirmwareFdSize|0x0|UINT32|0xa diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index 6e350bb2d6e0..da3535c75220 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -32,6 +32,27 @@ // Ext SCSI Pass Thru utilities // =20 +/** + Reads a 32-bit value into BAR0 using MMIO +**/ +STATIC +EFI_STATUS +PvScsiMmioRead32 ( + IN CONST PVSCSI_DEV *Dev, + IN UINT64 Offset, + OUT UINT32 *Value + ) +{ + return Dev->PciIo->Mem.Read ( + Dev->PciIo, + EfiPciIoWidthUint32, + PCI_BAR_IDX0, + Offset, + 1, // Count + Value + ); +} + /** Writes a 32-bit value into BAR0 using MMIO **/ @@ -133,6 +154,383 @@ PvScsiResetAdapter ( return PvScsiWriteCmdDesc (Dev, PvScsiCmdAdapterReset, NULL, 0); } =20 +/** + Returns if PVSCSI request ring is full +**/ +STATIC +BOOLEAN +PvScsiIsReqRingFull ( + IN CONST PVSCSI_DEV *Dev + ) +{ + PVSCSI_RINGS_STATE *RingsState; + UINT32 ReqNumEntries; + + RingsState =3D Dev->RingDesc.RingState; + ReqNumEntries =3D 1U << RingsState->ReqNumEntriesLog2; + return (RingsState->ReqProdIdx - RingsState->CmpConsIdx) >=3D ReqNumEntr= ies; +} + +/** + Returns pointer to current request descriptor to produce +**/ +STATIC +PVSCSI_RING_REQ_DESC * +PvScsiGetCurrentRequest ( + IN CONST PVSCSI_DEV *Dev + ) +{ + PVSCSI_RINGS_STATE *RingState; + UINT32 ReqNumEntries; + + RingState =3D Dev->RingDesc.RingState; + ReqNumEntries =3D 1U << RingState->ReqNumEntriesLog2; + return Dev->RingDesc.RingReqs + + (RingState->ReqProdIdx & (ReqNumEntries - 1)); +} + +/** + Returns pointer to current completion descriptor to consume +**/ +STATIC +PVSCSI_RING_CMP_DESC * +PvScsiGetCurrentResponse ( + IN CONST PVSCSI_DEV *Dev + ) +{ + PVSCSI_RINGS_STATE *RingState; + UINT32 CmpNumEntries; + + RingState =3D Dev->RingDesc.RingState; + CmpNumEntries =3D 1U << RingState->CmpNumEntriesLog2; + return Dev->RingDesc.RingCmps + + (RingState->CmpConsIdx & (CmpNumEntries - 1)); +} + +/** + Wait for device to signal completion of submitted requests +**/ +STATIC +EFI_STATUS +PvScsiWaitForRequestCompletion ( + IN CONST PVSCSI_DEV *Dev + ) +{ + EFI_STATUS Status; + UINT32 IntrStatus; + + // + // Note: We don't yet support Timeout according to + // EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET.Timeout. + // + // This is consistent with some other Scsi PassThru drivers + // such as VirtioScsi. + // + for (;;) { + Status =3D PvScsiMmioRead32 (Dev, PvScsiRegOffsetIntrStatus, &IntrStat= us); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // PVSCSI_INTR_CMPL_MASK is set if device completed submitted requests + // + if ((IntrStatus & PVSCSI_INTR_CMPL_MASK) !=3D 0) { + break; + } + + gBS->Stall (Dev->WaitForCmpStallInUsecs); + } + + // + // Acknowledge PVSCSI_INTR_CMPL_MASK in device interrupt-status register + // + return PvScsiMmioWrite32 ( + Dev, + PvScsiRegOffsetIntrStatus, + PVSCSI_INTR_CMPL_MASK + ); +} + +/** + Create a fake host adapter error +**/ +STATIC +EFI_STATUS +ReportHostAdapterError ( + OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet + ) +{ + Packet->InTransferLength =3D 0; + Packet->OutTransferLength =3D 0; + Packet->SenseDataLength =3D 0; + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER; + Packet->TargetStatus =3D EFI_EXT_SCSI_STATUS_TARGET_GOOD; + return EFI_DEVICE_ERROR; +} + +/** + Create a fake host adapter overrun error +**/ +STATIC +EFI_STATUS +ReportHostAdapterOverrunError ( + OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet + ) +{ + Packet->SenseDataLength =3D 0; + Packet->HostAdapterStatus =3D + EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN; + Packet->TargetStatus =3D EFI_EXT_SCSI_STATUS_TARGET_GOOD; + return EFI_BAD_BUFFER_SIZE; +} + +/** + Populate a PVSCSI request descriptor from the Extended SCSI Pass Thru + Protocol packet. +**/ +STATIC +EFI_STATUS +PopulateRequest ( + IN CONST PVSCSI_DEV *Dev, + IN UINT8 *Target, + IN UINT64 Lun, + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, + OUT PVSCSI_RING_REQ_DESC *Request + ) +{ + UINT8 TargetValue; + + // + // We only use first byte of target identifer + // + TargetValue =3D *Target; + + // + // Check for unsupported requests + // + if ( + // + // Bidirectional transfer was requested + // + (Packet->InTransferLength > 0 && Packet->OutTransferLength > 0) || + (Packet->DataDirection =3D=3D EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIO= NAL) || + // + // Command Descriptor Block bigger than this constant should be cons= idered + // out-of-band. We currently don't support these CDBs. + // + (Packet->CdbLength > PVSCSI_CDB_MAX_SIZE) + ) { + + // + // This error code doesn't require updates to the Packet output fields + // + return EFI_UNSUPPORTED; + } + + // + // Check for invalid parameters + // + if ( + // + // Addressed invalid device + // + (TargetValue > Dev->MaxTarget) || (Lun > Dev->MaxLun) || + // + // Invalid direction (there doesn't seem to be a macro for the "no d= ata + // transferred" "direction", eg. for TEST UNIT READY) + // + (Packet->DataDirection > EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL) = || + // + // Trying to receive, but destination pointer is NULL, or contradict= ing + // transfer direction + // + ((Packet->InTransferLength > 0) && + ((Packet->InDataBuffer =3D=3D NULL) || + (Packet->DataDirection =3D=3D EFI_EXT_SCSI_DATA_DIRECTION_WRITE) + ) + ) || + // + // Trying to send, but source pointer is NULL, or contradicting + // transfer direction + // + ((Packet->OutTransferLength > 0) && + ((Packet->OutDataBuffer =3D=3D NULL) || + (Packet->DataDirection =3D=3D EFI_EXT_SCSI_DATA_DIRECTION_READ) + ) + ) + ) { + + // + // This error code doesn't require updates to the Packet output fields + // + return EFI_INVALID_PARAMETER; + } + + // + // Check for input/output buffer too large for DMA communication buffer + // + if (Packet->InTransferLength > sizeof (Dev->DmaBuf->Data)) { + Packet->InTransferLength =3D sizeof (Dev->DmaBuf->Data); + return ReportHostAdapterOverrunError (Packet); + } + if (Packet->OutTransferLength > sizeof (Dev->DmaBuf->Data)) { + Packet->OutTransferLength =3D sizeof (Dev->DmaBuf->Data); + return ReportHostAdapterOverrunError (Packet); + } + + // + // Encode PVSCSI request + // + ZeroMem (Request, sizeof (*Request)); + + Request->Bus =3D 0; + Request->Target =3D TargetValue; + // + // This cast is safe as PVSCSI_DEV.MaxLun is defined as UINT8 + // + Request->Lun[1] =3D (UINT8)Lun; + Request->SenseLen =3D Packet->SenseDataLength; + // + // DMA communication buffer SenseData overflow is not possible + // due to Packet->SenseDataLength defined as UINT8 + // + Request->SenseAddr =3D PVSCSI_DMA_BUF_DEV_ADDR (Dev, SenseData); + Request->CdbLen =3D Packet->CdbLength; + CopyMem (Request->Cdb, Packet->Cdb, Packet->CdbLength); + Request->VcpuHint =3D 0; + Request->Tag =3D PVSCSI_SIMPLE_QUEUE_TAG; + if (Packet->DataDirection =3D=3D EFI_EXT_SCSI_DATA_DIRECTION_READ) { + Request->Flags =3D PVSCSI_FLAG_CMD_DIR_TOHOST; + Request->DataLen =3D Packet->InTransferLength; + } else { + Request->Flags =3D PVSCSI_FLAG_CMD_DIR_TODEVICE; + Request->DataLen =3D Packet->OutTransferLength; + CopyMem ( + Dev->DmaBuf->Data, + Packet->OutDataBuffer, + Packet->OutTransferLength + ); + } + Request->DataAddr =3D PVSCSI_DMA_BUF_DEV_ADDR (Dev, Data); + + return EFI_SUCCESS; +} + +/** + Handle the PVSCSI device response: + - Copy returned data from DMA communication buffer. + - Update fields in Extended SCSI Pass Thru Protocol packet as required. + - Translate response code to EFI status code and host adapter status. +**/ +STATIC +EFI_STATUS +HandleResponse ( + IN PVSCSI_DEV *Dev, + IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet, + IN CONST PVSCSI_RING_CMP_DESC *Response + ) +{ + // + // Fix SenseDataLength to amount of data returned + // + if (Packet->SenseDataLength > Response->SenseLen) { + Packet->SenseDataLength =3D (UINT8)Response->SenseLen; + } + // + // Copy sense data from DMA communication buffer + // + CopyMem ( + Packet->SenseData, + Dev->DmaBuf->SenseData, + Packet->SenseDataLength + ); + + // + // Copy device output from DMA communication buffer + // + if (Packet->DataDirection =3D=3D EFI_EXT_SCSI_DATA_DIRECTION_READ) { + CopyMem (Packet->InDataBuffer, Dev->DmaBuf->Data, Packet->InTransferLe= ngth); + } + + // + // Report target status + // + Packet->TargetStatus =3D Response->ScsiStatus; + + // + // Host adapter status and function return value depend on + // device response's host status + // + switch (Response->HostStatus) { + case PvScsiBtStatSuccess: + case PvScsiBtStatLinkedCommandCompleted: + case PvScsiBtStatLinkedCommandCompletedWithFlag: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK; + return EFI_SUCCESS; + + case PvScsiBtStatDataUnderrun: + // + // Report transferred amount in underrun + // + if (Packet->DataDirection =3D=3D EFI_EXT_SCSI_DATA_DIRECTION_READ) { + Packet->InTransferLength =3D (UINT32)Response->DataLen; + } else { + Packet->OutTransferLength =3D (UINT32)Response->DataLen; + } + Packet->HostAdapterStatus =3D + EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN; + return EFI_SUCCESS; + + case PvScsiBtStatDatarun: + Packet->HostAdapterStatus =3D + EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN; + return EFI_SUCCESS; + + case PvScsiBtStatSelTimeout: + Packet->HostAdapterStatus =3D + EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT; + return EFI_TIMEOUT; + + case PvScsiBtStatBusFree: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_F= REE; + break; + + case PvScsiBtStatInvPhase: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE= _ERROR; + break; + + case PvScsiBtStatSensFailed: + Packet->HostAdapterStatus =3D + EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED; + break; + + case PvScsiBtStatTagReject: + case PvScsiBtStatBadMsg: + Packet->HostAdapterStatus =3D + EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT; + break; + + case PvScsiBtStatBusReset: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_R= ESET; + break; + + case PvScsiBtStatHaTimeout: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEO= UT; + return EFI_TIMEOUT; + + case PvScsiBtStatScsiParity: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARIT= Y_ERROR; + break; + + default: + Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER; + break; + } + + return EFI_DEVICE_ERROR; +} + /** Check if Target argument to EXT_SCSI_PASS_THRU.GetNextTarget() and EXT_SCSI_PASS_THRU.GetNextTargetLun() is initialized @@ -168,7 +566,62 @@ PvScsiPassThru ( IN EFI_EVENT Event OPTIONAL ) { - return EFI_UNSUPPORTED; + PVSCSI_DEV *Dev; + EFI_STATUS Status; + PVSCSI_RING_REQ_DESC *Request; + PVSCSI_RING_CMP_DESC *Response; + + Dev =3D PVSCSI_FROM_PASS_THRU (This); + + if (PvScsiIsReqRingFull (Dev)) { + return EFI_NOT_READY; + } + + Request =3D PvScsiGetCurrentRequest (Dev); + + Status =3D PopulateRequest (Dev, Target, Lun, Packet, Request); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Writes to Request must be globally visible before making request + // available to device + // + MemoryFence (); + Dev->RingDesc.RingState->ReqProdIdx++; + + Status =3D PvScsiMmioWrite32 (Dev, PvScsiRegOffsetKickRwIo, 0); + if (EFI_ERROR (Status)) { + // + // If kicking the host fails, we must fake a host adapter error. + // EFI_NOT_READY would save us the effort, but it would also suggest t= hat + // the caller retry. + // + return ReportHostAdapterError (Packet); + } + + Status =3D PvScsiWaitForRequestCompletion (Dev); + if (EFI_ERROR (Status)) { + // + // If waiting for request completion fails, we must fake a host adapter + // error. EFI_NOT_READY would save us the effort, but it would also su= ggest + // that the caller retry. + // + return ReportHostAdapterError (Packet); + } + + Response =3D PvScsiGetCurrentResponse (Dev); + Status =3D HandleResponse (Dev, Packet, Response); + + // + // Reads from response must complete before releasing completion entry + // to device + // + MemoryFence (); + Dev->RingDesc.RingState->CmpConsIdx++; + + return Status; } =20 STATIC @@ -652,6 +1105,7 @@ PvScsiInit ( // Dev->MaxTarget =3D PcdGet8 (PcdPvScsiMaxTargetLimit); Dev->MaxLun =3D PcdGet8 (PcdPvScsiMaxLunLimit); + Dev->WaitForCmpStallInUsecs =3D PcdGet32 (PcdPvScsiWaitForCmpStallInUsec= s); =20 // // Set PCI Attributes diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index fff12146dc75..02feac734743 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -57,6 +57,7 @@ typedef struct { PVSCSI_DMA_DESC DmaBufDmaDesc; UINT8 MaxTarget; UINT8 MaxLun; + UINTN WaitForCmpStallInUsecs; EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; } PVSCSI_DEV; diff --git a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf b/OvmfPkg/PvScsiDxe/PvScsiDxe.= inf index 6200533698fc..284035fb10d4 100644 --- a/OvmfPkg/PvScsiDxe/PvScsiDxe.inf +++ b/OvmfPkg/PvScsiDxe/PvScsiDxe.inf @@ -39,5 +39,6 @@ gEfiPciIoProtocolGuid ## TO_START =20 [Pcd] - gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxLunLimit ## CONSUMES - gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxTargetLimit ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxLunLimit ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiMaxTargetLimit ## CONSUMES + gUefiOvmfPkgTokenSpaceGuid.PcdPvScsiWaitForCmpStallInUsecs ## CONSUMES --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56548): https://edk2.groups.io/g/devel/message/56548 Mute This Topic: https://groups.io/mt/72617153/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56549+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56549+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425556; cv=none; d=zohomail.com; s=zohoarc; b=VA9EkG6awUOREqf30X5UbtVd9PwiCzpyI+79uEo/+5pi4+01Ga3zqCG/BEOw+h7SPLZymHo7ImQjXOtop9zBw/GBmK1qX4fSYbgq2H1iM0abJUqAh3lZaI7oHtHIsHfIXG4mIAyS474Ho9R2qRvptH2YuQA+NvDnrvi/bN1fYwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425556; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=q7M2xceN4jZp3Sdia7HgHBXCur9JRx0DqJZNzRsQC20=; b=A+CoZYsX8EyMv1Jjd/TrcILH/kbacUiIqBZ0prjvJ/KhWJGgyIqaMCar6raGIeopWbRl/zOeV2XwQLdZPzhu0ffyTzQ/Z6T8Z6zbV7P61b5dpEalc3Xub84un2NJGOtlYy8XfrOtkJ/WsB0uuyZLHDnbYWXues0ZwCkETfy2zTQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56549+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425556013517.1999862436899; Sat, 28 Mar 2020 12:59:16 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kqxDYY1788612xocRzoPOUxj; Sat, 28 Mar 2020 12:59:15 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.14067.1585425555064701815 for ; Sat, 28 Mar 2020 12:59:15 -0700 X-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 02SJnOrC014136; Sat, 28 Mar 2020 19:59:14 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 301x0qsj8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:14 +0000 X-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 02SJpHaf050098; Sat, 28 Mar 2020 19:59:13 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 301xd211et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:13 +0000 X-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJxD5x017199; Sat, 28 Mar 2020 19:59:13 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:13 -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: [edk2-devel] [PATCH v3 16/17] OvmfPkg/PvScsiDxe: Reset device on ExitBootServices() Date: Sat, 28 Mar 2020 23:00:59 +0300 Message-Id: <20200328200100.60786-17-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: 9kXCqbHpuAKTSFvr5tbki3TEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425555; bh=RUTcZqmojCUyLExYT4eu4uwd28txYGV9WnmdCuPtk8c=; h=Cc:Date:From:Reply-To:Subject:To; b=gnpIL+5OK6a6zMySdHbuTZrX3nJDOVjP2zmKgwX8n62vYR4PsG7HUgucmFmGqesEMS2 /OBMTVBPd6HvtAK4W6kzA954gg2OK6e+LBChPQsMEswlEj8m0C0+BpdZfkNlbsUekf1ue 6YbM+Je+DZbAKkCtxgSQD0f+XCCXTjHg44Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This causes the device to forget about the request/completion rings. We allocated said rings in EfiBootServicesData type memory, and code executing after ExitBootServices() is permitted to overwrite it. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 43 +++++++++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index da3535c75220..d7f0d3c8790c 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -1221,6 +1221,31 @@ PvScsiUninit ( PvScsiRestorePciAttributes (Dev); } =20 +/** + Event notification called by ExitBootServices() +**/ +STATIC +VOID +EFIAPI +PvScsiExitBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + PVSCSI_DEV *Dev; + + Dev =3D Context; + DEBUG ((DEBUG_VERBOSE, "%a: Context=3D0x%p\n", __FUNCTION__, Context)); + + // + // Reset the device to stop device usage of the rings. + // + // We allocated said rings in EfiBootServicesData type memory, and code + // executing after ExitBootServices() is permitted to overwrite it. + // + PvScsiResetAdapter (Dev); +} + // // Driver Binding // @@ -1314,6 +1339,17 @@ PvScsiDriverBindingStart ( goto ClosePciIo; } =20 + Status =3D gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_CALLBACK, + &PvScsiExitBoot, + Dev, + &Dev->ExitBoot + ); + if (EFI_ERROR (Status)) { + goto UninitDev; + } + // // Setup complete, attempt to export the driver instance's PassThru inte= rface // @@ -1325,11 +1361,14 @@ PvScsiDriverBindingStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto UninitDev; + goto CloseExitBoot; } =20 return EFI_SUCCESS; =20 +CloseExitBoot: + gBS->CloseEvent (Dev->ExitBoot); + UninitDev: PvScsiUninit (Dev); =20 @@ -1384,6 +1423,8 @@ PvScsiDriverBindingStop ( return Status; } =20 + gBS->CloseEvent (Dev->ExitBoot); + PvScsiUninit (Dev); =20 gBS->CloseProtocol ( diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index 02feac734743..544359ebc05c 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -51,6 +51,7 @@ typedef struct { typedef struct { UINT32 Signature; EFI_PCI_IO_PROTOCOL *PciIo; + EFI_EVENT ExitBoot; UINT64 OriginalPciAttributes; PVSCSI_RING_DESC RingDesc; PVSCSI_DMA_BUFFER *DmaBuf; --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56549): https://edk2.groups.io/g/devel/message/56549 Mute This Topic: https://groups.io/mt/72617156/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Tue Nov 26 06:35:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56550+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56550+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1585425558; cv=none; d=zohomail.com; s=zohoarc; b=h1q1g833SkH8hA5ifJhHesYeIChfqlPFsU9RVc05DaBodWMUgOsgq+FNJHXoMlxzUKVS8hbqfta9qLzmVd32HoNBs+WIUMyqjaWZTNO3w9lrszoVsaXx5m4Ktv5xyhTK2Ubwh/du8WAtvlBdgMWaOlR8Dzk4wyqXw87sVI1O5+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585425558; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FWGSgiTSSsUEAbkmmJ/u/uWCJJfoZwz7WQeMGbuUujI=; b=DFLmh76IpttkfO5dFWBkq4e9t12K33442jIUd2NOPrVB1W+2zX67HP3jMXvpIAL33wk8Oq+wz2hwcqxhQIjhujayYTMD2ytkBzFQjZxMYXUpNmVjfkemAJFfgbum7V2CTbmD1oat/kAyXZA266DqOXN8IpyDLniTkeKVZ1Z4ABs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56550+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585425558717608.8686404533229; Sat, 28 Mar 2020 12:59:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6ipfYY1788612xqyD4E4E4eX; Sat, 28 Mar 2020 12:59:18 -0700 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.14140.1585425557901082248 for ; Sat, 28 Mar 2020 12:59:18 -0700 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02SJxHeF123729; Sat, 28 Mar 2020 19:59:17 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 301y7mhf95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:17 +0000 X-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 02SJonmw164674; Sat, 28 Mar 2020 19:59:17 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 301ups6hg0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:17 +0000 X-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 02SJxGVa025096; Sat, 28 Mar 2020 19:59:16 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:15 -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: [edk2-devel] [PATCH v3 17/17] OvmfPkg/PvScsiDxe: Enable device 64-bit DMA addresses Date: Sat, 28 Mar 2020 23:01:00 +0300 Message-Id: <20200328200100.60786-18-liran.alon@oracle.com> In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: dER4jf5Rbfaydnf0Vz27QHBwx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585425558; bh=kUyOD0zPv7Jlt1k/FFol3/OT/YVhYDU8uDq3omw5tEY=; h=Cc:Date:From:Reply-To:Subject:To; b=BAYYoY8fl+4ebgzENxTR0E3XQCREKgAhQ8aaquJYjbjxvohSnUsw3l1NrMaWh3TfiCE MNjHUQ+tCh798JDt29DBA5G8ouY0VbFt8KrZ2vSi7xFhhhWPJFpBL0TYjQEtzRom2EG7j nbDNEE6aNKjWApNHH0Xd2bjoI8UBE97Ocec= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Enable PCI dual-address cycle attribute to signal device supports 64-bit DMA addresses. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon Reviewed-by: Nikita Leshenko --- OvmfPkg/PvScsiDxe/PvScsi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index d7f0d3c8790c..0a66c98421a9 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -874,6 +874,29 @@ PvScsiSetPciAttributes ( return Status; } =20 + // + // Signal device supports 64-bit DMA addresses + // + Status =3D Dev->PciIo->Attributes ( + Dev->PciIo, + EfiPciIoAttributeOperationEnable, + EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE, + NULL + ); + if (EFI_ERROR (Status)) { + // + // Warn user that device will only be using 32-bit DMA addresses. + // + // Note that this does not prevent the device/driver from working + // and therefore we only warn and continue as usual. + // + DEBUG (( + DEBUG_WARN, + "%a: failed to enable 64-bit DMA addresses\n", + __FUNCTION__ + )); + } + return EFI_SUCCESS; } =20 --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56550): https://edk2.groups.io/g/devel/message/56550 Mute This Topic: https://groups.io/mt/72617157/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-