PCI DMA compat cleanups
Subsystems (10)
Start removing a few almost unused bits of the PCI DMA compat wrappers.
PATCH 1/3 PCI: remove DMA unmap wrappers
Only some of these were still used by the cxgb4 driver, and that despite the fact that the driver otherwise uses the generic DMA API.
--- drivers/infiniband/hw/cxgb4/qp.c | 10 +++++----- drivers/infiniband/hw/cxgb4/t4.h | 2 +- include/linux/pci-dma.h | 12 ------------ include/linux/pci.h | 1 - 4 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 include/linux/pci-dma.h
drivers/infiniband/hw/cxgb4/qp.c +5 -5
@@ -99,7 +99,7 @@ static void dealloc_oc_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)static void dealloc_host_sq (struct c4iw_rdev *rdev,struct t4_sq *sq) {dma_free_coherent (&(rdev->lldi.pdev->dev), sq->memsize, sq->queue, -pci_unmap_addr (sq, mapping)); +dma_unmap_addr (sq, mapping)); }static void dealloc_sq (struct c4iw_rdev *rdev,struct t4_sq *sq)
@@ -132,7 +132,7 @@ static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)if (!sq->queue)return -ENOMEM ; sq->phys_addr =virt_to_phys (sq->queue); -pci_unmap_addr_set (sq, mapping, sq->dma_addr); +dma_unmap_addr_set (sq, mapping, sq->dma_addr);return 0 ; }
@@ -2521,7 +2521,7 @@ static void free_srq_queue(struct c4iw_srq *srq, struct c4iw_dev_ucontext *uctx,dma_free_coherent (&rdev->lldi.pdev->dev, wq->memsize, wq->queue, -pci_unmap_addr (wq, mapping)); +dma_unmap_addr (wq, mapping));c4iw_rqtpool_free (rdev, wq->rqt_hwaddr, wq->rqt_size);kfree (wq->sw_rq);c4iw_put_qpid (rdev, wq->qid, uctx);
@@ -2570,7 +2570,7 @@ static int alloc_srq_queue(struct c4iw_srq *srq, struct c4iw_dev_ucontext *uctx, goto err_free_rqtpool;memset (wq->queue,0 , wq->memsize); -pci_unmap_addr_set (wq, mapping, wq->dma_addr); +dma_unmap_addr_set (wq, mapping, wq->dma_addr); wq->bar2_va = c4iw_bar2_addrs(rdev, wq->qid, T4_BAR2_QTYPE_EGRESS, &wq->bar2_qid,
@@ -2649,7 +2649,7 @@ static int alloc_srq_queue(struct c4iw_srq *srq, struct c4iw_dev_ucontext *uctx, err_free_queue:dma_free_coherent (&rdev->lldi.pdev->dev, wq->memsize, wq->queue, -pci_unmap_addr (wq, mapping)); +dma_unmap_addr (wq, mapping)); err_free_rqtpool:c4iw_rqtpool_free (rdev, wq->rqt_hwaddr, wq->rqt_size); err_free_pending_wrs:
drivers/infiniband/hw/cxgb4/t4.h +1 -1
@@ -397,7 +397,7 @@ struct t4_srq_pending_wr {struct t4_srq {union t4_recv_wr *queue;dma_addr_t dma_addr; -DECLARE_PCI_UNMAP_ADDR (mapping); +DEFINE_DMA_UNMAP_ADDR (mapping);struct t4_swrqe *sw_rq;void __iomem *bar2_va;u64 bar2_pa;
include/linux/pci-dma.h deleted +0 -12
@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_PCI_DMA_H -#define _LINUX_PCI_DMA_H - -#define DECLARE_PCI_UNMAP_ADDR (ADDR_NAME ) DEFINE_DMA_UNMAP_ADDR(ADDR_NAME); -#define DECLARE_PCI_UNMAP_LEN (LEN_NAME ) DEFINE_DMA_UNMAP_LEN(LEN_NAME); -#define pci_unmap_addr dma_unmap_addr -#define pci_unmap_addr_set dma_unmap_addr_set -#define pci_unmap_len dma_unmap_len -#define pci_unmap_len_set dma_unmap_len_set - -#endif
include/linux/pci.h +0 -1
@@ -1342,7 +1342,6 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode,/* kmem_cache style wrapper around pci_alloc_consistent() */ -#include <linux/pci-dma.h> #include <linux/dmapool.h> #define pci_pool dma_pool
Signature · 1 line
2.19.0
PATCH 2/3 PCI: remove pci_set_dma_seg_boundary
In reply to Christoph HellwigThe two callers can just use dma_set_seg_boundary directly.
--- drivers/pci/probe.c | 2 +- drivers/s390/net/ism_drv.c | 2 +- include/linux/pci-dma-compat.h | 9 --------- 3 files changed, 2 insertions(+), 11 deletions(-)
drivers/pci/probe.c +1 -1
@@ -2398,7 +2398,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.coherent_dma_mask =0xffffffffull ;pci_set_dma_max_seg_size (dev,65536 ); -pci_set_dma_seg_boundary (dev,0xffffffff ); +dma_set_seg_boundary (&dev->dev,0xffffffff );/* Fix up broken headers */ pci_fixup_device (pci_fixup_header, dev);
drivers/s390/net/ism_drv.c +1 -1
@@ -515,7 +515,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (ret) goto err_unmap; -pci_set_dma_seg_boundary (pdev,SZ_1M -1 ); +dma_set_seg_boundary (&pdev->dev,SZ_1M -1 );pci_set_dma_max_seg_size (pdev,SZ_1M );pci_set_master (pdev);
include/linux/pci-dma-compat.h +0 -9
@@ -125,12 +125,6 @@ static inline int pci_set_dma_max_seg_size(struct pci_dev *dev, {return dma_set_max_seg_size (&dev->dev, size); } - -static inline int pci_set_dma_seg_boundary (struct pci_dev *dev, -unsigned long mask) -{ -return dma_set_seg_boundary (&dev->dev, mask); -}#else static inline int pci_set_dma_mask (struct pci_dev *dev,u64 mask) {return -EIO ; }
@@ -139,9 +133,6 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)static inline int pci_set_dma_max_seg_size (struct pci_dev *dev,unsigned int size) {return -EIO ; } -static inline int pci_set_dma_seg_boundary (struct pci_dev *dev, -unsigned long mask) -{return -EIO ; }#endif #endif
Signature · 1 line
2.19.0
PATCH 3/3 PCI: remove pci_set_dma_max_seg_size
In reply to Christoph HellwigThe few callers can just use dma_set_max_seg_size directly.
--- drivers/ata/sata_inic162x.c | 2 +- drivers/block/rsxx/core.c | 2 +- drivers/pci/probe.c | 2 +- drivers/s390/net/ism_drv.c | 2 +- drivers/scsi/aacraid/linit.c | 2 +- include/linux/pci-dma-compat.h | 9 --------- 6 files changed, 5 insertions(+), 14 deletions(-)
drivers/ata/sata_inic162x.c +1 -1
@@ -873,7 +873,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)* like others but it will lock up the whole machine HARD if * 65536 byte PRD entry is fed. Reduce maximum segment size. */ - rc =pci_set_dma_max_seg_size (pdev,65536 -512 ); + rc =dma_set_max_seg_size (&pdev->dev,65536 -512 );if (rc) {dev_err (&pdev->dev,"failed to set the maximum segment size\n" );return rc;
drivers/block/rsxx/core.c +1 -1
@@ -780,7 +780,7 @@ static int rsxx_pci_probe(struct pci_dev *dev, goto failed_enable;pci_set_master (dev); -pci_set_dma_max_seg_size (dev,RSXX_HW_BLK_SIZE ); +dma_set_max_seg_size (&dev->dev,RSXX_HW_BLK_SIZE ); st =pci_set_dma_mask (dev,DMA_BIT_MASK (64 ));if (st) {
drivers/pci/probe.c +1 -1
@@ -2397,7 +2397,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.dma_parms = &dev->dma_parms; dev->dev.coherent_dma_mask =0xffffffffull ; -pci_set_dma_max_seg_size (dev,65536 ); +dma_set_max_seg_size (&dev->dev,65536 );dma_set_seg_boundary (&dev->dev,0xffffffff );/* Fix up broken headers */
drivers/s390/net/ism_drv.c +1 -1
@@ -516,7 +516,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_unmap;dma_set_seg_boundary (&pdev->dev,SZ_1M -1 ); -pci_set_dma_max_seg_size (pdev,SZ_1M ); +dma_set_max_seg_size (&pdev->dev,SZ_1M );pci_set_master (pdev); ism->smcd = smcd_alloc_dev(&pdev->dev, dev_name(&pdev->dev), &ism_ops,
drivers/scsi/aacraid/linit.c +1 -1
@@ -1747,7 +1747,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_sectors = (shost->sg_tablesize *8 ) +112 ; } - error =pci_set_dma_max_seg_size (pdev, + error =dma_set_max_seg_size (&pdev->dev, (aac->adapter_info.options &AAC_OPT_NEW_COMM ) ? (shost->max_sectors <<9 ) :65536 );if (error)
include/linux/pci-dma-compat.h +0 -9
@@ -119,20 +119,11 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) {return dma_set_coherent_mask (&dev->dev, mask); } - -static inline int pci_set_dma_max_seg_size (struct pci_dev *dev, -unsigned int size) -{ -return dma_set_max_seg_size (&dev->dev, size); -}#else static inline int pci_set_dma_mask (struct pci_dev *dev,u64 mask) {return -EIO ; }static inline int pci_set_consistent_dma_mask (struct pci_dev *dev,u64 mask) {return -EIO ; } -static inline int pci_set_dma_max_seg_size (struct pci_dev *dev, -unsigned int size) -{return -EIO ; }#endif #endif
Signature · 1 line
2.19.0
Re: [PATCH 1/3] PCI: remove DMA unmap wrappers
In reply to Christoph Hellwig[+cc folks from MAINTAINERS]
Quoted 2 lines · Christoph Hellwig
Only some of these were still used by the cxgb4 driver, and that despite the fact that the driver otherwise uses the generic DMA API.
This is trivial and I intend to apply it, so just copying cxgb4 folks as FYI.
Quoted 104 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/infiniband/hw/cxgb4/qp.c | 10 +++++----- drivers/infiniband/hw/cxgb4/t4.h | 2 +- include/linux/pci-dma.h | 12 ------------ include/linux/pci.h | 1 - 4 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 include/linux/pci-dma.hdrivers/infiniband/hw/cxgb4/qp.c +5
-5@@ -99,7 +99,7 @@ static void dealloc_oc_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)static void dealloc_host_sq (struct c4iw_rdev *rdev,struct t4_sq *sq) {dma_free_coherent (&(rdev->lldi.pdev->dev), sq->memsize, sq->queue, -pci_unmap_addr (sq, mapping)); +dma_unmap_addr (sq, mapping)); }static void dealloc_sq (struct c4iw_rdev *rdev,struct t4_sq *sq)@@ -132,7 +132,7 @@ static int alloc_host_sq(struct c4iw_rdev *rdev, struct t4_sq *sq)if (!sq->queue)return -ENOMEM ; sq->phys_addr =virt_to_phys (sq->queue); -pci_unmap_addr_set (sq, mapping, sq->dma_addr); +dma_unmap_addr_set (sq, mapping, sq->dma_addr);return 0 ; }@@ -2521,7 +2521,7 @@ static void free_srq_queue(struct c4iw_srq *srq, struct c4iw_dev_ucontext *uctx,dma_free_coherent (&rdev->lldi.pdev->dev, wq->memsize, wq->queue, -pci_unmap_addr (wq, mapping)); +dma_unmap_addr (wq, mapping));c4iw_rqtpool_free (rdev, wq->rqt_hwaddr, wq->rqt_size);kfree (wq->sw_rq);c4iw_put_qpid (rdev, wq->qid, uctx);@@ -2570,7 +2570,7 @@ static int alloc_srq_queue(struct c4iw_srq *srq, struct c4iw_dev_ucontext *uctx, goto err_free_rqtpool;memset (wq->queue,0 , wq->memsize); -pci_unmap_addr_set (wq, mapping, wq->dma_addr); +dma_unmap_addr_set (wq, mapping, wq->dma_addr); wq->bar2_va = c4iw_bar2_addrs(rdev, wq->qid, T4_BAR2_QTYPE_EGRESS, &wq->bar2_qid,@@ -2649,7 +2649,7 @@ static int alloc_srq_queue(struct c4iw_srq *srq, struct c4iw_dev_ucontext *uctx, err_free_queue:dma_free_coherent (&rdev->lldi.pdev->dev, wq->memsize, wq->queue, -pci_unmap_addr (wq, mapping)); +dma_unmap_addr (wq, mapping)); err_free_rqtpool:c4iw_rqtpool_free (rdev, wq->rqt_hwaddr, wq->rqt_size); err_free_pending_wrs:drivers/infiniband/hw/cxgb4/t4.h +1
-1@@ -397,7 +397,7 @@ struct t4_srq_pending_wr {struct t4_srq {union t4_recv_wr *queue;dma_addr_t dma_addr; -DECLARE_PCI_UNMAP_ADDR (mapping); +DEFINE_DMA_UNMAP_ADDR (mapping);struct t4_swrqe *sw_rq;void __iomem *bar2_va;u64 bar2_pa;include/linux/pci-dma.h deleted +0
-12@@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _LINUX_PCI_DMA_H -#define _LINUX_PCI_DMA_H - -#define DECLARE_PCI_UNMAP_ADDR (ADDR_NAME ) DEFINE_DMA_UNMAP_ADDR(ADDR_NAME); -#define DECLARE_PCI_UNMAP_LEN (LEN_NAME ) DEFINE_DMA_UNMAP_LEN(LEN_NAME); -#define pci_unmap_addr dma_unmap_addr -#define pci_unmap_addr_set dma_unmap_addr_set -#define pci_unmap_len dma_unmap_len -#define pci_unmap_len_set dma_unmap_len_set - -#endif include/linux/pci.h +0
-1@@ -1342,7 +1342,6 @@ int pci_set_vga_state(struct pci_dev *pdev, bool decode,/* kmem_cache style wrapper around pci_alloc_consistent() */ -#include <linux/pci-dma.h> #include <linux/dmapool.h> #define pci_pool dma_poolSignature · 1 line
2.19.0
Re: [PATCH 2/3] PCI: remove pci_set_dma_seg_boundary
In reply to Christoph Hellwig[+cc s390 network maintainers]
Quoted 1 line · Christoph Hellwig
The two callers can just use
dma_set_seg_boundarydirectly.
I intend to apply this trivial patch, so just FYI.
Quoted 63 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/pci/probe.c | 2 +- drivers/s390/net/ism_drv.c | 2 +- include/linux/pci-dma-compat.h | 9 --------- 3 files changed, 2 insertions(+), 11 deletions(-)drivers/pci/probe.c +1
-1@@ -2398,7 +2398,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.coherent_dma_mask =0xffffffffull ;pci_set_dma_max_seg_size (dev,65536 ); -pci_set_dma_seg_boundary (dev,0xffffffff ); +dma_set_seg_boundary (&dev->dev,0xffffffff );/* Fix up broken headers */ pci_fixup_device (pci_fixup_header, dev);drivers/s390/net/ism_drv.c +1
-1@@ -515,7 +515,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (ret) goto err_unmap; -pci_set_dma_seg_boundary (pdev,SZ_1M -1 ); +dma_set_seg_boundary (&pdev->dev,SZ_1M -1 );pci_set_dma_max_seg_size (pdev,SZ_1M );pci_set_master (pdev);include/linux/pci-dma-compat.h +0
-9@@ -125,12 +125,6 @@ static inline int pci_set_dma_max_seg_size(struct pci_dev *dev, {return dma_set_max_seg_size (&dev->dev, size); } - -static inline int pci_set_dma_seg_boundary (struct pci_dev *dev, -unsigned long mask) -{ -return dma_set_seg_boundary (&dev->dev, mask); -}#else static inline int pci_set_dma_mask (struct pci_dev *dev,u64 mask) {return -EIO ; }@@ -139,9 +133,6 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask)static inline int pci_set_dma_max_seg_size (struct pci_dev *dev,unsigned int size) {return -EIO ; } -static inline int pci_set_dma_seg_boundary (struct pci_dev *dev, -unsigned long mask) -{return -EIO ; }#endif #endif Signature · 1 line
2.19.0
Re: [PATCH 3/3] PCI: remove pci_set_dma_max_seg_size
In reply to Christoph Hellwig[+cc maintainers]
Quoted 1 line · Christoph Hellwig
The few callers can just use
dma_set_max_seg_sizedirectly.
I intend to apply this, just FYI about these trivial changes to your drivers.
Quoted 103 lines
Signed-off-by Christoph Hellwig <[email protected]>--- drivers/ata/sata_inic162x.c | 2 +- drivers/block/rsxx/core.c | 2 +- drivers/pci/probe.c | 2 +- drivers/s390/net/ism_drv.c | 2 +- drivers/scsi/aacraid/linit.c | 2 +- include/linux/pci-dma-compat.h | 9 --------- 6 files changed, 5 insertions(+), 14 deletions(-)drivers/ata/sata_inic162x.c +1
-1@@ -873,7 +873,7 @@ static int inic_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)* like others but it will lock up the whole machine HARD if * 65536 byte PRD entry is fed. Reduce maximum segment size. */ - rc =pci_set_dma_max_seg_size (pdev,65536 -512 ); + rc =dma_set_max_seg_size (&pdev->dev,65536 -512 );if (rc) {dev_err (&pdev->dev,"failed to set the maximum segment size\n" );return rc;drivers/block/rsxx/core.c +1
-1@@ -780,7 +780,7 @@ static int rsxx_pci_probe(struct pci_dev *dev, goto failed_enable;pci_set_master (dev); -pci_set_dma_max_seg_size (dev,RSXX_HW_BLK_SIZE ); +dma_set_max_seg_size (&dev->dev,RSXX_HW_BLK_SIZE ); st =pci_set_dma_mask (dev,DMA_BIT_MASK (64 ));if (st) {drivers/pci/probe.c +1
-1@@ -2397,7 +2397,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) dev->dev.dma_parms = &dev->dma_parms; dev->dev.coherent_dma_mask =0xffffffffull ; -pci_set_dma_max_seg_size (dev,65536 ); +dma_set_max_seg_size (&dev->dev,65536 );dma_set_seg_boundary (&dev->dev,0xffffffff );/* Fix up broken headers */ drivers/s390/net/ism_drv.c +1
-1@@ -516,7 +516,7 @@ static int ism_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_unmap;dma_set_seg_boundary (&pdev->dev,SZ_1M -1 ); -pci_set_dma_max_seg_size (pdev,SZ_1M ); +dma_set_max_seg_size (&pdev->dev,SZ_1M );pci_set_master (pdev); ism->smcd = smcd_alloc_dev(&pdev->dev, dev_name(&pdev->dev), &ism_ops,drivers/scsi/aacraid/linit.c +1
-1@@ -1747,7 +1747,7 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) shost->max_sectors = (shost->sg_tablesize *8 ) +112 ; } - error =pci_set_dma_max_seg_size (pdev, + error =dma_set_max_seg_size (&pdev->dev, (aac->adapter_info.options &AAC_OPT_NEW_COMM ) ? (shost->max_sectors <<9 ) :65536 );if (error)include/linux/pci-dma-compat.h +0
-9@@ -119,20 +119,11 @@ static inline int pci_set_consistent_dma_mask(struct pci_dev *dev, u64 mask) {return dma_set_coherent_mask (&dev->dev, mask); } - -static inline int pci_set_dma_max_seg_size (struct pci_dev *dev, -unsigned int size) -{ -return dma_set_max_seg_size (&dev->dev, size); -}#else static inline int pci_set_dma_mask (struct pci_dev *dev,u64 mask) {return -EIO ; }static inline int pci_set_consistent_dma_mask (struct pci_dev *dev,u64 mask) {return -EIO ; } -static inline int pci_set_dma_max_seg_size (struct pci_dev *dev, -unsigned int size) -{return -EIO ; }#endif #endif Signature · 1 line
2.19.0
Bjorn Helgaas
AppliedQuoted 1 line · Christoph Hellwig
Start removing a few almost unused bits of the PCI DMA compat wrappers.
Applied to pci/misc for v4.20, thanks!