public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Nikita Leshenko <nikita.leshchenko@oracle.com>, devel@edk2.groups.io
Cc: liran.alon@oracle.com, aaron.young@oracle.com,
	jordan.l.justen@intel.com, ard.biesheuvel@linaro.org
Subject: Re: [PATCH v2 04/13] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi
Date: Fri, 28 Feb 2020 09:26:23 +0100	[thread overview]
Message-ID: <465704e7-fcf4-e6ed-7e2e-e3ad7bb83970@redhat.com> (raw)
In-Reply-To: <20200226164151.125182-5-nikita.leshchenko@oracle.com>

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 <nikita.leshchenko@oracle.com>
> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Reviewed-by: Aaron Young <aaron.young@oracle.com>
> Reviewed-by: Liran Alon <liran.alon@oracle.com>
> ---
>  .../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 <IndustryStandard/Pci.h>
> +#include <IndustryStandard/FusionMptScsi.h>
> +#include <Library/DebugLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
>  #include <Library/UefiLib.h>
> +#include <Protocol/PciIo.h>

(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 <lersek@redhat.com>

Thanks
Laszlo


  reply	other threads:[~2020-02-28  8:26 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 16:41 [PATCH v2 00/13] OvmfPkg: Support booting from Fusion-MPT SCSI controllers Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 01/13] OvmfPkg/MptScsiDxe: Create empty driver Nikita Leshenko
2020-02-28  8:12   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 02/13] OvmfPkg/MptScsiDxe: Install DriverBinding Protocol Nikita Leshenko
2020-02-28  8:16   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 03/13] OvmfPkg/MptScsiDxe: Report name of driver Nikita Leshenko
2020-02-28  8:17   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 04/13] OvmfPkg/MptScsiDxe: Probe PCI devices and look for MptScsi Nikita Leshenko
2020-02-28  8:26   ` Laszlo Ersek [this message]
2020-02-26 16:41 ` [PATCH v2 05/13] OvmfPkg/MptScsiDxe: Install stubbed EXT_SCSI_PASS_THRU Nikita Leshenko
2020-02-28  8:35   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 06/13] OvmfPkg/MptScsiDxe: Report one Target and one LUN Nikita Leshenko
2020-02-28  8:41   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 07/13] OvmfPkg/MptScsiDxe: Build DevicePath for discovered devices Nikita Leshenko
2020-02-28  9:03   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 08/13] OvmfPkg/MptScsiDxe: Implement GetTargetLun Nikita Leshenko
2020-02-28  9:16   ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 09/13] OvmfPkg/MptScsiDxe: Open PciIo protocol for later use Nikita Leshenko
2020-02-28  9:50   ` Laszlo Ersek
2020-02-28  9:53     ` Laszlo Ersek
2020-02-26 16:41 ` [PATCH v2 10/13] OvmfPkg/MptScsiDxe: Set and restore PCI attributes Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 11/13] OvmfPkg/MptScsiDxe: Initialize hardware Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 12/13] OvmfPkg/MptScsiDxe: Implement the PassThru method Nikita Leshenko
2020-02-26 16:41 ` [PATCH v2 13/13] OvmfPkg/MptScsiDxe: Report multiple targets Nikita Leshenko
2020-02-27  9:52 ` [edk2-devel] [PATCH v2 00/13] OvmfPkg: Support booting from Fusion-MPT SCSI controllers Laszlo Ersek
2020-02-28  7:51 ` Laszlo Ersek
2020-02-28  8:06   ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=465704e7-fcf4-e6ed-7e2e-e3ad7bb83970@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox