Skip to contentSkip to conversation

net/ifc: do not notify before HW ready

PATCH Superseded Xiao Wang 5 participants 10 messages Sep 10, 2018 – Sep 26, 2018 Network drivers

lore
Share & tools
lore

Xiao Wang

author
#0 lore raw

PATCH 1/1 net/ifc: do not notify before HW ready

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")
---
 drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -4
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
Signature · 1 line
2.15.1
#1 lore raw

Hi, Xiao

Quoted 1 line · Xiao Wang
Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Could you help describe what problem is without this fix in commit log?

Thanks,
Xiaolong

Quoted 42 lines

---
drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -4
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
Signature · 1 line
2.15.1
#2 lore raw

Hi Xiaolong,

Quoted 7 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Thursday, September 13, 2018 8:55 PM
To: Wang, Xiao W <[email protected]>
Cc: Bie, Tiwei <[email protected]>; [email protected]
Subject: Re: [PATCH] net/ifc: do not notify before HW ready

Quoted 6 lines

Hi, Xiao

Quoted 1 line · Xiao Wang
Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Could you help describe what problem is without this fix in commit log?

Generally a driver should finish all the device configurations first then notify the HW for data processing.
Without this fix, the potential problems are:
1. If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the vDPA relay thread kicks it, a bad DMA request may happen.
2. The notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function. If there's really a kick relay before vdpa_ifcvf_start finishes, a null addr is accessed.

Would add the description in the commit log in v2.

Thanks for the comment,
Xiao

Quoted 45 lines

Thanks,
Xiaolong

Quoted 42 lines

---
drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -5
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
--

2.15.1

#3 lore raw
Quoted 12 lines · Xiao W

Hi Xiaolong,

Quoted 10 lines

-----Original Message-----
From: Ye, Xiaolong
Sent: Thursday, September 13, 2018 8:55 PM
To: Wang, Xiao W <[email protected]>
Cc: Bie, Tiwei <[email protected]>; [email protected]
Subject: Re: [PATCH] net/ifc: do not notify before HW ready

Hi, Xiao

On 09/10, Xiao Wang wrote:

Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Could you help describe what problem is without this fix in commit log?

Generally a driver should finish all the device configurations first then notify the HW for data processing.
Without this fix, the potential problems are:
1. If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the vDPA relay thread kicks it, a bad DMA request may happen.
2. The notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function. If there's really a kick relay before vdpa_ifcvf_start finishes, a null addr is accessed.

Thanks for the explanation.

Thanks,
Xiaolong

Quoted 49 lines

Would add the description in the commit log in v2.

Thanks for the comment,
Xiao

Quoted 45 lines

Thanks,
Xiaolong

Quoted 42 lines

---
drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -5
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
--

2.15.1

author
#4 lore raw

PATCH v2 1/1 net/ifc: do not notify before HW ready

In reply to Xiao Wang

If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the relay thread kicks it before HW is properly re-configured, a bad DMA request may happen.

Besides, the notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function, if a kick relay happens before vdpa_ifcvf_start finishes, a null addr is accessed.

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

---
v2:
* Add description for the fix in the commit log.

---
 drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -4
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
Signature · 1 line
2.15.1
Reviewed-by on v2 1/1
#5 lore raw

Looks good to me.

Thanks,
Xiaolong

Quoted 54 lines · Xiao Wang

If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the relay thread kicks it before HW is properly re-configured, a bad DMA request may happen.

Besides, the notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function, if a kick relay happens before vdpa_ifcvf_start finishes, a null addr is accessed.

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

---
v2:
* Add description for the fix in the commit log.
---
drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -4
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
Signature · 1 line
2.15.1
Applied
#6 lore raw
Quoted 9 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Ye Xiaolong
Sent: Friday, September 14, 2018 4:42 PM
To: Wang, Xiao W <[email protected]>
Cc: Bie, Tiwei <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/ifc: do not notify before HW ready

Quoted 19 lines

Looks good to me.

Thanks,
Xiaolong

Quoted 11 lines · Xiao Wang

If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the relay thread kicks it before HW is properly re-configured, a bad DMA request may happen.

Besides, the notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function, if a kick relay happens before vdpa_ifcvf_start finishes, a null addr is accessed.

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Applied to dpdk-next-net-intel.

Thanks
Qi

#7 lore raw
In reply to Xiao Wang
Quoted 10 lines · Xiao Wang

If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the relay thread kicks it before HW is properly re-configured, a bad DMA request may happen.

Besides, the notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function, if a kick relay happens before vdpa_ifcvf_start finishes, a null addr is accessed.

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Looks like this should be in stable branch too. Can you confirm?

Quoted 42 lines

---
v2:
* Add description for the fix in the commit log.

---
 drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ifc/ifcvf_vdpa.c +4 -4
index 3c5430dc0..7d3085d8d 100644
@@ -503,11 +503,11 @@ update_datapath(struct ifcvf_internal *internal)
 		if (ret)
 			goto err;
 
-		ret = setup_notify_relay(internal);
+		ret = vdpa_ifcvf_start(internal);
 		if (ret)
 			goto err;
 
-		ret = vdpa_ifcvf_start(internal);
+		ret = setup_notify_relay(internal);
 		if (ret)
 			goto err;
 
@@ -515,12 +515,12 @@ update_datapath(struct ifcvf_internal *internal)
 	} else if (rte_atomic32_read(&internal->running) &&
 		   (!rte_atomic32_read(&internal->started) ||
 		    !rte_atomic32_read(&internal->dev_attached))) {
-		vdpa_ifcvf_stop(internal);
-
 		ret = unset_notify_relay(internal);
 		if (ret)
 			goto err;
 
+		vdpa_ifcvf_stop(internal);
+
 		ret = vdpa_disable_vfio_intr(internal);
 		if (ret)
 			goto err;
#8 lore raw

Hi,

Quoted 13 lines

-----Original Message-----
From: Kevin Traynor [mailto:[email protected]]
Sent: Wednesday, September 26, 2018 1:16 AM
To: Wang, Xiao W <[email protected]>
Cc: Ye, Xiaolong <[email protected]>; Bie, Tiwei <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/ifc: do not notify before HW ready

Quoted 4 lines · Xiao Wang

If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the relay thread kicks it before HW is properly re-configured, a bad DMA request may happen.

Quoted 8 lines
Quoted 6 lines

Besides, the notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function, if a kick relay happens before vdpa_ifcvf_start finishes, a null addr is accessed.

Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Looks like this should be in stable branch too. Can you confirm?

Yes, they should go also into stable branch, thanks for the notice.

BRs,
Xiao

#9 lore raw
Quoted 19 lines · Xiao W

Hi,

Quoted 17 lines

-----Original Message-----
From: Kevin Traynor [mailto:[email protected]]
Sent: Wednesday, September 26, 2018 1:16 AM
To: Wang, Xiao W <[email protected]>
Cc: Ye, Xiaolong <[email protected]>; Bie, Tiwei <[email protected]>; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2] net/ifc: do not notify before HW ready

Quoted 8 lines · Xiao Wang

If the device is not clearly reset by the previous driver and holds some invalid ring addr, and the relay thread kicks it before HW is properly re-configured, a bad DMA request may happen.

Besides, the notify_addr which is used by the relay thread is set in the vdpa_ifcvf_start function, if a kick relay happens before vdpa_ifcvf_start finishes, a null addr is accessed.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Looks like this should be in stable branch too. Can you confirm?

Yes, they should go also into stable branch, thanks for the notice.

"Cc: [email protected]" already has been added while merging next-net Commit c5ea24905585 ("net/ifc: do not notify before HW ready")

Thanks for checking.