From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:29985 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728756AbfKEQuz (ORCPT ); Tue, 5 Nov 2019 11:50:55 -0500 Date: Tue, 5 Nov 2019 17:50:25 +0100 From: Cornelia Huck Subject: Re: [PATCH V8 3/6] mdev: introduce device specific ops Message-ID: <20191105175025.1a620844.cohuck@redhat.com> In-Reply-To: <20191105093240.5135-4-jasowang@redhat.com> References: <20191105093240.5135-1-jasowang@redhat.com> <20191105093240.5135-4-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-s390-owner@vger.kernel.org List-ID: To: Jason Wang Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, kwankhede@nvidia.com, alex.williamson@redhat.com, mst@redhat.com, tiwei.bie@intel.com, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, maxime.coquelin@redhat.com, cunming.liang@intel.com, zhihong.wang@intel.com, rob.miller@broadcom.com, xiao.w.wang@intel.com, haotian.wang@sifive.com, zhenyuw@linux.intel.com, zhi.a.wang@intel.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch, farman@linux.ibm.com, pasic@linux.ibm.com, sebott@linux.ibm.com, oberpar@linux.ibm.com, heiko.carstens@de.ibm.com, gor@linux.ibm.com, borntraeger@de.ibm.com, akrowiak@linux.ibm.com, freude@linux.ibm.com, lingshan.zhu@intel.com, idos@mellanox.com, eperezma@redhat.com, lulu@redhat.com, parav@mellanox.com, christophe.de.dinechin@gmail.com, kevin.tian@intel.com, stefanha@redhat.com On Tue, 5 Nov 2019 17:32:37 +0800 Jason Wang wrote: > Currently, except for the create and remove, the rest of > mdev_parent_ops is designed for vfio-mdev driver only and may not help > for kernel mdev driver. With the help of class id, this patch > introduces device specific callbacks inside mdev_device > structure. This allows different set of callback to be used by > vfio-mdev and virtio-mdev. >=20 > Reviewed-by: Parav Pandit > Signed-off-by: Jason Wang > --- > .../driver-api/vfio-mediated-device.rst | 35 +++++++++---- > MAINTAINERS | 1 + > drivers/gpu/drm/i915/gvt/kvmgt.c | 18 ++++--- > drivers/s390/cio/vfio_ccw_ops.c | 18 ++++--- > drivers/s390/crypto/vfio_ap_ops.c | 14 +++-- > drivers/vfio/mdev/mdev_core.c | 24 ++++++++- > drivers/vfio/mdev/mdev_private.h | 5 ++ > drivers/vfio/mdev/vfio_mdev.c | 37 ++++++------- > include/linux/mdev.h | 43 ++++----------- > include/linux/mdev_vfio_ops.h | 52 +++++++++++++++++++ > samples/vfio-mdev/mbochs.c | 20 ++++--- > samples/vfio-mdev/mdpy.c | 20 ++++--- > samples/vfio-mdev/mtty.c | 18 ++++--- > 13 files changed, 206 insertions(+), 99 deletions(-) > create mode 100644 include/linux/mdev_vfio_ops.h >=20 (...) > @@ -172,10 +163,34 @@ that a driver should use to unregister itself with = the mdev core driver:: > =20 > =09extern void mdev_unregister_device(struct device *dev); > =20 > -It is also required to specify the class_id in create() callback through= :: > +As multiple types of mediated devices may be supported, class id needs > +to be specified in the create callback(). This could be done The brackets should probably go behind 'create'? > +explicitly for the device that does not use on mdev bus for its "for devices that do not use the mdev bus" ? But why wouldn't they? I feel like I've missed some discussion here :/ > +operation through: > =20 > =09int mdev_set_class(struct mdev_device *mdev, u16 id); > =20 > +For the device that uses on the mdev bus for its operation, the class "For devices that use the mdev bus..." But same comment as above. > +should provide helper function to set class id and device specific > +ops. E.g for vfio-mdev devices, the function to be called is:: > + > +=09int mdev_set_vfio_ops(struct mdev_device *mdev, > + const struct mdev_vfio_device_ops *vfio_op= s); > + > +The class id (set by this function to MDEV_CLASS_ID_VFIO) is used to > +match a device with an mdev driver via its id table. The device > +specific callbacks (specified in *vfio_ops) are obtainable via > +mdev_get_vfio_ops() (for use by the mdev bus driver). A vfio-mdev > +device (class id MDEV_CLASS_ID_VFIO) uses the following > +device-specific ops: > + > +* open: open callback of vfio mediated device > +* close: close callback of vfio mediated device > +* ioctl: ioctl callback of vfio mediated device > +* read : read emulation callback > +* write: write emulation callback > +* mmap: mmap emulation callback > + > Mediated Device Management Interface Through sysfs > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D Otherwise, looks good.