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


Groups > linux.kernel > #1349914

Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function

From Felipe Balbi <balbi@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function
Date 2016-03-04 08:30 +0100
Message-ID <r8Sls-38B-19@gated-at.bofh.it> (permalink)
References <r8kMN-4cl-3@gated-at.bofh.it> <r8kMN-4cl-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

"Felipe F. Tonello" <eu@felipetonello.com> writes:
> [ text/plain ]
> Since f_midi_transmit is called by both ALSA and USB frameworks, it can
> potentially cause a race condition between both calls. This is bad because the
> way f_midi_transmit is implemented can't handle concurrent calls. This is due
> to the fact that the usb request fifo looks for the next element and only if
> it has data to process it enqueues the request, otherwise re-uses it. If both
> (ALSA and USB) frameworks calls this function at the same time, the
> kfifo_seek() will return the same usb_request, which will cause a race
> condition.
>
> To solve this problem a syncronization mechanism is necessary. In this case it
> is used a spinlock since f_midi_transmit is also called by usb_request->complete
> callback in interrupt context.
>
> On benchmarks realized by me, spinlocks were more efficient then scheduling
> the f_midi_transmit tasklet in process context and using a mutex to
> synchronize. Also it performs better then previous implementation that
> allocated a usb_request for every new transmit made.

behaves better in what way ? Also, previous implementation would not
suffer from this concurrency problem, right ?

-- 
balbi

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


Thread

[PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function "Felipe F. Tonello" <eu@felipetonello.com> - 2016-03-02 20:40 +0100
  Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe Balbi <balbi@kernel.org> - 2016-03-04 08:30 +0100
    Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-04 19:50 +0100
      Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe Balbi <balbi@kernel.org> - 2016-03-07 08:40 +0100
        Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit  function Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-07 10:30 +0100
          Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe Balbi <balbi@kernel.org> - 2016-03-08 08:40 +0100
            Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit  function Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-08 14:50 +0100
              Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe Balbi <balbi@kernel.org> - 2016-03-08 15:10 +0100
                Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit  function Felipe Ferreri Tonello <eu@felipetonello.com> - 2016-03-08 16:40 +0100
                Re: [PATCH 2/5] usb: gadget: f_midi: added spinlock on transmit function Felipe Balbi <balbi@kernel.org> - 2016-03-09 08:30 +0100

csiph-web