From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 9A26E5323 for ; Tue, 2 Oct 2018 16:22:18 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2018 07:22:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,332,1534834800"; d="scan'208";a="93954753" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.113]) ([10.237.220.113]) by fmsmga004.fm.intel.com with ESMTP; 02 Oct 2018 07:15:01 -0700 To: Jeff Guo , stephen@networkplumber.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, konstantin.ananyev@intel.com, gaetan.rivet@6wind.com, jingjing.wu@intel.com, thomas@monjalon.net, motih@mellanox.com, matan@mellanox.com, harry.van.haaren@intel.com, qi.z.zhang@intel.com, shaopeng.he@intel.com, bernard.iremonger@intel.com, arybchenko@solarflare.com Cc: jblunck@infradead.org, shreyansh.jain@nxp.com, dev@dpdk.org, helin.zhang@intel.com, jerin.jacob@caviumnetworks.com References: <1534503091-31910-1-git-send-email-jia.guo@intel.com> <1538485138-98076-1-git-send-email-jia.guo@intel.com> <1538485138-98076-5-git-send-email-jia.guo@intel.com> From: "Burakov, Anatoly" Message-ID: <628bc5ca-de09-0b54-8e1a-c0742ddb6890@intel.com> Date: Tue, 2 Oct 2018 15:15:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1538485138-98076-5-git-send-email-jia.guo@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 4/4] vfio: enable vfio hotplug by req notifier handler X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Oct 2018 14:22:19 -0000 On 02-Oct-18 1:58 PM, Jeff Guo wrote: > When device is be hot-unplugged, the vfio kernel module will sent req > notifier to request user space to release the allocated resources at > first. After that, vfio kernel module will detect the device disappear, > and then delete the device in kernel. > > This patch aim to add req notifier processing to enable hotplug for vfio. > By enable the req notifier monitoring and register the notifier callback, > when device be hot-unplugged, the hot-unplug handler will be called to > process hotplug for vfio. > > Signed-off-by: Jeff Guo > --- > v3->v2: > change some code style and typo. > --- > +/* enable notifier (only enable req now) */ > +static int > +pci_vfio_enable_notifier(struct rte_pci_device *dev, int vfio_dev_fd) > +{ > + int ret; > + int fd = -1; > + > + /* set up an eventfd for req notifier */ > + fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); > + if (fd < 0) { > + RTE_LOG(ERR, EAL, "Cannot set up eventfd, error %i (%s)\n", > + errno, strerror(errno)); > + return -1; > + } > + > + dev->req_notifier_handler.fd = fd; > + dev->req_notifier_handler.type = RTE_INTR_HANDLE_VFIO_REQ; > + dev->req_notifier_handler.vfio_dev_fd = vfio_dev_fd; > + ret = rte_intr_callback_register(&dev->req_notifier_handler, > + pci_vfio_req_handler, > + (void *)&dev->device); > + if (ret) { > + RTE_LOG(ERR, EAL, "Fail to register req notifier handler.\n"); > + goto error; At this point (and further down as well), if we go to error, we've already modified the req_notifier_handler data. Do we need to overwrite it? Maybe just do these operations on a local struct, and then do a memcpy into dev->req_notifier_handler on success? -- Thanks, Anatoly