All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	qemu-devel@nongnu.org, renxiaof@linux.vnet.ibm.com,
	cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, agraf@suse.com,
	pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com
Subject: Re: [PATCH v4 09/16] vfio: ccw: realize VFIO_DEVICE_GET_REGION_INFO ioctl
Date: Tue, 21 Mar 2017 12:47:34 -0600	[thread overview]
Message-ID: <20170321124734.57ee620c@t450s.home> (raw)
In-Reply-To: <20170317031743.40128-10-bjsdjshi@linux.vnet.ibm.com>

On Fri, 17 Mar 2017 04:17:36 +0100
Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:

> Introduce device information about vfio-ccw: VFIO_DEVICE_FLAGS_CCW.
> Realize VFIO_DEVICE_GET_REGION_INFO ioctl for vfio-ccw.
> 
> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
> Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
> ---
>  drivers/s390/cio/vfio_ccw_ops.c | 78 +++++++++++++++++++++++++++++++++++++++++
>  include/uapi/linux/vfio.h       | 11 ++++++
>  2 files changed, 89 insertions(+)
> 
> diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
> index 878c882..f3300dd 100644
> --- a/drivers/s390/cio/vfio_ccw_ops.c
> +++ b/drivers/s390/cio/vfio_ccw_ops.c
> @@ -188,6 +188,83 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
>  	return count;
>  }
>  
> +static int vfio_ccw_mdev_get_device_info(struct vfio_device_info *info)
> +{
> +	info->flags = VFIO_DEVICE_FLAGS_CCW;
> +	info->num_regions = VFIO_CCW_NUM_REGIONS;
> +	info->num_irqs = 0;
> +
> +	return 0;
> +}
> +
> +static int vfio_ccw_mdev_get_region_info(struct vfio_region_info *info,
> +					 u16 *cap_type_id,
> +					 void **cap_type)
> +{
> +	switch (info->index) {
> +	case VFIO_CCW_CONFIG_REGION_INDEX:
> +		info->offset = 0;
> +		info->size = sizeof(struct ccw_io_region);
> +		info->flags = VFIO_REGION_INFO_FLAG_READ
> +			      | VFIO_REGION_INFO_FLAG_WRITE;
> +		return 0;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
> +static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
> +				   unsigned int cmd,
> +				   unsigned long arg)
> +{
> +	int ret = 0;
> +	unsigned long minsz;
> +
> +	switch (cmd) {
> +	case VFIO_DEVICE_GET_INFO:
> +	{
> +		struct vfio_device_info info;
> +
> +		minsz = offsetofend(struct vfio_device_info, num_irqs);
> +
> +		if (copy_from_user(&info, (void __user *)arg, minsz))
> +			return -EFAULT;
> +
> +		if (info.argsz < minsz)
> +			return -EINVAL;
> +
> +		ret = vfio_ccw_mdev_get_device_info(&info);
> +		if (ret)
> +			return ret;
> +
> +		return copy_to_user((void __user *)arg, &info, minsz);
> +	}
> +	case VFIO_DEVICE_GET_REGION_INFO:
> +	{
> +		struct vfio_region_info info;
> +		u16 cap_type_id = 0;
> +		void *cap_type = NULL;
> +
> +		minsz = offsetofend(struct vfio_region_info, offset);
> +
> +		if (copy_from_user(&info, (void __user *)arg, minsz))
> +			return -EFAULT;
> +
> +		if (info.argsz < minsz)
> +			return -EINVAL;
> +
> +		ret = vfio_ccw_mdev_get_region_info(&info, &cap_type_id,
> +						    &cap_type);
> +		if (ret)
> +			return ret;
> +
> +		return copy_to_user((void __user *)arg, &info, minsz);
> +	}
> +	default:
> +		return -ENOTTY;
> +	}
> +}
> +
>  static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
>  	.owner			= THIS_MODULE,
>  	.supported_type_groups  = mdev_type_groups,
> @@ -197,6 +274,7 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
>  	.release		= vfio_ccw_mdev_release,
>  	.read			= vfio_ccw_mdev_read,
>  	.write			= vfio_ccw_mdev_write,
> +	.ioctl			= vfio_ccw_mdev_ioctl,
>  };
>  
>  int vfio_ccw_mdev_reg(struct subchannel *sch)
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index 6183789..3fd70ff 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -198,6 +198,7 @@ struct vfio_device_info {
>  #define VFIO_DEVICE_FLAGS_PCI	(1 << 1)	/* vfio-pci device */
>  #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)	/* vfio-platform device */
>  #define VFIO_DEVICE_FLAGS_AMBA  (1 << 3)	/* vfio-amba device */
> +#define VFIO_DEVICE_FLAGS_CCW	(1 << 4)	/* vfio-ccw device */
>  	__u32	num_regions;	/* Max region index + 1 */
>  	__u32	num_irqs;	/* Max IRQ index + 1 */
>  };
> @@ -447,6 +448,16 @@ enum {
>  	VFIO_PCI_NUM_IRQS
>  };
>  
> +/*
> + * The vfio-ccw bus driver makes use of the following fixed region.
> + * Unimplemented regions return a size of zero.
> + */
> +
> +enum {
> +	VFIO_CCW_CONFIG_REGION_INDEX,
> +	VFIO_CCW_NUM_REGIONS
> +};
> +
>  /**
>   * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12,
>   *					      struct vfio_pci_hot_reset_info)


Acked-by: Alex Williamson <alex.williamson@redhat.com>

WARNING: multiple messages have this Message-ID (diff)
From: Alex Williamson <alex.williamson@redhat.com>
To: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	qemu-devel@nongnu.org, renxiaof@linux.vnet.ibm.com,
	cornelia.huck@de.ibm.com, borntraeger@de.ibm.com, agraf@suse.com,
	pmorel@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH v4 09/16] vfio: ccw: realize VFIO_DEVICE_GET_REGION_INFO ioctl
Date: Tue, 21 Mar 2017 12:47:34 -0600	[thread overview]
Message-ID: <20170321124734.57ee620c@t450s.home> (raw)
In-Reply-To: <20170317031743.40128-10-bjsdjshi@linux.vnet.ibm.com>

On Fri, 17 Mar 2017 04:17:36 +0100
Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com> wrote:

> Introduce device information about vfio-ccw: VFIO_DEVICE_FLAGS_CCW.
> Realize VFIO_DEVICE_GET_REGION_INFO ioctl for vfio-ccw.
> 
> Reviewed-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
> Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
> ---
>  drivers/s390/cio/vfio_ccw_ops.c | 78 +++++++++++++++++++++++++++++++++++++++++
>  include/uapi/linux/vfio.h       | 11 ++++++
>  2 files changed, 89 insertions(+)
> 
> diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
> index 878c882..f3300dd 100644
> --- a/drivers/s390/cio/vfio_ccw_ops.c
> +++ b/drivers/s390/cio/vfio_ccw_ops.c
> @@ -188,6 +188,83 @@ static ssize_t vfio_ccw_mdev_write(struct mdev_device *mdev,
>  	return count;
>  }
>  
> +static int vfio_ccw_mdev_get_device_info(struct vfio_device_info *info)
> +{
> +	info->flags = VFIO_DEVICE_FLAGS_CCW;
> +	info->num_regions = VFIO_CCW_NUM_REGIONS;
> +	info->num_irqs = 0;
> +
> +	return 0;
> +}
> +
> +static int vfio_ccw_mdev_get_region_info(struct vfio_region_info *info,
> +					 u16 *cap_type_id,
> +					 void **cap_type)
> +{
> +	switch (info->index) {
> +	case VFIO_CCW_CONFIG_REGION_INDEX:
> +		info->offset = 0;
> +		info->size = sizeof(struct ccw_io_region);
> +		info->flags = VFIO_REGION_INFO_FLAG_READ
> +			      | VFIO_REGION_INFO_FLAG_WRITE;
> +		return 0;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
> +static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev,
> +				   unsigned int cmd,
> +				   unsigned long arg)
> +{
> +	int ret = 0;
> +	unsigned long minsz;
> +
> +	switch (cmd) {
> +	case VFIO_DEVICE_GET_INFO:
> +	{
> +		struct vfio_device_info info;
> +
> +		minsz = offsetofend(struct vfio_device_info, num_irqs);
> +
> +		if (copy_from_user(&info, (void __user *)arg, minsz))
> +			return -EFAULT;
> +
> +		if (info.argsz < minsz)
> +			return -EINVAL;
> +
> +		ret = vfio_ccw_mdev_get_device_info(&info);
> +		if (ret)
> +			return ret;
> +
> +		return copy_to_user((void __user *)arg, &info, minsz);
> +	}
> +	case VFIO_DEVICE_GET_REGION_INFO:
> +	{
> +		struct vfio_region_info info;
> +		u16 cap_type_id = 0;
> +		void *cap_type = NULL;
> +
> +		minsz = offsetofend(struct vfio_region_info, offset);
> +
> +		if (copy_from_user(&info, (void __user *)arg, minsz))
> +			return -EFAULT;
> +
> +		if (info.argsz < minsz)
> +			return -EINVAL;
> +
> +		ret = vfio_ccw_mdev_get_region_info(&info, &cap_type_id,
> +						    &cap_type);
> +		if (ret)
> +			return ret;
> +
> +		return copy_to_user((void __user *)arg, &info, minsz);
> +	}
> +	default:
> +		return -ENOTTY;
> +	}
> +}
> +
>  static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
>  	.owner			= THIS_MODULE,
>  	.supported_type_groups  = mdev_type_groups,
> @@ -197,6 +274,7 @@ static const struct mdev_parent_ops vfio_ccw_mdev_ops = {
>  	.release		= vfio_ccw_mdev_release,
>  	.read			= vfio_ccw_mdev_read,
>  	.write			= vfio_ccw_mdev_write,
> +	.ioctl			= vfio_ccw_mdev_ioctl,
>  };
>  
>  int vfio_ccw_mdev_reg(struct subchannel *sch)
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index 6183789..3fd70ff 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -198,6 +198,7 @@ struct vfio_device_info {
>  #define VFIO_DEVICE_FLAGS_PCI	(1 << 1)	/* vfio-pci device */
>  #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2)	/* vfio-platform device */
>  #define VFIO_DEVICE_FLAGS_AMBA  (1 << 3)	/* vfio-amba device */
> +#define VFIO_DEVICE_FLAGS_CCW	(1 << 4)	/* vfio-ccw device */
>  	__u32	num_regions;	/* Max region index + 1 */
>  	__u32	num_irqs;	/* Max IRQ index + 1 */
>  };
> @@ -447,6 +448,16 @@ enum {
>  	VFIO_PCI_NUM_IRQS
>  };
>  
> +/*
> + * The vfio-ccw bus driver makes use of the following fixed region.
> + * Unimplemented regions return a size of zero.
> + */
> +
> +enum {
> +	VFIO_CCW_CONFIG_REGION_INDEX,
> +	VFIO_CCW_NUM_REGIONS
> +};
> +
>  /**
>   * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12,
>   *					      struct vfio_pci_hot_reset_info)


Acked-by: Alex Williamson <alex.williamson@redhat.com>

  reply	other threads:[~2017-03-21 18:47 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17  3:17 [PATCH v4 00/16] basic vfio-ccw infrastructure Dong Jia Shi
2017-03-17  3:17 ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 01/16] s390: cio: introduce cio_cancel_halt_clear Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  9:26   ` Sebastian Ott
2017-03-17  9:26     ` [Qemu-devel] " Sebastian Ott
2017-03-17  9:39     ` Dong Jia Shi
2017-03-17  9:51       ` Sebastian Ott
2017-03-17  9:51         ` [Qemu-devel] " Sebastian Ott
2017-03-20  1:16         ` Dong Jia Shi
2017-03-23 11:51   ` Sebastian Ott
2017-03-23 11:51     ` [Qemu-devel] " Sebastian Ott
2017-03-24  7:24     ` Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 02/16] s390: cio: export more interfaces Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  9:29   ` Sebastian Ott
2017-03-17  9:29     ` [Qemu-devel] " Sebastian Ott
2017-03-17  9:42     ` Dong Jia Shi
2017-03-23 12:02   ` Sebastian Ott
2017-03-23 12:02     ` [Qemu-devel] " Sebastian Ott
2017-03-24  1:04     ` Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 03/16] vfio: ccw: define device_api strings Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-21 18:47   ` Alex Williamson
2017-03-21 18:47     ` [Qemu-devel] " Alex Williamson
2017-03-17  3:17 ` [PATCH v4 04/16] vfio: ccw: basic implementation for vfio_ccw driver Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 05/16] vfio: ccw: introduce channel program interfaces Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 06/16] vfio: ccw: register vfio_ccw to the mediated device framework Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 07/16] vfio: ccw: introduce ccw_io_region Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 08/16] vfio: ccw: handle ccw command request Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 09/16] vfio: ccw: realize VFIO_DEVICE_GET_REGION_INFO ioctl Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-21 18:47   ` Alex Williamson [this message]
2017-03-21 18:47     ` Alex Williamson
2017-03-17  3:17 ` [PATCH v4 10/16] vfio: ccw: realize VFIO_DEVICE_RESET ioctl Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 11/16] vfio: ccw: realize VFIO_DEVICE_G(S)ET_IRQ_INFO ioctls Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-21 18:47   ` Alex Williamson
2017-03-21 18:47     ` [Qemu-devel] " Alex Williamson
2017-03-22  2:07     ` Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 12/16] vfio: ccw: return I/O results asynchronously Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 13/16] vfio: ccw: introduce a finite state machine Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 14/16] docs: add documentation for vfio-ccw Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-21 18:47   ` Alex Williamson
2017-03-21 18:47     ` [Qemu-devel] " Alex Williamson
2017-03-22  2:34     ` Dong Jia Shi
2017-03-28  8:16       ` Cornelia Huck
2017-03-28  8:16         ` [Qemu-devel] " Cornelia Huck
2017-03-28  8:49         ` Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 15/16] vfio: ccw: introduce support for ccw0 Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-17  3:17 ` [PATCH v4 16/16] MAINTAINERS: Add vfio-ccw maintainers Dong Jia Shi
2017-03-17  3:17   ` [Qemu-devel] " Dong Jia Shi
2017-03-28  8:20 ` [PATCH v4 00/16] basic vfio-ccw infrastructure Cornelia Huck
2017-03-28  8:20   ` [Qemu-devel] " Cornelia Huck
2017-03-28  8:39   ` Christian Borntraeger
2017-03-28  8:39     ` [Qemu-devel] " Christian Borntraeger
2017-03-28  8:39     ` Christian Borntraeger
2017-03-28 13:31     ` Cornelia Huck
2017-03-28 13:31       ` [Qemu-devel] " Cornelia Huck
2017-03-28 15:23     ` Alex Williamson
2017-03-28 15:23       ` [Qemu-devel] " Alex Williamson

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=20170321124734.57ee620c@t450s.home \
    --to=alex.williamson@redhat.com \
    --cc=agraf@suse.com \
    --cc=bjsdjshi@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pmorel@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=renxiaof@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.