netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] dpaa2-eth: free already allocated channels on probe defer
@ 2019-11-12 16:21 Ioana Ciornei
  2019-11-13  3:50 ` David Miller
  2019-11-13  8:03 ` Simon Horman
  0 siblings, 2 replies; 3+ messages in thread
From: Ioana Ciornei @ 2019-11-12 16:21 UTC (permalink / raw)
  To: davem, netdev; +Cc: Ioana Ciornei

The setup_dpio() function tries to allocate a number of channels equal
to the number of CPUs online. When there are not enough DPCON objects
already probed, the function will return EPROBE_DEFER. When this
happens, the already allocated channels are not freed. This results in
the incapacity of properly probing the next time around.
Fix this by freeing the channels on the error path.

Fixes: d7f5a9d89a55 ("dpaa2-eth: defer probe on object allocate")
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
 - add the proper Fixes tag
Changes in v3:
 - cleanup should be done only on EPROBE_DEFER

 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index 19379bae0144..bf5add954181 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -2232,8 +2232,16 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
 err_service_reg:
 	free_channel(priv, channel);
 err_alloc_ch:
-	if (err == -EPROBE_DEFER)
+	if (err == -EPROBE_DEFER) {
+		for (i = 0; i < priv->num_channels; i++) {
+			channel = priv->channel[i];
+			nctx = &channel->nctx;
+			dpaa2_io_service_deregister(channel->dpio, nctx, dev);
+			free_channel(priv, channel);
+		}
+		priv->num_channels = 0;
 		return err;
+	}
 
 	if (cpumask_empty(&priv->dpio_cpumask)) {
 		dev_err(dev, "No cpu with an affine DPIO/DPCON\n");
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v3] dpaa2-eth: free already allocated channels on probe defer
  2019-11-12 16:21 [PATCH net v3] dpaa2-eth: free already allocated channels on probe defer Ioana Ciornei
@ 2019-11-13  3:50 ` David Miller
  2019-11-13  8:03 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-11-13  3:50 UTC (permalink / raw)
  To: ioana.ciornei; +Cc: netdev

From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Tue, 12 Nov 2019 18:21:52 +0200

> The setup_dpio() function tries to allocate a number of channels equal
> to the number of CPUs online. When there are not enough DPCON objects
> already probed, the function will return EPROBE_DEFER. When this
> happens, the already allocated channels are not freed. This results in
> the incapacity of properly probing the next time around.
> Fix this by freeing the channels on the error path.
> 
> Fixes: d7f5a9d89a55 ("dpaa2-eth: defer probe on object allocate")
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v3] dpaa2-eth: free already allocated channels on probe defer
  2019-11-12 16:21 [PATCH net v3] dpaa2-eth: free already allocated channels on probe defer Ioana Ciornei
  2019-11-13  3:50 ` David Miller
@ 2019-11-13  8:03 ` Simon Horman
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2019-11-13  8:03 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, netdev

On Tue, Nov 12, 2019 at 06:21:52PM +0200, Ioana Ciornei wrote:
> The setup_dpio() function tries to allocate a number of channels equal
> to the number of CPUs online. When there are not enough DPCON objects
> already probed, the function will return EPROBE_DEFER. When this
> happens, the already allocated channels are not freed. This results in
> the incapacity of properly probing the next time around.
> Fix this by freeing the channels on the error path.
> 
> Fixes: d7f5a9d89a55 ("dpaa2-eth: defer probe on object allocate")
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Thanks for the update,

Reviewed-by: Simon Horman <simon.horman@netronome.com>

> ---
> Changes in v2:
>  - add the proper Fixes tag
> Changes in v3:
>  - cleanup should be done only on EPROBE_DEFER
> 
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> index 19379bae0144..bf5add954181 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> @@ -2232,8 +2232,16 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
>  err_service_reg:
>  	free_channel(priv, channel);
>  err_alloc_ch:
> -	if (err == -EPROBE_DEFER)
> +	if (err == -EPROBE_DEFER) {
> +		for (i = 0; i < priv->num_channels; i++) {
> +			channel = priv->channel[i];
> +			nctx = &channel->nctx;
> +			dpaa2_io_service_deregister(channel->dpio, nctx, dev);
> +			free_channel(priv, channel);
> +		}
> +		priv->num_channels = 0;
>  		return err;
> +	}
>  
>  	if (cpumask_empty(&priv->dpio_cpumask)) {
>  		dev_err(dev, "No cpu with an affine DPIO/DPCON\n");
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-13  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-12 16:21 [PATCH net v3] dpaa2-eth: free already allocated channels on probe defer Ioana Ciornei
2019-11-13  3:50 ` David Miller
2019-11-13  8:03 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).