All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Chengwen Feng <fengchengwen@huawei.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH] dma/hisilicon: fix stop dmadev fail
Date: Wed, 15 Oct 2025 11:36:19 +0200	[thread overview]
Message-ID: <13676403.VsHLxoZxqI@thomas> (raw)
In-Reply-To: <20251013092211.6804-1-fengchengwen@huawei.com>

13/10/2025 11:22, Chengwen Feng:
> Stop dmadev may fail if there are pending DMA transfers, we need make
> sure there are no pending DMA transfers when stop.
> 
> This commit uses following scheme:
> 1. flag stop proc so that new request will not process.
> 2. setting drop flag for all descriptor to quick complete.
> 3. waiting dmadev to complete.
> 
> Fixes: 3c5f5f03a047 ("dma/hisilicon: add control path")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
[...]
> +static int
> +hisi_dma_vchan_status(const struct rte_dma_dev *dev, uint16_t vchan,
> +		      enum rte_dma_vchan_status *status);

This declaration can be avoided by moving hisi_dma_stop()
which is anyway almost new.

>  static int
>  hisi_dma_stop(struct rte_dma_dev *dev)
>  {
> +#define MAX_WAIT_MSEC	10
> +	struct hisi_dma_dev *hw = dev->data->dev_private;
> +	enum rte_dma_vchan_status status;
> +	uint32_t i;
> +
> +	/* Flag stop processing new requests. */
> +	hw->stop_proc = 1;
> +	rte_delay_ms(1);
> +
> +	/* Force set drop flag so that the hardware can quickly complete. */
> +	for (i = 0; i <= hw->sq_depth_mask; i++)
> +		hw->sqe[i].dw0 |= SQE_DROP_FLAG;
> +
> +	i = 0;
> +	do {
> +		hisi_dma_vchan_status(dev, 0, &status);
> +		if (status != RTE_DMA_VCHAN_ACTIVE)
> +			break;
> +		rte_delay_ms(1);
> +	} while (i++ < MAX_WAIT_MSEC);
> +	if (status == RTE_DMA_VCHAN_ACTIVE) {
> +		HISI_DMA_ERR(hw, "dev is still active!");
> +		return -EBUSY;
> +	}
> +
>  	return hisi_dma_reset_hw(dev->data->dev_private);
>  }

Applied with suggested move, thanks.



      reply	other threads:[~2025-10-15  9:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13  9:22 [PATCH] dma/hisilicon: fix stop dmadev fail Chengwen Feng
2025-10-15  9:36 ` Thomas Monjalon [this message]

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=13676403.VsHLxoZxqI@thomas \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.