From: Alan Stern <stern@rowland.harvard.edu>
To: Andrej Shadura <andrew.shadura@collabora.co.uk>
Cc: linux-usb@vger.kernel.org, "Jiří Kosina" <jikos@kernel.org>,
linux-input@vger.kernel.org,
"Andrzej Pietrasiewicz" <andrzej.p@collabora.com>,
kernel@collabora.com, "Ezequiel Garcia" <ezequiel@collabora.com>,
"Vasily Khoruzhick" <anarsoul@gmail.com>
Subject: Re: [PATCH v3] HID: add driver for U2F Zero built-in LED and RNG
Date: Thu, 3 Oct 2019 11:25:29 -0400 (EDT) [thread overview]
Message-ID: <Pine.LNX.4.44L0.1910031124460.1797-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <43025708-080e-b577-031a-840b4cd42f3f@collabora.co.uk>
On Thu, 3 Oct 2019, Andrej Shadura wrote:
> On 01/04/2019 14:42, Andrej Shadura wrote:
> > U2F Zero supports custom commands for blinking the LED and getting data
> > from the internal hardware RNG. Expose the blinking function as a LED
> > device, and the internal hardware RNG as an HWRNG so that it can be used
> > to feed the enthropy pool.
> >
> > Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
>
> I’ve been testing this with a different modification of U2F Zero,
> Nitrokey FIDO U2F, and on that device only I’m getting a kernel warning
> (see below).
>
> > +static int u2fzero_recv(struct u2fzero_device *dev,
> > + struct u2f_hid_report *req,
> > + struct u2f_hid_msg *resp)
> > +{
> > + int ret;
> > + struct hid_device *hdev = dev->hdev;
> > + struct u2fzero_transfer_context ctx;
> > +
> > + mutex_lock(&dev->lock);
> > +
> > + memcpy(dev->buf_out, req, sizeof(struct u2f_hid_report));
> > +
> > + dev->urb->context = &ctx;
> > + init_completion(&ctx.done);
> > +
> > + ret = usb_submit_urb(dev->urb, GFP_NOIO);
>
> Here, usb_submit_urb() returns EBUSY in the first attempt to read random
> numbers from the device:
>
> URB ffff917256d5d540 submitted while active
> WARNING: CPU: 3 PID: 31 at drivers/usb/core/urb.c:363
> usb_submit_urb+0x4c2/0x5b0
> <...>
> Call Trace:
> u2fzero_rng_read+0x16e/0x340 [hid_u2fzero]
> ? ttwu_do_activate+0x67/0x90
> add_early_randomness+0x53/0xc0
> hwrng_register+0x175/0x180
> devm_hwrng_register+0x41/0x7e
> u2fzero_probe+0x2dd/0x350 [hid_u2fzero]
> hid_device_probe+0x119/0x180 [hid]
> really_probe+0xfe/0x3b0
> driver_probe_device+0xba/0x100
> __device_attach_driver+0x97/0x100
>
> I don’t understand why since 1) it’s likely to be the first transmission
> of this URB, 2) there’s a mutex locked just before it. I received a
> comment from a colleague mentioning I’m probably not using the mutex
> correctly, but I don’t understand why.
>
> I’m trying to figure this out, so I’d welcome any help with it.
You can try using usbmon to see exactly what URBs are actually running.
Alan Stern
prev parent reply other threads:[~2019-10-03 15:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-01 12:42 [v3] HID: add driver for U2F Zero built-in LED and RNG Andrej Shadura
2019-04-10 12:02 ` Jiri Kosina
2019-04-10 12:02 ` [PATCH v3] " Jiri Kosina
2019-04-11 9:58 ` [v3] " Benjamin Tissoires
2019-04-11 9:58 ` [PATCH v3] " Benjamin Tissoires
2019-04-11 10:35 ` [v3] " Jiri Kosina
2019-04-11 10:35 ` [PATCH v3] " Jiri Kosina
2019-04-11 11:52 ` [v3] " Andrej Shadura
2019-04-11 11:52 ` [PATCH v3] " Andrej Shadura
2019-04-17 14:43 ` [v3] " Jiri Kosina
2019-04-17 14:43 ` [PATCH v3] " Jiri Kosina
2019-04-17 14:47 ` [v3] " Andrej Shadura
2019-04-17 14:47 ` [PATCH v3] " Andrej Shadura
2019-10-03 7:19 ` Andrej Shadura
2019-10-03 15:25 ` Alan Stern [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=Pine.LNX.4.44L0.1910031124460.1797-100000@iolanthe.rowland.org \
--to=stern@rowland.harvard.edu \
--cc=anarsoul@gmail.com \
--cc=andrew.shadura@collabora.co.uk \
--cc=andrzej.p@collabora.com \
--cc=ezequiel@collabora.com \
--cc=jikos@kernel.org \
--cc=kernel@collabora.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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).