All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
To: Kirti Wankhede <kwankhede@nvidia.com>
Cc: kevin.tian@intel.com, cjia@nvidia.com, kvm@vger.kernel.org,
	qemu-devel@nongnu.org, linux-kernel@vger.kernel.org,
	jike.song@intel.com, alex.williamson@redhat.com,
	kraxel@redhat.com, pbonzini@redhat.com,
	bjsdjshi@linux.vnet.ibm.com
Subject: Re: [PATCH v12 01/22] vfio: Mediated device Core driver
Date: Tue, 15 Nov 2016 16:30:48 +0800	[thread overview]
Message-ID: <28509.8877306611$1505294594@news.gmane.org> (raw)
In-Reply-To: <1479138156-28905-2-git-send-email-kwankhede@nvidia.com>

* Kirti Wankhede <kwankhede@nvidia.com> [2016-11-14 21:12:15 +0530]:

Hi Kirti,

[...]

> diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> new file mode 100644
> index 000000000000..613e8a8a3b2a
> --- /dev/null
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -0,0 +1,374 @@
> +/*
> + * Mediated device Core Driver
> + *
> + * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
> + *     Author: Neo Jia <cjia@nvidia.com>
> + *             Kirti Wankhede <kwankhede@nvidia.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/device.h>
> +#include <linux/slab.h>
> +#include <linux/uuid.h>
> +#include <linux/sysfs.h>
> +#include <linux/mdev.h>
> +
> +#include "mdev_private.h"
> +
> +#define DRIVER_VERSION		"0.1"
> +#define DRIVER_AUTHOR		"NVIDIA Corporation"
> +#define DRIVER_DESC		"Mediated device Core Driver"
> +
> +static LIST_HEAD(parent_list);
> +static DEFINE_MUTEX(parent_list_lock);
> +static struct class_compat *mdev_bus_compat_class;
> +
> +static int _find_mdev_device(struct device *dev, void *data)
What the underscore prefix implies to me is that this should not be
called directly. While ...

> +{
> +	struct mdev_device *mdev;
> +
> +	if (!dev_is_mdev(dev))
> +		return 0;
> +
> +	mdev = to_mdev_device(dev);
> +
> +	if (uuid_le_cmp(mdev->uuid, *(uuid_le *)data) == 0)
> +		return 1;
> +
> +	return 0;
> +}
[...]

> +
> +static int mdev_device_remove_cb(struct device *dev, void *data)
> +{
> +	if (!dev_is_mdev(dev))
> +		return 0;
> +
> +	return mdev_device_remove(dev, data ? *(bool *)data : true);
*(bool *)data will always be true, correct?
If so, we chould get rid of it.

> +}
> +
[...]

> diff --git a/drivers/vfio/mdev/mdev_driver.c b/drivers/vfio/mdev/mdev_driver.c
> new file mode 100644
> index 000000000000..6c19a2f6b5a2
> --- /dev/null
> +++ b/drivers/vfio/mdev/mdev_driver.c
> @@ -0,0 +1,120 @@
> +/*
> + * MDEV driver
> + *
> + * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
> + *     Author: Neo Jia <cjia@nvidia.com>
> + *             Kirti Wankhede <kwankhede@nvidia.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/iommu.h>
> +#include <linux/mdev.h>
> +
> +#include "mdev_private.h"
> +
> +static int mdev_attach_iommu(struct mdev_device *mdev)
> +{
> +	int ret;
> +	struct iommu_group *group;
> +
> +	group = iommu_group_alloc();
> +	if (IS_ERR(group))
> +		return PTR_ERR(group);
> +
> +	ret = iommu_group_add_device(group, &mdev->dev);
> +	if (ret)
> +		goto attach_fail;
> +
> +	dev_info(&mdev->dev, "MDEV: group_id = %d\n", iommu_group_id(group));
> +attach_fail:
> +	iommu_group_put(group);
> +	return ret;
> +}
No need for a goto here. How about:
	ret = iommu_group_add_device(group, &mdev->dev);
	if (!ret)
		dev_info(&mdev->dev, "MDEV: group_id = %d\n",
			 iommu_group_id(group));
	iommu_group_put(group);
	return ret;

Or just remove the dev_info stuff?

[...]

> diff --git a/drivers/vfio/mdev/mdev_sysfs.c b/drivers/vfio/mdev/mdev_sysfs.c
> new file mode 100644
> index 000000000000..04f9b2925e6d
> --- /dev/null
> +++ b/drivers/vfio/mdev/mdev_sysfs.c
[...]

> +
> +static int add_mdev_supported_type_groups(struct parent_device *parent)
> +{
> +	int i;
> +
> +	for (i = 0; parent->ops->supported_type_groups[i]; i++) {
> +		struct mdev_type *type;
> +
> +		type = add_mdev_supported_type(parent,
> +					parent->ops->supported_type_groups[i]);
> +		if (IS_ERR(type)) {
> +			struct mdev_type *ltype, *tmp;
> +
> +			list_for_each_entry_safe(ltype, tmp, &parent->type_list,
> +						  next) {
> +				list_del(&ltype->next);
> +				remove_mdev_supported_type(ltype);
> +			}
> +			return PTR_ERR(type);
> +		}
> +		list_add(&type->next, &parent->type_list);
> +	}
> +	return 0;
> +}
> +
> +/* mdev sysfs Functions */
s/F/f/

