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: [email protected]
> 
> Signed-off-by: Chengwen Feng <[email protected]>
> ---
[...]
> +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 via email to