mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Sverdlin, Alexander" <alexander.sverdlin@siemens.com>
To: "andrew+netdev@lunn.ch" <andrew+netdev@lunn.ch>,
	"s-vadapalli@ti.com" <s-vadapalli@ti.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"dan.carpenter@linaro.org" <dan.carpenter@linaro.org>,
	"jpanis@baylibre.com" <jpanis@baylibre.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"horms@kernel.org" <horms@kernel.org>,
	"edumazet@google.com" <edumazet@google.com>,
	"rogerq@kernel.org" <rogerq@kernel.org>,
	"kuba@kernel.org" <kuba@kernel.org>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"vigneshr@ti.com" <vigneshr@ti.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"srk@ti.com" <srk@ti.com>
Subject: Re: [PATCH net] net: ethernet: ti: am65-cpsw: Fix NAPI registration sequence
Date: Tue, 11 Mar 2025 07:09:56 +0000	[thread overview]
Message-ID: <421a4c67865215927897e16866814bd6eb68a89d.camel@siemens.com> (raw)
In-Reply-To: <20250311061214.4111634-1-s-vadapalli@ti.com>

Hi Siddharth!

On Tue, 2025-03-11 at 11:42 +0530, Siddharth Vadapalli wrote:
> From: Vignesh Raghavendra <vigneshr@ti.com>
> 
> Registering the interrupts for TX or RX DMA Channels prior to registering
> their respective NAPI callbacks can result in a NULL pointer dereference.
> This is seen in practice as a random occurrence since it depends on the
> randomness associated with the generation of traffic by Linux and the
> reception of traffic from the wire.
> 
> Fixes: 681eb2beb3ef ("net: ethernet: ti: am65-cpsw: ensure proper channel cleanup in error path")

The patch Vignesh mentions here...

> Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
> Co-developed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
> ---
> 
> Hello,
> 
> This patch is based on commit
> 4d872d51bc9d Merge tag 'x86-urgent-2025-03-10' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
> of Mainline Linux.
> 
> Regards,
> Siddharth.
> 
>  drivers/net/ethernet/ti/am65-cpsw-nuss.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> index 2806238629f8..d5291281c781 100644
> --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
> @@ -2314,6 +2314,9 @@ static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common)
>  		hrtimer_init(&tx_chn->tx_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_PINNED);
>  		tx_chn->tx_hrtimer.function = &am65_cpsw_nuss_tx_timer_callback;
>  
> +		netif_napi_add_tx(common->dma_ndev, &tx_chn->napi_tx,
> +				  am65_cpsw_nuss_tx_poll);
> +
>  		ret = devm_request_irq(dev, tx_chn->irq,
>  				       am65_cpsw_nuss_tx_irq,
>  				       IRQF_TRIGGER_HIGH,
> @@ -2323,9 +2326,6 @@ static int am65_cpsw_nuss_ndev_add_tx_napi(struct am65_cpsw_common *common)
>  				tx_chn->id, tx_chn->irq, ret);
>  			goto err;
>  		}
> -
> -		netif_napi_add_tx(common->dma_ndev, &tx_chn->napi_tx,
> -				  am65_cpsw_nuss_tx_poll);

... has accounted for the fact ..._napi_add_... happens after [possibly unsuccessful] request_irq,
please grep for "for (--i ;". Is it necessary to adjust both loops, in the below case too?

>  	}
>  
>  	return 0;
> @@ -2569,6 +2569,9 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
>  			     HRTIMER_MODE_REL_PINNED);
>  		flow->rx_hrtimer.function = &am65_cpsw_nuss_rx_timer_callback;
>  
> +		netif_napi_add(common->dma_ndev, &flow->napi_rx,
> +			       am65_cpsw_nuss_rx_poll);
> +
>  		ret = devm_request_irq(dev, flow->irq,
>  				       am65_cpsw_nuss_rx_irq,
>  				       IRQF_TRIGGER_HIGH,
> @@ -2579,9 +2582,6 @@ static int am65_cpsw_nuss_init_rx_chns(struct am65_cpsw_common *common)
>  			flow->irq = -EINVAL;
>  			goto err_flow;
>  		}
> -
> -		netif_napi_add(common->dma_ndev, &flow->napi_rx,
> -			       am65_cpsw_nuss_rx_poll);
>  	}
>  
>  	/* setup classifier to route priorities to flows */

-- 
Alexander Sverdlin
Siemens AG
www.siemens.com

  reply	other threads:[~2025-03-11  7:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11  6:12 Siddharth Vadapalli
2025-03-11  7:09 ` Sverdlin, Alexander [this message]
2025-03-11  8:51   ` s-vadapalli
2025-03-11  8:56     ` Sverdlin, Alexander
2025-03-11  9:00       ` s-vadapalli

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=421a4c67865215927897e16866814bd6eb68a89d.camel@siemens.com \
    --to=alexander.sverdlin@siemens.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jpanis@baylibre.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rogerq@kernel.org \
    --cc=s-vadapalli@ti.com \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®