kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: elezegarcia@gmail.com (Ezequiel Garcia)
To: kernelnewbies@lists.kernelnewbies.org
Subject: [Q] USB urb completion handler
Date: Wed, 23 May 2012 23:41:26 -0300	[thread overview]
Message-ID: <CALF0-+VFOUN6bcRjCcBtFNw2dbKes9awK9SV6nTqfBNyKG64ig@mail.gmail.com> (raw)
In-Reply-To: <CANudz+sWy7yMFw0W7qT-1==yB1OqnzEQYTC=kNEvKMHRSrTtVA@mail.gmail.com>

On Wed, May 23, 2012 at 10:44 PM, loody <miloody@gmail.com> wrote:
> take multi-core system for example, it is possible your completion
> handler execute at the same time, except you add a spin lock for
> activating your completion function.
>

That's the reason I'm asking in first place.
But if that is true, then it seems to me some drivers wouldn't be
working (unlikely, right?)

You can take a look at pwc completion for instance:

static void pwc_isoc_handler(struct urb *urb)
{
[snip]
        if (pdev->fill_buf == NULL)
                pdev->fill_buf = pwc_get_next_fill_buf(pdev);
---

As you can see, there is no lock here (though there is lock
to get the next fill_buf) and pdev->fill_buf is obviously not local.

On the other hand, em28xx has a tighter locking scheme:

static void em28xx_irq_callback(struct urb *urb)
{
[snip]
        /* Copy data from URB */
        spin_lock(&dev->slock);
        dev->isoc_ctl.isoc_copy(dev, urb);
        spin_unlock(&dev->slock);
---

Currently, I'm running a three core (yes three!) streaming at a high
rate and I'm following pwc locking (per queue). So far no races found (phew).

As a sidenote, em28xx locking can be improved for a very simple
reason: it's locking code instead of data.
Unfortunately, I don't own that hardware to fix and test such a patch.

  reply	other threads:[~2012-05-24  2:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07 17:18 [Q] USB urb completion handler Ezequiel Garcia
     [not found] ` <CA+MoWDp7taxx=6=DTM2MnU9GfU5F_bPLCHNh=j5GfJNwwqVkHQ@mail.gmail.com>
     [not found]   ` <CALF0-+WPDfWg_afT1at=6yjouXPPJorMsenCGPfb2U7pYGSGnw@mail.gmail.com>
     [not found]     ` <CA+MoWDpfp4bk-+Sg5abfWtJEA7UPDg9FdyJATfgWkLiLOaz2_A@mail.gmail.com>
     [not found]       ` <CALF0-+U=U=Rc0YATz-YNHN_HnXOr2LpZzoPLH02uSJpTYxdtuQ@mail.gmail.com>
2012-05-07 17:55         ` Fwd: " Ezequiel Garcia
2012-05-22  6:55           ` loody
2012-05-22 17:37             ` Ezequiel Garcia
2012-05-24  1:44               ` loody
2012-05-24  2:41                 ` Ezequiel Garcia [this message]
2012-05-22  6:56 ` loody

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=CALF0-+VFOUN6bcRjCcBtFNw2dbKes9awK9SV6nTqfBNyKG64ig@mail.gmail.com \
    --to=elezegarcia@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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).