From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/2] virtio: allow drivers to validate features
Date: Thu, 30 Mar 2017 17:57:11 +0300 [thread overview]
Message-ID: <20170330175457-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170330110627.01713921.cornelia.huck@de.ibm.com>
On Thu, Mar 30, 2017 at 11:06:27AM +0200, Cornelia Huck wrote:
> 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?
It's up to the driver - we probably should document that on failure
neither probe nor remove will be called. On success we proceed
to probe.
> >
> > 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...
True. Patches welcome.
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/2] virtio: allow drivers to validate features
Date: Thu, 30 Mar 2017 17:57:11 +0300 [thread overview]
Message-ID: <20170330175457-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20170330110627.01713921.cornelia.huck@de.ibm.com>
On Thu, Mar 30, 2017 at 11:06:27AM +0200, Cornelia Huck wrote:
> 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?
It's up to the driver - we probably should document that on failure
neither probe nor remove will be called. On success we proceed
to probe.
> >
> > 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...
True. Patches welcome.
next prev parent reply other threads:[~2017-03-30 14:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-29 17:14 [PATCH 1/2] virtio: allow drivers to validate features Michael S. Tsirkin
2017-03-29 17:14 ` Michael S. Tsirkin
2017-03-29 17:14 ` [PATCH 2/2] virtio_net: clear MTU when out of range Michael S. Tsirkin
2017-03-29 17:14 ` Michael S. Tsirkin
2017-03-30 9:06 ` [PATCH 1/2] virtio: allow drivers to validate features Cornelia Huck
2017-03-30 14:57 ` Michael S. Tsirkin [this message]
2017-03-30 14:57 ` Michael S. Tsirkin
2017-03-30 9:06 ` Cornelia Huck
2017-03-30 19:39 ` David Miller
2017-03-30 19:39 ` David Miller
2017-03-31 3:27 ` Michael S. Tsirkin
2017-03-31 3:27 ` 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=20170330175457-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=cornelia.huck@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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.