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.2464.1585247218327746522 for ; Thu, 26 Mar 2020 11:26:58 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VA7mVFJ2; 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=1585247217; 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=7BC5Ce5K56hFvfd5Z88CdpsvEwGlqoMzyQkySEhM6rQ=; b=VA7mVFJ2w5NJHcYfP9y49aZ1fycDeMaHNg+qn4w1iGd+NfngZgTthqhbEXyk4mp2frENdK pFTpCgAByqo9zbFSzuvRV98xr/465GzkSdk6kBnoimz7PtJ55xIrfdy1ewBThFVQXVlO/Q zJnhcTVXQHCT0SzpHBB1dmN3VDpLJDw= 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-325-UOYET1nCPW-WvyyLpr4fCA-1; Thu, 26 Mar 2020 14:26:48 -0400 X-MC-Unique: UOYET1nCPW-WvyyLpr4fCA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD732801E72; Thu, 26 Mar 2020 18:26:46 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-128.ams2.redhat.com [10.36.113.128]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75AD1CDBCC; Thu, 26 Mar 2020 18:26:04 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v2 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: <20200325161005.16743-1-liran.alon@oracle.com> <20200325161005.16743-13-liran.alon@oracle.com> From: "Laszlo Ersek" Message-ID: <8502c8f4-9d55-ed3f-17ef-fd14f8be24aa@redhat.com> Date: Thu, 26 Mar 2020 19:25:56 +0100 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: <20200325161005.16743-13-liran.alon@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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/25/20 17:10, Liran Alon wrote: > The following commits will complete the implementation of > device initialization. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2567 > Signed-off-by: Liran Alon > --- > OvmfPkg/PvScsiDxe/PvScsi.c | 91 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 91 insertions(+) > > diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c > index 531bed4e5ab7..831a78cc18c7 100644 > --- a/OvmfPkg/PvScsiDxe/PvScsi.c > +++ b/OvmfPkg/PvScsiDxe/PvScsi.c > @@ -30,6 +30,84 @@ > // 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 PVSCSI command to device > +**/ > +STATIC > +EFI_STATUS > +PvScsiWriteCmdDesc ( > + IN CONST PVSCSI_DEV *Dev, > + IN UINT32 Cmd, > + IN UINT32 *DescWords, > + 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; > +} > + > /** > Check if Target argument to EXT_SCSI_PASS_THRU.GetNextTarget() and > EXT_SCSI_PASS_THRU.GetNextTargetLun() is initialized > @@ -357,6 +435,14 @@ PvScsiInit ( > return Status; > } > > + // > + // Reset adapter > + // > + Status = PvScsiWriteCmdDesc (Dev, PvScsiCmdAdapterReset, NULL, 0); > + if (EFI_ERROR (Status)) { > + goto RestorePciAttributes; > + } > + > // > // Populate the exported interface's attributes > // > @@ -387,6 +473,11 @@ PvScsiInit ( > Dev->PassThruMode.IoAlign = 0; > > return EFI_SUCCESS; > + > +RestorePciAttributes: > + PvScsiRestorePciAttributes (Dev); > + > + return Status; > } > > STATIC > Nice. Reviewed-by: Laszlo Ersek