diff mbox series

[net,v2] net/mlx5: Fix setting of irq->map.index for static IRQ case

Message ID 20230531084856.2091666-1-schnelle@linux.ibm.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net,v2] net/mlx5: Fix setting of irq->map.index for static IRQ case | 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 success CCed 10 of 10 maintainers
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, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Niklas Schnelle May 31, 2023, 8:48 a.m. UTC
When dynamic IRQ allocation is not supported all IRQs are allocated up
front in mlx5_irq_table_create() instead of dynamically as part of
mlx5_irq_alloc(). In the latter dynamic case irq->map.index is set
via the mapping returned by pci_msix_alloc_irq_at(). In the static case
and prior to commit 1da438c0ae02 ("net/mlx5: Fix indexing of mlx5_irq")
irq->map.index was set in mlx5_irq_alloc() twice once initially to 0 and
then to the requested index before storing in the xarray. After this
commit it is only set to 0 which breaks all other IRQ mappings.

Fix this by setting irq->map.index to the requested index together with
irq->map.virq and improve the related comment to make it clearer which
cases it deals with.

Tested-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Eli Cohen <elic@nvidia.com>
Fixes: 1da438c0ae02 ("net/mlx5: Fix indexing of mlx5_irq")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
v1 -> v2:
- Added R-bs/Acks
- Fixed typos in commit message

 drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Cédric Le Goater May 31, 2023, 9:38 a.m. UTC | #1
On 5/31/23 10:48, Niklas Schnelle wrote:
> When dynamic IRQ allocation is not supported all IRQs are allocated up
> front in mlx5_irq_table_create() instead of dynamically as part of
> mlx5_irq_alloc(). In the latter dynamic case irq->map.index is set
> via the mapping returned by pci_msix_alloc_irq_at(). In the static case
> and prior to commit 1da438c0ae02 ("net/mlx5: Fix indexing of mlx5_irq")
> irq->map.index was set in mlx5_irq_alloc() twice once initially to 0 and
> then to the requested index before storing in the xarray. After this
> commit it is only set to 0 which breaks all other IRQ mappings.
> 
> Fix this by setting irq->map.index to the requested index together with
> irq->map.virq and improve the related comment to make it clearer which
> cases it deals with.
> 
> Tested-by: Mark Brown <broonie@kernel.org>
> Reviewed-by: Mark Brown <broonie@kernel.org>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> Reviewed-by: Eli Cohen <elic@nvidia.com>
> Fixes: 1da438c0ae02 ("net/mlx5: Fix indexing of mlx5_irq")
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>

I was seeing the issue on a zLPAR with a mlx5 VF device. The patch fixes it.

Tested-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.



> ---
> v1 -> v2:
> - Added R-bs/Acks
> - Fixed typos in commit message
> 
>   drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
> index db5687d9fec9..fd5b43e8f3bb 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
> @@ -232,12 +232,13 @@ struct mlx5_irq *mlx5_irq_alloc(struct mlx5_irq_pool *pool, int i,
>   	if (!irq)
>   		return ERR_PTR(-ENOMEM);
>   	if (!i || !pci_msix_can_alloc_dyn(dev->pdev)) {
> -		/* The vector at index 0 was already allocated.
> -		 * Just get the irq number. If dynamic irq is not supported
> -		 * vectors have also been allocated.
> +		/* The vector at index 0 is always statically allocated. If
> +		 * dynamic irq is not supported all vectors are statically
> +		 * allocated. In both cases just get the irq number and set
> +		 * the index.
>   		 */
>   		irq->map.virq = pci_irq_vector(dev->pdev, i);
> -		irq->map.index = 0;
> +		irq->map.index = i;
>   	} else {
>   		irq->map = pci_msix_alloc_irq_at(dev->pdev, MSI_ANY_INDEX, af_desc);
>   		if (!irq->map.virq) {
Saeed Mahameed May 31, 2023, 9:49 p.m. UTC | #2
On 31 May 11:38, Cédric Le Goater wrote:
>On 5/31/23 10:48, Niklas Schnelle wrote:
>>When dynamic IRQ allocation is not supported all IRQs are allocated up
>>front in mlx5_irq_table_create() instead of dynamically as part of
>>mlx5_irq_alloc(). In the latter dynamic case irq->map.index is set
>>via the mapping returned by pci_msix_alloc_irq_at(). In the static case
>>and prior to commit 1da438c0ae02 ("net/mlx5: Fix indexing of mlx5_irq")
>>irq->map.index was set in mlx5_irq_alloc() twice once initially to 0 and
>>then to the requested index before storing in the xarray. After this
>>commit it is only set to 0 which breaks all other IRQ mappings.
>>
>>Fix this by setting irq->map.index to the requested index together with
>>irq->map.virq and improve the related comment to make it clearer which
>>cases it deals with.
>>
>>Tested-by: Mark Brown <broonie@kernel.org>
>>Reviewed-by: Mark Brown <broonie@kernel.org>
>>Reviewed-by: Simon Horman <simon.horman@corigine.com>
>>Reviewed-by: Eli Cohen <elic@nvidia.com>
>>Fixes: 1da438c0ae02 ("net/mlx5: Fix indexing of mlx5_irq")
>>Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
>

Applied to net-mlx5. 

Thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
index db5687d9fec9..fd5b43e8f3bb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/pci_irq.c
@@ -232,12 +232,13 @@  struct mlx5_irq *mlx5_irq_alloc(struct mlx5_irq_pool *pool, int i,
 	if (!irq)
 		return ERR_PTR(-ENOMEM);
 	if (!i || !pci_msix_can_alloc_dyn(dev->pdev)) {
-		/* The vector at index 0 was already allocated.
-		 * Just get the irq number. If dynamic irq is not supported
-		 * vectors have also been allocated.
+		/* The vector at index 0 is always statically allocated. If
+		 * dynamic irq is not supported all vectors are statically
+		 * allocated. In both cases just get the irq number and set
+		 * the index.
 		 */
 		irq->map.virq = pci_irq_vector(dev->pdev, i);
-		irq->map.index = 0;
+		irq->map.index = i;
 	} else {
 		irq->map = pci_msix_alloc_irq_at(dev->pdev, MSI_ANY_INDEX, af_desc);
 		if (!irq->map.virq) {