Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301283

Re: [PATCH] usb: f_fs: avoid race condition with ffs_epfile_io_complete

From Peter Chen <hzpeterchen@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] usb: f_fs: avoid race condition with ffs_epfile_io_complete
Date 2016-01-05 07:00 +0100
Message-ID <qNsOZ-5ZH-5@gated-at.bofh.it> (permalink)
References <qKWgy-5cf-7@gated-at.bofh.it> <qNqDv-4wz-1@gated-at.bofh.it> <qNrgd-514-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] usb: f_fs: avoid race condition with  ffs_epfile_io_complete Peter Chen <hzpeterchen@gmail.com> - 2016-01-05 04:40 +0100
  RE: [PATCH] usb: f_fs: avoid race condition with  ffs_epfile_io_complete "Du, Changbin" <changbin.du@intel.com> - 2016-01-05 05:20 +0100
    Re: [PATCH] usb: f_fs: avoid race condition with  ffs_epfile_io_complete Peter Chen <hzpeterchen@gmail.com> - 2016-01-05 07:00 +0100
      RE: [PATCH] usb: f_fs: avoid race condition with  ffs_epfile_io_complete "Du, Changbin" <changbin.du@intel.com> - 2016-01-05 07:30 +0100
      Re: [PATCH] usb: f_fs: avoid race condition with ffs_epfile_io_complete Michal Nazarewicz <mina86@mina86.com> - 2016-01-05 13:50 +0100

csiph-web