DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment
@ 2021-02-01 20:31 Maxime Coquelin
  2021-02-02 10:03 ` David Marchand
  2021-02-02 10:32 ` Ling, WeiX
  0 siblings, 2 replies; 4+ messages in thread
From: Maxime Coquelin @ 2021-02-01 20:31 UTC (permalink / raw)
  To: dev, yinan.wang, chenbo.xia, amorenoz, david.marchand, weix.ling,
	yux.jiang
  Cc: Maxime Coquelin

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 <weix.ling@intel.com>
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment
  2021-02-01 20:31 [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment Maxime Coquelin
@ 2021-02-02 10:03 ` David Marchand
  2021-02-02 23:26   ` Ferruh Yigit
  2021-02-02 10:32 ` Ling, WeiX
  1 sibling, 1 reply; 4+ messages in thread
From: David Marchand @ 2021-02-02 10:03 UTC (permalink / raw)
  To: Maxime Coquelin
  Cc: dev, Wang, Yinan, Xia, Chenbo, Adrian Moreno Zapata, Wei Ling, Yu Jiang

On Mon, Feb 1, 2021 at 9:33 PM Maxime Coquelin
<maxime.coquelin@redhat.com> 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 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 <weix.ling@intel.com>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Reviewed-by: David Marchand <david.marchand@redhat.com>


-- 
David Marchand


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment
  2021-02-01 20:31 [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment Maxime Coquelin
  2021-02-02 10:03 ` David Marchand
@ 2021-02-02 10:32 ` Ling, WeiX
  1 sibling, 0 replies; 4+ messages in thread
From: Ling, WeiX @ 2021-02-02 10:32 UTC (permalink / raw)
  To: Maxime Coquelin, dev, Wang, Yinan, Xia, Chenbo, amorenoz,
	david.marchand, Jiang, YuX

Tested-by: Wei Ling <weix.ling@intel.com>

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Tuesday, February 2, 2021 04:32 AM
> To: dev@dpdk.org; Wang, Yinan <yinan.wang@intel.com>; Xia, Chenbo
> <chenbo.xia@intel.com>; amorenoz@redhat.com;
> david.marchand@redhat.com; Ling, WeiX <weix.ling@intel.com>; Jiang, YuX
> <yux.jiang@intel.com>
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v2] net/virtio: fix Virtio-PCI ops assignment


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment
  2021-02-02 10:03 ` David Marchand
@ 2021-02-02 23:26   ` Ferruh Yigit
  0 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2021-02-02 23:26 UTC (permalink / raw)
  To: dev, Maxime Coquelin; +Cc: David Marchand, Wei Ling

On 2/2/2021 10:03 AM, David Marchand wrote:
> On Mon, Feb 1, 2021 at 9:33 PM Maxime Coquelin
> <maxime.coquelin@redhat.com> 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 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 <weix.ling@intel.com>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Reviewed-by: David Marchand <david.marchand@redhat.com>
> 
> Tested-by: Wei Ling <weix.ling@intel.com>
 >

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-02 23:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 20:31 [dpdk-dev] [PATCH v2] net/virtio: fix Virtio-PCI ops assignment Maxime Coquelin
2021-02-02 10:03 ` David Marchand
2021-02-02 23:26   ` Ferruh Yigit
2021-02-02 10:32 ` Ling, WeiX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).