platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 18/24] mlxbf-tmfifo: sparse tags for config access
       [not found] <20200803205814.540410-1-mst@redhat.com>
@ 2020-08-03 21:00 ` Michael S. Tsirkin
  2020-08-04 14:56   ` Cornelia Huck
  0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2020-08-03 21:00 UTC (permalink / raw)
  To: linux-kernel
  Cc: Vadim Pasternak, platform-driver-x86, Darren Hart,
	virtualization, Andy Shevchenko

mlxbf-tmfifo accesses config space using native types -
which works for it since the legacy virtio native types.

This will break if it ever needs to support modern virtio,
so with new tags previously introduced for virtio net config,
sparse now warns for this in drivers.

Since this is a legacy only device, fix it up using
virtio_legacy_is_little_endian for now.

No functional changes.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/platform/mellanox/mlxbf-tmfifo.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c
index 5739a9669b29..bbc4e71a16ff 100644
--- a/drivers/platform/mellanox/mlxbf-tmfifo.c
+++ b/drivers/platform/mellanox/mlxbf-tmfifo.c
@@ -625,7 +625,10 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring,
 			vdev_id = VIRTIO_ID_NET;
 			hdr_len = sizeof(struct virtio_net_hdr);
 			config = &fifo->vdev[vdev_id]->config.net;
-			if (ntohs(hdr.len) > config->mtu +
+			/* A legacy-only interface for now. */
+			if (ntohs(hdr.len) >
+			    __virtio16_to_cpu(virtio_legacy_is_little_endian(),
+					      config->mtu) +
 			    MLXBF_TMFIFO_NET_L2_OVERHEAD)
 				return;
 		} else {
@@ -1231,8 +1234,12 @@ static int mlxbf_tmfifo_probe(struct platform_device *pdev)
 
 	/* Create the network vdev. */
 	memset(&net_config, 0, sizeof(net_config));
-	net_config.mtu = ETH_DATA_LEN;
-	net_config.status = VIRTIO_NET_S_LINK_UP;
+
+	/* A legacy-only interface for now. */
+	net_config.mtu = __cpu_to_virtio16(virtio_legacy_is_little_endian(),
+					   ETH_DATA_LEN);
+	net_config.status = __cpu_to_virtio16(virtio_legacy_is_little_endian(),
+					      VIRTIO_NET_S_LINK_UP);
 	mlxbf_tmfifo_get_cfg_mac(net_config.mac);
 	rc = mlxbf_tmfifo_create_vdev(dev, fifo, VIRTIO_ID_NET,
 				      MLXBF_TMFIFO_NET_FEATURES, &net_config,
-- 
MST

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 18/24] mlxbf-tmfifo: sparse tags for config access
  2020-08-03 21:00 ` [PATCH v2 18/24] mlxbf-tmfifo: sparse tags for config access Michael S. Tsirkin
@ 2020-08-04 14:56   ` Cornelia Huck
  2020-08-05 13:29     ` Michael S. Tsirkin
  0 siblings, 1 reply; 3+ messages in thread
From: Cornelia Huck @ 2020-08-04 14:56 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Vadim Pasternak, linux-kernel, platform-driver-x86, Darren Hart,
	virtualization, Andy Shevchenko

On Mon, 3 Aug 2020 17:00:01 -0400
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> mlxbf-tmfifo accesses config space using native types -
> which works for it since the legacy virtio native types.
> 
> This will break if it ever needs to support modern virtio,
> so with new tags previously introduced for virtio net config,
> sparse now warns for this in drivers.
> 
> Since this is a legacy only device, fix it up using
> virtio_legacy_is_little_endian for now.

I'm wondering if the driver should make this more explicit?

No issues with the patch, though.

> 
> No functional changes.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/platform/mellanox/mlxbf-tmfifo.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)

Acked-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 18/24] mlxbf-tmfifo: sparse tags for config access
  2020-08-04 14:56   ` Cornelia Huck
@ 2020-08-05 13:29     ` Michael S. Tsirkin
  0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2020-08-05 13:29 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Vadim Pasternak, linux-kernel, platform-driver-x86, Darren Hart,
	virtualization, Andy Shevchenko

On Tue, Aug 04, 2020 at 04:56:34PM +0200, Cornelia Huck wrote:
> On Mon, 3 Aug 2020 17:00:01 -0400
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > mlxbf-tmfifo accesses config space using native types -
> > which works for it since the legacy virtio native types.
> > 
> > This will break if it ever needs to support modern virtio,
> > so with new tags previously introduced for virtio net config,
> > sparse now warns for this in drivers.
> > 
> > Since this is a legacy only device, fix it up using
> > virtio_legacy_is_little_endian for now.
> 
> I'm wondering if the driver should make this more explicit?


Not sure how though.

> No issues with the patch, though.
> 
> > 
> > No functional changes.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  drivers/platform/mellanox/mlxbf-tmfifo.c | 13 ++++++++++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> Acked-by: Cornelia Huck <cohuck@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-08-05 13:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200803205814.540410-1-mst@redhat.com>
2020-08-03 21:00 ` [PATCH v2 18/24] mlxbf-tmfifo: sparse tags for config access Michael S. Tsirkin
2020-08-04 14:56   ` Cornelia Huck
2020-08-05 13:29     ` Michael S. Tsirkin

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).