From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Burakov, Anatoly" Subject: Re: [PATCH v3 4/4] vfio: enable vfio hotplug by req notifier handler Date: Tue, 2 Oct 2018 15:15:00 +0100 Message-ID: <628bc5ca-de09-0b54-8e1a-c0742ddb6890@intel.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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: jblunck@infradead.org, shreyansh.jain@nxp.com, dev@dpdk.org, helin.zhang@intel.com, jerin.jacob@caviumnetworks.com 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 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) In-Reply-To: <1538485138-98076-5-git-send-email-jia.guo@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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