All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Laura Abbott <labbott@fedoraproject.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCHv3] Input: xpad - Fix double URB submission races
Date: Wed, 9 Dec 2015 22:45:44 -0800	[thread overview]
Message-ID: <20151210064544.GA35875@dtor-ws> (raw)
In-Reply-To: <1447714033-13809-1-git-send-email-labbott@fedoraproject.org>

Hi Laura,

On Mon, Nov 16, 2015 at 02:47:13PM -0800, Laura Abbott wrote:
> +static int __xpad_submit_urb(struct usb_xpad *xpad,
> +			unsigned char odata[XPAD_PKT_LEN], int transfer_length,
> +			int type, bool safe_submit)
> +{
> +	int ret;
> +
> +	if (safe_submit || xpad->submit_state == OUT_IRQ_AVAILABLE) {
> +		memcpy(xpad->odata, odata, transfer_length);
> +		xpad->irq_out->transfer_buffer_length = transfer_length;
> +		ret = usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
> +		xpad->submit_state = OUT_IRQ_QUEUE_EMPTY;
> +		xpad->out_submitter = type;
> +	} else {
> +		/*
> +		 * The goal here is to prevent starvation of any other type.
> +		 * If this type matches what is being submitted and there is
> +		 * another type in the queue, don't ovewrite it
> +		 */
> +		if (xpad->submit_state != OUT_IRQ_QUEUE_EMPTY &&
> +		    xpad->out_submitter == type &&
> +		    xpad->queue_submitter != type) {
> +			ret = -EBUSY;
> +			goto out;

No, we do not want to return "busy" here. We should save the most
up-to-date request of given type and re-submit it when URB is no longer
busy.

I CCed you on another patch addressing the same issue, please take a
look when you have a chance.

Thanks.

-- 
Dmitry

      reply	other threads:[~2015-12-10  6:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-16 22:47 [PATCHv3] Input: xpad - Fix double URB submission races Laura Abbott
2015-12-10  6:45 ` Dmitry Torokhov [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=20151210064544.GA35875@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=labbott@fedoraproject.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.