RE: [PATCH] dmaengine: rcar-dmac: fixup spinlock in rcar-dmac

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Morimoto-san,

> Current rcar-dmac driver is using spin_lock_irq() / spin_unlock_irq()
> in some functions. But, some other driver might call DMAEngine API
> during interrupt disabled. In such case, rcar-dmac side spin_unlock_irq()
> forcefully allows all interrupts. Therefore, other driver receives
> unexpected interruption, and its exclusive access control will be broken.
> This patch replaces spin_lock_irq() to spin_lock_irqsave(),
> and spin_unlock_irq() to spin_unlock_irqrestore().
> 
> Signed-off-by: Jun Watanabe <jun.watanabe.ue@xxxxxxxxxxx>
> Signed-off-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@xxxxxxxxxxxx>
> Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@xxxxxxxxxxx>
< snip >
> @@ -493,15 +494,18 @@ static int rcar_dmac_desc_alloc(struct rcar_dmac_chan *chan, gfp_t gfp)
>  static void rcar_dmac_desc_put(struct rcar_dmac_chan *chan,
>  			       struct rcar_dmac_desc *desc)
>  {
> -	spin_lock_irq(&chan->lock);
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&chan->lock, flags);
>  	list_splice_tail_init(&desc->chunks, &chan->desc.chunks_free);
>  	list_add_tail(&desc->node, &chan->desc.free);
> -	spin_unlock_irq(&chan->lock);
> +	spin_unlock_irqrestore(&chan->lock, flags);
>  }

This change is already submitted from Laurent-san:
http://thread.gmane.org/gmane.linux.ports.sh.devel/43446/focus=43451

< snip >
> @@ -542,12 +546,13 @@ static void rcar_dmac_desc_recycle_acked(struct rcar_dmac_chan *chan)
>  static struct rcar_dmac_desc *rcar_dmac_desc_get(struct rcar_dmac_chan *chan)
>  {
>  	struct rcar_dmac_desc *desc;
> +	unsigned long flags;
>  	int ret;
> 
>  	/* Recycle acked descriptors before attempting allocation. */
>  	rcar_dmac_desc_recycle_acked(chan);
> 
> -	spin_lock_irq(&chan->lock);
> +	spin_lock_irqsave(&chan->lock, flags);
> 
>  	do {
>  		if (list_empty(&chan->desc.free)) {

I guess this will conflict the following patch.
But, I'm not sure how to fix conflict with other patch:
http://thread.gmane.org/gmane.linux.ports.sh.devel/43446/focus=43447

< snip >
> @@ -617,9 +623,10 @@ static struct rcar_dmac_xfer_chunk *
>  rcar_dmac_xfer_chunk_get(struct rcar_dmac_chan *chan)
>  {
>  	struct rcar_dmac_xfer_chunk *chunk;
> +	unsigned long flags;
>  	int ret;
> 
> -	spin_lock_irq(&chan->lock);
> +	spin_lock_irqsave(&chan->lock, flags);
> 
>  	do {
>  		if (list_empty(&chan->desc.chunks_free)) {

Same the above.

< snip >
> @@ -1349,8 +1357,9 @@ static irqreturn_t rcar_dmac_isr_channel_thread(int irq, void *dev)
>  {
>  	struct rcar_dmac_chan *chan = dev;
>  	struct rcar_dmac_desc *desc;
> +	unsigned long flags;
> 
> -	spin_lock_irq(&chan->lock);
> +	spin_lock_irqsave(&chan->lock, flags);

Since this function is not dmaengine API, I don't think we need this change.

Best regards,
Yoshihiro Shimoda

--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux PCI]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux