diff mbox series

[net] sfc: fix XDP queues mode with legacy IRQ

Message ID 20230613133854.37832-1-ihuguet@redhat.com (mailing list archive)
State Accepted
Commit e84a1e1e683f3558e30f437d7c99df35afb8b52c
Delegated to: Netdev Maintainers
Headers show
Series [net] sfc: fix XDP queues mode with legacy IRQ | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 6 maintainers not CCed: hawk@kernel.org daniel@iogearbox.net john.fastabend@gmail.com mkl@pengutronix.de bpf@vger.kernel.org ast@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 28 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Íñigo Huguet June 13, 2023, 1:38 p.m. UTC
In systems without MSI-X capabilities, xdp_txq_queues_mode is calculated
in efx_allocate_msix_channels, but when enabling MSI-X fails, it was not
changed to a proper default value. This was leading to the driver
thinking that it has dedicated XDP queues, when it didn't.

Fix it by setting xdp_txq_queues_mode to the correct value if the driver
fallbacks to MSI or legacy IRQ mode. The correct value is
EFX_XDP_TX_QUEUES_BORROWED because there are not XDP dedicated queues.

The issue can be easily visible if the kernel is started with pci=nomsi,
then a call trace is shown. It is not shown only with sfc's modparam
interrupt_mode=2. Call trace example:
 WARNING: CPU: 2 PID: 663 at drivers/net/ethernet/sfc/efx_channels.c:828 efx_set_xdp_channels+0x124/0x260 [sfc]
 [...skip...]
 Call Trace:
  <TASK>
  efx_set_channels+0x5c/0xc0 [sfc]
  efx_probe_nic+0x9b/0x15a [sfc]
  efx_probe_all+0x10/0x1a2 [sfc]
  efx_pci_probe_main+0x12/0x156 [sfc]
  efx_pci_probe_post_io+0x18/0x103 [sfc]
  efx_pci_probe.cold+0x154/0x257 [sfc]
  local_pci_probe+0x42/0x80

Fixes: 6215b608a8c4 ("sfc: last resort fallback for lack of xdp tx queues")
Reported-by: Yanghang Liu <yanghliu@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
---
 drivers/net/ethernet/sfc/efx_channels.c       | 2 ++
 drivers/net/ethernet/sfc/siena/efx_channels.c | 2 ++
 2 files changed, 4 insertions(+)

Comments

Martin Habets June 15, 2023, 8 a.m. UTC | #1
On Tue, Jun 13, 2023 at 03:38:54PM +0200, Íñigo Huguet wrote:
> In systems without MSI-X capabilities, xdp_txq_queues_mode is calculated
> in efx_allocate_msix_channels, but when enabling MSI-X fails, it was not
> changed to a proper default value. This was leading to the driver
> thinking that it has dedicated XDP queues, when it didn't.
> 
> Fix it by setting xdp_txq_queues_mode to the correct value if the driver
> fallbacks to MSI or legacy IRQ mode. The correct value is
> EFX_XDP_TX_QUEUES_BORROWED because there are not XDP dedicated queues.

Small typo: not should be no.

> 
> The issue can be easily visible if the kernel is started with pci=nomsi,
> then a call trace is shown. It is not shown only with sfc's modparam
> interrupt_mode=2. Call trace example:
>  WARNING: CPU: 2 PID: 663 at drivers/net/ethernet/sfc/efx_channels.c:828 efx_set_xdp_channels+0x124/0x260 [sfc]
>  [...skip...]
>  Call Trace:
>   <TASK>
>   efx_set_channels+0x5c/0xc0 [sfc]
>   efx_probe_nic+0x9b/0x15a [sfc]
>   efx_probe_all+0x10/0x1a2 [sfc]
>   efx_pci_probe_main+0x12/0x156 [sfc]
>   efx_pci_probe_post_io+0x18/0x103 [sfc]
>   efx_pci_probe.cold+0x154/0x257 [sfc]
>   local_pci_probe+0x42/0x80
> 
> Fixes: 6215b608a8c4 ("sfc: last resort fallback for lack of xdp tx queues")
> Reported-by: Yanghang Liu <yanghliu@redhat.com>
> Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

Acked-by: Martin Habets <habetsm.xilinx@gmail.com>

