diff mbox series

[1/2,net-next,v3] igc: avoid kernel warning when changing RX ring parameters

Message ID 20220114165106.1085474-2-vinschen@redhat.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series igb/igc: fix XDP registration | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 5 blamed authors not CCed: jithu.joseph@intel.com anthony.l.nguyen@intel.com andre.guedes@intel.com maciej.fijalkowski@intel.com vedang.patel@intel.com; 14 maintainers not CCed: jithu.joseph@intel.com anthony.l.nguyen@intel.com kuba@kernel.org hawk@kernel.org jesse.brandeburg@intel.com andre.guedes@intel.com maciej.fijalkowski@intel.com daniel@iogearbox.net john.fastabend@gmail.com intel-wired-lan@lists.osuosl.org bpf@vger.kernel.org ast@kernel.org vedang.patel@intel.com davem@davemloft.net
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 35 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Corinna Vinschen Jan. 14, 2022, 4:51 p.m. UTC
Calling ethtool changing the RX ring parameters like this:

  $ ethtool -G eth0 rx 1024

on igc triggers the "Missing unregister, handled but fix driver" warning in
xdp_rxq_info_reg().

igc_ethtool_set_ringparam() copies the igc_ring structure but neglects to
reset the xdp_rxq_info member before calling igc_setup_rx_resources().
This in turn calls xdp_rxq_info_reg() with an already registered xdp_rxq_info.

Make sure to unregister the xdp_rxq_info structure first in
igc_setup_rx_resources.  Move xdp_rxq_info handling down to bethe last
action, thus allowing to remove the xdp_rxq_info_unreg call in the error path.

Fixes: 73f1071c1d29 ("igc: Add support for XDP_TX action")
Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
---
 drivers/net/ethernet/intel/igc/igc_main.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

Comments

Vinicius Costa Gomes Jan. 14, 2022, 7:10 p.m. UTC | #1
Corinna Vinschen <vinschen@redhat.com> writes:

> Calling ethtool changing the RX ring parameters like this:
>
>   $ ethtool -G eth0 rx 1024
>
> on igc triggers the "Missing unregister, handled but fix driver" warning in
> xdp_rxq_info_reg().
>
> igc_ethtool_set_ringparam() copies the igc_ring structure but neglects to
> reset the xdp_rxq_info member before calling igc_setup_rx_resources().
> This in turn calls xdp_rxq_info_reg() with an already registered xdp_rxq_info.
>
> Make sure to unregister the xdp_rxq_info structure first in
> igc_setup_rx_resources.  Move xdp_rxq_info handling down to bethe last
> action, thus allowing to remove the xdp_rxq_info_unreg call in the error path.
>
> Fixes: 73f1071c1d29 ("igc: Add support for XDP_TX action")
> Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
> ---
>  drivers/net/ethernet/intel/igc/igc_main.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 2f17f36e94fd..97144f6db36e 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -505,14 +505,6 @@ int igc_setup_rx_resources(struct igc_ring *rx_ring)
>  	u8 index = rx_ring->queue_index;
>  	int size, desc_len, res;
>  
> -	res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, ndev, index,
> -			       rx_ring->q_vector->napi.napi_id);
> -	if (res < 0) {
> -		netdev_err(ndev, "Failed to register xdp_rxq index %u\n",
> -			   index);
> -		return res;
> -	}
> -
>  	size = sizeof(struct igc_rx_buffer) * rx_ring->count;
>  	rx_ring->rx_buffer_info = vzalloc(size);
>  	if (!rx_ring->rx_buffer_info)
> @@ -534,10 +526,20 @@ int igc_setup_rx_resources(struct igc_ring *rx_ring)
>  	rx_ring->next_to_clean = 0;
>  	rx_ring->next_to_use = 0;
>  
> +	/* XDP RX-queue info */
> +	if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq))
> +		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
> +	res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, ndev, index,
> +			       rx_ring->q_vector->napi.napi_id);
> +	if (res < 0) {
> +		netdev_err(ndev, "Failed to register xdp_rxq index %u\n",
> +			   index);
> +		return res;

Here and in the igb patch, it should be 'goto err', no?

Another suggestion is to add the warning that Lennert reported in the
commit message (the comment from Maciej in that other thread).

Apart from that, I think this is cleaner than what I had proposed.


Cheers,
Corinna Vinschen Jan. 14, 2022, 7:25 p.m. UTC | #2
On Jan 14 11:10, Vinicius Costa Gomes wrote:
> Corinna Vinschen <vinschen@redhat.com> writes:
> 
> > Calling ethtool changing the RX ring parameters like this:
> >
> >   $ ethtool -G eth0 rx 1024
> >
> > on igc triggers the "Missing unregister, handled but fix driver" warning in
> > xdp_rxq_info_reg().
> >
> > igc_ethtool_set_ringparam() copies the igc_ring structure but neglects to
> > reset the xdp_rxq_info member before calling igc_setup_rx_resources().
> > This in turn calls xdp_rxq_info_reg() with an already registered xdp_rxq_info.
> >
> > Make sure to unregister the xdp_rxq_info structure first in
> > igc_setup_rx_resources.  Move xdp_rxq_info handling down to bethe last
> > action, thus allowing to remove the xdp_rxq_info_unreg call in the error path.
> >
> > Fixes: 73f1071c1d29 ("igc: Add support for XDP_TX action")
> > Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
> > ---
> >  drivers/net/ethernet/intel/igc/igc_main.c | 20 +++++++++++---------
> >  1 file changed, 11 insertions(+), 9 deletions(-)
> > [...]
> > @@ -534,10 +526,20 @@ int igc_setup_rx_resources(struct igc_ring *rx_ring)
> >  	rx_ring->next_to_clean = 0;
> >  	rx_ring->next_to_use = 0;
> >  
> > +	/* XDP RX-queue info */
> > +	if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq))
> > +		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
> > +	res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, ndev, index,
> > +			       rx_ring->q_vector->napi.napi_id);
> > +	if (res < 0) {
> > +		netdev_err(ndev, "Failed to register xdp_rxq index %u\n",
> > +			   index);
> > +		return res;
> 
> Here and in the igb patch, it should be 'goto err', no?

D'oh, of course.  Soory and thanks for catching.  I'll prepare a v4.

> Another suggestion is to add the warning that Lennert reported in the
> commit message (the comment from Maciej in that other thread).

The current commit message already mentiones the "Missing unregister,
handled but fix driver" warning.  Do you mean the entire warning
snippet including call stack?  If so, no problem.  I'll add it to v4,
too.

Shall I also add "Reported-by: Lennert ..."?  Funny enough we
encountered the problem independently at almost the same time, so when I
sent my v1 of the patch I wasn't even aware of the thread started by
Lennert and only saw it afterwards :}

