From: Andrew Lunn <andrew@lunn.ch>
To: Leon Romanovsky <leon@kernel.org>
Cc: Sunil Kovvuri <sunil.kovvuri@gmail.com>,
Linux Netdev List <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Tomasz Duszynski <tduszynski@marvell.com>,
Subbaraya Sundeep <sbhatta@marvell.com>,
Geetha sowjanya <gakula@marvell.com>,
Sunil Goutham <sgoutham@marvell.com>
Subject: Re: [PATCH v2 net-next 3/7] octeontx2-vf: Virtual function driver support
Date: Sun, 15 Mar 2020 09:42:15 +0100 [thread overview]
Message-ID: <20200315084215.GI8622@lunn.ch> (raw)
In-Reply-To: <20200314191258.GB3046@unreal>
> > > > +static int otx2vf_process_mbox_msg_up(struct otx2_nic *vf,
> > > > + struct mbox_msghdr *req)
> > > > +{
> > > > + /* Check if valid, if not reply with a invalid msg */
> > > > + if (req->sig != OTX2_MBOX_REQ_SIG) {
> > > > + otx2_reply_invalid_msg(&vf->mbox.mbox_up, 0, 0, req->id);
> > > > + return -ENODEV;
> > > > + }
> > > > +
> > > > + switch (req->id) {
> > > > +#define M(_name, _id, _fn_name, _req_type, _rsp_type) \
> > > > + case _id: { \
> > > > + struct _rsp_type *rsp; \
> > > > + int err; \
> > > > + \
> > > > + rsp = (struct _rsp_type *)otx2_mbox_alloc_msg( \
> > > > + &vf->mbox.mbox_up, 0, \
> > > > + sizeof(struct _rsp_type)); \
> > > > + if (!rsp) \
> > > > + return -ENOMEM; \
> > > > + \
> > > > + rsp->hdr.id = _id; \
> > > > + rsp->hdr.sig = OTX2_MBOX_RSP_SIG; \
> > > > + rsp->hdr.pcifunc = 0; \
> > > > + rsp->hdr.rc = 0; \
> > > > + \
> > > > + err = otx2_mbox_up_handler_ ## _fn_name( \
> > > > + vf, (struct _req_type *)req, rsp); \
> > > > + return err; \
> > > > + }
> > > > +MBOX_UP_CGX_MESSAGES
> > > > +#undef M
> > >
> > > "return ..." inside macro which is called by another macro is highly
> > > discouraged by the Linux kernel coding style.
> > >
> >
> > There are many mailbox messages to handle and adding each one of them
> > to switch case would be a
> > lot of duplicate code. Hence we choose to with these macros.
>
> The coding style section 12.1 talks exactly about that pattern.
> https://elixir.bootlin.com/linux/latest/source/Documentation/process/coding-style.rst#L752
> Somehow all other drivers succeeded to write their code without such
> macros, I'm confident that you will success too. Please try your best.
Hi Sunil
It is easy to create locking bugs with returns in macros. I've
inherited code which did this, not realized where was a return hidden
in a macro, and as a result got locks wrong, resulting in a deadlock.
Andrew
next prev parent reply other threads:[~2020-03-15 8:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-13 9:42 [PATCH v2 net-next 0/7] octeontx2-vf: Add network driver for virtual function sunil.kovvuri
2020-03-13 9:42 ` [PATCH v2 net-next 1/7] octeontx2-pf: Enable SRIOV and added VF mbox handling sunil.kovvuri
2020-03-13 9:42 ` [PATCH v2 net-next 2/7] octeontx2-pf: Handle VF function level reset sunil.kovvuri
2020-03-13 18:16 ` Leon Romanovsky
2020-03-14 15:42 ` Sunil Kovvuri
2020-03-13 9:42 ` [PATCH v2 net-next 3/7] octeontx2-vf: Virtual function driver support sunil.kovvuri
2020-03-13 18:11 ` Leon Romanovsky
2020-03-14 15:40 ` Sunil Kovvuri
2020-03-14 17:59 ` Leon Romanovsky
2020-03-14 19:12 ` Leon Romanovsky
2020-03-15 8:42 ` Andrew Lunn [this message]
2020-03-13 9:42 ` [PATCH v2 net-next 4/7] octeontx2-vf: Ethtool support sunil.kovvuri
2020-03-13 17:56 ` Leon Romanovsky
2020-03-14 15:42 ` Sunil Kovvuri
2020-03-13 9:42 ` [PATCH v2 net-next 5/7] octeontx2-vf: Link event notification support sunil.kovvuri
2020-03-13 9:42 ` [PATCH v2 net-next 6/7] octeontx2-pf: Cleanup all receive buffers in SG descriptor sunil.kovvuri
2020-03-13 9:42 ` [PATCH v2 net-next 7/7] octeontx2-af: Remove driver version and fix authorship sunil.kovvuri
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=20200315084215.GI8622@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=gakula@marvell.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=sunil.kovvuri@gmail.com \
--cc=tduszynski@marvell.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).