From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web10.1195.1588168259998378414 for ; Wed, 29 Apr 2020 06:51:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KFzlvy1c; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588168259; 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=0fJOA5E0+/eIewTwpxzXNEkeWem6+bzzlxgTJuMmNmo=; b=KFzlvy1c6XS7ttFIiP8OKGxaDuYYWfWfStDFrS8abtqhcWMgIdOUBIEE7k242+8duxlQy9 evl3U9GdJG6EAGw0REmUGtHm/qvo6wx6m6yUNYs6cMUc4Jnr+mgL+odVpWPWjdkOqa9g5c VrV4uvUJgURu8y2TX5hOe+DF1Tk+ByA= 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-177-u16Z5sAUOuSx5v09hzx0AQ-1; Wed, 29 Apr 2020 09:50:57 -0400 X-MC-Unique: u16Z5sAUOuSx5v09hzx0AQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CBC6A45F; Wed, 29 Apr 2020 13:50:55 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-1.ams2.redhat.com [10.36.114.1]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4920A5D9C9; Wed, 29 Apr 2020 13:50:54 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v5 09/12] OvmfPkg/MptScsiDxe: Set and restore PCI attributes To: devel@edk2.groups.io, nikita.leshchenko@oracle.com Cc: liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Ard Biesheuvel References: <20200424175927.41210-1-nikita.leshchenko@oracle.com> <20200424175927.41210-10-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Wed, 29 Apr 2020 15:50:53 +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: <20200424175927.41210-10-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 04/24/20 19:59, Nikita Leshenko wrote: > Enable the IO Space and Bus Mastering and restore the original values > when the device is stopped. This is a standard procedure in PCI > drivers. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 > Signed-off-by: Nikita Leshenko > Reviewed-by: Liran Alon > Reviewed-by: Laszlo Ersek > --- > OvmfPkg/MptScsiDxe/MptScsi.c | 65 +++++++++++++++++++++++++++++++++++- > 1 file changed, 64 insertions(+), 1 deletion(-) This patch has undergone (since v4) more changes than what I had tied my R-b to, in the v4 review. So I think including the R-b upfront, in v5, is not justified. However, the updates all look good, in the end. Therefore: Reviewed-by: Laszlo Ersek Thanks Laszlo > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index ed7fabf8b471..e88ac2867a75 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -37,6 +37,7 @@ typedef struct { > EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; > UINT8 MaxTarget; > EFI_PCI_IO_PROTOCOL *PciIo; > + UINT64 OriginalPciAttributes; > } MPT_SCSI_DEV; > > #define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \ > @@ -334,6 +335,53 @@ MptScsiControllerStart ( > goto FreePool; > } > > + Status = Dev->PciIo->Attributes ( > + Dev->PciIo, > + EfiPciIoAttributeOperationGet, > + 0, > + &Dev->OriginalPciAttributes > + ); > + if (EFI_ERROR (Status)) { > + goto CloseProtocol; > + } > + > + // > + // Enable I/O Space & Bus-Mastering > + // > + Status = Dev->PciIo->Attributes ( > + Dev->PciIo, > + EfiPciIoAttributeOperationEnable, > + (EFI_PCI_IO_ATTRIBUTE_IO | > + EFI_PCI_IO_ATTRIBUTE_BUS_MASTER), > + NULL > + ); > + if (EFI_ERROR (Status)) { > + goto CloseProtocol; > + } > + > + // > + // Signal device supports 64-bit DMA addresses > + // > + Status = 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__ > + )); > + } > + > // > // Host adapter channel, doesn't exist > // > @@ -358,11 +406,19 @@ MptScsiControllerStart ( > &Dev->PassThru > ); > if (EFI_ERROR (Status)) { > - goto CloseProtocol; > + goto RestoreAttributes; > } > > return EFI_SUCCESS; > > +RestoreAttributes: > + Dev->PciIo->Attributes ( > + Dev->PciIo, > + EfiPciIoAttributeOperationSet, > + Dev->OriginalPciAttributes, > + NULL > + ); > + > CloseProtocol: > gBS->CloseProtocol ( > ControllerHandle, > @@ -414,6 +470,13 @@ MptScsiControllerStop ( > return Status; > } > > + Dev->PciIo->Attributes ( > + Dev->PciIo, > + EfiPciIoAttributeOperationSet, > + Dev->OriginalPciAttributes, > + NULL > + ); > + > gBS->CloseProtocol ( > ControllerHandle, > &gEfiPciIoProtocolGuid, >