From: Christoph Hellwig <hch@lst.de>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: David Airlie <airlied@linux.ie>,
Tony Krowiak <akrowiak@linux.ibm.com>,
Alex Williamson <alex.williamson@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Cornelia Huck <cohuck@redhat.com>,
Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org,
Eric Farman <farman@linux.ibm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
intel-gfx@lists.freedesktop.org,
intel-gvt-dev@lists.freedesktop.org,
Jani Nikula <jani.nikula@linux.intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
kvm@vger.kernel.org, Kirti Wankhede <kwankhede@nvidia.com>,
linux-s390@vger.kernel.org,
Peter Oberparleiter <oberpar@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Pierre Morel <pmorel@linux.ibm.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Vineeth Vijayan <vneethv@linux.ibm.com>,
Zhenyu Wang <zhenyuw@linux.intel.com>,
Zhi Wang <zhi.a.wang@intel.com>,
"Raj, Ashok" <ashok.raj@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Christoph Hellwig <hch@lst.de>,
Leon Romanovsky <leonro@nvidia.com>,
Max Gurtovoy <mgurtovoy@nvidia.com>,
Tarun Gupta <targupta@nvidia.com>
Subject: Re: [PATCH 18/18] vfio/mdev: Correct the function signatures for the mdev_type_attributes
Date: Tue, 23 Mar 2021 20:31:03 +0100 [thread overview]
Message-ID: <20210323193103.GP17735@lst.de> (raw)
In-Reply-To: <18-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com>
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 <jgg@nvidia.com>
> ---
> 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 <hch@lst.de>
next prev parent reply other threads:[~2021-03-23 19:32 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-23 17:55 [PATCH 00/18] Make vfio_mdev type safe Jason Gunthorpe
2021-03-23 17:55 ` [PATCH 01/18] vfio/mdev: Fix missing static's on MDEV_TYPE_ATTR's Jason Gunthorpe
2021-03-23 17:55 ` [PATCH 02/18] vfio/mdev: Add missing typesafety around mdev_device Jason Gunthorpe
2021-03-26 2:04 ` Tian, Kevin
2021-03-30 15:24 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 03/18] vfio/mdev: Simplify driver registration Jason Gunthorpe
2021-03-23 19:14 ` Christoph Hellwig
2021-03-26 12:10 ` Jason Gunthorpe
2021-03-26 12:55 ` Christoph Hellwig
2021-03-26 2:17 ` Tian, Kevin
2021-03-30 15:28 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 04/18] vfio/mdev: Use struct mdev_type in struct mdev_device Jason Gunthorpe
2021-03-23 19:15 ` Christoph Hellwig
2021-03-26 2:29 ` Tian, Kevin
2021-04-06 18:41 ` Jason Gunthorpe
2021-03-30 15:31 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 05/18] vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer Jason Gunthorpe
2021-03-23 19:15 ` Christoph Hellwig
2021-04-06 16:08 ` Jason Gunthorpe
2021-03-26 2:38 ` Tian, Kevin
2021-03-29 8:42 ` Max Gurtovoy
2021-03-30 15:34 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 06/18] vfio/mdev: Expose mdev_get/put_parent to mdev_private.h Jason Gunthorpe
2021-03-23 19:16 ` Christoph Hellwig
2021-03-26 2:47 ` Tian, Kevin
2021-03-30 15:37 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 07/18] vfio/mdev: Add missing reference counting to mdev_type Jason Gunthorpe
2021-03-23 19:17 ` Christoph Hellwig
2021-03-26 2:52 ` Tian, Kevin
2021-03-30 15:38 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 08/18] vfio/mdev: Reorganize mdev_device_create() Jason Gunthorpe
2021-03-23 19:20 ` Christoph Hellwig
2021-03-26 3:33 ` Tian, Kevin
2021-03-26 3:36 ` Tian, Kevin
2021-04-06 16:40 ` Jason Gunthorpe
2021-03-26 3:31 ` Tian, Kevin
2021-03-30 15:50 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 09/18] vfio/mdev: Add missing error handling to dev_set_name() Jason Gunthorpe
2021-03-23 19:21 ` Christoph Hellwig
2021-03-26 3:35 ` Tian, Kevin
2021-03-29 8:50 ` Max Gurtovoy
2021-03-30 15:53 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 10/18] vfio/mdev: Remove duplicate storage of parent in mdev_device Jason Gunthorpe
2021-03-23 19:22 ` Christoph Hellwig
2021-03-26 3:53 ` Tian, Kevin
2021-03-26 11:53 ` Jason Gunthorpe
2021-03-30 16:14 ` Cornelia Huck
2021-03-30 16:50 ` Jason Gunthorpe
2021-03-30 16:15 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 11/18] vfio/mdev: Add mdev/mtype_get_type_group_id() Jason Gunthorpe
2021-03-23 19:23 ` Christoph Hellwig
2021-04-06 18:53 ` Jason Gunthorpe
2021-03-26 5:52 ` Tian, Kevin
2021-03-30 16:26 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 12/18] vfio/mtty: Use mdev_get_type_group_id() Jason Gunthorpe
2021-03-23 19:24 ` Christoph Hellwig
2021-03-23 17:55 ` [PATCH 13/18] vfio/mdpy: " Jason Gunthorpe
2021-03-23 19:25 ` Christoph Hellwig
2021-03-23 17:55 ` [PATCH 14/18] vfio/mbochs: " Jason Gunthorpe
2021-03-23 19:25 ` Christoph Hellwig
2021-03-23 17:55 ` [PATCH 17/18] vfio/mdev: Remove kobj from mdev_parent_ops->create() Jason Gunthorpe
2021-03-23 19:29 ` Christoph Hellwig
2021-03-26 6:11 ` Tian, Kevin
2021-03-30 16:29 ` Cornelia Huck
2021-03-23 17:55 ` [PATCH 18/18] vfio/mdev: Correct the function signatures for the mdev_type_attributes Jason Gunthorpe
2021-03-23 19:31 ` Christoph Hellwig [this message]
2021-04-06 18:34 ` Jason Gunthorpe
2021-03-26 7:03 ` Tian, Kevin
2021-03-30 16:35 ` Cornelia Huck
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=20210323193103.GP17735@lst.de \
--to=hch@lst.de \
--cc=airlied@linux.ie \
--cc=akrowiak@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=ashok.raj@intel.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=dan.j.williams@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=farman@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jgg@nvidia.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=leonro@nvidia.com \
--cc=linux-s390@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=oberpar@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=rodrigo.vivi@intel.com \
--cc=targupta@nvidia.com \
--cc=vneethv@linux.ibm.com \
--cc=zhenyuw@linux.intel.com \
--cc=zhi.a.wang@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox