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.2463.1587024351521606168 for ; Thu, 16 Apr 2020 01:05:52 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dt/01woz; 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=1587024350; 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=Y0XnP4xEfFckm8m3TU8xPbx2uJikPDsarriKCZCq1rE=; b=Dt/01wozSQO/AjJM+FfMAEJPgzSMm5oR5/guYgfkmQJ6YmpI/sbLhGX3A/fAlZvDcU5Ad5 WXDnGRh5d4jKAMy3aFl3PzYo2w3QxFGmTA4rNZME+4uAiPYtfvznR2ShgfVo3CNRbDuGj7 xbTBRVBp0QTz9Fa2c2hWdUOvtpQkD2w= 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-307-B3NMyQrxPuGzjhdl2Ao7Og-1; Thu, 16 Apr 2020 04:05:44 -0400 X-MC-Unique: B3NMyQrxPuGzjhdl2Ao7Og-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 0A1DF1005510; Thu, 16 Apr 2020 08:05:43 +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 920B999DEE; Thu, 16 Apr 2020 08:05:41 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v4 08/13] OvmfPkg/MptScsiDxe: Open PciIo protocol for later use 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-9-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Thu, 16 Apr 2020 10:05:40 +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-9-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: > This will give us an exclusive access to the PciIo of this device > after it was started and until is will be stopped. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 > Signed-off-by: Nikita Leshenko > Reviewed-by: Liran Alon > --- > OvmfPkg/MptScsiDxe/MptScsi.c | 30 +++++++++++++++++++++++++++++- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 69ab947c0da2..275265774252 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -35,6 +35,7 @@ typedef struct { > UINT32 Signature; > EFI_EXT_SCSI_PASS_THRU_PROTOCOL PassThru; > EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; > + EFI_PCI_IO_PROTOCOL *PciIo; > } MPT_SCSI_DEV; > > #define MPT_SCSI_FROM_PASS_THRU(PassThruPtr) \ > @@ -295,6 +296,18 @@ MptScsiControllerStart ( > > Dev->Signature = MPT_SCSI_DEV_SIGNATURE; > > + Status = gBS->OpenProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + (VOID **)&Dev->PciIo, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status)) { > + goto FreePool; > + } > + > // > // Host adapter channel, doesn't exist > // > @@ -319,11 +332,19 @@ MptScsiControllerStart ( > &Dev->PassThru > ); > if (EFI_ERROR (Status)) { > - goto FreePool; > + goto CloseProtocol; > } > > return EFI_SUCCESS; > > +CloseProtocol: > + gBS->CloseProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + ControllerHandle > + ); > + > FreePool: > FreePool (Dev); > > @@ -367,6 +388,13 @@ MptScsiControllerStop ( > return Status; > } > > + gBS->CloseProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + ControllerHandle > + ); > + > FreePool (Dev); > > return Status; > Reviewed-by: Laszlo Ersek