From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c6trH-0006Ii-FC for qemu-devel@nongnu.org; Wed, 16 Nov 2016 01:38:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c6trE-0002Lx-BB for qemu-devel@nongnu.org; Wed, 16 Nov 2016 01:38:11 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46511 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c6trE-0002Lr-4f for qemu-devel@nongnu.org; Wed, 16 Nov 2016 01:38:08 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAG6Y29T024801 for ; Wed, 16 Nov 2016 01:38:07 -0500 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 26rbr1n0en-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 16 Nov 2016 01:38:07 -0500 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Nov 2016 23:38:06 -0700 Date: Wed, 16 Nov 2016 14:37:59 +0800 From: Dong Jia Shi References: <1479223805-22895-1-git-send-email-kwankhede@nvidia.com> <1479223805-22895-13-git-send-email-kwankhede@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1479223805-22895-13-git-send-email-kwankhede@nvidia.com> Message-Id: <20161116063759.GD5531@bjsdjshi@linux.vnet.ibm.com> Subject: Re: [Qemu-devel] [PATCH v13 12/22] vfio: Add notifier callback to parent's ops structure of mdev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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, jike.song@intel.com, bjsdjshi@linux.vnet.ibm.com, linux-kernel@vger.kernel.org * Kirti Wankhede [2016-11-15 20:59:55 +0530]: Hi Kirti, [...] > diff --git a/drivers/vfio/mdev/vfio_mdev.c b/drivers/vfio/mdev/vfio_mdev.c > index ffc36758cb84..4fc63db38829 100644 > --- a/drivers/vfio/mdev/vfio_mdev.c > +++ b/drivers/vfio/mdev/vfio_mdev.c > @@ -24,6 +24,15 @@ > #define DRIVER_AUTHOR "NVIDIA Corporation" > #define DRIVER_DESC "VFIO based driver for Mediated device" > > +static int vfio_mdev_notifier(struct notifier_block *nb, unsigned long action, > + void *data) > +{ > + struct mdev_device *mdev = container_of(nb, struct mdev_device, nb); > + struct parent_device *parent = mdev->parent; > + > + return parent->ops->notifier(mdev, action, data); > +} > + > static int vfio_mdev_open(void *device_data) > { > struct mdev_device *mdev = device_data; > @@ -36,9 +45,18 @@ static int vfio_mdev_open(void *device_data) > if (!try_module_get(THIS_MODULE)) > return -ENODEV; > > + if (likely(parent->ops->notifier)) { > + mdev->nb.notifier_call = vfio_mdev_notifier; > + if (vfio_register_notifier(&mdev->dev, &mdev->nb)) > + pr_err("Failed to register notifier for mdev\n"); I think we should just return here if the error value is not -ENOTTY. > + } > + > ret = parent->ops->open(mdev); > - if (ret) > + if (ret) { > + if (likely(parent->ops->notifier)) > + vfio_unregister_notifier(&mdev->dev, &mdev->nb); > module_put(THIS_MODULE); > + } > > return ret; > } [...] -- Dong Jia