Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1612760

Re: [PATCH 1/2] virtio: allow drivers to validate features

From Cornelia Huck <cornelia.huck@de.ibm.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] virtio: allow drivers to validate features
Date 2017-03-30 11:10 +0200
Message-ID <tqEfE-451-17@gated-at.bofh.it> (permalink)
References <tqpqi-1xr-5@gated-at.bofh.it>
Organization IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

Show all headers | View raw


On Wed, 29 Mar 2017 20:14:44 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> Some drivers can't support all features in all configurations.  At the
> moment we blindly set FEATURES_OK and later FAILED.  Support this better
> by adding a callback drivers can use to do some early checks.

Looks reasonable. Do we need to document that the driver must not do
anything beyond dealing with features and reading the config space that
early?

> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  drivers/virtio/virtio.c | 6 ++++++
>  include/linux/virtio.h  | 1 +
>  2 files changed, 7 insertions(+)
> 
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 400d70b..48230a5 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -232,6 +232,12 @@ static int virtio_dev_probe(struct device *_d)
>  		if (device_features & (1ULL << i))
>  			__virtio_set_bit(dev, i);
>  
> +	if (drv->validate) {
> +		err = drv->validate(dev);
> +		if (err)
> +			goto err;
> +	}
> +
>  	err = virtio_finalize_features(dev);
>  	if (err)
>  		goto err;
> diff --git a/include/linux/virtio.h b/include/linux/virtio.h
> index 193fea9..ed04753 100644
> --- a/include/linux/virtio.h
> +++ b/include/linux/virtio.h
> @@ -176,6 +176,7 @@ struct virtio_driver {
>  	unsigned int feature_table_size;
>  	const unsigned int *feature_table_legacy;
>  	unsigned int feature_table_size_legacy;
> +	int (*validate)(struct virtio_device *dev);
>  	int (*probe)(struct virtio_device *dev);
>  	void (*scan)(struct virtio_device *dev);
>  	void (*remove)(struct virtio_device *dev);

Would be good to add some doc; but other members are undocumented here
already...

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] virtio: allow drivers to validate features "Michael S. Tsirkin" <mst@redhat.com> - 2017-03-29 19:20 +0200
  [PATCH 2/2] virtio_net: clear MTU when out of range "Michael S. Tsirkin" <mst@redhat.com> - 2017-03-29 19:20 +0200
  Re: [PATCH 1/2] virtio: allow drivers to validate features Cornelia Huck <cornelia.huck@de.ibm.com> - 2017-03-30 11:10 +0200
    Re: [PATCH 1/2] virtio: allow drivers to validate features "Michael S. Tsirkin" <mst@redhat.com> - 2017-03-30 17:00 +0200
  Re: [PATCH 1/2] virtio: allow drivers to validate features David Miller <davem@davemloft.net> - 2017-03-30 21:50 +0200
    Re: [PATCH 1/2] virtio: allow drivers to validate features "Michael S. Tsirkin" <mst@redhat.com> - 2017-03-31 05:30 +0200

csiph-web