Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934252AbdC3O5X (ORCPT ); Thu, 30 Mar 2017 10:57:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49398 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933681AbdC3O5T (ORCPT ); Thu, 30 Mar 2017 10:57:19 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3805E80F90 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mst@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3805E80F90 Date: Thu, 30 Mar 2017 17:57:11 +0300 From: "Michael S. Tsirkin" To: Cornelia Huck 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 Message-ID: <20170330175457-mutt-send-email-mst@kernel.org> References: <1490807652-27889-1-git-send-email-mst@redhat.com> <20170330110627.01713921.cornelia.huck@de.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170330110627.01713921.cornelia.huck@de.ibm.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 30 Mar 2017 14:57:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2011 Lines: 57 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" 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 > > --- > > 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.