From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: Re: [PATCH 1/2] virtio: initialize iopl when device is initialized Date: Wed, 29 Jul 2015 19:26:17 +0200 Message-ID: <3368758.BASS8qfG8B@xps13> References: <1425602726-26538-1-git-send-email-stephen@networkplumber.org> <20150306082057.5c505f54@urahara> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: dev@dpdk.org To: Stephen Hemminger Return-path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by dpdk.org (Postfix) with ESMTP id 5A86C5680 for ; Wed, 29 Jul 2015 19:27:32 +0200 (CEST) Received: by wicmv11 with SMTP id mv11so228029297wic.0 for ; Wed, 29 Jul 2015 10:27:32 -0700 (PDT) In-Reply-To: <20150306082057.5c505f54@urahara> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2015-03-06 08:20, Stephen Hemminger: > The issue is that virtio has no place it can do iopl() and have the IRQ thread > work. It only shows up on real code where application is daemon, not in a toy > demo or test application. > > Right now: > gcc start > rte_virtio_pmd_init > iopl > main > daemon > fork > fork > Process is now child of init not original process > > rte_eal_init > fork (pthread) for irq thread > irq thread > (no iopl permssion) > program start > rte_pmd_virtio_configure This call tree is wrong. Below is the right (and more complete) one: gcc start driver constructor rte_eal_driver_register (if .a) main rte_eal_init eal_parse_args rte_eal_pci_init rte_eal_memory_init rte_eal_intr_init pthread_create eal_intr_thread_main eal_intr_handle_interrupts eal_intr_process_interrupts virtio_interrupt_handler dlopen (if .so) driver constructor rte_eal_driver_register rte_eal_dev_init driver->init rte_virtio_pmd_init rte_eal_iopl_init rte_eth_driver_register pthread_create rte_eal_pci_probe driver->devinit rte_eth_dev_init rte_eth_dev_allocate eth_drv->eth_dev_init eth_virtio_dev_init virtio_resource_init > So the only place where iopl() can be done in the proper context > so that the IRQ (and other helper threads in future) have the correct > permissions is in eal_init. No there are 2 other possible solutions: 1) Move rte_eal_intr_init() after rte_eal_dev_init(). 2) Move dlopen() before rte_eal_intr_init() and call iopl in the constructor. With the second solution, we must also keep an iopl call in rte_virtio_pmd_init() to return an error if iopl fails. The second solution was proposed in the series sent by David: http://dpdk.org/ml/archives/dev/2015-March/014931.html http://dpdk.org/ml/archives/dev/2015-March/014932.html