Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932892AbdC3JGl (ORCPT ); Thu, 30 Mar 2017 05:06:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57732 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932302AbdC3JGi (ORCPT ); Thu, 30 Mar 2017 05:06:38 -0400 Date: Thu, 30 Mar 2017 11:06:27 +0200 From: Cornelia Huck To: "Michael S. Tsirkin" 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 In-Reply-To: <1490807652-27889-1-git-send-email-mst@redhat.com> References: <1490807652-27889-1-git-send-email-mst@redhat.com> Organization: IBM Deutschland Research & Development GmbH Vorsitzende des Aufsichtsrats: Martina Koederitz =?UTF-8?B?R2VzY2jDpGZ0c2bDvGhydW5nOg==?= Dirk Wittkopp Sitz der Gesellschaft: =?UTF-8?B?QsO2Ymxpbmdlbg==?= Registergericht: Amtsgericht Stuttgart, HRB 243294 X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17033009-0040-0000-0000-000003577648 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17033009-0041-0000-0000-000024BD93CB Message-Id: <20170330110627.01713921.cornelia.huck@de.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-30_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703300082 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1684 Lines: 50 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? > > 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...