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 AEEBFA0A0B; Mon, 1 Feb 2021 21:33:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B3E4160654; Mon, 1 Feb 2021 21:33:56 +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 EC06540693 for ; Mon, 1 Feb 2021 21:33:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612211634; 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: content-transfer-encoding:content-transfer-encoding; bh=cBAgju6+dP+yregAAlZmY1c+FeUvl56YmAiOj3HY/VU=; b=DjiwHpjfYsHXJPDmCmrnIwv9EFIYvFf8Hph4n9hO4GPxYreHlYjMZouEQbRDH0GVRyrAMK 8EY6FTy73qNqIijCt0JnZeYX+oA+JnhiGOgbu139YgSNuUJiVbBzE7TNpxh9V14YY40CT7 8w0W/5p0mPB1/5M1sL16tHnUxkGgM+E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-O6EvutaXPWSZaZhQMn-USQ-1; Mon, 01 Feb 2021 15:33:49 -0500 X-MC-Unique: O6EvutaXPWSZaZhQMn-USQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9A42D107ACE4; Mon, 1 Feb 2021 20:33:47 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 261E91975E; Mon, 1 Feb 2021 20:33:39 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, yinan.wang@intel.com, chenbo.xia@intel.com, amorenoz@redhat.com, david.marchand@redhat.com, weix.ling@intel.com, yux.jiang@intel.com Cc: Maxime Coquelin Date: Mon, 1 Feb 2021 21:31:38 +0100 Message-Id: <20210201203138.87301-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Subject: [dpdk-dev] [PATCH v2] 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" 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 ensures port ID assignment is done at early primary process probe time, before it is 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_ethdev.c | 1 - drivers/net/virtio/virtio_pci_ethdev.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e030fe31f4..333a5243a9 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1838,7 +1838,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) return -ENOMEM; } - hw->port_id = eth_dev->data->port_id; rte_spinlock_init(&hw->state_lock); /* reset device and negotiate default features */ diff --git a/drivers/net/virtio/virtio_pci_ethdev.c b/drivers/net/virtio/virtio_pci_ethdev.c index 1b818c4565..3bb5c6268b 100644 --- a/drivers/net/virtio/virtio_pci_ethdev.c +++ b/drivers/net/virtio/virtio_pci_ethdev.c @@ -77,6 +77,7 @@ eth_virtio_pci_init(struct rte_eth_dev *eth_dev) int ret; if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + hw->port_id = eth_dev->data->port_id; ret = vtpci_init(RTE_ETH_DEV_TO_PCI(eth_dev), dev); if (ret) { PMD_INIT_LOG(ERR, "Failed to init PCI device\n"); -- 2.29.2