On Thu, Jun 03, 2021 at 04:00:55PM +0530, Devesh Sharma wrote: > Enabling Atomic operations for Gen P5 devices if the underlying > platform supports global atomic ops. > > Signed-off-by: Devesh Sharma <devesh.sharma@xxxxxxxxxxxx> > --- > drivers/infiniband/hw/bnxt_re/ib_verbs.c | 4 ++++ > drivers/infiniband/hw/bnxt_re/main.c | 3 +++ > drivers/infiniband/hw/bnxt_re/qplib_res.c | 17 +++++++++++++++++ > drivers/infiniband/hw/bnxt_re/qplib_res.h | 1 + > drivers/infiniband/hw/bnxt_re/qplib_sp.c | 13 ++++++++++++- > drivers/infiniband/hw/bnxt_re/qplib_sp.h | 2 -- > 6 files changed, 37 insertions(+), 3 deletions(-) > > diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > index 537471ffaa79..a113d8d9e9ed 100644 > --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c > +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c > @@ -163,6 +163,10 @@ int bnxt_re_query_device(struct ib_device *ibdev, > ib_attr->max_qp_init_rd_atom = dev_attr->max_qp_init_rd_atom; > ib_attr->atomic_cap = IB_ATOMIC_NONE; > ib_attr->masked_atomic_cap = IB_ATOMIC_NONE; > + if (dev_attr->is_atomic) { > + ib_attr->atomic_cap = IB_ATOMIC_GLOB; > + ib_attr->masked_atomic_cap = IB_ATOMIC_GLOB; > + } > > ib_attr->max_ee_rd_atom = 0; > ib_attr->max_res_rd_atom = 0; > diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c > index b090dfa4f4cb..0de4e22f9750 100644 > --- a/drivers/infiniband/hw/bnxt_re/main.c > +++ b/drivers/infiniband/hw/bnxt_re/main.c > @@ -128,6 +128,9 @@ static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode) > rdev->rcfw.res = &rdev->qplib_res; > > bnxt_re_set_drv_mode(rdev, wqe_mode); > + if (bnxt_qplib_determine_atomics(en_dev->pdev)) > + ibdev_info(&rdev->ibdev, > + "platform doesn't support global atomics."); > return 0; > } > > diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c > index 3ca47004b752..108a591e66ff 100644 > --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c > +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c > @@ -959,3 +959,20 @@ int bnxt_qplib_alloc_res(struct bnxt_qplib_res *res, struct pci_dev *pdev, > bnxt_qplib_free_res(res); > return rc; > } > + > +int bnxt_qplib_determine_atomics(struct pci_dev *dev) > +{ > + int comp; > + u16 ctl2; > + > + comp = pci_enable_atomic_ops_to_root(dev, > + PCI_EXP_DEVCAP2_ATOMIC_COMP32); > + if (comp) > + return -ENOTSUPP; I would say that it needs to be EOPNOTSUPP, not critical. > + comp = pci_enable_atomic_ops_to_root(dev, > + PCI_EXP_DEVCAP2_ATOMIC_COMP64); > + if (comp) > + return -ENOTSUPP; Thanks