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 07/13] OvmfPkg/MptScsiDxe: Build DevicePath for discovered devices
Date: Fri, 28 Feb 2020 10:03:52 +0100	[thread overview]
Message-ID: <6f916738-86a5-b1a1-fbc1-6959169dfd6e@redhat.com> (raw)
In-Reply-To: <20200226164151.125182-8-nikita.leshchenko@oracle.com>

On 02/26/20 17:41, Nikita Leshenko wrote:
> Used to identify the individual disks in the hardware tree
> 
> 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>
> ---
>  OvmfPkg/MptScsiDxe/MptScsi.c | 17 ++++++++++++++++-
>  1 file changed, 16 insertions(+), 1 deletion(-)
> 
> diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c
> index 76f0515b52..593cf30f6b 100644
> --- a/OvmfPkg/MptScsiDxe/MptScsi.c
> +++ b/OvmfPkg/MptScsiDxe/MptScsi.c
> @@ -128,7 +128,22 @@ MptScsiBuildDevicePath (
>    IN OUT EFI_DEVICE_PATH_PROTOCOL                  **DevicePath
>    )
>  {
> -  return EFI_UNSUPPORTED;
> +  SCSI_DEVICE_PATH *ScsiDevicePath;
> +
> +  ScsiDevicePath = AllocateZeroPool (sizeof (*ScsiDevicePath));
> +  if (ScsiDevicePath == NULL) {
> +    return EFI_OUT_OF_RESOURCES;
> +  }
> +
> +  ScsiDevicePath->Header.Type      = MESSAGING_DEVICE_PATH;
> +  ScsiDevicePath->Header.SubType   = MSG_SCSI_DP;
> +  ScsiDevicePath->Header.Length[0] = (UINT8)sizeof (*ScsiDevicePath);
> +  ScsiDevicePath->Header.Length[1] = (UINT8)sizeof (*ScsiDevicePath) >> 8;

(1) This does not cause ill behavior in practice, but the value makes no
sense. You are first casting the result of the sizeof operator to UINT8,
and then right-shifting that by 8 bits. That is guaranteed to produce
zero, regardless of what sizeof returns. You should use

  (UINT8)(sizeof (*ScsiDevicePath) >> 8)

> +  ScsiDevicePath->Pun              = *Target;

(2) Aha, OK. I was a bit surprised by the previous patch, but it is
certainly valid. You want to use target identifiers that are all 0xFF
bytes, except the very first byte.

That's fine (and "PcdMptScsiMaxTargetLimit" is also consistent with
that, having type UINT8), but please announce this decision more
visibly. Please append:

----
This driver uses the first byte (out of TARGET_MAX_BYTES) in Target IDs
for representing the target, the other bytes are always 0xFF in Target IDs.
----

to the commit messages of:
- OvmfPkg/MptScsiDxe: Report one Target and one LUN
- OvmfPkg/MptScsiDxe: Build DevicePath for discovered devices
- OvmfPkg/MptScsiDxe: Implement GetTargetLun
- OvmfPkg/MptScsiDxe: Report multiple targets

> +  ScsiDevicePath->Lun              = (UINT16)Lun;

This funcion is missing the target / lun validity check at the top (the
UEFI spec describes that related to the EFI_NOT_FOUND return status --
"The SCSI devices specified by Target and Lun does not exist on the
SCSI channel").

My understanding is that the driver only supports (*Target=0 && Lun=0)
at this point.

(3) So please express that at the start of the function. (Return
EFI_NOT_FOUND otherwise.)

(4) And, in patch "OvmfPkg/MptScsiDxe: Report multiple targets", please
also update this function -- MptScsiBuildDevicePath() --, so that it
accept (*Target) values up to and including "Dev->MaxTarget".

> +
> +  *DevicePath = &ScsiDevicePath->Header;
> +  return EFI_SUCCESS;
>  }
>  
>  STATIC
> 

Thanks
Laszlo


  reply	other threads:[~2020-02-28  9:04 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
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 [this message]
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=6f916738-86a5-b1a1-fbc1-6959169dfd6e@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