[PATCH] dma/hisilicon: fix stop dmadev fail

Thomas Monjalon thomas at monjalon.net
Wed Oct 15 11:36:19 CEST 2025


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 at dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen at 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.




More information about the dev mailing list