From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 059E9A0A0B; Mon, 1 Feb 2021 17:32:28 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9011F40693; Mon, 1 Feb 2021 17:32:28 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mails.dpdk.org (Postfix) with ESMTP id C385240687 for ; Mon, 1 Feb 2021 17:32:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612197147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=BxC5oDTerhAC7aU6ZRs04wuhlcszDIzXs8icEv9K7Mc=; b=KMa9SkQvu7IY0HgcqwnJgtF26omtibsBI06gJcAg+DWT8eo9pExW44O8fOVPYPS8PfpPQe /w5E3MYiO8x8G3tll2uVArD3f3yanAt4eyS0UOCTmvqOJcOBGQlvWPJuWdySsS39ePKq9r QG19BDgGbhBhsfKI87w4K0QQH4mVjss= Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-pvI5HAqEPPOC6JLvyKf49A-1; Mon, 01 Feb 2021 11:32:24 -0500 X-MC-Unique: pvI5HAqEPPOC6JLvyKf49A-1 Received: by mail-vs1-f72.google.com with SMTP id j85so1792047vsd.0 for ; Mon, 01 Feb 2021 08:32:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=BxC5oDTerhAC7aU6ZRs04wuhlcszDIzXs8icEv9K7Mc=; b=kWpjHRBZTMchzDaAArUL5fMfxOMONZ7+qN4IANLLfKSJP/hYQn3Jj1zjx3kWzvg0dT xOOZ44UabTMM4xy+MU2l96ZH7PgYBNUH/BTsmKiGRzdifnItqX1cr794gkHuiFL9Oz0h sjDF7KDpfOj/sRCQmnp/oY3eXQ5czQP4QvcNEGGIPcRJdO2yE6v1Chg5OX7jbCxoJCHv 8RgUlkQRWDl82RH6inYlzsZD8E85RI6aorf2dpgDs44dx3uVarm5OnUh626LNzQg/WV4 tU2KQfcI7F+QJyRJqNyib0I2ERZPhUzZG8U71E4X3oxqhI+qlQMlVnctNP7IqH/OzAI0 JubA== X-Gm-Message-State: AOAM5332Dm9trtz+ur/P4ktfkMa79kgy4+/1O4VTpeT9VIuB3qiam9bl +iisleHMk7peHVnbvyz8Q6PfvyStYqLeeqqinLKdLoCo1H4WBsyh9F75cYOfqviwlHFqHOz1ZRd 1w496pYdfmF9d7ufxGXo= X-Received: by 2002:a05:6102:3136:: with SMTP id f22mr10211960vsh.17.1612197144115; Mon, 01 Feb 2021 08:32:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyPdPVngcd6MvlAJC/rpPOPZb0k0o26c4X9qL/J+eavTYOUikpDl8sSyvNXNfz/iNo27bu4EMkhIDSURaSBUE= X-Received: by 2002:a05:6102:3136:: with SMTP id f22mr10211939vsh.17.1612197143902; Mon, 01 Feb 2021 08:32:23 -0800 (PST) MIME-Version: 1.0 References: <20210201151630.54564-1-maxime.coquelin@redhat.com> In-Reply-To: <20210201151630.54564-1-maxime.coquelin@redhat.com> From: David Marchand Date: Mon, 1 Feb 2021 17:32:12 +0100 Message-ID: To: Maxime Coquelin Cc: dev , "Wang, Yinan" , "Xia, Chenbo" , Adrian Moreno Zapata , Wei Ling , Yu Jiang Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH] net/virtio: fix Virtio-PCI ops assignment X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list 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 Mon, Feb 1, 2021 at 4:16 PM Maxime Coquelin wrote: > > VIRTIO_OPS() macro relies on the port ID stored in the > virtio_hw struct. Issue is that it is used before being > assigned at init time. It results in all devices setting > ops on port ID 0, causing crash later when calling ops > for port IDs other than 0. > > This patch ensure port ID assignment is done before being > used. > > Bugzilla ID: 631 > Fixes: 512e27eeb743 ("net/virtio: move PCI specific dev init to PCI ethdev init") > > Reported-by: Wei Ling > Signed-off-by: Maxime Coquelin > --- > drivers/net/virtio/virtio_pci_ethdev.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c > index 1b818c4565..547cb8ffa0 100644 > --- a/drivers/net/virtio/virtio_pci_ethdev.c > +++ b/drivers/net/virtio/virtio_pci_ethdev.c > @@ -76,6 +76,9 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev) > struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev); > int ret; > > + /* Required to assign Virtio ops */ > + hw->port_id = eth_dev->data->port_id; > + > if (rte_eal_process_type() == RTE_PROC_PRIMARY) { > ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), dev); > if (ret) { We probably don't need to set hw->port-id in eth_virtio_dev_init anymore. And I would only set it in the primary process context, letting the secondary pick what has been chosen by the primary? -- David Marchand