Re: [PATCH v2 3/3] dmaengine: fsl-dpaa2-qdma: Remove the macro of DPDMAI_MAX_QUEUE_NUM

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

 



On 22-04-21, 16:44, Guanhua Gao wrote:
> The max number of queue supported by DPAA2 qdma is determined
> by the number of CPUs. Due to the number of CPUs are different
> in different LS2 platforms, we remove the macro of
> DPDMAI_MAX_QUEUE_NUM which is defined 8.
> 
> Signed-off-by: Guanhua Gao <guanhua.gao@xxxxxxx>
> ---
> Change in v2:
>  - Add new patch.
> 
>  drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c | 43 +++++++++++++++++++++----
>  drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h |  4 +--
>  drivers/dma/fsl-dpaa2-qdma/dpdmai.h     |  5 ---
>  3 files changed, 39 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
> index 86c7ec5dc74e..3875fbb9fac3 100644
> --- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
> +++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
> @@ -314,6 +314,8 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev)
>  	struct dpaa2_qdma_priv_per_prio *ppriv;
>  	struct device *dev = &ls_dev->dev;
>  	struct dpaa2_qdma_priv *priv;
> +	struct dpdmai_rx_queue_attr *rx_queue_attr;
> +	struct dpdmai_tx_queue_attr *tx_queue_attr;
>  	int err = -EINVAL;
>  	int i;
>  
> @@ -335,33 +337,51 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev)
>  				    &priv->dpdmai_attr);
>  	if (err) {
>  		dev_err(dev, "dpdmai_get_attributes() failed\n");
> -		goto exit;
> +		goto err_get_attr;
>  	}
>  
>  	priv->num_pairs = priv->dpdmai_attr.num_of_queues;
> +	rx_queue_attr = kcalloc(priv->num_pairs, sizeof(*rx_queue_attr),
> +				GFP_KERNEL);
> +	if (!rx_queue_attr) {
> +		err = -ENOMEM;
> +		goto err_get_attr;
> +	}
> +	priv->rx_queue_attr = rx_queue_attr;
> +
> +	tx_queue_attr = kcalloc(priv->num_pairs, sizeof(*tx_queue_attr),
> +				GFP_KERNEL);
> +	if (!tx_queue_attr) {
> +		err = -ENOMEM;
> +		goto err_tx_queue;
> +	}
> +	priv->tx_queue_attr = tx_queue_attr;

Pointer is set here

> +
>  	ppriv = kcalloc(priv->num_pairs, sizeof(*ppriv), GFP_KERNEL);
>  	if (!ppriv) {
>  		err = -ENOMEM;
> -		goto exit;
> +		goto err_ppriv;
>  	}
>  	priv->ppriv = ppriv;
>  
>  	for (i = 0; i < priv->num_pairs; i++) {
>  		err = dpdmai_get_rx_queue(priv->mc_io, 0, ls_dev->mc_handle,
> -					  i, 0, &priv->rx_queue_attr[i]);
> +					  i, 0, priv->rx_queue_attr + i);
>  		if (err) {
>  			dev_err(dev, "dpdmai_get_rx_queue() failed\n");
>  			goto exit;
>  		}
> -		ppriv->rsp_fqid = priv->rx_queue_attr[i].fqid;
> +		ppriv->rsp_fqid = ((struct dpdmai_rx_queue_attr *)
> +				   (priv->rx_queue_attr + i))->fqid;
>  
>  		err = dpdmai_get_tx_queue(priv->mc_io, 0, ls_dev->mc_handle,
> -					  i, 0, &priv->tx_queue_attr[i]);
> +					  i, 0, priv->tx_queue_attr + i);
>  		if (err) {
>  			dev_err(dev, "dpdmai_get_tx_queue() failed\n");
>  			goto exit;
>  		}
> -		ppriv->req_fqid = priv->tx_queue_attr[i].fqid;
> +		ppriv->req_fqid = ((struct dpdmai_tx_queue_attr *)
> +				   (priv->tx_queue_attr + i))->fqid;
>  		ppriv->prio = DPAA2_QDMA_DEFAULT_PRIORITY;
>  		ppriv->priv = priv;
>  		ppriv->chan_id = i;
> @@ -370,6 +390,12 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev)
>  
>  	return 0;
>  exit:
> +	kfree(ppriv);
> +err_ppriv:
> +	kfree(priv->tx_queue_attr);
> +err_tx_queue:
> +	kfree(priv->rx_queue_attr);

Freed on error but you still have dangling reference held

> +err_get_attr:
>  	dpdmai_close(priv->mc_io, 0, ls_dev->mc_handle);
>  	return err;
>  }
> @@ -733,6 +759,8 @@ static int dpaa2_qdma_probe(struct fsl_mc_device *dpdmai_dev)
>  	dpaa2_dpmai_store_free(priv);
>  	dpaa2_dpdmai_dpio_free(priv);
>  err_dpio_setup:
> +	kfree(priv->rx_queue_attr);
> +	kfree(priv->tx_queue_attr);
>  	kfree(priv->ppriv);
>  	dpdmai_close(priv->mc_io, 0, dpdmai_dev->mc_handle);
>  err_dpdmai_setup:
> @@ -763,6 +791,9 @@ static int dpaa2_qdma_remove(struct fsl_mc_device *ls_dev)
>  	dpaa2_dpdmai_free_channels(dpaa2_qdma);
>  
>  	dma_async_device_unregister(&dpaa2_qdma->dma_dev);
> +	kfree(priv->rx_queue_attr);
> +	kfree(priv->tx_queue_attr);
> +	kfree(priv->ppriv);
>  	kfree(priv);
>  	kfree(dpaa2_qdma);
>  
> diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
> index 0a405fb13452..38aed372214e 100644
> --- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
> +++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
> @@ -123,8 +123,8 @@ struct dpaa2_qdma_priv {
>  	struct dpaa2_qdma_engine	*dpaa2_qdma;
>  	struct dpaa2_qdma_priv_per_prio	*ppriv;
>  
> -	struct dpdmai_rx_queue_attr rx_queue_attr[DPDMAI_MAX_QUEUE_NUM];
> -	struct dpdmai_tx_queue_attr tx_queue_attr[DPDMAI_MAX_QUEUE_NUM];
> +	struct dpdmai_rx_queue_attr *rx_queue_attr;
> +	struct dpdmai_tx_queue_attr *tx_queue_attr;
>  };
>  
>  struct dpaa2_qdma_priv_per_prio {
> diff --git a/drivers/dma/fsl-dpaa2-qdma/dpdmai.h b/drivers/dma/fsl-dpaa2-qdma/dpdmai.h
> index 0a87d37f7a92..f3a3eac97400 100644
> --- a/drivers/dma/fsl-dpaa2-qdma/dpdmai.h
> +++ b/drivers/dma/fsl-dpaa2-qdma/dpdmai.h
> @@ -51,11 +51,6 @@
>   * Contains initialization APIs and runtime control APIs for DPDMAI
>   */
>  
> -/*
> - * Maximum number of Tx/Rx queues per DPDMAI object
> - */
> -#define DPDMAI_MAX_QUEUE_NUM	8
> -
>  /**
>   * Maximum number of Tx/Rx priorities per DPDMAI object
>   */
> -- 
> 2.25.1

-- 
~Vinod



[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