net/ifc: do not notify before HW ready

Message ID 20180910110531.138449-1-xiao.w.wang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series net/ifc: do not notify before HW ready |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xiao Wang Sept. 10, 2018, 11:05 a.m. UTC
  Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
---
 drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Xiao Wang Sept. 13, 2018, 7:23 a.m. UTC | #1
Hi Xiaolong,

> -----Original Message-----
> From: Ye, Xiaolong
> Sent: Thursday, September 13, 2018 8:55 PM
> To: Wang, Xiao W <xiao.w.wang@intel.com>
> Cc: Bie, Tiwei <tiwei.bie@intel.com>; dev@dpdk.org
> Subject: Re: [PATCH] net/ifc: do not notify before HW ready
> 
> Hi, Xiao
> 
> On 09/10, Xiao Wang wrote:
> >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
> 
> Thanks,
> Xiaolong
> >
> >Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
> >---
> > drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> >diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c
> >index 3c5430dc0..7d3085d8d 100644
> >--- a/drivers/net/ifc/ifcvf_vdpa.c
> >+++ b/drivers/net/ifc/ifcvf_vdpa.c
> >@@ -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
> >
  
Xiaolong Ye Sept. 13, 2018, 12:55 p.m. UTC | #2
Hi, Xiao

On 09/10, Xiao Wang wrote:
>Fixes: a3f8150eac6d ("net/ifcvf: add ifcvf vDPA driver")

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

Thanks,
Xiaolong
>
>Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
>---
> drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c
>index 3c5430dc0..7d3085d8d 100644
>--- a/drivers/net/ifc/ifcvf_vdpa.c
>+++ b/drivers/net/ifc/ifcvf_vdpa.c
>@@ -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
>
  
Xiaolong Ye Sept. 13, 2018, 8:25 p.m. UTC | #3
On 09/13, Wang, Xiao W wrote:
>Hi Xiaolong,
>
>> -----Original Message-----
>> From: Ye, Xiaolong
>> Sent: Thursday, September 13, 2018 8:55 PM
>> To: Wang, Xiao W <xiao.w.wang@intel.com>
>> Cc: Bie, Tiwei <tiwei.bie@intel.com>; dev@dpdk.org
>> Subject: Re: [PATCH] net/ifc: do not notify before HW ready
>> 
>> Hi, Xiao
>> 
>> On 09/10, Xiao Wang wrote:
>> >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
>Would add the description in the commit log in v2.
>
>Thanks for the comment,
>Xiao
>> 
>> Thanks,
>> Xiaolong
>> >
>> >Signed-off-by: Xiao Wang <xiao.w.wang@intel.com>
>> >---
>> > drivers/net/ifc/ifcvf_vdpa.c | 8 ++++----
>> > 1 file changed, 4 insertions(+), 4 deletions(-)
>> >
>> >diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c
>> >index 3c5430dc0..7d3085d8d 100644
>> >--- a/drivers/net/ifc/ifcvf_vdpa.c
>> >+++ b/drivers/net/ifc/ifcvf_vdpa.c
>> >@@ -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
>> >
  

Patch

diff --git a/drivers/net/ifc/ifcvf_vdpa.c b/drivers/net/ifc/ifcvf_vdpa.c
index 3c5430dc0..7d3085d8d 100644
--- a/drivers/net/ifc/ifcvf_vdpa.c
+++ b/drivers/net/ifc/ifcvf_vdpa.c
@@ -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;