linux-yocto/drivers/infiniband/core
Michael Margolin 24eb0979ff RDMA/core: Fix best page size finding when it can cross SG entries
[ Upstream commit 486055f5e09df959ad4e3aa4ee75b5c91ddeec2e ]

A single scatter-gather entry is limited by a 32 bits "length" field
that is practically 4GB - PAGE_SIZE. This means that even when the
memory is physically contiguous, we might need more than one entry to
represent it. Additionally when using dmabuf, the sg_table might be
originated outside the subsystem and optimized for other needs.

For instance an SGT of 16GB GPU continuous memory might look like this:
(a real life example)

dma_address 34401400000, length fffff000
dma_address 345013ff000, length fffff000
dma_address 346013fe000, length fffff000
dma_address 347013fd000, length fffff000
dma_address 348013fc000, length 4000

Since ib_umem_find_best_pgsz works within SG entries, in the above case
we will result with the worst possible 4KB page size.

Fix this by taking into consideration only the alignment of addresses of
real discontinuity points rather than treating SG entries as such, and
adjust the page iterator to correctly handle cross SG entry pages.

There is currently an assumption that drivers do not ask for pages
bigger than maximal DMA size supported by their devices.

Reviewed-by: Firas Jahjah <firasj@amazon.com>
Reviewed-by: Yonatan Nachum <ynachum@amazon.com>
Signed-off-by: Michael Margolin <mrgolin@amazon.com>
Link: https://patch.msgid.link/20250217141623.12428-1-mrgolin@amazon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-06-04 14:40:13 +02:00
..
addr.c
agent.c
agent.h
cache.c IB/core: Fix ib_cache_setup_one error flow cleanup 2024-10-17 15:21:06 +02:00
cgroup.c
cm_msgs.h
cm_trace.c
cm_trace.h trace: Relocate event helper files 2024-03-06 14:45:17 +00:00
cm.c RDMA/cm: Print the old state when cm_destroy_id gets timeout 2024-04-27 17:07:09 +02:00
cma_configfs.c RDMA/cma: Fix truncation compilation warning in make_cma_ports 2023-10-10 22:00:45 +02:00
cma_priv.h RDMA/core: Add an rb_tree that stores cm_ids sorted by ifindex and remote IP 2022-06-16 09:54:35 +03:00
cma_trace.c
cma_trace.h trace: Relocate event helper files 2024-03-06 14:45:17 +00:00
cma.c RDMA/cma: Fix workqueue crash in cma_netevent_work_handler 2025-04-25 10:43:55 +02:00
core_priv.h
counters.c
cq.c
device.c RDMA/core: Don't expose hw_counters outside of init net namespace 2025-04-10 14:33:34 +02:00
ib_core_uverbs.c
iwcm.c RDMA/iwcm: Fix WARNING:at_kernel/workqueue.c:#check_flush_dependency 2024-10-17 15:21:05 +02:00
iwcm.h
iwpm_msg.c
iwpm_util.c
iwpm_util.h
lag.c RDMA/core: Remove 'device' argument from rdma_build_skb() 2022-08-28 14:29:07 +03:00
mad_priv.h
mad_rmpp.c
mad_rmpp.h
mad.c IB/mad: Check available slots before posting receive WRs 2025-04-10 14:33:34 +02:00
Makefile
mr_pool.c
multicast.c
netlink.c
nldev.c RDMA/core: Require admin capabilities to set system parameters 2023-10-10 22:00:44 +02:00
opa_smi.h
packer.c
rdma_core.c RDMA: Correct duplicated words in comments 2022-06-24 16:52:28 -03:00
rdma_core.h
restrack.c RDMA/restrack: Fix potential invalid address access 2024-07-05 09:31:49 +02:00
restrack.h
roce_gid_mgmt.c IB: Fix repeated words 'the the' comments 2022-07-22 12:02:29 -03:00
rw.c RDMA/rw: drop pci_p2pdma_[un]map_sg() 2022-07-26 07:28:07 -04:00
sa_query.c RDMA/core: Use size_{add,sub,mul}() in calls to struct_size() 2023-11-20 11:52:04 +01:00
sa.h
security.c
smi.c
smi.h
sysfs.c RDMA/core: Don't expose hw_counters outside of init net namespace 2025-04-10 14:33:34 +02:00
trace.c
ucma.c RDMA/core: Rename rdma_route.num_paths field to num_pri_alt_paths 2022-09-22 12:35:13 +03:00
ud_header.c
umem_dmabuf.c RDMA: Handle the return code from dma_resv_wait_timeout() properly 2022-08-16 17:13:23 +03:00
umem_odp.c RDMA/core: Silence oversized kvmalloc() warning 2025-04-25 10:43:48 +02:00
umem.c RDMA/core: Fix best page size finding when it can cross SG entries 2025-06-04 14:40:13 +02:00
user_mad.c IB/core: Implement a limit on UMAD receive List 2024-07-11 12:47:05 +02:00
uverbs_cmd.c RDMA/uverbs: Propagate errors from rdma_lookup_get_uobject() 2025-06-04 14:40:06 +02:00
uverbs_ioctl.c RDMA/core: Add UVERBS_ATTR_RAW_FD 2022-09-27 10:15:24 -03:00
uverbs_main.c RDMA/uverbs: Fix typo of sizeof argument 2023-10-10 22:00:45 +02:00
uverbs_marshall.c
uverbs_std_types_async_fd.c
uverbs_std_types_counters.c IB/uverbs: Fix an potential error pointer dereference 2023-09-13 09:42:53 +02:00
uverbs_std_types_cq.c
uverbs_std_types_device.c
uverbs_std_types_dm.c
uverbs_std_types_flow_action.c
uverbs_std_types_mr.c
uverbs_std_types_qp.c
uverbs_std_types_srq.c
uverbs_std_types_wq.c
uverbs_std_types.c
uverbs_uapi.c
uverbs.h
verbs.c RDMA/core: Fix best page size finding when it can cross SG entries 2025-06-04 14:40:13 +02:00