> ---
>  drivers/net/ethernet/sfc/efx_channels.c       | 2 ++
>  drivers/net/ethernet/sfc/siena/efx_channels.c | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
> index fcea3ea809d7..41b33a75333c 100644
> --- a/drivers/net/ethernet/sfc/efx_channels.c
> +++ b/drivers/net/ethernet/sfc/efx_channels.c
> @@ -301,6 +301,7 @@ int efx_probe_interrupts(struct efx_nic *efx)
>  		efx->tx_channel_offset = 0;
>  		efx->n_xdp_channels = 0;
>  		efx->xdp_channel_offset = efx->n_channels;
> +		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
>  		rc = pci_enable_msi(efx->pci_dev);
>  		if (rc == 0) {
>  			efx_get_channel(efx, 0)->irq = efx->pci_dev->irq;
> @@ -322,6 +323,7 @@ int efx_probe_interrupts(struct efx_nic *efx)
>  		efx->tx_channel_offset = efx_separate_tx_channels ? 1 : 0;
>  		efx->n_xdp_channels = 0;
>  		efx->xdp_channel_offset = efx->n_channels;
> +		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
>  		efx->legacy_irq = efx->pci_dev->irq;
>  	}
>  
> diff --git a/drivers/net/ethernet/sfc/siena/efx_channels.c b/drivers/net/ethernet/sfc/siena/efx_channels.c
> index 06ed74994e36..1776f7f8a7a9 100644
> --- a/drivers/net/ethernet/sfc/siena/efx_channels.c
> +++ b/drivers/net/ethernet/sfc/siena/efx_channels.c
> @@ -302,6 +302,7 @@ int efx_siena_probe_interrupts(struct efx_nic *efx)
>  		efx->tx_channel_offset = 0;
>  		efx->n_xdp_channels = 0;
>  		efx->xdp_channel_offset = efx->n_channels;
> +		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
>  		rc = pci_enable_msi(efx->pci_dev);
>  		if (rc == 0) {
>  			efx_get_channel(efx, 0)->irq = efx->pci_dev->irq;
> @@ -323,6 +324,7 @@ int efx_siena_probe_interrupts(struct efx_nic *efx)
>  		efx->tx_channel_offset = efx_siena_separate_tx_channels ? 1 : 0;
>  		efx->n_xdp_channels = 0;
>  		efx->xdp_channel_offset = efx->n_channels;
> +		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
>  		efx->legacy_irq = efx->pci_dev->irq;
>  	}
>  
> -- 
> 2.40.1
patchwork-bot+netdevbpf@kernel.org June 15, 2023, 10:50 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Tue, 13 Jun 2023 15:38:54 +0200 you wrote:
> In systems without MSI-X capabilities, xdp_txq_queues_mode is calculated
> in efx_allocate_msix_channels, but when enabling MSI-X fails, it was not
> changed to a proper default value. This was leading to the driver
> thinking that it has dedicated XDP queues, when it didn't.
> 
> Fix it by setting xdp_txq_queues_mode to the correct value if the driver
> fallbacks to MSI or legacy IRQ mode. The correct value is
> EFX_XDP_TX_QUEUES_BORROWED because there are not XDP dedicated queues.
> 
> [...]

Here is the summary with links:
  - [net] sfc: fix XDP queues mode with legacy IRQ
    https://git.kernel.org/netdev/net/c/e84a1e1e683f

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
index fcea3ea809d7..41b33a75333c 100644
--- a/drivers/net/ethernet/sfc/efx_channels.c
+++ b/drivers/net/ethernet/sfc/efx_channels.c
@@ -301,6 +301,7 @@  int efx_probe_interrupts(struct efx_nic *efx)
 		efx->tx_channel_offset = 0;
 		efx->n_xdp_channels = 0;
 		efx->xdp_channel_offset = efx->n_channels;
+		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
 		rc = pci_enable_msi(efx->pci_dev);
 		if (rc == 0) {
 			efx_get_channel(efx, 0)->irq = efx->pci_dev->irq;
@@ -322,6 +323,7 @@  int efx_probe_interrupts(struct efx_nic *efx)
 		efx->tx_channel_offset = efx_separate_tx_channels ? 1 : 0;
 		efx->n_xdp_channels = 0;
 		efx->xdp_channel_offset = efx->n_channels;
+		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
 		efx->legacy_irq = efx->pci_dev->irq;
 	}
 
diff --git a/drivers/net/ethernet/sfc/siena/efx_channels.c b/drivers/net/ethernet/sfc/siena/efx_channels.c
index 06ed74994e36..1776f7f8a7a9 100644
--- a/drivers/net/ethernet/sfc/siena/efx_channels.c
+++ b/drivers/net/ethernet/sfc/siena/efx_channels.c
@@ -302,6 +302,7 @@  int efx_siena_probe_interrupts(struct efx_nic *efx)
 		efx->tx_channel_offset = 0;
 		efx->n_xdp_channels = 0;
 		efx->xdp_channel_offset = efx->n_channels;
+		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
 		rc = pci_enable_msi(efx->pci_dev);
 		if (rc == 0) {
 			efx_get_channel(efx, 0)->irq = efx->pci_dev->irq;
@@ -323,6 +324,7 @@  int efx_siena_probe_interrupts(struct efx_nic *efx)
 		efx->tx_channel_offset = efx_siena_separate_tx_channels ? 1 : 0;
 		efx->n_xdp_channels = 0;
 		efx->xdp_channel_offset = efx->n_channels;
+		efx->xdp_txq_queues_mode = EFX_XDP_TX_QUEUES_BORROWED;
 		efx->legacy_irq = efx->pci_dev->irq;
 	}