From: "Bruno Prémont" <bonbons@linux-vserver.org>
To: Andrew de los Reyes <andrew-vger@gizmolabs.org>
Cc: David Herrmann <dh.herrmann@googlemail.com>,
Linux Input <linux-input@vger.kernel.org>,
Nestor Lopez Casado <nlopezcasad@logitech.com>,
Benjamin Tissoires <benjamin.tissoires@gmail.com>,
Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH] HID: Separate struct hid_device's driver_lock into two locks.
Date: Thu, 14 Feb 2013 08:06:48 +0100 [thread overview]
Message-ID: <20130214080648.6f84682e@pluto.restena.lu> (raw)
In-Reply-To: <CAG_cf+cm_q-0KJzZUaBsw=i5zqGp_Q+6Ga8=7mWVMXXidfEVpA@mail.gmail.com>
On Wed, 13 Feb 2013 21:08:20 -0800 Andrew de los Reyes wrote:
> > > > /**
> > > > + * hid_device_io_start - enable HID input during probe, remove
> > > > + *
> > > > + * @hid - the device
> > > > + *
> > > > + * This should only be called during probe or remove. It will allow
> > > > + * incoming packets to be delivered to the driver.
> > > > + */
> > > > +static inline void hid_device_io_start(struct hid_device *hid) {
> > > > + up(&hid->driver_input_lock);
> > > > + hid->io_started = true;
> > >
> > > Shouldn't these lines be swapped? Doesn't matter but it looks weird to
> > > me this way.
> > >
> > > But more importantly, we must go sure this is called from the same
> > > thread that probe() is called on. Other use-cases are not supported by
> > > semaphores and might break due to missing barriers. So maybe the
> > > comment could include that?
> >
> > Maybe even check what value hid->io_started has and WARN() [+skip
> > up()/down()]
> > in case hid_device_io_start()/stop() was not called in a balanced way.
>
> It is a goal to support hid_device_io_start()/stop() not being called
> in a balanced way. This is specifically needed by a change I'm making
> to hid-logitech-dj.c: During probe(), the driver will send out a
> request to the USB dongle to list any attached mice/keyboards. The
> reply packets aren't needed during probe(), so probe will return, but
> the driver wants packets to flow in, and it doesn't mind if they come
> in while probe() is still running or not. In this case, during
> probe(), the driver will call hid_device_io_start() to allow incoming
> packets, but then not call hid_device_io_stop().
With unbalanced I meant calling hid_device_io_start()/stop() twice or
more in a row in _probe() (or _remove()) without corresponding
_stop()/_start() call.
That kind of cases might happen (mostly) with error paths.
Like the following (simplified) example when both if() match:
int driver_probe(...)
{
...
if (...) {
...
hid_device_io_start();
...
}
...
if (...) {
...
hid_device_io_start();
...
}
...
}
Bruno
next prev parent reply other threads:[~2013-02-14 7:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-10 17:47 [PATCH] HID: Separate struct hid_device's driver_lock into two locks Andrew de los Reyes
2013-02-11 15:42 ` David Herrmann
2013-02-11 17:55 ` Bruno Prémont
2013-02-11 19:13 ` Andrew de los Reyes
2013-02-11 21:05 ` Bruno Prémont
2013-02-14 5:08 ` Andrew de los Reyes
2013-02-14 7:06 ` Bruno Prémont [this message]
2013-02-17 1:43 ` Andrew de los Reyes
-- strict thread matches above, loose matches on Subject: below --
2013-02-14 5:07 Andrew de los Reyes
2013-02-18 13:08 ` Jiri Kosina
2013-02-25 13:03 ` Jiri Kosina
2013-02-25 13:09 ` David Herrmann
2013-02-25 13:15 ` Jiri Kosina
2013-02-25 17:16 ` Andrew de los Reyes
2012-11-25 18:48 Andrew de los Reyes
2012-11-26 17:56 ` Bruno Prémont
2012-11-26 18:34 ` Benjamin Tissoires
2012-11-26 18:54 ` David Herrmann
2012-11-26 20:50 ` Andrew de los Reyes
2012-12-04 8:04 ` Jiri Kosina
2012-12-03 13:17 ` Jiri Kosina
2012-12-03 17:53 ` Nestor Lopez Casado
2013-02-05 15:07 ` Jiri Kosina
2013-02-05 16:19 ` Nestor Lopez Casado
[not found] ` <CAG_cf+ev2y1MHNJFYZycbjQfNgk4hYYRaEoFsKkZyhzAzMgc1A@mail.gmail.com>
2013-02-05 17:22 ` David Herrmann
2013-02-05 17:50 ` Nestor Lopez Casado
2013-02-06 15:10 ` Jiri Kosina
2013-02-06 15:21 ` David Herrmann
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=20130214080648.6f84682e@pluto.restena.lu \
--to=bonbons@linux-vserver.org \
--cc=andrew-vger@gizmolabs.org \
--cc=benjamin.tissoires@gmail.com \
--cc=dh.herrmann@googlemail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=nlopezcasad@logitech.com \
/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;
as well as URLs for NNTP newsgroup(s).