From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by dpdk.org (Postfix) with ESMTP id 9C6C2FEB; Wed, 31 Oct 2018 19:40:06 +0100 (CET) Received: by mail-wr1-f68.google.com with SMTP id u1-v6so17662982wrn.0; Wed, 31 Oct 2018 11:40:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sV/fdltn3K+Syt8GMuEP7rhL35P5Ajz4wka9sQSSruA=; b=mEFi/qACTVabM5bcWujkH6Ezoz3Z8EloWUgpxe4rLOtRW7A/LGE1gIqs8auIFLDaOD Gi6/hfF2qCXuTE2VmoIYHDpvq9OhFStuT+lDsN2a5lbApiP1e/Tp0/jpnX1FUWKkWJhq sQheCs45Dkqskx1hNdiBpFbHQhSnKmN7lOaFJE+i3rdA4Th95jMBci0lMgh2vuABtl/7 rFxKeJ1pDtYYtL2v+3su2fGFjJsACQ5QLihyVri+ncoBb1AYeQnkuf14XbgpJEVIcJTZ 83TfYW9qZRmYr1G3RQ9v69QyuTBDO8rBFTjtr8EnNdkyfuZcAhoUR1MT9/ENbFKVzKlf /iBQ== X-Gm-Message-State: AGRZ1gIzsOrsXLTZVsHMWpbDVNJrLGdE7K64G6BqZg/wAoObWA2v+M1M +J5Yu3g8pHqLDUaP35Hqa5qr3tOU X-Google-Smtp-Source: AJdET5c777bnwDhNBW26V7Uov/9OKCjn8L/nfmVhSIJilwNraHXfBa8x0UmdUIUmoFj6QIBj5e+2dw== X-Received: by 2002:adf:edcf:: with SMTP id v15-v6mr3684237wro.182.1541011205637; Wed, 31 Oct 2018 11:40:05 -0700 (PDT) Received: from localhost ([2a01:4b00:f419:6f00:8361:8946:ba2b:d556]) by smtp.gmail.com with ESMTPSA id m141-v6sm131573wmd.14.2018.10.31.11.40.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 11:40:04 -0700 (PDT) From: Luca Boccassi To: dev@dpdk.org Cc: yongwang@vmware.com, 3chas3@gmail.com, bruce.richardson@intel.com, anatoly.burakov@intel.com, thomas@monjalon.net, llouis@vmware.com, Luca Boccassi , stable@dpdk.org, Brian Russell Date: Wed, 31 Oct 2018 18:39:43 +0000 Message-Id: <20181031183945.29509-1-bluca@debian.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20180816135032.28283-1-bluca@debian.org> References: <20180816135032.28283-1-bluca@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 1/3] net/virtio: register/unregister intr handler on start/stop 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: Wed, 31 Oct 2018 18:40:06 -0000 Register and unregister the virtio interrupt handler when the device is started and stopped. This allows a virtio device to be hotplugged or unplugged. Fixes: c1f86306a026 ("virtio: add new driver") Cc: stable@dpdk.org Signed-off-by: Brian Russell Signed-off-by: Luca Boccassi Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_ethdev.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 10a7e3fcc..da8717726 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1679,11 +1679,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) if (ret < 0) goto out; - /* Setup interrupt callback */ - if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) - rte_intr_callback_register(eth_dev->intr_handle, - virtio_interrupt_handler, eth_dev); - return 0; out: @@ -1706,11 +1701,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) eth_dev->tx_pkt_burst = NULL; eth_dev->rx_pkt_burst = NULL; - /* reset interrupt callback */ - if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) - rte_intr_callback_unregister(eth_dev->intr_handle, - virtio_interrupt_handler, - eth_dev); if (eth_dev->device) rte_pci_unmap_device(RTE_ETH_DEV_TO_PCI(eth_dev)); @@ -1969,6 +1959,12 @@ virtio_dev_start(struct rte_eth_dev *dev) dev->data->dev_conf.intr_conf.rxq) { virtio_intr_disable(dev); + /* Setup interrupt callback */ + if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) + rte_intr_callback_register(dev->intr_handle, + virtio_interrupt_handler, + dev); + if (virtio_intr_enable(dev) < 0) { PMD_DRV_LOG(ERR, "interrupt enable failed"); return -EIO; @@ -2078,9 +2074,17 @@ virtio_dev_stop(struct rte_eth_dev *dev) PMD_INIT_LOG(DEBUG, "stop"); rte_spinlock_lock(&hw->state_lock); - if (intr_conf->lsc || intr_conf->rxq) + if (intr_conf->lsc || intr_conf->rxq) { virtio_intr_disable(dev); + /* Reset interrupt callback */ + if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) { + rte_intr_callback_unregister(dev->intr_handle, + virtio_interrupt_handler, + dev); + } + } + hw->started = 0; memset(&link, 0, sizeof(link)); rte_eth_linkstatus_set(dev, &link); -- 2.19.1