From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vincent Mailhol <mailhol@kernel.org>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
Harald Mommer <harald.mommer@oss.qualcomm.com>,
Francesco Valla <francesco@valla.it>,
Matias Ezequiel Vara Larsen <mvaralar@redhat.com>,
Mikhail Golubev-Ciuchea
<mikhail.golubev-ciuchea@oss.qualcomm.com>,
Jason Wang <jasowang@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
linux-can@vger.kernel.org, virtualization@lists.linux.dev,
Wolfgang Grandegger <wg@grandegger.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: Re: [PATCH v7] can: virtio: Add virtio CAN driver
Date: Tue, 3 Feb 2026 07:49:49 -0500 [thread overview]
Message-ID: <20260203074916-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CAMZ6Rq+M2zS=BbOz3x0GPprO+J+yreAbjOAsr=3bjfi9gRvApQ@mail.gmail.com>
On Tue, Feb 03, 2026 at 01:32:47PM +0100, Vincent Mailhol wrote:
> On Mar. 3 Feb. 2026 at 13:05, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Tue, Feb 03, 2026 at 12:55:07PM +0100, Harald Mommer wrote:
> > >
> > >
> > > On 1/9/26 18:23, Francesco Valla wrote:
> > > >> +static u8 virtio_can_send_ctrl_msg(struct net_device *ndev, u16 msg_type)
> > > >> +{
> > > >> + struct scatterlist sg_out, sg_in, *sgs[2] = { &sg_out, &sg_in };
> > > >> + struct virtio_can_priv *priv = netdev_priv(ndev);
> > > >> + struct device *dev = &priv->vdev->dev;
> > > >> + struct virtqueue *vq;
> > > >> + unsigned int len;
> > > >> + int err;
> > > >> +
> > > >> + vq = priv->vqs[VIRTIO_CAN_QUEUE_CONTROL];
> > > > Nit: consider initializing this above, while declaring it.
> > >
> > > All those "Nit" regarding initialization cause problems. There is a reason why it was done the way it is.
> > >
> > > The network people require that the declaration lines are ordered by line length. longest line first. This is called "Reverse Christmas tree". Don't ask me why, this formatting style is what the network people require. Their subsystem, their rules.
>
> I am fine with the Reverse Christmas Tree in general, except when it
> randomly splits the initialization, as is the case here. As you noted,
> this is a coding rule of the network subsystem, but here we are the
> CAN subsystem. So yes, the CAN is itself a sub-subsystem of network,
> but my point is that we are a different team of maintainers. I would
> like to ask the network maintainers for understanding regarding our
> different preferences on that topic.
>
> Unless Marc or Oliver have a strong opinion on this, I would prefer
> not to push the Reverse Christmas Tree to its limits and to allow,
> within the CAN subtree, exceptions whenever this would avoid some
> hanging initializations.
>
> > > To initialize the vq you need now already the priv initialized. If now the vq line becomes longer than the priv line you will violate the special formatting requirements of the network subsystem.
> > >
> > > Solution was: What you see above.
> > >
> > > Regards
> > > Harald
> >
> > So you reorder it then:
> >
> > struct scatterlist sg_out, sg_in, *sgs[2] = { &sg_out, &sg_in };
> > struct virtqueue *vq = priv->vqs[VIRTIO_CAN_QUEUE_CONTROL];
> > struct virtio_can_priv *priv = netdev_priv(ndev);
> > struct device *dev = &priv->vdev->dev;
> > unsigned int len;
> > int err;
> >
> >
> > and where is the problem?
>
> The problem is that priv is not yet declared. So this:
>
> struct scatterlist sg_out, sg_in, *sgs[2] = { &sg_out, &sg_in };
> struct virtio_can_priv *priv = netdev_priv(ndev);
> struct virtqueue *vq = priv->vqs[VIRTIO_CAN_QUEUE_CONTROL];
> struct device *dev = &priv->vdev->dev;
> unsigned int len;
> int err;
>
> is forced,
Ah. Good point.
> which, IMHO, is totally *fine* and way better than
> deporting down the vq initialization.
Indeed.
> > On the flip size, this guarantees we will not forget to initialize.
>
> Yes!
>
>
> Yours sincerely,
> Vincent Mailhol
next prev parent reply other threads:[~2026-02-03 12:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 18:44 [PATCH v7] can: virtio: Add virtio CAN driver Matias Ezequiel Vara Larsen
2026-01-09 17:23 ` Francesco Valla
2026-01-12 16:48 ` Matias Ezequiel Vara Larsen
2026-02-03 11:55 ` Harald Mommer
2026-02-03 12:05 ` Michael S. Tsirkin
2026-02-03 12:32 ` Vincent Mailhol
2026-02-03 12:49 ` Michael S. Tsirkin [this message]
2026-02-03 15:18 ` Harald Mommer
2026-02-03 16:20 ` Michael S. Tsirkin
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=20260203074916-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=francesco@valla.it \
--cc=harald.mommer@oss.qualcomm.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mikhail.golubev-ciuchea@oss.qualcomm.com \
--cc=mkl@pengutronix.de \
--cc=mvaralar@redhat.com \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=wg@grandegger.com \
--cc=xuanzhuo@linux.alibaba.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