[...]

> diff --git a/include/linux/mdev.h b/include/linux/mdev.h
> new file mode 100644
> index 000000000000..4900cc472364
> --- /dev/null
> +++ b/include/linux/mdev.h
> @@ -0,0 +1,168 @@
> +/*
> + * Mediated device definition
> + *
> + * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
> + *     Author: Neo Jia <cjia@nvidia.com>
> + *             Kirti Wankhede <kwankhede@nvidia.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#ifndef MDEV_H
> +#define MDEV_H
> +
> +/* Parent Device */
This is really a nit pick:
s/Device/device/

> +struct parent_device {
> +	struct device		*dev;
> +	const struct parent_ops	*ops;
> +
> +	/* internal */
> +	struct kref		ref;
> +	struct mutex		lock;
> +	struct list_head	next;
> +	struct kset		*mdev_types_kset;
> +	struct list_head	type_list;
> +};
> +
> +/* Mediated device */
[...]

All findings from me are nitpickings. If you like you can have my r-b:
Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>

-- 
Dong Jia

  reply	other threads:[~2016-11-15  8:30 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-14 15:42 [PATCH v12 00/22] Add Mediated device support Kirti Wankhede
2016-11-14 15:42 ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 01/22] vfio: Mediated device Core driver Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-15  8:30   ` Dong Jia Shi [this message]
2016-11-15  8:30   ` Dong Jia Shi
2016-11-15 15:16     ` Kirti Wankhede
2016-11-15 15:16       ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 02/22] vfio: VFIO based driver for Mediated devices Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 03/22] vfio: Rearrange functions to get vfio_group from dev Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 04/22] vfio: Common function to increment container_users Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 05/22] vfio iommu: Added pin and unpin callback functions to vfio_iommu_driver_ops Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 19:43   ` Alex Williamson
2016-11-14 19:43     ` [Qemu-devel] " Alex Williamson
2016-11-15 15:03     ` Kirti Wankhede
2016-11-15 15:03       ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 06/22] vfio iommu type1: Update arguments of vfio_lock_acct Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42   ` Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 07/22] vfio iommu type1: Update argument of vaddr_get_pfn() Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 08/22] vfio iommu type1: Add find_iommu_group() function Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 09/22] vfio iommu type1: Add task structure to vfio_dma Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-15  5:26   ` Alexey Kardashevskiy
2016-11-15  5:26     ` [Qemu-devel] " Alexey Kardashevskiy
2016-11-14 15:42 ` [PATCH v12 10/22] vfio iommu type1: Add support for mediated devices Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 23:25   ` Alex Williamson
2016-11-14 23:25     ` [Qemu-devel] " Alex Williamson
2016-11-15 15:09     ` Kirti Wankhede
2016-11-15 15:09       ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 11/22] vfio iommu: Add blocking notifier to notify DMA_UNMAP Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 23:58   ` Alex Williamson
2016-11-14 23:58     ` [Qemu-devel] " Alex Williamson
2016-11-15 15:11     ` Kirti Wankhede
2016-11-15 15:11       ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 12/22] vfio: Add notifier callback to parent's ops structure of mdev Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-15  6:45   ` Jike Song
2016-11-15  6:45     ` [Qemu-devel] " Jike Song
2016-11-15  8:11     ` Kirti Wankhede
2016-11-15  8:11       ` [Qemu-devel] " Kirti Wankhede
2016-11-15  9:30       ` Jike Song
2016-11-15  9:30         ` [Qemu-devel] " Jike Song
2016-11-15 15:19     ` Alex Williamson
2016-11-15 15:19       ` [Qemu-devel] " Alex Williamson
2016-11-16  5:52       ` Jike Song
2016-11-16  5:52         ` [Qemu-devel] " Jike Song
2016-11-14 15:42 ` [PATCH v12 13/22] vfio: Introduce common function to add capabilities Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 14/22] vfio_pci: Update vfio_pci to use vfio_info_add_capability() Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 15/22] vfio: Introduce vfio_set_irqs_validate_and_prepare() Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 16/22] vfio_pci: Updated to use vfio_set_irqs_validate_and_prepare() Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 17/22] vfio_platform: " Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 18/22] vfio: Define device_api strings Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 19/22] docs: Add Documentation for Mediated devices Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 20/22] docs: Sysfs ABI for mediated device framework Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 21/22] docs: Sample driver to demonstrate how to use Mediated " Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 22/22] MAINTAINERS: Add entry VFIO based Mediated device drivers Kirti Wankhede
2016-11-14 15:42   ` [Qemu-devel] " Kirti Wankhede

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='28509.8877306611$1505294594@news.gmane.org' \
    --to=bjsdjshi@linux.vnet.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=cjia@nvidia.com \
    --cc=jike.song@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.