| @@ -497,7 +497,7 @@ struct ib_umem *ib_umem_get_attr_or_va(struct ib_device *device, · 496 unmodified lines |
| 497 | 497 | } |
| 498 | 498 | EXPORT_SYMBOL(ib_umem_get_attr_or_va); |
| 499 | 499 | |
| 500 | | −static int uverbs_create_cq_get_buffer_desc(struct uverbs_attr_bundle *attrs, |
| 500 | +static int uverbs_create_cq_get_buffer_desc(const struct uverbs_attr_bundle *attrs, |
| 501 | 501 | struct ib_uverbs_buffer_desc *desc) |
| 502 | 502 | { |
| 503 | 503 | struct ib_device *ib_dev = attrs->context->device; |
| @@ -547,6 +547,61 @@ static int uverbs_create_cq_get_buffer_desc(struct uverbs_attr_bundle *attrs, · 43 unmodified lines |
| 547 | 547 | return -ENODATA; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | +/** |
| 551 | + * ib_umem_get_cq_buf - Pin a CQ buffer umem from per-command attributes. |
| 552 | + * @device: IB device. |
| 553 | + * @attrs: uverbs attribute bundle (may be NULL). |
| 554 | + * @size: minimum required CQ buffer length. |
| 555 | + * @access: IB access flags. |
| 556 | + * |
| 557 | + * Resolves the CQ buffer from the new UMEM attribute or the legacy |
| 558 | + * CQ buffer attributes. There is no UHW VA fallback, so the caller |
| 559 | + * must arrange its own backing (typically an in-kernel allocation) |
| 560 | + * when no source is available. |
| 561 | + * |
| 562 | + * Return: caller-owned umem on success; NULL when no source supplied |
| 563 | + * a buffer; ERR_PTR(...) on error. |
| 564 | + */ |
| 565 | +struct ib_umem *ib_umem_get_cq_buf(struct ib_device *device, |
| 566 | + const struct uverbs_attr_bundle *attrs, |
| 567 | + size_t size, int access) |
| 568 | +{ |
| 569 | + return ib_umem_get_from_attrs(device, attrs, |
| 570 | + UVERBS_ATTR_CREATE_CQ_BUF_UMEM, |
| 571 | + uverbs_create_cq_get_buffer_desc, |
| 572 | + size, access); |
| 573 | +} |
| 574 | +EXPORT_SYMBOL(ib_umem_get_cq_buf); |
| 575 | + |
| 576 | +/** |
| 577 | + * ib_umem_get_cq_buf_or_va - Pin a CQ buffer umem with UHW VA fallback. |
| 578 | + * @device: IB device. |
| 579 | + * @attrs: uverbs attribute bundle (may be NULL). |
| 580 | + * @addr: UHW user VA used when no per-command attribute matched. |
| 581 | + * @size: on the attr / legacy paths, the minimum required umem length |
| 582 | + * validated post-pin; on the VA fallback path, the length to pin. |
| 583 | + * @access: IB access flags. |
| 584 | + * |
| 585 | + * Like ib_umem_get_cq_buf(), but pins @addr/@size when neither the |
| 586 | + * UMEM attribute nor the legacy CQ buffer attributes are supplied. |
| 587 | + * |
| 588 | + * See ib_umem_get_attr_or_va() for the note on @size's dual role and |
| 589 | + * the migration path for drivers that would distinguish a user-supplied |
| 590 | + * length from a driver-computed minimum. |
| 591 | + * |
| 592 | + * Return: caller-owned umem on success, ERR_PTR(...) on error. |
| 593 | + */ |
| 594 | +struct ib_umem *ib_umem_get_cq_buf_or_va(struct ib_device *device, |
| 595 | + const struct uverbs_attr_bundle *attrs, |
| 596 | + u64 addr, size_t size, int access) |
| 597 | +{ |
| 598 | + return ib_umem_get_from_attrs_or_va(device, attrs, |
| 599 | + UVERBS_ATTR_CREATE_CQ_BUF_UMEM, |
| 600 | + uverbs_create_cq_get_buffer_desc, |
| 601 | + addr, size, access); |
| 602 | +} |
| 603 | +EXPORT_SYMBOL(ib_umem_get_cq_buf_or_va); |
| 604 | + |
| 550 | 605 | /** |
| 551 | 606 | * ib_umem_get_cq_tmp - Temporary CQ buffer umem getter. |
| 552 | 607 | * @device: IB device. |