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 472EEA0A0B; Mon, 1 Feb 2021 16:16:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FA4216065F; Mon, 1 Feb 2021 16:16:56 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id C0521160654 for ; Mon, 1 Feb 2021 16:16:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612192614; 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=gnTl/iUtrwU+hXqgIRmkgkayEqapueM13Lk6avXEE14=; b=iJ3wko+1fv2lh5AACYIbNkeZrjwdwakXXAWT+G4izXcrUIY3LybrmBACNi6cAIvzdWyVhL N/3TqU/j2PGgZ6ZGDiJeX27Ti4xXFXUBgRTfz9oVIOCcGUGZl+imfeVibPFNJPm85zoo3m kAj5yMLQ+7I1BTR5rQDYxcQAcmfPeWE= 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-515-EEt2DPeaNRqf5WPXVsahLA-1; Mon, 01 Feb 2021 10:16:44 -0500 X-MC-Unique: EEt2DPeaNRqf5WPXVsahLA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E596E10151E9; Mon, 1 Feb 2021 15:16:42 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.36.110.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 298605D9E2; Mon, 1 Feb 2021 15:16:32 +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 16:16:30 +0100 Message-Id: <20210201151630.54564-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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] 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 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) { -- 2.29.2