All of lore.kernel.org
 help / color / mirror / Atom feed
From: Devesh Sharma <devesh.sharma@broadcom.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: linux-rdma <linux-rdma@vger.kernel.org>,
	Jason Gunthorpe <jgg@mellanox.com>,
	Doug Ledford <dledford@redhat.com>
Subject: Re: [PATCH for-next 4/7] RDMA/bnxt_re: Refactor net ring allocation function
Date: Mon, 27 Jan 2020 16:55:07 +0530	[thread overview]
Message-ID: <CANjDDBj_vieac6bzbNHNa-WhzpRoSJfOG-bQNqK7U8fN7A+WaA@mail.gmail.com> (raw)
In-Reply-To: <20200127080216.GK3870@unreal>

On Mon, Jan 27, 2020 at 1:32 PM Leon Romanovsky <leon@kernel.org> wrote:
>
> On Mon, Jan 27, 2020 at 01:10:10PM +0530, Devesh Sharma wrote:
> > On Sun, Jan 26, 2020 at 7:59 PM Leon Romanovsky <leon@kernel.org> wrote:
> > >
> > > On Fri, Jan 24, 2020 at 12:52:42AM -0500, Devesh Sharma wrote:
> > > > Introducing a new attribute structure to reduce
> > > > the long list of arguments passed in bnxt_re_net_ring_alloc()
> > > > function.
> > > >
> > > > The caller of bnxt_re_net_ring_alloc should fill in
> > > > the list of attributes in bnxt_re_ring_attr structure
> > > > and then pass the pointer to the function.
> > > >
> > > > Signed-off-by: Naresh Kumar PBS <nareshkumar.pbs@broadcom.com>
> > > > Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
> > > > Signed-off-by: Devesh Sharma <devesh.sharma@broadcom.com>
> > > > ---
> > > >  drivers/infiniband/hw/bnxt_re/bnxt_re.h |  9 +++++
> > > >  drivers/infiniband/hw/bnxt_re/main.c    | 65 ++++++++++++++++++---------------
> > > >  2 files changed, 45 insertions(+), 29 deletions(-)
> > > >
> > > > diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h
> > > > index 86274f4..c736e82 100644
> > > > --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h
> > > > +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h
> > > > @@ -89,6 +89,15 @@
> > > >
> > > >  #define BNXT_RE_DEFAULT_ACK_DELAY    16
> > > >
> > > > +struct bnxt_re_ring_attr {
> > > > +     dma_addr_t      *dma_arr;
> > > > +     int             pages;
> > > > +     int             type;
> > > > +     u32             depth;
> > > > +     u32             lrid; /* Logical ring id */
> > > > +     u8              mode;
> > > > +};
> > > > +
> > > >  struct bnxt_re_work {
> > > >       struct work_struct      work;
> > > >       unsigned long           event;
> > > > diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
> > > > index a966c68..648a5ea 100644
> > > > --- a/drivers/infiniband/hw/bnxt_re/main.c
> > > > +++ b/drivers/infiniband/hw/bnxt_re/main.c
> > > > @@ -427,9 +427,9 @@ static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev,
> > > >       return rc;
> > > >  }
> > > >
> > > > -static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, dma_addr_t *dma_arr,
> > > > -                               int pages, int type, u32 ring_mask,
> > > > -                               u32 map_index, u16 *fw_ring_id)
> > > > +static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev,
> > > > +                               struct bnxt_re_ring_attr *ring_attr,
> > > > +                               u16 *fw_ring_id)
> > > >  {
> > > >       struct bnxt_en_dev *en_dev = rdev->en_dev;
> > > >       struct hwrm_ring_alloc_input req = {0};
> > > > @@ -443,18 +443,18 @@ static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, dma_addr_t *dma_arr,
> > > >       memset(&fw_msg, 0, sizeof(fw_msg));
> > > >       bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1);
> > > >       req.enables = 0;
> > > > -     req.page_tbl_addr =  cpu_to_le64(dma_arr[0]);
> > > > -     if (pages > 1) {
> > > > +     req.page_tbl_addr =  cpu_to_le64(ring_attr->dma_arr[0]);
> > > > +     if (ring_attr->pages > 1) {
> > > >               /* Page size is in log2 units */
> > > >               req.page_size = BNXT_PAGE_SHIFT;
> > > >               req.page_tbl_depth = 1;
> > > >       }
> > > >       req.fbo = 0;
> > > >       /* Association of ring index with doorbell index and MSIX number */
> > > > -     req.logical_id = cpu_to_le16(map_index);
> > > > -     req.length = cpu_to_le32(ring_mask + 1);
> > > > -     req.ring_type = type;
> > > > -     req.int_mode = RING_ALLOC_REQ_INT_MODE_MSIX;
> > > > +     req.logical_id = cpu_to_le16(ring_attr->lrid);
> > > > +     req.length = cpu_to_le32(ring_attr->depth + 1);
> > > > +     req.ring_type = ring_attr->type;
> > > > +     req.int_mode = ring_attr->mode;
> > > >       bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
> > > >                           sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
> > > >       rc = en_dev->en_ops->bnxt_send_fw_msg(en_dev, BNXT_ROCE_ULP, &fw_msg);
> > > > @@ -1006,12 +1006,13 @@ static void bnxt_re_free_res(struct bnxt_re_dev *rdev)
> > > >
> > > >  static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev)
> > > >  {
> > > > +     struct bnxt_qplib_ctx *qplib_ctx;
> > > > +     struct bnxt_re_ring_attr rattr;
> > > >       int num_vec_created = 0;
> > > > -     dma_addr_t *pg_map;
> > > >       int rc = 0, i;
> > > > -     int pages;
> > > >       u8 type;
> > > >
> > > > +     memset(&rattr, 0, sizeof(rattr));
> > >
> > > Initialize rattr to zero from the beginning and save call to memset.
> > I moved from static initialization to memset due to some sparse/smatch
> > warnings, rattr has a "pointer member".
>
> Can you share the error and tool version, because it is pretty common
> way to initialize variables? Also "= {0}" would solve your checker
> warning.
I will have to duplicate it again to report the precise warning but
based on my memory, sparse or smatch was shouting about "pointer
converted to integer without cast"
I guess that was because rattr.dma_arr is a pointer and static
initialization was assigning value 0 while it should had been NULL. If
you insist I would send you exact warning msg and tool-version-number
soon.
>
> Thanks

  reply	other threads:[~2020-01-27 11:25 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  5:52 [PATCH for-next 0/7] Refactor control path of bnxt_re driver Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 1/7] RDMA/bnxt_re: Refactor queue pair creation code Devesh Sharma
2020-01-24 11:23   ` Leon Romanovsky
2020-01-25 17:03     ` Devesh Sharma
2020-01-25 18:50       ` Leon Romanovsky
2020-01-27  7:39         ` Devesh Sharma
2020-01-30  6:04           ` Devesh Sharma
2020-01-25 17:46   ` Jason Gunthorpe
2020-01-27  8:13     ` Devesh Sharma
2020-01-27  8:16       ` Devesh Sharma
2020-01-27  9:27         ` Leon Romanovsky
2020-01-27  9:26       ` Leon Romanovsky
2020-01-27 11:31         ` Devesh Sharma
2020-01-30  6:04       ` Devesh Sharma
2020-01-30 13:37   ` Parav Pandit
2020-01-30 16:03     ` Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 2/7] RDMA/bnxt_re: Replace chip context structure with pointer Devesh Sharma
2020-01-25 18:03   ` Jason Gunthorpe
2020-01-27  7:39     ` Devesh Sharma
2020-01-27  8:04       ` Leon Romanovsky
2020-01-27 11:17         ` Devesh Sharma
2020-01-28 20:15       ` Jason Gunthorpe
2020-01-30  6:05         ` Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 3/7] RDMA/bnxt_re: Refactor hardware queue memory allocation Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 4/7] RDMA/bnxt_re: Refactor net ring allocation function Devesh Sharma
2020-01-26 14:29   ` Leon Romanovsky
2020-01-27  7:40     ` Devesh Sharma
2020-01-27  8:02       ` Leon Romanovsky
2020-01-27 11:25         ` Devesh Sharma [this message]
2020-01-27 12:44           ` Leon Romanovsky
2020-01-27 14:14             ` Devesh Sharma
2020-01-28 18:09               ` Jason Gunthorpe
2020-01-28  0:35       ` Jason Gunthorpe
2020-01-28  2:43         ` Devesh Sharma
2020-01-28 18:09           ` Jason Gunthorpe
2020-01-29  8:29             ` Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 5/7] RDMA/bnxt_re: Refactor command queue management code Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 6/7] RDMA/bnxt_re: Refactor notification " Devesh Sharma
2020-01-24  5:52 ` [PATCH for-next 7/7] RDMA/bnxt_re: Refactor doorbell management functions Devesh Sharma
2020-01-25 18:04 ` [PATCH for-next 0/7] Refactor control path of bnxt_re driver Jason Gunthorpe
2020-01-27  7:39   ` Devesh Sharma

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANjDDBj_vieac6bzbNHNa-WhzpRoSJfOG-bQNqK7U8fN7A+WaA@mail.gmail.com \
    --to=devesh.sharma@broadcom.com \
    --cc=dledford@redhat.com \
    --cc=jgg@mellanox.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.