Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/umem: Add ib_umem_dmabuf_get_pinned_and_lock helper

Move the inner logic of ib_umem_dmabuf_get_pinned_with_dma_device()
to a new static function that returns with the lock held upon success.

The intent is to allow reuse for the future get_pinned_revocable_and_lock
function.

Signed-off-by: Jacob Moroni <jmoroni@google.com>
Link: https://patch.msgid.link/20260305170826.3803155-2-jmoroni@google.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Jacob Moroni and committed by
Leon Romanovsky
553dfa8c 1dc469f6

+26 -9
+26 -9
drivers/infiniband/core/umem_dmabuf.c
··· 195 195 .move_notify = ib_umem_dmabuf_unsupported_move_notify, 196 196 }; 197 197 198 - struct ib_umem_dmabuf * 199 - ib_umem_dmabuf_get_pinned_with_dma_device(struct ib_device *device, 200 - struct device *dma_device, 201 - unsigned long offset, size_t size, 202 - int fd, int access) 198 + static struct ib_umem_dmabuf * 199 + ib_umem_dmabuf_get_pinned_and_lock(struct ib_device *device, 200 + struct device *dma_device, 201 + unsigned long offset, 202 + size_t size, int fd, int access, 203 + const struct dma_buf_attach_ops *ops) 203 204 { 204 205 struct ib_umem_dmabuf *umem_dmabuf; 205 206 int err; 206 207 207 - umem_dmabuf = ib_umem_dmabuf_get_with_dma_device(device, dma_device, offset, 208 - size, fd, access, 209 - &ib_umem_dmabuf_attach_pinned_ops); 208 + umem_dmabuf = 209 + ib_umem_dmabuf_get_with_dma_device(device, dma_device, offset, 210 + size, fd, access, ops); 210 211 if (IS_ERR(umem_dmabuf)) 211 212 return umem_dmabuf; 212 213 ··· 220 219 err = ib_umem_dmabuf_map_pages(umem_dmabuf); 221 220 if (err) 222 221 goto err_release; 223 - dma_resv_unlock(umem_dmabuf->attach->dmabuf->resv); 224 222 225 223 return umem_dmabuf; 226 224 ··· 227 227 dma_resv_unlock(umem_dmabuf->attach->dmabuf->resv); 228 228 ib_umem_release(&umem_dmabuf->umem); 229 229 return ERR_PTR(err); 230 + } 231 + 232 + struct ib_umem_dmabuf * 233 + ib_umem_dmabuf_get_pinned_with_dma_device(struct ib_device *device, 234 + struct device *dma_device, 235 + unsigned long offset, size_t size, 236 + int fd, int access) 237 + { 238 + struct ib_umem_dmabuf *umem_dmabuf = 239 + ib_umem_dmabuf_get_pinned_and_lock(device, dma_device, offset, 240 + size, fd, access, 241 + &ib_umem_dmabuf_attach_pinned_ops); 242 + if (IS_ERR(umem_dmabuf)) 243 + return umem_dmabuf; 244 + 245 + dma_resv_unlock(umem_dmabuf->attach->dmabuf->resv); 246 + return umem_dmabuf; 230 247 } 231 248 EXPORT_SYMBOL(ib_umem_dmabuf_get_pinned_with_dma_device); 232 249