From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754137AbcKBIAM (ORCPT ); Wed, 2 Nov 2016 04:00:12 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:6502 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753918AbcKBIAK (ORCPT ); Wed, 2 Nov 2016 04:00:10 -0400 X-PGP-Universal: processed; by hqnvupgp07.nvidia.com on Tue, 01 Nov 2016 12:59:54 -0700 Subject: Re: [PATCH v10 01/19] vfio: Mediated device Core driver To: Jike Song References: <1477517366-27871-1-git-send-email-kwankhede@nvidia.com> <1477517366-27871-2-git-send-email-kwankhede@nvidia.com> <581425F9.5070902@intel.com> <5814E63F.9070609@intel.com> CC: , , , , , , , , X-Nvconfidentiality: public From: Kirti Wankhede Message-ID: <9d417e40-f4d3-ab3c-47a1-ac730e6e4ae6@nvidia.com> Date: Wed, 2 Nov 2016 13:29:28 +0530 MIME-Version: 1.0 In-Reply-To: <5814E63F.9070609@intel.com> X-Originating-IP: [10.24.216.210] X-ClientProxiedBy: DRHKMAIL102.nvidia.com (10.25.59.16) To bgmail102.nvidia.com (10.25.59.11) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/29/2016 11:41 PM, Jike Song wrote: > On 10/29/2016 06:06 PM, Kirti Wankhede wrote: >> >> >> On 10/29/2016 10:00 AM, Jike Song wrote: >>> On 10/27/2016 05:29 AM, Kirti Wankhede wrote: >>>> +int mdev_register_device(struct device *dev, const struct parent_ops *ops) >>>> +{ >>>> + int ret; >>>> + struct parent_device *parent; >>>> + >>>> + /* check for mandatory ops */ >>>> + if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) >>>> + return -EINVAL; >>>> + >>>> + dev = get_device(dev); >>>> + if (!dev) >>>> + return -EINVAL; >>>> + >>>> + mutex_lock(&parent_list_lock); >>>> + >>>> + /* Check for duplicate */ >>>> + parent = __find_parent_device(dev); >>>> + if (parent) { >>>> + ret = -EEXIST; >>>> + goto add_dev_err; >>>> + } >>>> + >>>> + parent = kzalloc(sizeof(*parent), GFP_KERNEL); >>>> + if (!parent) { >>>> + ret = -ENOMEM; >>>> + goto add_dev_err; >>>> + } >>>> + >>>> + kref_init(&parent->ref); >>>> + mutex_init(&parent->lock); >>>> + >>>> + parent->dev = dev; >>>> + parent->ops = ops; >>>> + >>>> + ret = parent_create_sysfs_files(parent); >>>> + if (ret) { >>>> + mutex_unlock(&parent_list_lock); >>>> + mdev_put_parent(parent); >>>> + return ret; >>>> + } >>>> + >>>> + ret = class_compat_create_link(mdev_bus_compat_class, dev, NULL); >>>> + if (ret) >>>> + dev_warn(dev, "Failed to create compatibility class link\n"); >>>> + >>> >>> Hi Kirti, >>> >>> Like I replied to previous version: >>> >>> http://www.spinics.net/lists/kvm/msg139331.html >>> >> >> Hi Jike, >> >> I saw your reply but by that time v10 version of patch series was out >> for review. >> > > Ah..yes, I forgot that :) > >>> You can always check if mdev_bus_compat_class already registered >>> here, and register it if not yet. Same logic should be adopted to >>> mdev_init. >>> >>> Current implementation will simply panic if configured as builtin, >>> which is rare but far from impossible. >>> >> >> Can you verify attached patch with v10 patch-set whether this works for you? >> I'll incorporate this change in my next version. >> > > Seems cool. But would you please also keep the register in mdev_init(), > just check the 'in case it was already registered' case? Thanks! > The class is used only to keep symbolic to the devices which are registered to mdev framework. So I think its ok to register this class when first device is registered. Thanks, Kirti From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49617) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1qSx-0004w4-O4 for qemu-devel@nongnu.org; Wed, 02 Nov 2016 04:00:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1qSw-0004K6-SZ for qemu-devel@nongnu.org; Wed, 02 Nov 2016 04:00:11 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:6507) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1qSw-0004Jc-Jt for qemu-devel@nongnu.org; Wed, 02 Nov 2016 04:00:10 -0400 References: <1477517366-27871-1-git-send-email-kwankhede@nvidia.com> <1477517366-27871-2-git-send-email-kwankhede@nvidia.com> <581425F9.5070902@intel.com> <5814E63F.9070609@intel.com> From: Kirti Wankhede Message-ID: <9d417e40-f4d3-ab3c-47a1-ac730e6e4ae6@nvidia.com> Date: Wed, 2 Nov 2016 13:29:28 +0530 MIME-Version: 1.0 In-Reply-To: <5814E63F.9070609@intel.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v10 01/19] vfio: Mediated device Core driver List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jike Song Cc: 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, bjsdjshi@linux.vnet.ibm.com, linux-kernel@vger.kernel.org On 10/29/2016 11:41 PM, Jike Song wrote: > On 10/29/2016 06:06 PM, Kirti Wankhede wrote: >> >> >> On 10/29/2016 10:00 AM, Jike Song wrote: >>> On 10/27/2016 05:29 AM, Kirti Wankhede wrote: >>>> +int mdev_register_device(struct device *dev, const struct parent_ops *ops) >>>> +{ >>>> + int ret; >>>> + struct parent_device *parent; >>>> + >>>> + /* check for mandatory ops */ >>>> + if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) >>>> + return -EINVAL; >>>> + >>>> + dev = get_device(dev); >>>> + if (!dev) >>>> + return -EINVAL; >>>> + >>>> + mutex_lock(&parent_list_lock); >>>> + >>>> + /* Check for duplicate */ >>>> + parent = __find_parent_device(dev); >>>> + if (parent) { >>>> + ret = -EEXIST; >>>> + goto add_dev_err; >>>> + } >>>> + >>>> + parent = kzalloc(sizeof(*parent), GFP_KERNEL); >>>> + if (!parent) { >>>> + ret = -ENOMEM; >>>> + goto add_dev_err; >>>> + } >>>> + >>>> + kref_init(&parent->ref); >>>> + mutex_init(&parent->lock); >>>> + >>>> + parent->dev = dev; >>>> + parent->ops = ops; >>>> + >>>> + ret = parent_create_sysfs_files(parent); >>>> + if (ret) { >>>> + mutex_unlock(&parent_list_lock); >>>> + mdev_put_parent(parent); >>>> + return ret; >>>> + } >>>> + >>>> + ret = class_compat_create_link(mdev_bus_compat_class, dev, NULL); >>>> + if (ret) >>>> + dev_warn(dev, "Failed to create compatibility class link\n"); >>>> + >>> >>> Hi Kirti, >>> >>> Like I replied to previous version: >>> >>> http://www.spinics.net/lists/kvm/msg139331.html >>> >> >> Hi Jike, >> >> I saw your reply but by that time v10 version of patch series was out >> for review. >> > > Ah..yes, I forgot that :) > >>> You can always check if mdev_bus_compat_class already registered >>> here, and register it if not yet. Same logic should be adopted to >>> mdev_init. >>> >>> Current implementation will simply panic if configured as builtin, >>> which is rare but far from impossible. >>> >> >> Can you verify attached patch with v10 patch-set whether this works for you? >> I'll incorporate this change in my next version. >> > > Seems cool. But would you please also keep the register in mdev_init(), > just check the 'in case it was already registered' case? Thanks! > The class is used only to keep symbolic to the devices which are registered to mdev framework. So I think its ok to register this class when first device is registered. Thanks, Kirti