> Apart from that, I think this is cleaner than what I had proposed.

Thanks,
Corinna
Corinna Vinschen Jan. 14, 2022, 7:44 p.m. UTC | #3
On Jan 14 20:25, Corinna Vinschen wrote:
> On Jan 14 11:10, Vinicius Costa Gomes wrote:
> > Corinna Vinschen <vinschen@redhat.com> writes:
> > 
> > > Calling ethtool changing the RX ring parameters like this:
> > >
> > >   $ ethtool -G eth0 rx 1024
> > >
> > > on igc triggers the "Missing unregister, handled but fix driver" warning in
> > > xdp_rxq_info_reg().
> > >
> > > igc_ethtool_set_ringparam() copies the igc_ring structure but neglects to
> > > reset the xdp_rxq_info member before calling igc_setup_rx_resources().
> > > This in turn calls xdp_rxq_info_reg() with an already registered xdp_rxq_info.
> > >
> > > Make sure to unregister the xdp_rxq_info structure first in
> > > igc_setup_rx_resources.  Move xdp_rxq_info handling down to bethe last
> > > action, thus allowing to remove the xdp_rxq_info_unreg call in the error path.
> > >
> > > Fixes: 73f1071c1d29 ("igc: Add support for XDP_TX action")
> > > Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
> > > ---
> > >  drivers/net/ethernet/intel/igc/igc_main.c | 20 +++++++++++---------
> > >  1 file changed, 11 insertions(+), 9 deletions(-)
> > > [...]
> > > @@ -534,10 +526,20 @@ int igc_setup_rx_resources(struct igc_ring *rx_ring)
> > >  	rx_ring->next_to_clean = 0;
> > >  	rx_ring->next_to_use = 0;
> > >  
> > > +	/* XDP RX-queue info */
> > > +	if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq))
> > > +		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
> > > +	res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, ndev, index,
> > > +			       rx_ring->q_vector->napi.napi_id);
> > > +	if (res < 0) {
> > > +		netdev_err(ndev, "Failed to register xdp_rxq index %u\n",
> > > +			   index);
> > > +		return res;
> > 
> > Here and in the igb patch, it should be 'goto err', no?
> 
> D'oh, of course.  Soory and thanks for catching.  I'll prepare a v4.
> 
> > Another suggestion is to add the warning that Lennert reported in the
> > commit message (the comment from Maciej in that other thread).
> 
> The current commit message already mentiones the "Missing unregister,
> handled but fix driver" warning.  Do you mean the entire warning
> snippet including call stack?  If so, no problem.  I'll add it to v4,
> too.
> 
> Shall I also add "Reported-by: Lennert ..."?  Funny enough we
> encountered the problem independently at almost the same time, so when I
> sent my v1 of the patch I wasn't even aware of the thread started by
> Lennert and only saw it afterwards :}

Never mind, I just send a v4 with all of that.


Corinna
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
index 2f17f36e94fd..97144f6db36e 100644
--- a/drivers/net/ethernet/intel/igc/igc_main.c
+++ b/drivers/net/ethernet/intel/igc/igc_main.c
@@ -505,14 +505,6 @@  int igc_setup_rx_resources(struct igc_ring *rx_ring)
 	u8 index = rx_ring->queue_index;
 	int size, desc_len, res;
 
-	res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, ndev, index,
-			       rx_ring->q_vector->napi.napi_id);
-	if (res < 0) {
-		netdev_err(ndev, "Failed to register xdp_rxq index %u\n",
-			   index);
-		return res;
-	}
-
 	size = sizeof(struct igc_rx_buffer) * rx_ring->count;
 	rx_ring->rx_buffer_info = vzalloc(size);
 	if (!rx_ring->rx_buffer_info)
@@ -534,10 +526,20 @@  int igc_setup_rx_resources(struct igc_ring *rx_ring)
 	rx_ring->next_to_clean = 0;
 	rx_ring->next_to_use = 0;
 
+	/* XDP RX-queue info */
+	if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq))
+		xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
+	res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, ndev, index,
+			       rx_ring->q_vector->napi.napi_id);
+	if (res < 0) {
+		netdev_err(ndev, "Failed to register xdp_rxq index %u\n",
+			   index);
+		return res;
+	}
+
 	return 0;
 
 err:
-	xdp_rxq_info_unreg(&rx_ring->xdp_rxq);
 	vfree(rx_ring->rx_buffer_info);
 	rx_ring->rx_buffer_info = NULL;
 	netdev_err(ndev, "Unable to allocate memory for Rx descriptor ring\n");