IB/mlx5: Use PCI device for dma mappings
Subsystems (2)
PATCH 1/1 IB/mlx5: Use PCI device for dma mappings
From: Parav Pandit <[email protected]>
DMA operation of the IB device is done using ib_device->dma_device.
Instead of accessing parent of the IB device, use the PCI dma device which is setup to ib_device->dma_device during IB device registration.
---
Chagenlog:
v1:
* Use PCI device directly instead of ib_dma API
* Limited checkpatch to 80 symbols.
v0: https://lore.kernel.org/linux-rdma/[email protected]
--- drivers/infiniband/hw/mlx5/mr.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/infiniband/hw/mlx5/mr.c +11 -9
@@ -1081,7 +1081,7 @@ static void *mlx5_ib_create_xlt_wr(struct mlx5_ib_mr *mr, unsigned int flags) {struct mlx5_ib_dev *dev = mr->dev; -struct device *ddev = dev->ib_dev.dev.parent; +struct device *ddev = &dev->mdev->pdev->dev;dma_addr_t dma;void *xlt;
@@ -1118,7 +1118,7 @@ static void *mlx5_ib_create_xlt_wr(struct mlx5_ib_mr *mr,static void mlx5_ib_unmap_free_xlt (struct mlx5_ib_dev *dev,void *xlt,struct ib_sge *sg) { -struct device *ddev = dev->ib_dev.dev.parent; +struct device *ddev = &dev->mdev->pdev->dev;dma_unmap_single (ddev, sg->addr, sg->length,DMA_TO_DEVICE );mlx5_ib_free_xlt (xlt, sg->length);
@@ -1143,7 +1143,7 @@ int mlx5_ib_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages, int page_shift, int flags) {struct mlx5_ib_dev *dev = mr->dev; -struct device *ddev = dev->ib_dev.dev.parent; +struct device *ddev = &dev->mdev->pdev->dev;void *xlt;struct mlx5_umr_wr wr;struct ib_sge sg;
@@ -1222,7 +1222,7 @@ int mlx5_ib_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,static int mlx5_ib_update_mr_pas (struct mlx5_ib_mr *mr,unsigned int flags) {struct mlx5_ib_dev *dev = mr->dev; -struct device *ddev = dev->ib_dev.dev.parent; +struct device *ddev = &dev->mdev->pdev->dev;struct ib_block_iter biter;struct mlx5_mtt *cur_mtt;struct mlx5_umr_wr wr;
@@ -1751,6 +1751,8 @@ mlx5_alloc_priv_descs(struct ib_device *device, int ndescs, int desc_size) { +struct mlx5_ib_dev *dev =to_mdev (device); +struct device *ddev = &dev->mdev->pdev->dev;int size = ndescs * desc_size;int add_size;int ret;
@@ -1763,9 +1765,8 @@ mlx5_alloc_priv_descs(struct ib_device *device, mr->descs =PTR_ALIGN (mr->descs_alloc,MLX5_UMR_ALIGN ); - mr->desc_map =dma_map_single (device->dev.parent, mr->descs, - size,DMA_TO_DEVICE ); -if (dma_mapping_error (device->dev.parent, mr->desc_map)) { + mr->desc_map =dma_map_single (ddev, mr->descs, size,DMA_TO_DEVICE ); +if (dma_mapping_error (ddev, mr->desc_map)) { ret = -ENOMEM ; goto err; }
@@ -1783,9 +1784,10 @@ mlx5_free_priv_descs(struct mlx5_ib_mr *mr)if (mr->descs) {struct ib_device *device = mr->ibmr.device;int size = mr->max_descs * mr->desc_size; +struct mlx5_ib_dev *dev =to_mdev (device); -dma_unmap_single (device->dev.parent, mr->desc_map, - size,DMA_TO_DEVICE ); +dma_unmap_single (&dev->mdev->pdev->dev, mr->desc_map, size, +DMA_TO_DEVICE );kfree (mr->descs_alloc); mr->descs =NULL ; }
--
2.28.0
Quoted 15 lines · Leon Romanovsky
From: Parav Pandit <[email protected]>
DMA operation of the IB device is done using
ib_device->dma_device.Instead of accessing parent of the IB device, use the PCI dma device which is setup to
ib_device->dma_deviceduring IB device registration.Signed-off-by Parav Pandit <[email protected]>Signed-off-by Leon Romanovsky <[email protected]>---
Chagenlog:
v1:
* Use PCI device directly instead ofib_dmaAPI
* Limited checkpatch to 80 symbols.
v0: https://lore.kernel.org/linux-rdma/[email protected]
Quoted 3 lines
--- drivers/infiniband/hw/mlx5/mr.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
Applied to for-next, thanks
Jason