DMA Engine development
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: vkoul@kernel.org
Cc: dmaengine@vger.kernel.org, dan.j.williams@intel.com, fan.du@intel.com
Subject: Re: [PATCH] dmaengine: ioatdma: fix unprotected timer deletion
Date: Thu, 16 May 2019 09:11:27 -0700	[thread overview]
Message-ID: <f80ae09d-82f3-e395-f797-afd79381ce36@intel.com> (raw)
In-Reply-To: <155744504539.8006.16459393524018173816.stgit@djiang5-desk3.ch.intel.com>



On 5/9/19 4:37 PM, Dave Jiang wrote:
> When ioat_free_chan_resources() gets called, ioat_stop() is called without
> chan->cleanup_lock. ioat_stop modifies IOAT_RUN bit.  It needs to be
> protected by cleanup_lock. Also, in the __cleanup() path, if IOAT_RUN is
> cleared, we should not touch the timer again. We observed that the timer
> routine was run after timer was deleted.
> 
> Fixes: 3372de5813e ("dmaengine: ioatdma: removal of dma_v3.c and relevant ioat3
> references")
> 
> Reported-by: Fan Du <fan.du@intel.com>
> Tested-by: Fan Du <fan.du@intel.com>
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>

Vinod, can you hold off on this please? There may be more changes. Thanks.

> ---
>  drivers/dma/ioat/dma.c |   16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
> index f373a139e0c3..78598ba5c73b 100644
> --- a/drivers/dma/ioat/dma.c
> +++ b/drivers/dma/ioat/dma.c
> @@ -138,11 +138,14 @@ void ioat_stop(struct ioatdma_chan *ioat_chan)
>  	struct pci_dev *pdev = ioat_dma->pdev;
>  	int chan_id = chan_num(ioat_chan);
>  	struct msix_entry *msix;
> +	unsigned long flags;
>  
> -	/* 1/ stop irq from firing tasklets
> -	 * 2/ stop the tasklet from re-arming irqs
> -	 */
> +	spin_lock_irqsave(&ioat_chan->cleanup_lock, flags);
>  	clear_bit(IOAT_RUN, &ioat_chan->state);
> +	spin_unlock_irqrestore(&ioat_chan->cleanup_lock, flags);
> +
> +	/* flush inflight timers */
> +	del_timer_sync(&ioat_chan->timer);
>  
>  	/* flush inflight interrupts */
>  	switch (ioat_dma->irq_mode) {
> @@ -158,9 +161,6 @@ void ioat_stop(struct ioatdma_chan *ioat_chan)
>  		break;
>  	}
>  
> -	/* flush inflight timers */
> -	del_timer_sync(&ioat_chan->timer);
> -
>  	/* flush inflight tasklet runs */
>  	tasklet_kill(&ioat_chan->cleanup_task);
>  
> @@ -652,7 +652,9 @@ static void __cleanup(struct ioatdma_chan *ioat_chan, dma_addr_t phys_complete)
>  	if (active - i == 0) {
>  		dev_dbg(to_dev(ioat_chan), "%s: cancel completion timeout\n",
>  			__func__);
> -		mod_timer(&ioat_chan->timer, jiffies + IDLE_TIMEOUT);
> +
> +		if (test_bit(IOAT_RUN, &ioat_chan->state))
> +			mod_timer(&ioat_chan->timer, jiffies + IDLE_TIMEOUT);
>  	}
>  
>  	/* microsecond delay by sysfs variable  per pending descriptor */
> 

  reply	other threads:[~2019-05-16 16:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09 23:37 [PATCH] dmaengine: ioatdma: fix unprotected timer deletion Dave Jiang
2019-05-16 16:11 ` Dave Jiang [this message]
2019-05-21  5:09   ` Vinod Koul

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=f80ae09d-82f3-e395-f797-afd79381ce36@intel.com \
    --to=dave.jiang@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=fan.du@intel.com \
    --cc=vkoul@kernel.org \
    /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