From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web12.11232.1582878395964200048 for ; Fri, 28 Feb 2020 00:26:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Md9CfveJ; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582878395; 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=RuEtC0IBZmsVZRYmuESBD2uboHyYOQJXbUdFyzsydNc=; b=Md9CfveJQ9nZ2cWRfFDkwlbTwnrHOHjB/o5spPTdz7wEmyzLl4VW3Rfd9gvlVEto6sb8jX pb43cEwxmiQuw4hIcFpvBV59DeNHZlZwrz3cXgUtikf2Iaa86NscknsZTtn6Kw0ESvYVnp DN8sA0n7nHwmr9dZzJCzUQYx0frmTd8= 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-260-S9-gkcJHN--0DTwXL6snXA-1; Fri, 28 Feb 2020 03:26:28 -0500 X-MC-Unique: S9-gkcJHN--0DTwXL6snXA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2AB7DB60; Fri, 28 Feb 2020 08:26:26 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-243.ams2.redhat.com [10.36.116.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0014B60C18; Fri, 28 Feb 2020 08:26:24 +0000 (UTC) Subject: Re: [PATCH v2 04/13] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi To: Nikita Leshenko , devel@edk2.groups.io Cc: liran.alon@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org References: <20200226164151.125182-1-nikita.leshchenko@oracle.com> <20200226164151.125182-5-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: <465704e7-fcf4-e6ed-7e2e-e3ad7bb83970@redhat.com> Date: Fri, 28 Feb 2020 09:26:23 +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: <20200226164151.125182-5-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 02/26/20 17:41, Nikita Leshenko wrote: > The MptScsiControllerSupported function is called on handles passed in > by the ConnectController() boot service and if the handle is the > lsi53c1030 controller the function would return success. A successful > return value will attach our driver to the device. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Nikita Leshenko > Reviewed-by: Konrad Rzeszutek Wilk > Reviewed-by: Aaron Young > Reviewed-by: Liran Alon > --- > .../Include/IndustryStandard/FusionMptScsi.h | 24 +++++++++ > OvmfPkg/MptScsiDxe/MptScsi.c | 50 ++++++++++++++++++- > OvmfPkg/MptScsiDxe/MptScsiDxe.inf | 6 +++ > 3 files changed, 79 insertions(+), 1 deletion(-) > create mode 100644 OvmfPkg/Include/IndustryStandard/FusionMptScsi.h > > diff --git a/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h b/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h > new file mode 100644 > index 0000000000..3b911bdb5b > --- /dev/null > +++ b/OvmfPkg/Include/IndustryStandard/FusionMptScsi.h > @@ -0,0 +1,24 @@ > +/** @file > + > + Macros and type definitions for LSI Fusion MPT SCSI devices. > + > + Copyright (C) 2020, Oracle and/or its affiliates. All rights reserved. > + > + This program and the accompanying materials are licensed and made available > + under the terms and conditions of the BSD License which accompanies this > + distribution. The full text of the license may be found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT > + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > + > +// > +// Device offsets and constants > +// > + > +#define LSI_LOGIC_PCI_VENDOR_ID 0x1000 Matches PCI_VENDOR_ID_LSI_LOGIC from QEMU's "include/hw/pci/pci_ids.h". OK. > +#define LSI_53C1030_PCI_DEVICE_ID 0x0030 Not sure about this one; possibly implemented by a different hypervisor. But that should be OK. > +#define LSI_SAS1068_PCI_DEVICE_ID 0x0054 matches PCI_DEVICE_ID_LSI_SAS1068 > +#define LSI_SAS1068E_PCI_DEVICE_ID 0x0058 Also from another hypervisor, I'd guess; OK. > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 40194b5ead..6dc6257eba 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -15,7 +15,12 @@ > > **/ > > +#include > +#include > +#include > +#include > #include > +#include (1) Please keep #include directives sorted. > > // > // Higher versions will be used before lower, 0x10-0xffffffef is the version > @@ -36,7 +41,50 @@ MptScsiControllerSupported ( > IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL > ) > { > - return EFI_UNSUPPORTED; > + EFI_STATUS Status; > + EFI_PCI_IO_PROTOCOL *PciIo; > + PCI_TYPE00 Pci; > + > + Status = gBS->OpenProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + (VOID **)&PciIo, > + This->DriverBindingHandle, > + ControllerHandle, > + EFI_OPEN_PROTOCOL_BY_DRIVER > + ); > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + Status = PciIo->Pci.Read ( > + PciIo, > + EfiPciIoWidthUint32, > + 0, > + sizeof (Pci) / sizeof (UINT32), > + &Pci > + ); > + if (EFI_ERROR (Status)) { > + goto Done; > + } > + > + if (Pci.Hdr.VendorId == LSI_LOGIC_PCI_VENDOR_ID && > + (Pci.Hdr.DeviceId == LSI_53C1030_PCI_DEVICE_ID || > + Pci.Hdr.DeviceId == LSI_SAS1068_PCI_DEVICE_ID || > + Pci.Hdr.DeviceId == LSI_SAS1068E_PCI_DEVICE_ID)) { > + Status = EFI_SUCCESS; > + } else { > + Status = EFI_UNSUPPORTED; > + } > + > +Done: > + gBS->CloseProtocol ( > + ControllerHandle, > + &gEfiPciIoProtocolGuid, > + This->DriverBindingHandle, > + ControllerHandle > + ); > + return Status; > } > > STATIC > diff --git a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf > index 4b1a23c33a..dc3795c867 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsiDxe.inf > +++ b/OvmfPkg/MptScsiDxe/MptScsiDxe.inf > @@ -27,7 +27,13 @@ > > [Packages] > MdePkg/MdePkg.dec > + OvmfPkg/OvmfPkg.dec > > [LibraryClasses] > + DebugLib > + UefiBootServicesTableLib > UefiDriverEntryPoint > UefiLib > + > +[Protocols] > + gEfiPciIoProtocolGuid ## TO_START > We don't necessarily have to pull in DebugLib in this patch, but it's also harmless. With (1) addressed: Reviewed-by: Laszlo Ersek Thanks Laszlo