From: Sarah Sharp <sarah.a.sharp-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Petko Manolov <petkan-nPnTwAqkgEqakBO8gow8eQ@public.gmane.org>
Cc: linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Greg KH
<gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org>,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Stephen Hemminger
<stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org>
Subject: Re: Active URB submitted twice in pegasus driver
Date: Tue, 26 Mar 2013 14:37:57 -0700 [thread overview]
Message-ID: <20130326213757.GA19141@xanatos> (raw)
In-Reply-To: <alpine.DEB.2.02.1303262247490.3959@fry>
On Tue, Mar 26, 2013 at 10:54:25PM +0200, Petko Manolov wrote:
> On Tue, 26 Mar 2013, Sarah Sharp wrote:
>
> >But considering the multicast code is pretty old, I bet I'm running into
> >a different bug...
>
> The fix is rather small. Approximately one gigabyte was transferred
> while alternating in and out of promiscuous mode. No issues.
>
> I guess this should move the driver out of the equation.
>
>
> cheers,
> Petko
> diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
> index 73051d1..879da39 100644
> --- a/drivers/net/usb/pegasus.c
> +++ b/drivers/net/usb/pegasus.c
> @@ -1220,8 +1220,6 @@ static void pegasus_set_multicast(struct net_device *net)
> pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS;
> }
>
> - pegasus->ctrl_urb->status = 0;
> -
> pegasus->flags |= ETH_REGS_CHANGE;
> ctrl_callback(pegasus->ctrl_urb);
> }
This patch does avoid writes to the URB, however...
static void ctrl_callback(struct urb *urb)
{
pegasus_t *pegasus = urb->context;
int status = urb->status;
if (!pegasus)
return;
switch (status) {
case 0:
if (pegasus->flags & ETH_REGS_CHANGE) {
pegasus->flags &= ~ETH_REGS_CHANGE;
pegasus->flags |= ETH_REGS_CHANGED;
update_eth_regs_async(pegasus);
return;
}
break;
ctrl_callback is still reading the URB status, and using it in the
switch statement. It's also using the urb->context as well, to dig out
a pointer (pegasus_t) that the pegasus_set_multicast already has access
to. What happens if an URB to get the registers completes at the same
time pegasus_set_multicast calls ctrl_callback? If the URB failed for
some reason (e.g. bad cable, stall), you'll miss that if statement. I
don't think that's what you intended to do.
I think the fix should be to just to move the if block into a new
function, and call it both in ctrl_callback() and
pegasus_set_multicast().
Further, is it possible to call any of these functions asynchronously?
- get_registers
- set_registers
- update_eth_regs_async
What happens if the upper layer calls get_registers and
update_eth_regs_async in rapid succession? You'll attempt to use the
control URB in both places, which will trigger the original warning I
was reporting. Or is there some locking somewhere I'm missing?
Sarah Sharp
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-03-26 21:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 22:38 Active URB submitted twice in pegasus driver Sarah Sharp
2013-03-26 15:22 ` Petko Manolov
2013-03-26 17:01 ` Sarah Sharp
2013-03-26 17:28 ` Petko Manolov
2013-03-26 18:52 ` Sarah Sharp
2013-03-26 20:54 ` Petko Manolov
2013-03-26 21:37 ` Sarah Sharp [this message]
2013-03-26 22:26 ` Petko Manolov
2013-04-05 17:01 ` Petko Manolov
2013-04-08 15:49 ` Sarah Sharp
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=20130326213757.GA19141@xanatos \
--to=sarah.a.sharp-vuqaysv1563yd54fqh9/ca@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=petkan-nPnTwAqkgEqakBO8gow8eQ@public.gmane.org \
--cc=stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.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