public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <hzpeterchen@gmail.com>
To: "Du, Changbin" <changbin.du@intel.com>
Cc: "balbi@ti.com" <balbi@ti.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"mina86@mina86.com" <mina86@mina86.com>,
	"r.baldyga@samsung.com" <r.baldyga@samsung.com>,
	"rui.silva@linaro.org" <rui.silva@linaro.org>,
	"k.opasiak@samsung.com" <k.opasiak@samsung.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: f_fs: avoid race condition with ffs_epfile_io_complete
Date: Tue, 5 Jan 2016 13:49:06 +0800	[thread overview]
Message-ID: <20160105054906.GB29244@shlinux2> (raw)
In-Reply-To: <0C18FE92A7765D4EB9EE5D38D86A563A05C93F77@SHSMSX103.ccr.corp.intel.com>

On Tue, Jan 05, 2016 at 04:09:47AM +0000, Du, Changbin wrote:
> > > To avoid this, just dequeue the request first. After usb_ep_dequeue, the
> > > request must be done or canceled.
> > >
> > > With this change, we can ensure no race condition in f_fs driver. But
> > > actually I found some of the udc driver has analogical issue in its
> > > dequeue implementation. For example,
> > > 1) the dequeue function hold the controller's lock.
> > > 2) before driver request controller  to stop transfer, a request
> > >    completed.
> > > 3) the controller trigger a interrupt, but its irq handler need wait
> > >    dequeue function to release the lock.
> > > 4) dequeue function give back the request with negative status, and
> > >    release lock.
> > > 5) irq handler get lock but the request has already been given back.
> > >
> > 
> > get unlock?
> > 
> > During the interrupt handler, it should only handle the "data complete"
> > interrupt on queued request; if the "data complete" interrupt occurs, but
> > it belongs to nobody, it will handle noop.
> > 
> > 
> > Best Regards,
> > Peter Chen
> 
> You are right, but the problem is the request->status is wrong. If the data
> send out but report caller as -EINTR, it will introduce duplicate-send
> issue.
> 

Why -EINTR, the kernel-doc said it should return -ECONNRESET for active
request, see include/linux/usb/gadget.h.

-- 

Best Regards,
Peter Chen

  reply	other threads:[~2016-01-05  5:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29  6:36 [PATCH] usb: f_fs: avoid race condition with ffs_epfile_io_complete changbin.du
2016-01-04 20:33 ` Michal Nazarewicz
2016-01-05  3:32 ` Peter Chen
2016-01-05  4:09   ` Du, Changbin
2016-01-05  5:49     ` Peter Chen [this message]
2016-01-05  6:22       ` Du, Changbin
2016-01-05 12:45       ` Michal Nazarewicz

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=20160105054906.GB29244@shlinux2 \
    --to=hzpeterchen@gmail.com \
    --cc=balbi@ti.com \
    --cc=changbin.du@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=k.opasiak@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.com \
    --cc=r.baldyga@samsung.com \
    --cc=rui.silva@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    /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