From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web12.2500.1587024674616072728 for ; Thu, 16 Apr 2020 01:11:14 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JH08PUFi; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587024673; 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=mpAKE5XnTde49NXJMiFkNqFeV2juzIRq2xlPN35WEzY=; b=JH08PUFiR9ARoqDwXqktxylgaMjTdoFlpfEjgQdLmMyiAJ90ukiSzwDRSD+AC7xWp01Ve2 nBmjfpUVEYyIqhvSsFH/muRn7AlWKkDNptfli/2a/O7avvqgN6wz85STL7Pu6KwyqNE5c5 0v83A6Cr7dtJWhZdxKdxdllyrC62vqc= 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-469-X5PnKz9ZMMCzWNc9OKhrzA-1; Thu, 16 Apr 2020 04:11:11 -0400 X-MC-Unique: X5PnKz9ZMMCzWNc9OKhrzA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 91155107ACCA; Thu, 16 Apr 2020 08:11:10 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-225.ams2.redhat.com [10.36.114.225]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26EAE99E03; Thu, 16 Apr 2020 08:11:08 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v4 09/13] 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: <20200414173813.7715-1-nikita.leshchenko@oracle.com> <20200414173813.7715-10-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Thu, 16 Apr 2020 10:11:08 +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: <20200414173813.7715-10-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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/14/20 19:38, 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 > --- > OvmfPkg/MptScsiDxe/MptScsi.c | 42 +++++++++++++++++++++++++++++++++++- > 1 file changed, 41 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 275265774252..4bfd03d2acb0 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -36,6 +36,7 @@ typedef struct { > EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; > EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; > EFI_PCI_IO_PROTOCOL *PciIo; > + UINT64 OriginalPciAttributes; > } MPT_SCSI_DEV; > > #define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \ > @@ -308,6 +309,30 @@ 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; > + } > + > // > // Host adapter channel, doesn't exist > // > @@ -332,11 +357,19 @@ MptScsiControllerStart ( > &Dev->PassThru > ); > if (EFI_ERROR (Status)) { > - goto CloseProtocol; > + goto RestoreAttributes; > } > > return EFI_SUCCESS; > > +RestoreAttributes: > + Dev->PciIo->Attributes ( > + Dev->PciIo, > + EfiPciIoAttributeOperationEnable, (1) This should be "...Set", not "...Enable". > + Dev->OriginalPciAttributes, > + NULL > + ); > + > CloseProtocol: > gBS->CloseProtocol ( > ControllerHandle, > @@ -388,6 +421,13 @@ MptScsiControllerStop ( > return Status; > } > > + Dev->PciIo->Attributes ( > + Dev->PciIo, > + EfiPciIoAttributeOperationEnable, (2) Same as (1). With (1) and (2) fixed: Reviewed-by: Laszlo Ersek Thanks Laszlo > + Dev->OriginalPciAttributes, > + NULL > + ); > + > gBS->CloseProtocol ( > ControllerHandle, > &gEfiPciIoProtocolGuid, >