From nobody Tue Nov 26 09:29:08 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 --- 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-