public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"lersek@redhat.com" <lersek@redhat.com>,
	Marcin Wojtas <mw@semihalf.com>
Cc: "leif.lindholm@linaro.org" <leif.lindholm@linaro.org>,
	"ard.biesheuvel@linaro.org" <ard.biesheuvel@linaro.org>,
	"jsd@semihalf.com" <jsd@semihalf.com>,
	"jaz@semihalf.com" <jaz@semihalf.com>,
	"Tian, Feng" <feng.tian@intel.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>,
	"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: Return error when the device is not present
Date: Fri, 2 Aug 2019 01:05:09 +0000	[thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A093C914B2D@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <8885da65-2d0f-ac2b-00c1-8ba6230ca9a8@redhat.com>

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Laszlo Ersek
> Sent: Wednesday, July 31, 2019 7:37 PM
> To: Marcin Wojtas; devel@edk2.groups.io
> Cc: leif.lindholm@linaro.org; ard.biesheuvel@linaro.org; jsd@semihalf.com;
> jaz@semihalf.com; Tian, Feng; Kinney, Michael D; Gao, Liming
> Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/UsbBusDxe: Return error
> when the device is not present
> 
> On 07/31/19 08:25, Marcin Wojtas wrote:
> > Until now, during the USB device enumeration when its PortState
> > USB_PORT_STAT_CONNECTION bit was not set, the stack was not
> informed
> > that the device is not present. Fix that by returning appropriate
> > error code.
> >
> > Change-Id: I588f82b987993e9755f64ce76cde9eb690ef1d54
> > Signed-off-by: Marcin Wojtas <mw@semihalf.com>
> > ---
> >  MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> > index be9d9bd..ab1db15 100644
> > --- a/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> > +++ b/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbEnumer.c
> > @@ -719,6 +719,7 @@ UsbEnumerateNewDev (
> >
> >    if (!USB_BIT_IS_SET (PortState.PortStatus,
> USB_PORT_STAT_CONNECTION)) {
> >      DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: No device present at
> port %d\n", Port));
> > +    Status = EFI_NOT_FOUND;
> >      goto ON_ERROR;
> >    } else if (USB_BIT_IS_SET (PortState.PortStatus,
> USB_PORT_STAT_SUPER_SPEED)){
> >      Child->Speed      = EFI_USB_SPEED_SUPER;
> >
> 
> I think the patch is correct, based on a quite superficial analysis (i.e. without
> actual knowledge of USB specifics on my part).
> 
> The reason is that Status is EFI_SUCCESS when the "goto" statement is
> reached, due to the preceding context
> 
>   Status = HubApi->GetPortStatus (HubIf, Port, &PortState);
> 
>   if (EFI_ERROR (Status)) {
>     DEBUG ((EFI_D_ERROR, "UsbEnumerateNewDev: failed to get speed of
> port %d\n", Port));
>     goto ON_ERROR;
>   }
> 
> And, the ON_ERROR label is documented as:
> 
> ON_ERROR:
>   //
>   // If reach here, it means the enumeration process on a given port is
> interrupted due to error.
>   // [...]
>   //
>   return Status;
> 
> We shouldn't report success when there is no device present on the port.
> 
> I think EFI_NOT_FOUND is a suitable error code; while it is not listed explicitly
> in the leading comment on the function, it does fit under
> 
>   @retval Others                Failed to enumerate the device.
> 
> Marcin, can you please remove the "Change-Id" tag from the commit
> message? (Or the MdeModulePkg maintainers could do that, just before
> they push the patch.)


Thanks Laszlo,

I will help to remove the 'Change-Id' tag when pushing this patch.

Best Regards,
Hao Wu


> 
> With "Change-Id" removed:
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 
> Thanks
> Laszlo
> 
> 


  reply	other threads:[~2019-08-02  1:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31  6:25 [PATCH] MdeModulePkg/UsbBusDxe: Return error when the device is not present Marcin Wojtas
2019-07-31 11:37 ` Laszlo Ersek
2019-08-02  1:05   ` Wu, Hao A [this message]
2019-07-31 16:51 ` [edk2-devel] " Ni, Ray
2019-08-02  1:03   ` Wu, Hao A
2019-08-02  7:11     ` Marcin Wojtas
2019-08-05  1:37       ` Wu, Hao A

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=B80AF82E9BFB8E4FBD8C89DA810C6A093C914B2D@SHSMSX104.ccr.corp.intel.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