Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934815AbcJ2SOc (ORCPT ); Sat, 29 Oct 2016 14:14:32 -0400 Received: from mga05.intel.com ([192.55.52.43]:28647 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751292AbcJ2SOb (ORCPT ); Sat, 29 Oct 2016 14:14:31 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,565,1473145200"; d="scan'208";a="779626405" Message-ID: <5814E63F.9070609@intel.com> Date: Sun, 30 Oct 2016 02:11:11 +0800 From: Jike Song User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Kirti Wankhede 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 Subject: Re: [PATCH v10 01/19] vfio: Mediated device Core driver References: <1477517366-27871-1-git-send-email-kwankhede@nvidia.com> <1477517366-27871-2-git-send-email-kwankhede@nvidia.com> <581425F9.5070902@intel.com> In-Reply-To: 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 Content-Length: 2106 Lines: 84 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! -- Thanks, Jike