From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAEB0C433DB for ; Tue, 23 Mar 2021 19:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85F3B619C8 for ; Tue, 23 Mar 2021 19:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbhCWTbk (ORCPT ); Tue, 23 Mar 2021 15:31:40 -0400 Received: from verein.lst.de ([213.95.11.211]:34028 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230406AbhCWTbH (ORCPT ); Tue, 23 Mar 2021 15:31:07 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 144AA68C7B; Tue, 23 Mar 2021 20:31:03 +0100 (CET) Date: Tue, 23 Mar 2021 20:31:03 +0100 From: Christoph Hellwig To: Jason Gunthorpe Cc: David Airlie , Tony Krowiak , Alex Williamson , Christian Borntraeger , Cornelia Huck , Daniel Vetter , dri-devel@lists.freedesktop.org, Eric Farman , Harald Freudenberger , Vasily Gorbik , Heiko Carstens , intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , kvm@vger.kernel.org, Kirti Wankhede , linux-s390@vger.kernel.org, Peter Oberparleiter , Halil Pasic , Pierre Morel , Rodrigo Vivi , Vineeth Vijayan , Zhenyu Wang , Zhi Wang , "Raj, Ashok" , Dan Williams , Christoph Hellwig , Leon Romanovsky , Max Gurtovoy , Tarun Gupta Subject: Re: [PATCH 18/18] vfio/mdev: Correct the function signatures for the mdev_type_attributes Message-ID: <20210323193103.GP17735@lst.de> References: <0-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com> <18-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-s390@vger.kernel.org On Tue, Mar 23, 2021 at 02:55:35PM -0300, Jason Gunthorpe wrote: > The driver core standard is to pass in the properly typed object, the > properly typed attribute and the buffer data. It stems from the root > kobject method: > > ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..) > > Each subclass of kobject should provide their own function with the same > signature but more specific types, eg struct device uses: > > ssize_t (*show)(struct device *dev, struct device_attribute *attr,..) > > In this case the existing signature is: > > ssize_t (*show)(struct kobject *kobj, struct device *dev,..) > > Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'. > > Change the mdev_type related sysfs attribute functions to: > > ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..) > > In order to restore type safety and match the driver core standard > > There are no current users of 'attr', but if it is ever needed it would be > hard to add in retroactively, so do it now. > > Signed-off-by: Jason Gunthorpe > --- > drivers/gpu/drm/i915/gvt/gvt.c | 21 +++++++++++---------- > drivers/s390/cio/vfio_ccw_ops.c | 15 +++++++++------ > drivers/s390/crypto/vfio_ap_ops.c | 12 +++++++----- > drivers/vfio/mdev/mdev_core.c | 14 ++++++++++++-- > drivers/vfio/mdev/mdev_sysfs.c | 11 ++++++----- > include/linux/mdev.h | 11 +++++++---- > samples/vfio-mdev/mbochs.c | 26 +++++++++++++++----------- > samples/vfio-mdev/mdpy.c | 24 ++++++++++++++---------- > samples/vfio-mdev/mtty.c | 18 +++++++++--------- > 9 files changed, 90 insertions(+), 62 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c > index 4b47a18e9dfa0f..3703814a669b46 100644 > --- a/drivers/gpu/drm/i915/gvt/gvt.c > +++ b/drivers/gpu/drm/i915/gvt/gvt.c > @@ -54,14 +54,15 @@ intel_gvt_find_vgpu_type(struct intel_gvt *gvt, unsigned int type_group_id) > return &gvt->types[type_group_id]; > } > > -static ssize_t available_instances_show(struct kobject *kobj, > - struct device *dev, char *buf) > +static ssize_t available_instances_show(struct mdev_type *mtype, > + struct mdev_type_attribute *attr, > + char *buf) > { > struct intel_vgpu_type *type; > unsigned int num = 0; > - void *gvt = kdev_to_i915(dev)->gvt; > + void *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt; > > - type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); > + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(mtype)); Somewhere in this series you should probably switch intel_gvt_find_vgpu_type to only get the mtype, as it can trivially deduct the gvt from it (which also seems to have lost its type somewhere..) Otherwise looks good: Reviewed-by: Christoph Hellwig From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BB17C433E0 for ; Tue, 23 Mar 2021 19:31:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2046E619B8 for ; Tue, 23 Mar 2021 19:31:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2046E619B8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A0E816E943; Tue, 23 Mar 2021 19:31:08 +0000 (UTC) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4FBD06E943; Tue, 23 Mar 2021 19:31:07 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 144AA68C7B; Tue, 23 Mar 2021 20:31:03 +0100 (CET) Date: Tue, 23 Mar 2021 20:31:03 +0100 From: Christoph Hellwig To: Jason Gunthorpe Message-ID: <20210323193103.GP17735@lst.de> References: <0-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com> <18-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <18-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Subject: Re: [Intel-gfx] [PATCH 18/18] vfio/mdev: Correct the function signatures for the mdev_type_attributes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, Kirti Wankhede , Vineeth Vijayan , Leon Romanovsky , Christoph Hellwig , linux-s390@vger.kernel.org, "Raj, Ashok" , Halil Pasic , Christian Borntraeger , Tarun Gupta , intel-gfx@lists.freedesktop.org, Max Gurtovoy , Eric Farman , Vasily Gorbik , Heiko Carstens , Harald Freudenberger , Dan Williams , intel-gvt-dev@lists.freedesktop.org, Tony Krowiak , Pierre Morel , Cornelia Huck , Peter Oberparleiter Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Tue, Mar 23, 2021 at 02:55:35PM -0300, Jason Gunthorpe wrote: > The driver core standard is to pass in the properly typed object, the > properly typed attribute and the buffer data. It stems from the root > kobject method: > > ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,..) > > Each subclass of kobject should provide their own function with the same > signature but more specific types, eg struct device uses: > > ssize_t (*show)(struct device *dev, struct device_attribute *attr,..) > > In this case the existing signature is: > > ssize_t (*show)(struct kobject *kobj, struct device *dev,..) > > Where kobj is a 'struct mdev_type *' and dev is 'mdev_type->parent->dev'. > > Change the mdev_type related sysfs attribute functions to: > > ssize_t (*show)(struct mdev_type *mtype, struct mdev_type_attribute *attr,..) > > In order to restore type safety and match the driver core standard > > There are no current users of 'attr', but if it is ever needed it would be > hard to add in retroactively, so do it now. > > Signed-off-by: Jason Gunthorpe > --- > drivers/gpu/drm/i915/gvt/gvt.c | 21 +++++++++++---------- > drivers/s390/cio/vfio_ccw_ops.c | 15 +++++++++------ > drivers/s390/crypto/vfio_ap_ops.c | 12 +++++++----- > drivers/vfio/mdev/mdev_core.c | 14 ++++++++++++-- > drivers/vfio/mdev/mdev_sysfs.c | 11 ++++++----- > include/linux/mdev.h | 11 +++++++---- > samples/vfio-mdev/mbochs.c | 26 +++++++++++++++----------- > samples/vfio-mdev/mdpy.c | 24 ++++++++++++++---------- > samples/vfio-mdev/mtty.c | 18 +++++++++--------- > 9 files changed, 90 insertions(+), 62 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c > index 4b47a18e9dfa0f..3703814a669b46 100644 > --- a/drivers/gpu/drm/i915/gvt/gvt.c > +++ b/drivers/gpu/drm/i915/gvt/gvt.c > @@ -54,14 +54,15 @@ intel_gvt_find_vgpu_type(struct intel_gvt *gvt, unsigned int type_group_id) > return &gvt->types[type_group_id]; > } > > -static ssize_t available_instances_show(struct kobject *kobj, > - struct device *dev, char *buf) > +static ssize_t available_instances_show(struct mdev_type *mtype, > + struct mdev_type_attribute *attr, > + char *buf) > { > struct intel_vgpu_type *type; > unsigned int num = 0; > - void *gvt = kdev_to_i915(dev)->gvt; > + void *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt; > > - type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(kobj)); > + type = intel_gvt_find_vgpu_type(gvt, mtype_get_type_group_id(mtype)); Somewhere in this series you should probably switch intel_gvt_find_vgpu_type to only get the mtype, as it can trivially deduct the gvt from it (which also seems to have lost its type somewhere..) Otherwise looks good: Reviewed-by: Christoph Hellwig _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx