aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Schnelle <schnelle@linux.ibm.com>2023-09-29 13:17:30 +0200
committerNiklas Schnelle <schnelle@linux.ibm.com>2023-09-29 13:48:56 +0200
commit5c8884ca8aea3fbd22cfd44435311fd907733440 (patch)
treeed0d7dc34ef287f520276faec9c815c9e927468c
parent3b45ec92a4b2b729b408cf46c3466172a4d8285e (diff)
downloadlinux-b4/mlx5_init_fix.tar.gz
net/mlx5: fix calling mlx5_cmd_init() before DMA mask is setb4/mlx5_init_fix
Since commit 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and reload routines") mlx5_cmd_init() is called in mlx5_mdev_init() which is called in probe_one() before mlx5_pci_init(). This is a problem because mlx5_pci_init() is where the DMA and coherent mask is set but mlx5_cmd_init() already does a dma_alloc_coherent(). Thus a DMA allocation is done during probe before the correct mask is set. This causes probe to fail initialization of the cmdif SW structs on s390x after that is converted to the common dma-iommu code. This is because on s390x DMA addresses below 4 GiB are reserved on current machines and unlike the old s390x specific DMA API implementation common code enforces DMA masks. Fix this by moving set_dma_caps() out of mlx5_pci_init() and into probe_one() before mlx5_mdev_init(). To match the overall naming scheme rename it to mlx5_dma_init(). Link: https://lore.kernel.org/linux-iommu/cfc9e9128ed5571d2e36421e347301057662a09e.camel@linux.ibm.com/ Fixes: 06cd555f73ca ("net/mlx5: split mlx5_cmd_init() to probe and reload routines") Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/main.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 15561965d2afa..f251d233a16cb 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -250,7 +250,7 @@ static void mlx5_set_driver_version(struct mlx5_core_dev *dev)
mlx5_cmd_exec_in(dev, set_driver_version, in);
}
-static int set_dma_caps(struct pci_dev *pdev)
+static int mlx5_dma_init(struct pci_dev *pdev)
{
int err;
@@ -905,12 +905,6 @@ static int mlx5_pci_init(struct mlx5_core_dev *dev, struct pci_dev *pdev,
pci_set_master(pdev);
- err = set_dma_caps(pdev);
- if (err) {
- mlx5_core_err(dev, "Failed setting DMA capabilities mask, aborting\n");
- goto err_clr_master;
- }
-
if (pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP32) &&
pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP64) &&
pci_enable_atomic_ops_to_root(pdev, PCI_EXP_DEVCAP2_ATOMIC_COMP128))
@@ -1908,9 +1902,15 @@ static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
goto adev_init_err;
}
+ err = mlx5_dma_init(pdev);
+ if (err) {
+ mlx5_core_err(dev, "Failed setting DMA capabilities mask, aborting\n");
+ goto dma_init_err;
+ }
+
err = mlx5_mdev_init(dev, prof_sel);
if (err)
- goto mdev_init_err;
+ goto dma_init_err;
err = mlx5_pci_init(dev, pdev, id);
if (err) {
@@ -1942,7 +1942,7 @@ err_init_one:
mlx5_pci_close(dev);
pci_init_err:
mlx5_mdev_uninit(dev);
-mdev_init_err:
+dma_init_err:
mlx5_adev_idx_free(dev->priv.adev_idx);
adev_init_err:
mlx5_devlink_free(devlink);