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 3B012A0A0B; Mon, 1 Feb 2021 17:53:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C2F9A40693; Mon, 1 Feb 2021 17:53:26 +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 6F92940687 for ; Mon, 1 Feb 2021 17:53:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612198404; 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: in-reply-to:in-reply-to:references:references; bh=ZET8KEPfOFS7CNjCTIM1MvjJu9i+4U5eWSQrjjqTmqA=; b=OVxpVlVzVv8EAcqMu4lJvjONi1C2QdGZ6732uUXLuVmN1BSZf8xnbjMACBg9IK7cH7J1VI oTQgcf7mP6hMvFYdFmXA4VN1xrhoCGmOpLLjDBz38BmLsZbwzt2HmOOWMDmBUhpaLUtr+B YKl7gndVukGQ+TpIZNP4mEI+qWZZUI8= 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-143-YPrLcRsYM3agVQXnNi-9Hg-1; Mon, 01 Feb 2021 11:53:22 -0500 X-MC-Unique: YPrLcRsYM3agVQXnNi-9Hg-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 6D72385B671; Mon, 1 Feb 2021 16:53:10 +0000 (UTC) Received: from [10.36.110.37] (unknown [10.36.110.37]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA61127C40; Mon, 1 Feb 2021 16:53:08 +0000 (UTC) To: David Marchand Cc: dev , "Wang, Yinan" , "Xia, Chenbo" , Adrian Moreno Zapata , Wei Ling , Yu Jiang References: <20210201151630.54564-1-maxime.coquelin@redhat.com> From: Maxime Coquelin Message-ID: <45148d3d-ce90-e764-4bd8-146c1071ab16@redhat.com> Date: Mon, 1 Feb 2021 17:53:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: 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-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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 2/1/21 5:32 PM, David Marchand wrote: > 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? > > I agree, I will remove the second assignment and also move this one only for primary process. Thanks, Maxime