remove dma_virt_ops v2
Subsystems (11)
Christoph Hellwig
maintainerHi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify the INFINIBAND_VIRT_DMA dependencies
- add a ib_uses_virt_dma helper
- use ib_uses_virt_dma in nvmet-rdma to disable p2p for virt_dma devices
- use ib_dma_max_seg_size in umem
- stop using dmapool in rds
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logs
Christoph Hellwig
maintainerPATCH 1/10 RMDA/sw: don't allow drivers using dma_virt_ops on highmem configs
dma_virt_ops requires that all pages have a kernel virtual address. Introduce a INFINIBAND_VIRT_DMA Kconfig symbol that depends on !HIGHMEM and make all three driver depend on the new symbol.
Also remove the ARCH_DMA_ADDR_T_64BIT dependency, which has been obsolete since commit 4965a68780c5 ("arch: define the ARCH_DMA_ADDR_T_64BIT config symbol in lib/Kconfig")
--- drivers/infiniband/Kconfig | 3 +++ drivers/infiniband/sw/rdmavt/Kconfig | 3 ++- drivers/infiniband/sw/rxe/Kconfig | 2 +- drivers/infiniband/sw/siw/Kconfig | 1 + 4 files changed, 7 insertions(+), 2 deletions(-)
drivers/infiniband/Kconfig +3 -0
@@ -73,6 +73,9 @@ config INFINIBAND_ADDR_TRANS_CONFIGFS This allows the user to config the default GID type that the CM uses for each device, when initiaing new connections. +config INFINIBAND_VIRT_DMA + def_bool !HIGHMEM + if INFINIBAND_USER_ACCESS || !INFINIBAND_USER_ACCESS source "drivers/infiniband/hw/mthca/Kconfig" source "drivers/infiniband/hw/qib/Kconfig"
drivers/infiniband/sw/rdmavt/Kconfig +2 -1
@@ -1,7 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only config INFINIBAND_RDMAVT tristate "RDMA verbs transport library" - depends on X86_64 && ARCH_DMA_ADDR_T_64BIT + depends on INFINIBAND_VIRT_DMA + depends on X86_64 depends on PCI select DMA_VIRT_OPS help
drivers/infiniband/sw/rxe/Kconfig +1 -1
@@ -2,7 +2,7 @@ config RDMA_RXE tristate "Software RDMA over Ethernet (RoCE) driver" depends on INET && PCI && INFINIBAND - depends on !64BIT || ARCH_DMA_ADDR_T_64BIT + depends on INFINIBAND_VIRT_DMA select NET_UDP_TUNNEL select CRYPTO_CRC32 select DMA_VIRT_OPS
drivers/infiniband/sw/siw/Kconfig +1 -0
@@ -1,6 +1,7 @@ config RDMA_SIW tristate "Software RDMA over TCP/IP (iWARP) driver" depends on INET && INFINIBAND && LIBCRC32C + depends on INFINIBAND_VIRT_DMA select DMA_VIRT_OPS help This driver implements the iWARP RDMA transport over
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 2/10 RDMA/umem: use ib_dma_max_seg_size instead of dma_get_max_seg_size
In reply to Christoph HellwigRDMA ULPs must not call DMA mapping APIs directly but instead use the ib_dma_* wrappers.
--- drivers/infiniband/core/umem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/core/umem.c +4 -4
@@ -220,10 +220,10 @@ struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, cur_base += ret *PAGE_SIZE ; npages -= ret; - sg =__sg_alloc_table_from_pages ( - &umem->sg_head, page_list, ret,0 , ret <<PAGE_SHIFT , -dma_get_max_seg_size (device->dma_device), sg, npages, -GFP_KERNEL ); + sg =__sg_alloc_table_from_pages (&umem->sg_head, page_list, ret, +0 , ret <<PAGE_SHIFT , +ib_dma_max_seg_size (device), sg, npages, +GFP_KERNEL ); umem->sg_nents = umem->sg_head.nents;if (IS_ERR (sg)) {unpin_user_pages_dirty_lock (page_list, ret,0 );
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 3/10 RDMA: lift ibdev_to_node from rds to common code
In reply to Christoph HellwigLift the ibdev_to_node from rds to common code and document it.
--- include/rdma/ib_verbs.h | 13 +++++++++++++ net/rds/ib.h | 7 ------- 2 files changed, 13 insertions(+), 7 deletions(-)
include/rdma/ib_verbs.h +13 -0
@@ -4615,6 +4615,19 @@ static inline struct ib_device *rdma_device_to_ibdev(struct device *device)return coredev->owner; } +/** +* ibdev_to_node - return the NUMA node for a given ib_device +* @dev: device to get the NUMA node for. +*/ +static inline int ibdev_to_node (struct ib_device *ibdev) +{ +struct device *parent = ibdev->dev.parent; + +if (!parent) +return NUMA_NO_NODE ; +return dev_to_node (parent); +} +/** * rdma_device_to_drv_device - Helper macro to reach back to driver's * ib_device holder structure from device pointer.
net/rds/ib.h +0 -7
@@ -264,13 +264,6 @@ struct rds_ib_device {int *vector_load; }; -static inline int ibdev_to_node (struct ib_device *ibdev) -{ -struct device *parent; - - parent = ibdev->dev.parent; -return parent ?dev_to_node (parent) :NUMA_NO_NODE ; -}#define rdsibdev_to_node (rdsibdev) ibdev_to_node(rdsibdev->dev)/* bits for i_ack_flags */
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 4/10 nvme-rdma: use ibdev_to_node instead of dereferencing ->dma_device
In reply to Christoph Hellwig->dma_device is a private implementation detail of the RDMA core. Use the ibdev_to_node helper to get the NUMA node for a ib_device instead of poking into ->dma_device.
--- drivers/nvme/host/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/rdma.c +1 -1
@@ -854,7 +854,7 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl,return error; ctrl->device = ctrl->queues[0 ].device; - ctrl->ctrl.numa_node =dev_to_node (ctrl->device->dev->dma_device); + ctrl->ctrl.numa_node =ibdev_to_node (ctrl->device->dev);/* T10-PI support */ if (ctrl->device->dev->attrs.device_cap_flags &
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 5/10 rds: stop using dmapool
In reply to Christoph HellwigRDMA ULPs should only perform DMA through the ib_dma_* API instead of using the hidden dma_device directly. In addition using the dma coherent API family that dmapool is a part of can be very ineffcient on plaforms that are not DMA coherent. Switch to use slab allocations and the ib_dma_* APIs instead.
--- net/rds/ib.c | 10 ---- net/rds/ib.h | 6 --- net/rds/ib_cm.c | 128 ++++++++++++++++++++++++++++------------------ net/rds/ib_recv.c | 18 +++++-- net/rds/ib_send.c | 8 +++ 5 files changed, 101 insertions(+), 69 deletions(-)
net/rds/ib.c +0 -10
@@ -30,7 +30,6 @@* SOFTWARE. * */ -#include <linux/dmapool.h> #include <linux/kernel.h> #include <linux/in.h> #include <linux/if.h>
@@ -108,7 +107,6 @@ static void rds_ib_dev_free(struct work_struct *work)rds_ib_destroy_mr_pool (rds_ibdev->mr_1m_pool);if (rds_ibdev->pd)ib_dealloc_pd (rds_ibdev->pd); -dma_pool_destroy (rds_ibdev->rid_hdrs_pool);list_for_each_entry_safe (i_ipaddr, i_next, &rds_ibdev->ipaddr_list, list) {list_del (&i_ipaddr->list);
@@ -191,14 +189,6 @@ static int rds_ib_add_one(struct ib_device *device) rds_ibdev->pd =NULL ; goto put_dev; } - rds_ibdev->rid_hdrs_pool =dma_pool_create (device->name, - device->dma_device, -sizeof (struct rds_header ), -L1_CACHE_BYTES ,0 ); -if (!rds_ibdev->rid_hdrs_pool) { - ret = -ENOMEM ; - goto put_dev; - } rds_ibdev->mr_1m_pool =rds_ib_create_mr_pool (rds_ibdev,RDS_IB_MR_1M_POOL );
net/rds/ib.h +0 -6
@@ -246,7 +246,6 @@ struct rds_ib_device {struct list_head conn_list;struct ib_device *dev;struct ib_pd *pd; -struct dma_pool *rid_hdrs_pool;/* RDS headers DMA pool */ u8 odp_capable:1;unsigned int max_mrs;
@@ -380,11 +379,6 @@ int rds_ib_cm_handle_connect(struct rdma_cm_id *cm_id,int rds_ib_cm_initiate_connect (struct rdma_cm_id *cm_id,bool isv6);void rds_ib_cm_connect_complete (struct rds_connection *conn,struct rdma_cm_event *event); -struct rds_header **rds_dma_hdrs_alloc (struct ib_device *ibdev, -struct dma_pool *pool, -dma_addr_t **dma_addrs,u32 num_hdrs); -void rds_dma_hdrs_free (struct dma_pool *pool,struct rds_header **hdrs, -dma_addr_t *dma_addrs,u32 num_hdrs); #define rds_ib_conn_error(conn, fmt...) \ __rds_ib_conn_error(conn, KERN_WARNING "RDS/IB: " fmt)
net/rds/ib_cm.c +78 -50
230 lines not on this page · raw message
net/rds/ib_recv.c +15 -3
@@ -662,10 +662,16 @@ static void rds_ib_send_ack(struct rds_ib_connection *ic, unsigned int adv_credi seq =rds_ib_get_ack (ic);rdsdebug ("send_ack: ic %p ack %llu\n" , ic, (unsigned long long ) seq); + +ib_dma_sync_single_for_cpu (ic->rds_ibdev->dev, ic->i_ack_dma, +sizeof (*hdr),DMA_TO_DEVICE );rds_message_populate_header (hdr,0 ,0 ,0 ); hdr->h_ack =cpu_to_be64 (seq); hdr->h_credit = adv_credits;rds_message_make_checksum (hdr); +ib_dma_sync_single_for_device (ic->rds_ibdev->dev, ic->i_ack_dma, +sizeof (*hdr),DMA_TO_DEVICE ); + ic->i_ack_queued = jiffies; ret =ib_post_send (ic->i_cm_id->qp, &ic->i_ack_wr,NULL );
@@ -845,6 +851,7 @@ static void rds_ib_process_recv(struct rds_connection *conn,struct rds_ib_connection *ic = conn->c_transport_data;struct rds_ib_incoming *ibinc = ic->i_ibinc;struct rds_header *ihdr, *hdr; +dma_addr_t dma_addr = ic->i_recv_hdrs_dma[recv - ic->i_recvs];/* XXX shut down the connection if port 0,0 are seen? */
@@ -863,6 +870,8 @@ static void rds_ib_process_recv(struct rds_connection *conn, ihdr = ic->i_recv_hdrs[recv - ic->i_recvs]; +ib_dma_sync_single_for_cpu (ic->rds_ibdev->dev, dma_addr, +sizeof (*ihdr),DMA_FROM_DEVICE );/* Validate the checksum. */ if (!rds_message_verify_checksum (ihdr)) { rds_ib_conn_error(conn, "incoming message "
@@ -870,7 +879,7 @@ static void rds_ib_process_recv(struct rds_connection *conn,"forcing a reconnect\n" , &conn->c_faddr);rds_stats_inc (s_recv_drop_bad_checksum); -return ; + goto done; }/* Process the ACK sequence which comes with every packet */
@@ -899,7 +908,7 @@ static void rds_ib_process_recv(struct rds_connection *conn,*/ rds_ib_frag_free (ic, recv->r_frag); recv->r_frag =NULL ; -return ; + goto done; }/*
@@ -933,7 +942,7 @@ static void rds_ib_process_recv(struct rds_connection *conn, hdr->h_dport != ihdr->h_dport) {rds_ib_conn_error (conn,"fragment header mismatch; forcing reconnect\n" ); -return ; + goto done; } }
@@ -965,6 +974,9 @@ static void rds_ib_process_recv(struct rds_connection *conn,rds_inc_put (&ibinc->ii_inc); } +done: +ib_dma_sync_single_for_device (ic->rds_ibdev->dev, dma_addr, +sizeof (*ihdr),DMA_FROM_DEVICE ); } void rds_ib_recv_cqe_handler(struct rds_ib_connection *ic,
net/rds/ib_send.c +8 -0
@@ -638,6 +638,10 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, send->s_sge[0 ].length =sizeof (struct rds_header ); send->s_sge[0 ].lkey = ic->i_pd->local_dma_lkey; +ib_dma_sync_single_for_cpu (ic->rds_ibdev->dev, + ic->i_send_hdrs_dma[pos], +sizeof (struct rds_header ), +DMA_TO_DEVICE );memcpy (ic->i_send_hdrs[pos], &rm->m_inc.i_hdr,sizeof (struct rds_header ));
@@ -688,6 +692,10 @@ int rds_ib_xmit(struct rds_connection *conn, struct rds_message *rm, adv_credits =0 ;rds_ib_stats_inc (s_ib_tx_credit_updates); } +ib_dma_sync_single_for_device (ic->rds_ibdev->dev, + ic->i_send_hdrs_dma[pos], +sizeof (struct rds_header ), +DMA_TO_DEVICE );if (prev) prev->s_wr.next = &send->s_wr;
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 6/10 RDMA/core: remove ib_dma_{alloc,free}_coherent
In reply to Christoph HellwigThese two functions are entirely unused.
--- include/rdma/ib_verbs.h | 29 ----------------------------- 1 file changed, 29 deletions(-)
include/rdma/ib_verbs.h +0 -29
@@ -4098,35 +4098,6 @@ static inline void ib_dma_sync_single_for_device(struct ib_device *dev,dma_sync_single_for_device (dev->dma_device, addr, size, dir); } -/** -* ib_dma_alloc_coherent - Allocate memory and map it for DMA -* @dev: The device for which the DMA address is requested -* @size: The size of the region to allocate in bytes -* @dma_handle: A pointer for returning the DMA address of the region -* @flag: memory allocator flags -*/ -static inline void *ib_dma_alloc_coherent (struct ib_device *dev, -size_t size, -dma_addr_t *dma_handle, -gfp_t flag) -{ -return dma_alloc_coherent (dev->dma_device, size, dma_handle, flag); -} - -/** -* ib_dma_free_coherent - Free memory allocated by ib_dma_alloc_coherent() -* @dev: The device for which the DMA addresses were allocated -* @size: The size of the region -* @cpu_addr: the address returned by ib_dma_alloc_coherent() -* @dma_handle: the DMA address returned by ib_dma_alloc_coherent() -*/ -static inline void ib_dma_free_coherent (struct ib_device *dev, -size_t size,void *cpu_addr, -dma_addr_t dma_handle) -{ -dma_free_coherent (dev->dma_device, size, cpu_addr, dma_handle); -} -/* ib_reg_user_mr - register a memory region for virtual addresses from kernel * space. This function should be called when 'current' is the owning MM. */
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 7/10 RDMA/core: remove use of dma_virt_ops
In reply to Christoph HellwigUse the ib_dma_* helpers to skip the DMA translation instead. This removes the last user if dma_virt_ops and keeps the weird layering violation inside the RDMA core instead of burderning the DMA mapping subsystems with it. This also means the software RDMA drivers now don't have to mess with DMA parameters that are not relevant to them at all, and that in the future we can use PCI P2P transfers even for software RDMA, as there is no first fake layer of DMA mapping that the P2P DMA support.
--- drivers/infiniband/core/device.c | 43 ++++++++-------- drivers/infiniband/core/rw.c | 5 +- drivers/infiniband/sw/rdmavt/Kconfig | 1 - drivers/infiniband/sw/rdmavt/mr.c | 6 +-- drivers/infiniband/sw/rdmavt/vt.c | 8 --- drivers/infiniband/sw/rxe/Kconfig | 1 - drivers/infiniband/sw/rxe/rxe_verbs.c | 7 --- drivers/infiniband/sw/rxe/rxe_verbs.h | 1 - drivers/infiniband/sw/siw/Kconfig | 1 - drivers/infiniband/sw/siw/siw.h | 1 - drivers/infiniband/sw/siw/siw_main.c | 7 --- drivers/nvme/target/rdma.c | 3 +- include/rdma/ib_verbs.h | 73 ++++++++++++++++++--------- 13 files changed, 81 insertions(+), 76 deletions(-)
drivers/infiniband/core/device.c +23 -20
@@ -1177,25 +1177,6 @@ static int assign_name(struct ib_device *device, const char *name)return ret; } -static void setup_dma_device (struct ib_device *device, -struct device *dma_device) -{ -/* -* If the caller does not provide a DMA capable device then the IB -* device will be used. In this case the caller should fully setup the -* ibdev for DMA. This usually means using dma_virt_ops. -*/ -#ifdef CONFIG_DMA_VIRT_OPS -if (!dma_device) { - device->dev.dma_ops = &dma_virt_ops; - dma_device = &device->dev; - } -#endif -WARN_ON (!dma_device); - device->dma_device = dma_device; -WARN_ON (!device->dma_device->dma_parms); -} -/* * setup_device() allocates memory and sets up data that requires calling the * device ops, this is the only reason these actions are not done during
@@ -1341,7 +1322,14 @@ int ib_register_device(struct ib_device *device, const char *name,if (ret)return ret; -setup_dma_device (device, dma_device); +/* +* If the caller does not provide a DMA capable device then the IB core +* will set up ib_sge and scatterlist structures that stash the kernel +* virtual address into the address field. +*/ +WARN_ON (dma_device && !dma_device->dma_parms); + device->dma_device = dma_device; + ret =setup_device (device);if (ret)return ret;
@@ -2675,6 +2663,21 @@ void ib_set_device_ops(struct ib_device *dev, const struct ib_device_ops *ops) }EXPORT_SYMBOL (ib_set_device_ops); +#ifdef CONFIG_INFINIBAND_VIRT_DMA +int ib_dma_virt_map_sg (struct ib_device *dev,struct scatterlist *sg,int nents) +{ +struct scatterlist *s; +int i; + +for_each_sg (sg, s, nents, i) { +sg_dma_address (s) = (uintptr_t )sg_virt (s); +sg_dma_len (s) = s->length; + } +return nents; +} +EXPORT_SYMBOL (ib_dma_virt_map_sg); +#endif /* CONFIG_INFINIBAND_VIRT_DMA */ +static const struct rdma_nl_cbs ibnl_ls_cb_table[RDMA_NL_LS_NUM_OPS ] = { [RDMA_NL_LS_OP_RESOLVE ] = { .doit = ib_nl_handle_resolve_resp,
drivers/infiniband/core/rw.c +4 -1
@@ -285,8 +285,11 @@ static void rdma_rw_unmap_sg(struct ib_device *dev, struct scatterlist *sg,static int rdma_rw_map_sg (struct ib_device *dev,struct scatterlist *sg,u32 sg_cnt,enum dma_data_direction dir) { -if (is_pci_p2pdma_page (sg_page (sg))) +if (is_pci_p2pdma_page (sg_page (sg))) { +if (WARN_ON_ONCE (ib_uses_virt_dma (dev))) +return 0 ;return pci_p2pdma_map_sg (dev->dma_device, sg, sg_cnt, dir); + }return ib_dma_map_sg (dev, sg, sg_cnt, dir); }
drivers/infiniband/sw/rdmavt/Kconfig +0 -1
@@ -4,6 +4,5 @@ config INFINIBAND_RDMAVT depends on INFINIBAND_VIRT_DMA depends on X86_64 depends on PCI - select DMA_VIRT_OPS help This is a common software verbs provider for RDMA networks.
drivers/infiniband/sw/rdmavt/mr.c +2 -4
@@ -324,8 +324,6 @@ static void __rvt_free_mr(struct rvt_mr *mr)* @acc: access flags * * Return: the memory region on success, otherwise returns an errno. -* Note that all DMA addresses should be created via the functions in -* struct dma_virt_ops. */ struct ib_mr *rvt_get_dma_mr (struct ib_pd *pd,int acc) {
@@ -766,7 +764,7 @@ int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd,/* * We use LKEY == zero for kernel virtual addresses -* (see rvt_get_dma_mr() and dma_virt_ops). +* (see rvt_get_dma_mr()). */ if (sge->lkey ==0 ) {struct rvt_dev_info *dev =ib_to_rvt (pd->ibpd.device);
@@ -877,7 +875,7 @@ int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge,/* * We use RKEY == zero for kernel virtual addresses -* (see rvt_get_dma_mr() and dma_virt_ops). +* (see rvt_get_dma_mr()). */ rcu_read_lock ();if (rkey ==0 ) {
drivers/infiniband/sw/rdmavt/vt.c +0 -8
@@ -524,7 +524,6 @@ static noinline int check_support(struct rvt_dev_info *rdi, int verb)int rvt_register_device (struct rvt_dev_info *rdi) {int ret =0 , i; -u64 dma_mask;if (!rdi)return -EINVAL ;
@@ -579,13 +578,6 @@ int rvt_register_device(struct rvt_dev_info *rdi)/* Completion queues */ spin_lock_init (&rdi->n_cqs_lock); -/* DMA Operations */ - rdi->ibdev.dev.dma_parms = rdi->ibdev.dev.parent->dma_parms; - dma_mask =IS_ENABLED (CONFIG_64BIT ) ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ); - ret =dma_coerce_mask_and_coherent (&rdi->ibdev.dev, dma_mask); -if (ret) - goto bail_wss; -/* Protection Domain */ spin_lock_init (&rdi->n_pds_lock); rdi->n_pds_allocated =0 ;
drivers/infiniband/sw/rxe/Kconfig +0 -1
@@ -5,7 +5,6 @@ config RDMA_RXE depends on INFINIBAND_VIRT_DMA select NET_UDP_TUNNEL select CRYPTO_CRC32 - select DMA_VIRT_OPS help This driver implements the InfiniBand RDMA transport over the Linux network stack. It enables a system with a
drivers/infiniband/sw/rxe/rxe_verbs.c +0 -7
@@ -1118,7 +1118,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name)int err;struct ib_device *dev = &rxe->ib_dev;struct crypto_shash *tfm; -u64 dma_mask;strlcpy (dev->node_desc,"rxe" ,sizeof (dev->node_desc));
@@ -1129,12 +1128,6 @@ int rxe_register_device(struct rxe_dev *rxe, const char *ibdev_name) dev->local_dma_lkey =0 ;addrconf_addr_eui48 ((unsigned char *)&dev->node_guid, rxe->ndev->dev_addr); - dev->dev.dma_parms = &rxe->dma_parms; -dma_set_max_seg_size (&dev->dev,UINT_MAX ); - dma_mask =IS_ENABLED (CONFIG_64BIT ) ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ); - err =dma_coerce_mask_and_coherent (&dev->dev, dma_mask); -if (err) -return err; dev->uverbs_cmd_mask =BIT_ULL (IB_USER_VERBS_CMD_GET_CONTEXT ) |BIT_ULL (IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL )
drivers/infiniband/sw/rxe/rxe_verbs.h +0 -1
@@ -352,7 +352,6 @@ struct rxe_port {struct rxe_dev {struct ib_device ib_dev;struct ib_device_attr attr; -struct device_dma_parameters dma_parms;int max_ucontext;int max_inline_data;struct mutex usdev_lock;
drivers/infiniband/sw/siw/Kconfig +0 -1
@@ -2,7 +2,6 @@ config RDMA_SIW tristate "Software RDMA over TCP/IP (iWARP) driver" depends on INET && INFINIBAND && LIBCRC32C depends on INFINIBAND_VIRT_DMA - select DMA_VIRT_OPS help This driver implements the iWARP RDMA transport over the Linux TCP/IP network stack. It enables a system with a
drivers/infiniband/sw/siw/siw.h +0 -1
@@ -69,7 +69,6 @@ struct siw_pd {struct siw_device {struct ib_device base_dev; -struct device_dma_parameters dma_parms;struct net_device *netdev;struct siw_dev_cap attrs;
drivers/infiniband/sw/siw/siw_main.c +0 -7
@@ -306,7 +306,6 @@ static struct siw_device *siw_device_create(struct net_device *netdev)struct siw_device *sdev =NULL ;struct ib_device *base_dev;struct device *parent = netdev->dev.parent; -u64 dma_mask;int rv;if (!parent) {
@@ -383,12 +382,6 @@ static struct siw_device *siw_device_create(struct net_device *netdev)*/ base_dev->phys_port_cnt =1 ; base_dev->dev.parent = parent; - base_dev->dev.dma_parms = &sdev->dma_parms; -dma_set_max_seg_size (&base_dev->dev,UINT_MAX ); - dma_mask =IS_ENABLED (CONFIG_64BIT ) ?DMA_BIT_MASK (64 ) :DMA_BIT_MASK (32 ); -if (dma_coerce_mask_and_coherent (&base_dev->dev, dma_mask)) - goto error; - base_dev->num_comp_vectors =num_possible_cpus ();xa_init_flags (&sdev->qp_xa,XA_FLAGS_ALLOC1 );
drivers/nvme/target/rdma.c +2 -1
@@ -414,7 +414,8 @@ static int nvmet_rdma_alloc_rsp(struct nvmet_rdma_device *ndev,if (ib_dma_mapping_error (ndev->device, r->send_sge.addr)) goto out_free_rsp; - r->req.p2p_client = &ndev->device->dev; +if (!ib_uses_virt_dma (ndev->device)) + r->req.p2p_client = &ndev->device->dev; r->send_sge.length =sizeof (*r->req.cqe); r->send_sge.lkey = ndev->pd->local_dma_lkey;
include/rdma/ib_verbs.h +50 -23
139 lines not on this page · raw message
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 8/10 PCI/P2PDMA: Remove the DMA_VIRT_OPS hacks
In reply to Christoph HellwigNow that all users of dma_virt_ops are gone we can remove the workaround for it in the PCI peer to peer code.
--- drivers/pci/p2pdma.c | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/pci/p2pdma.c +0 -20
@@ -556,15 +556,6 @@ int pci_p2pdma_distance_many(struct pci_dev *provider, struct device **clients,return -1 ;for (i =0 ; i < num_clients; i++) { -#ifdef CONFIG_DMA_VIRT_OPS -if (clients[i]->dma_ops == &dma_virt_ops) { -if (verbose) -dev_warn (clients[i], -"cannot be used for peer-to-peer DMA because the driver makes use of dma_virt_ops\n" ); -return -1 ; - } -#endif - pci_client =find_parent_pci_dev (clients[i]);if (!pci_client) {if (verbose)
@@ -837,17 +828,6 @@ static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap,phys_addr_t paddr;int i; -/* -* p2pdma mappings are not compatible with devices that use -* dma_virt_ops. If the upper layers do the right thing -* this should never happen because it will be prevented -* by the check in pci_p2pdma_distance_many() -*/ -#ifdef CONFIG_DMA_VIRT_OPS -if (WARN_ON_ONCE (dev->dma_ops == &dma_virt_ops)) -return 0 ; -#endif -for_each_sg (sg, s, nents, i) { paddr =sg_phys (s);
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 9/10 PCI/P2PDMA: Cleanup __pci_p2pdma_map_sg a bit
In reply to Christoph HellwigRemove the pointless paddr variable that was only used once.
--- drivers/pci/p2pdma.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/pci/p2pdma.c +1 -4
@@ -825,13 +825,10 @@ static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap, struct device *dev, struct scatterlist *sg, int nents) { struct scatterlist *s; -phys_addr_t paddr;int i;for_each_sg (sg, s, nents, i) { - paddr =sg_phys (s); - - s->dma_address = paddr - p2p_pgmap->bus_offset; + s->dma_address =sg_phys (s) - p2p_pgmap->bus_offset;sg_dma_len (s) = s->length; }
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerPATCH 10/10 dma-mapping: remove dma_virt_ops
In reply to Christoph HellwigNow that the RDMA core deals with devices that only do DMA mapping in lower layers properly, there is no user for dma_virt_ops and it can be removed.
--- include/linux/dma-mapping.h | 2 -- kernel/dma/Kconfig | 5 --- kernel/dma/Makefile | 1 - kernel/dma/virt.c | 61 ------------------------------------- 4 files changed, 69 deletions(-) delete mode 100644 kernel/dma/virt.c
include/linux/dma-mapping.h +0 -2
@@ -565,6 +565,4 @@ static inline int dma_mmap_wc(struct device *dev,int dma_direct_set_offset (struct device *dev,phys_addr_t cpu_start,dma_addr_t dma_start,u64 size); -extern const struct dma_map_ops dma_virt_ops; -#endif /* _LINUX_DMA_MAPPING_H */
kernel/dma/Kconfig +0 -5
@@ -75,11 +75,6 @@ config ARCH_HAS_DMA_PREP_COHERENT config ARCH_HAS_FORCE_DMA_UNENCRYPTED bool -config DMA_VIRT_OPS - bool - depends on HAS_DMA - select DMA_OPS - config SWIOTLB bool select NEED_DMA_MAP_STATE
kernel/dma/Makefile +0 -1
@@ -5,7 +5,6 @@ obj-$(CONFIG_DMA_OPS) += ops_helpers.o obj-$(CONFIG_DMA_OPS) += dummy.o obj-$(CONFIG_DMA_CMA) += contiguous.o obj-$(CONFIG_DMA_DECLARE_COHERENT) += coherent.o -obj-$(CONFIG_DMA_VIRT_OPS) += virt.o obj-$(CONFIG_DMA_API_DEBUG) += debug.o obj-$(CONFIG_SWIOTLB) += swiotlb.o obj-$(CONFIG_DMA_COHERENT_POOL) += pool.o
kernel/dma/virt.c deleted +0 -61
61 lines not on this page · raw message
Signature · 1 line
2.28.0
Christoph Hellwig
maintainerping?
Quoted 21 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rds
Quoted 3 lines
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logs
---end quoted text---
Quoted 27 lines · Christoph Hellwig
ping?
Quoted 24 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rdsChanges since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logs
Santosh can you please check the RDA parts??
Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
+ Ka-Cheong
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Christoph Hellwig
ping?
Quoted 21 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rds
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logsSantosh can you please check the RDA parts??
Hi Ka-Cheong,
Can you please check Christoph change [1] which clean-up dma-pool API to use ib_dma_* and slab allocator ? This was added as part of your "net/rds: Use DMA memory pool allocation for rds_header" commit.
Regards,
Santosh
[1] https://www.spinics.net/lists/linux-pci/msg101547.html
_______________________________________________
iommu mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Quoted 35 lines · On 11/13/20 1:36 AM, [email protected] wrote:
+ Ka-Cheong
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Christoph Hellwig
ping?
Quoted 21 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rdsQuoted 6 lines
Quoted 3 lines
Quoted 3 lines
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logsSantosh can you please check the RDA parts??
Quoted 6 lines
Hi Ka-Cheong,
Can you please check Christoph change [1] which clean-up dma-pool API to use ib_dma_* and slab allocator ? This was added as part of your "net/rds: Use DMA memory pool allocation for
rds_header" commit.
I applied the patch and ran some basic testing. And it seems to work fine.
Thanks.
Signature · 2 lines
K. Poon [email protected]
Quoted 38 lines · Ka-Cheong Poon
Quoted 37 lines · On 11/13/20 1:36 AM, [email protected] wrote:
+ Ka-Cheong
Quoted 25 lines · Jason Gunthorpe
Quoted 24 lines · Christoph Hellwig
ping?
Quoted 21 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rdsQuoted 6 lines
Quoted 3 lines
Quoted 3 lines
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logsSantosh can you please check the RDA parts??
Hi Ka-Cheong,
Quoted 9 lines
Quoted 4 lines
Can you please check Christoph change [1] which clean-up dma-pool API to use ib_dma_* and slab allocator ? This was added as part of your "net/rds: Use DMA memory pool allocation for
rds_header" commit.I applied the patch and ran some basic testing. And it seems to work fine.
Thanks Ka-Cheong.
Jason, Feel free to add ack for the RDS part.
Regards,
Santosh
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Jason Gunthorpe
maintainerQuoted 21 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rds
Quoted 3 lines
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logs
Lets give Santosh a little longer for RDS, I've grabbed the precursor parts to for-next for now:
nvme-rdma: Use ibdev_to_node instead of dereferencing ->dma_device
RDMA: Lift ibdev_to_node from rds to common code RDMA/core: Remove ib_dma_{alloc,free}_coherent RDMA/umem: Use ib_dma_max_seg_size instead of dma_get_max_seg_size RMDA/sw: Don't allow drivers using dma_virt_ops on highmem configs
Will get the rest next week regardless.
Thanks,
Jason
Christoph Hellwig
maintainerQuoted 1 line · Jason Gunthorpe
RMDA/sw: Don't allow drivers using
dma_virt_opson highmem configs
I think this one actually is something needed in 5.10 and -stable.
Quoted 4 lines · Christoph Hellwig
Quoted 1 line · Jason Gunthorpe
RMDA/sw: Don't allow drivers using
dma_virt_opson highmem configsI think this one actually is something needed in 5.10 and -stable.
Done, I added a
Jason
Christoph Hellwig
maintainerQuoted 9 lines · Jason Gunthorpe
Quoted 4 lines · Christoph Hellwig
Quoted 1 line · Jason Gunthorpe
RMDA/sw: Don't allow drivers using
dma_virt_opson highmem configsI think this one actually is something needed in 5.10 and -stable.
Done, I added a
Fixes 551199aca1c3 ("lib/dma-virt: Add dma_virt_ops")
Note that the drivers had open coded versions of this earlier. I think this goes back to the addition of the qib driver which is now gone or the addition of the hfi1 or rxe drivers for something that still matters.
Mike Marciniszyn
Tested-byQuoted 6 lines
Quoted 1 line
Fixes 551199aca1c3 ("lib/dma-virt: Add dma_virt_ops")Note that the drivers had open coded versions of this earlier. I think this goes back to the addition of the qib driver which is now gone or the addition of the hfi1 or rxe drivers for something that still matters
Christoph,Jason
I built a branch using the following recipe:
https://patchwork.kernel.org/project/linux-rdma/patch/:
[email protected]/ dma-mapping: remove dma_virt_ops [email protected]/ PCI/P2PDMA: Cleanup __pci_p2pdma_map_sg a bit
[email protected]/ PCI/P2PDMA: Remove the DMA_VIRT_OPS hacks [email protected]/ RDMA/core: remove use of dma_virt_ops [email protected]/ RDMA/core: remove ib_dma_{alloc,free}_coherent [email protected]/ rds: stop using dmapool [email protected]/ nvme-rdma: use ibdev_to_node instead of dereferencing ->dma_device [email protected]/ RDMA: lift ibdev_to_node from rds to common code [email protected]/ RDMA/umem: use ib_dma_max_seg_size instead of dma_get_max_seg_size
rdma/for-rc dabbd6abcdbe which has RMDA/sw: don't allow drivers using dma_virt_ops on highmem configs
All of our rdmavt/hfi1 tests passed.
So I can at least vouch for "RDMA/core: remove use of dma_virt_ops"
Mike
Jason Gunthorpe
maintainerQuoted 21 lines · Christoph Hellwig
Hi Jason,
this series switches the RDMA core to opencode the special case of devices bypassing the DMA mapping in the RDMA ULPs. The virt ops have caused a bit of trouble due to the P2P code node working with them due to the fact that we'd do two dma mapping iterations for a single I/O, but also are a bit of layering violation and lead to more code than necessary.
Tested with nvme-rdma over rxe.
Note that the rds changes are untested, as I could not find any simple rds test setup.
Changes since v2:
- simplify theINFINIBAND_VIRT_DMAdependencies
- add aib_uses_virt_dmahelper
- useib_uses_virt_dmain nvmet-rdma to disable p2p forvirt_dmadevices
- useib_dma_max_seg_sizein umem
- stop using dmapool in rds
Quoted 3 lines
Changes since v1:
- disable software RDMA drivers for highmem configs
- update the PCI commit logs
All applied to for-next, thanks everyone
Jason
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu