linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kirti Wankhede <kwankhede@nvidia.com>
To: <alex.williamson@redhat.com>, <pbonzini@redhat.com>,
	<kraxel@redhat.com>, <cjia@nvidia.com>, <qemu-devel@nongnu.org>,
	<kvm@vger.kernel.org>, <kevin.tian@intel.com>,
	<jike.song@intel.com>, <bjsdjshi@linux.vnet.ibm.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v12 01/22] vfio: Mediated device Core driver
Date: Tue, 15 Nov 2016 20:46:32 +0530	[thread overview]
Message-ID: <fa18e55b-7010-d7db-a2ba-e20d2ea910ea@nvidia.com> (raw)
In-Reply-To: <20161115083048.GA17048@bjsdjshi@linux.vnet.ibm.com>



On 11/15/2016 2:00 PM, Dong Jia Shi wrote:
> * 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 ...
> 

This only called here, i.e. it is not called directly:

         dev = device_find_child(parent->dev, &uuid, _find_mdev_device);



>> +{
>> +	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.
> 

No, data can be true or false based in when it is called. This is passed
to mdev_device_remove_ops() where I had added comment.

/*
 * mdev_device_remove_ops gets called from sysfs's 'remove' and when parent
 * device is being unregistered from mdev device framework.
 * - 'force_remove' is set to 'false' when called from sysfs's 'remove'
which
 *   indicates that if the mdev device is active, used by VMM or userspace
 *   application, vendor driver could return error then don't remove the
device.
 * - 'force_remove' is set to 'true' when called from
mdev_unregister_device()
 *   which indicate that parent device is being removed from mdev device
 *   framework so remove mdev device forcefully.
 */
static int mdev_device_remove_ops(struct mdev_device *mdev, bool
force_remove)



>> +}
>> +
> [...]
> 
>> 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;
> 

Ok.

> Or just remove the dev_info stuff?
> 
> [...]
> 
> 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>

Thanks,
Kirti

  parent reply	other threads:[~2016-11-15 15:16 UTC|newest]

Thread overview: 36+ 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 ` [PATCH v12 01/22] vfio: Mediated device Core driver Kirti Wankhede
     [not found]   ` <20161115083048.GA17048@bjsdjshi@linux.vnet.ibm.com>
2016-11-15 15:16     ` Kirti Wankhede [this message]
2016-11-14 15:42 ` [PATCH v12 02/22] vfio: VFIO based driver for Mediated devices 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 ` [PATCH v12 04/22] vfio: Common function to increment container_users 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 19:43   ` Alex Williamson
2016-11-15 15:03     ` 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 ` [PATCH v12 07/22] vfio iommu type1: Update argument of vaddr_get_pfn() 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 ` [PATCH v12 09/22] vfio iommu type1: Add task structure to vfio_dma Kirti Wankhede
2016-11-15  5:26   ` Alexey Kardashevskiy
2016-11-14 15:42 ` [PATCH v12 10/22] vfio iommu type1: Add support for mediated devices Kirti Wankhede
2016-11-14 23:25   ` Alex Williamson
2016-11-15 15:09     ` 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 23:58   ` Alex Williamson
2016-11-15 15:11     ` 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-15  6:45   ` Jike Song
2016-11-15  8:11     ` Kirti Wankhede
2016-11-15  9:30       ` Jike Song
2016-11-15 15:19     ` Alex Williamson
2016-11-16  5:52       ` 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 ` [PATCH v12 14/22] vfio_pci: Update vfio_pci to use vfio_info_add_capability() 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 ` [PATCH v12 16/22] vfio_pci: Updated to use vfio_set_irqs_validate_and_prepare() Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 17/22] vfio_platform: " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 18/22] vfio: Define device_api strings Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 19/22] docs: Add Documentation for Mediated devices 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 ` [PATCH v12 21/22] docs: Sample driver to demonstrate how to use Mediated " Kirti Wankhede
2016-11-14 15:42 ` [PATCH v12 22/22] MAINTAINERS: Add entry VFIO based Mediated device drivers 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=fa18e55b-7010-d7db-a2ba-e20d2ea910ea@nvidia.com \
    --to=kwankhede@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=bjsdjshi@linux.vnet.ibm.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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).