public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Doug Anderson <dianders@chromium.org>
Cc: linux-usb@vger.kernel.org, stern@rowland.harvard.edu,
	linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	Herve Codina <herve.codina@bootlin.com>,
	Rob Herring <robh@kernel.org>,
	Grant Grundler <grundler@chromium.org>,
	Oliver Neukum <oneukum@suse.com>,
	Yajun Deng <yajun.deng@linux.dev>
Subject: Re: [PATCH v2 1/2] USB: make single lock for all usb dynamic id lists
Date: Fri, 15 Nov 2024 17:46:00 +0100	[thread overview]
Message-ID: <2024111554-elves-crumpled-0a24@gregkh> (raw)
In-Reply-To: <CAD=FV=XGBfkLQ2N3dr3smhMDb+ze-XpbHjd7EChAByGNwJOnOw@mail.gmail.com>

On Thu, Nov 14, 2024 at 02:37:10PM -0800, Doug Anderson wrote:
> Hi,
> 
> On Tue, Nov 12, 2024 at 10:49 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > There are a number of places where we accidentally pass in a constant
> > structure to later cast it off to a dynamic one, and then attempt to
> > grab a lock on it, which is not a good idea.  To help resolve this, move
> > the dynamic id lock out of the dynamic id structure for the driver and
> > into one single lock for all USB dynamic ids.  As this lock should never
> > have any real contention (it's only every accessed when a device is
> 
> nit: s/every/ever/
> 
> 
> > added or removed, which is always serialized) there should not be any
> > difference except for some memory savings.
> >
> > Note, this just converts the existing use of the dynamic id lock to the
> > new static lock, there is one place that is accessing the dynamic id
> > list without grabbing the lock, that will be fixed up in a follow-on
> > change.
> >
> > Cc: Johan Hovold <johan@kernel.org>
> > Cc: Herve Codina <herve.codina@bootlin.com>
> > Cc: Rob Herring <robh@kernel.org>
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Grant Grundler <grundler@chromium.org>
> > Cc: Oliver Neukum <oneukum@suse.com>
> > Cc: Yajun Deng <yajun.deng@linux.dev>
> > Cc: Douglas Anderson <dianders@chromium.org>
> > Cc: linux-usb@vger.kernel.org
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> > v2: - change to a mutex
> >     - strip out of larger series
> >
> >  drivers/usb/common/common.c     |  3 +++
> >  drivers/usb/core/driver.c       | 15 +++++----------
> >  drivers/usb/serial/bus.c        |  4 +---
> >  drivers/usb/serial/usb-serial.c |  4 +---
> >  include/linux/usb.h             |  2 +-
> >  5 files changed, 11 insertions(+), 17 deletions(-)
> 
> I'm not familiar enough with the code to confirm with 100% certainty
> your assertions that there won't be any contention problems with this
> lock. However, your argument sounds reasonable to me and, since you
> are much more familiar with the subsystem, I'll believe you. :-)
> 
> I would have a slight concern that you are changing a "spin_lock" to a
> "mutex", which doesn't seem to be talked about in the patch
> description. This is likely to be fine given that all of the users are
> "spin_lock" and not "spin_lock_irq" or "spin_lock_irqsave", but it
> still makes me worried that there's some random bit of code somewhere
> that calls one of these functions while sleeping is disabled. I guess
> that's not likely.
> 
> In any case, this seems OK to me assuming it tests well.
> 
> Reviewed-by: Douglas Anderson <dianders@chromium.org>
> 

THanks for the reviews!

      reply	other threads:[~2024-11-15 16:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-13  6:49 [PATCH v2 1/2] USB: make single lock for all usb dynamic id lists Greg Kroah-Hartman
2024-11-13  6:49 ` [PATCH v2 2/2] USB: properly lock dynamic id list when showing an id Greg Kroah-Hartman
2024-11-14 22:37 ` [PATCH v2 1/2] USB: make single lock for all usb dynamic id lists Doug Anderson
2024-11-15 16:46   ` Greg Kroah-Hartman [this message]

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-all 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=2024111554-elves-crumpled-0a24@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=dianders@chromium.org \
    --cc=grundler@chromium.org \
    --cc=herve.codina@bootlin.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=robh@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=yajun.deng@linux.dev \
    /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