From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.groups.io with SMTP id smtpd.web10.52763.1585581593803984269 for ; Mon, 30 Mar 2020 08:19:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g0FGJGgq; spf=pass (domain: redhat.com, ip: 216.205.24.74, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585581592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kbUxJjEBY/B6E7rCbJnziEMJv8XEfeDZayyFchbuKcM=; b=g0FGJGgq+7qnCIv1vBXvuCIBxQnJhcpqUTAJRxyqNKY7dRXAfjRmZQQ9fiJY8Xs7q2MmhB mtKdZVjOaJiHHOfT6waHnUsL4qLP0hlnlsTRRqHMA4oT1ITnJfgnM9/m753ELQ8IH/ymeR zKaL5B5E94lfQcAW/kMmSGVdO5Lz7gg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-Qy5-MOmHPfeJnsSTSRsx7Q-1; Mon, 30 Mar 2020 11:19:46 -0400 X-MC-Unique: Qy5-MOmHPfeJnsSTSRsx7Q-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64847800D5F; Mon, 30 Mar 2020 15:19:45 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-191.ams2.redhat.com [10.36.112.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9F62B5C1BB; Mon, 30 Mar 2020 15:19:43 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v3 12/17] OvmfPkg/PvScsiDxe: Reset adapter on init To: devel@edk2.groups.io, liran.alon@oracle.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org References: <20200328200100.60786-1-liran.alon@oracle.com> <20200328200100.60786-13-liran.alon@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Mon, 30 Mar 2020 17:19:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200328200100.60786-13-liran.alon@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 03/28/20 21:00, Liran Alon wrote: > The following commits will complete the implementation of > device initialization. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 > Reviewed-by: Laszlo Ersek > Signed-off-by: Liran Alon > --- > OvmfPkg/PvScsiDxe/PvScsi.c | 114 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 114 insertions(+) Thanks for the updates in this patch, my R-b stands. Laszlo > 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 > // > > +/** > + 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 command > + have a descriptor). The descriptor is > + provided as an array of UINT32 words and > + is must be 32-bit aligned. > + @param[in] DescWordsCount The number of words in command descriptor. > + Caller must specify here 0 if DescWords > + is not supplied (It is optional). In that > + 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 = 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; > } > > + // > + // Reset adapter > + // > + Status = PvScsiResetAdapter (Dev); > + if (EFI_ERROR (Status)) { > + goto RestorePciAttributes; > + } > + > // > // Populate the exported interface's attributes > // > @@ -387,6 +496,11 @@ PvScsiInit ( > Dev->PassThruMode.IoAlign = 0; > > return EFI_SUCCESS; > + > +RestorePciAttributes: > + PvScsiRestorePciAttributes (Dev); > + > + return Status; > } > > STATIC >