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

RDMA/core: Add protection for shared CQs used by ULPs

A pre-step for adding shared CQs. Add the infrastructure to prevent shared
CQ users from altering the CQ configurations. For now all cqs are marked
as private (non-shared). The core driver should use the new force
functions to perform resize/destroy/moderation changes that are not
allowed for users of shared CQs.

Link: https://lore.kernel.org/r/1590568495-101621-2-git-send-email-yaminf@mellanox.com
Signed-off-by: Yamin Friedman <yaminf@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>

authored by

Yamin Friedman and committed by
Jason Gunthorpe
3446cbd2 0b8e125e

+13 -1
+9
drivers/infiniband/core/verbs.c
··· 2005 2005 2006 2006 int rdma_set_cq_moderation(struct ib_cq *cq, u16 cq_count, u16 cq_period) 2007 2007 { 2008 + if (cq->shared) 2009 + return -EOPNOTSUPP; 2010 + 2008 2011 return cq->device->ops.modify_cq ? 2009 2012 cq->device->ops.modify_cq(cq, cq_count, 2010 2013 cq_period) : -EOPNOTSUPP; ··· 2016 2013 2017 2014 int ib_destroy_cq_user(struct ib_cq *cq, struct ib_udata *udata) 2018 2015 { 2016 + if (WARN_ON_ONCE(cq->shared)) 2017 + return -EOPNOTSUPP; 2018 + 2019 2019 if (atomic_read(&cq->usecnt)) 2020 2020 return -EBUSY; 2021 2021 ··· 2031 2025 2032 2026 int ib_resize_cq(struct ib_cq *cq, int cqe) 2033 2027 { 2028 + if (cq->shared) 2029 + return -EOPNOTSUPP; 2030 + 2034 2031 return cq->device->ops.resize_cq ? 2035 2032 cq->device->ops.resize_cq(cq, cqe, NULL) : -EOPNOTSUPP; 2036 2033 }
+4 -1
include/rdma/ib_verbs.h
··· 1613 1613 1614 1614 /* updated only by trace points */ 1615 1615 ktime_t timestamp; 1616 - bool interrupt; 1616 + u8 interrupt:1; 1617 + u8 shared:1; 1617 1618 1618 1619 /* 1619 1620 * Implementation details of the RDMA core, don't use in drivers: ··· 3910 3909 * ib_free_cq_user - Free kernel/user CQ 3911 3910 * @cq: The CQ to free 3912 3911 * @udata: Valid user data or NULL for kernel objects 3912 + * 3913 + * NOTE: This function shouldn't be called on shared CQs. 3913 3914 */ 3914 3915 void ib_free_cq_user(struct ib_cq *cq, struct ib_udata *udata); 3915 3916