[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAD=FV=V4R9TAGH+cCG=YBgCFO5F9hniPV-ycZjk5=z5mSjFQ7A@mail.gmail.com>
Date: Wed, 27 Sep 2023 08:28:40 -0700
From: Doug Anderson <dianders@...omium.org>
To: Alan Stern <stern@...land.harvard.edu>
Cc: Jakub Kicinski <kuba@...nel.org>,
Hayes Wang <hayeswang@...ltek.com>,
"David S . Miller" <davem@...emloft.net>,
linux-usb@...r.kernel.org, Grant Grundler <grundler@...omium.org>,
Edward Hill <ecgh@...omium.org>, andre.przywara@....com,
bjorn@...k.no, edumazet@...gle.com, gaul@...l.org,
horms@...nel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, pabeni@...hat.com
Subject: Re: [PATCH 2/3] r8152: Retry register reads/writes
Hi,
On Wed, Sep 27, 2023 at 6:43 AM Alan Stern <stern@...land.harvard.edu> wrote:
>
> On Tue, Sep 26, 2023 at 02:27:27PM -0700, Douglas Anderson wrote:
> > +
> > +static
> > +int r8152_control_msg(struct usb_device *udev, unsigned int pipe, __u8 request,
> > + __u8 requesttype, __u16 value, __u16 index, void *data,
> > + __u16 size, const char *msg_tag)
> > +{
> > + int i;
> > + int ret;
> > +
> > + for (i = 0; i < REGISTER_ACCESS_TRIES; i++) {
> > + ret = usb_control_msg(udev, pipe, request, requesttype,
> > + value, index, data, size,
> > + USB_CTRL_GET_TIMEOUT);
> > +
> > + /* No need to retry or spam errors if the USB device got
> > + * unplugged; just return immediately.
> > + */
> > + if (udev->state == USB_STATE_NOTATTACHED)
> > + return ret;
>
> Rather than testing udev->state, it would be better to check whether
> ret == -ENODEV. udev->state is meant primarily for use by the USB core
> and it's subject to races.
Thanks for looking my patch over!
Happy to change this to -ENODEV. In my early drafts of this patch I
looked at -ENODEV but I noticed that other places in the driver were
checking `udev->state == USB_STATE_NOTATTACHED` so I changed it. In
reality I think for this code path it doesn't matter a whole lot. The
only thing it's doing is avoiding a few extra retries and avoiding a
log message. :-)
I'll wait a few more days to see if there is any other feedback on
this series and then send a new version with that addressed. If
someone needs me to send a new version sooner then please yell.
-Doug
Powered by blists - more mailing lists