[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090401111116.7c604530@hcegtvedt>
Date: Wed, 1 Apr 2009 11:11:16 +0200
From: Hans-Christian Egtvedt <hans-christian.egtvedt@...el.com>
To: Haavard Skinnemoen <haavard.skinnemoen@...el.com>
Cc: "Sosnowski, Maciej" <maciej.sosnowski@...el.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Williams, Dan J" <dan.j.williams@...el.com>
Subject: Re: [PATCH 2/2] dw_dmac: add cyclic API to DW DMA driver
On Wed, 1 Apr 2009 10:28:30 +0200
Haavard Skinnemoen <haavard.skinnemoen@...el.com> wrote:
> Sosnowski, Maciej wrote:
> > > +void dw_dma_cyclic_stop(struct dma_chan *chan)
> > > +{
> > > + struct dw_dma_chan *dwc = to_dw_dma_chan(chan);
> > > + struct dw_dma *dw =
> > > to_dw_dma(dwc->chan.device); +
> > > + channel_clear_bit(dw, CH_EN, dwc->mask);
> > > + while (dma_readl(dw, CH_EN) & dwc->mask)
> > > + cpu_relax();
> > > +}
> >
> > Don't you need locks in dw_dma_cyclic_stop?
>
> Good question. On one hand, if cyclic_start() can race with
> cyclic_stop(), the client probably has more serious issues to deal
> with. On the other hand, if something ever manages to set the CH_EN
> bit at the wrong moment, the loop may never finish.
>
> So it's probably safest to wrap it in spin_lock_bh(). You should
> probably add a note that this function can not be called from
> interrupt context too.
>
The problem then is when calling cyclic_stop from the trigger function
in an ALSA driver.
http://www.kernel.org/pub/linux/kernel/people/tiwai/docs/writing-an-alsa-driver/ch05s06.html#pcm-interface-operators-trigger-callback
This callback is atomic, and with interrupts disabled. So using
spin_lock_bh() is AFAICT not allowed.
I am going to brush up the interface and document that the _stop and
_start interface has to be called with interrupts disabled. Will post a
v2 shortly.
--
Best regards,
Hans-Christian Egtvedt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists