[DPDK] /driver/bus/ifpga: fix driver probe failure handler

Message ID 1547430043-62302-1-git-send-email-andy.pei@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [DPDK] /driver/bus/ifpga: fix driver probe failure handler |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Pei, Andy Jan. 14, 2019, 1:40 a.m. UTC
  In the original code, when a device probe a driver,
if the driver in the driver list does not support
this device, a error is returned.
After this patch, a device wil try to match driver
in the driver list one by one until an appropriate
driver is found. If the current driver does not
support the device or some error happens, just try
the next driver in the list.
If all the drivers in the list are tried and no
driver matches. 0 is returned.

fixes: 05fa3d4a6539
cc: rosen.xu@intel.com
cc: tianfei.zhang@intel.com
cc: andy.pei@intel.com

Signed-off-by: AndyPei <andy.pei@intel.com>
---
 drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
  

Comments

Xu, Rosen Jan. 14, 2019, 5:14 a.m. UTC | #1
> -----Original Message-----
> From: Pei, Andy
> Sent: Monday, January 14, 2019 9:41
> To: dev@dpdk.org
> Cc: Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei
> <tianfei.zhang@intel.com>; Pei, Andy <andy.pei@intel.com>
> Subject: [DPDK] /driver/bus/ifpga: fix driver probe failure handler
> 
> In the original code, when a device probe a driver, if the driver in the driver
> list does not support this device, a error is returned.
> After this patch, a device wil try to match driver in the driver list one by one
> until an appropriate driver is found. If the current driver does not support
> the device or some error happens, just try the next driver in the list.
> If all the drivers in the list are tried and no driver matches. 0 is returned.
> 
> fixes: 05fa3d4a6539
> cc: rosen.xu@intel.com
> cc: tianfei.zhang@intel.com
> cc: andy.pei@intel.com
> 
> Signed-off-by: AndyPei <andy.pei@intel.com>
> ---
>  drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
> index e4b7b6f..55d3abf 100644
> --- a/drivers/bus/ifpga/ifpga_bus.c
> +++ b/drivers/bus/ifpga/ifpga_bus.c
> @@ -306,12 +306,19 @@ void rte_ifpga_driver_unregister(struct
> rte_afu_driver *driver)
>  	}
> 
>  	TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
> -		if (ifpga_probe_one_driver(drv, afu_dev)) {
> -			ret = -1;
> -			break;
> -		}
> +		ret = ifpga_probe_one_driver(drv, afu_dev);
> +		if (ret < 0)
> +			/* negative value is an error */
> +			return ret;
> +		if (ret > 0)
> +			/* positive value means driver doesn't support it */
> +			continue;
> +		return 0;
>  	}
> -	return ret;
> +	if ((ret > 0) && (afu_dev->driver == NULL))
> +		return 0;
> +	else
> +		return ret;
>  }
> 
>  /*
> --
> 1.8.3.1
Acked-by: Rosen Xu <rosen.xu@intel.com>
  
Xu, Rosen Jan. 15, 2019, 8:38 a.m. UTC | #2
Hi Andy,

> -----Original Message-----
> From: Pei, Andy
> Sent: Monday, January 14, 2019 9:41
> To: dev@dpdk.org
> Cc: Xu, Rosen <rosen.xu@intel.com>; Zhang, Tianfei
> <tianfei.zhang@intel.com>; Pei, Andy <andy.pei@intel.com>
> Subject: [DPDK] /driver/bus/ifpga: fix driver probe failure handler
> 
The subject should be started with bus/ifpga.
I think the tital should be fix ifpga afu driver probe failure handler

> In the original code, when a device probe a driver, if the driver in the driver
In the original code, when a AFU device is scanned, if its driver in the driver

> list does not support this device, a error is returned.
an error will return

> After this patch, a device wil try to match driver in the driver list one by one
With this patch, a device will......
> until an appropriate driver is found. If the current driver does not support
> the device or some error happens, just try the next driver in the list.
> If all the drivers in the list are tried and no driver matches. 0 is returned.
> 
> fixes: 05fa3d4a6539

Pls use git fixline 05fa3d4a6539 to generate the full fixline

> cc: rosen.xu@intel.com
> cc: tianfei.zhang@intel.com
> cc: andy.pei@intel.com
Don't need these cc, pls only Cc: stable@dpdk.org

> Signed-off-by: AndyPei <andy.pei@intel.com>
> ---
>  drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
> index e4b7b6f..55d3abf 100644
> --- a/drivers/bus/ifpga/ifpga_bus.c
> +++ b/drivers/bus/ifpga/ifpga_bus.c
> @@ -306,12 +306,19 @@ void rte_ifpga_driver_unregister(struct
> rte_afu_driver *driver)
>  	}
> 
>  	TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
> -		if (ifpga_probe_one_driver(drv, afu_dev)) {
> -			ret = -1;
> -			break;
> -		}
> +		ret = ifpga_probe_one_driver(drv, afu_dev);
> +		if (ret < 0)
> +			/* negative value is an error */
> +			return ret;
> +		if (ret > 0)
> +			/* positive value means driver doesn't support it */
> +			continue;
> +		return 0;
>  	}
> -	return ret;
> +	if ((ret > 0) && (afu_dev->driver == NULL))
> +		return 0;
> +	else
> +		return ret;
>  }
> 
>  /*
> --
> 1.8.3.1
  

Patch

diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c
index e4b7b6f..55d3abf 100644
--- a/drivers/bus/ifpga/ifpga_bus.c
+++ b/drivers/bus/ifpga/ifpga_bus.c
@@ -306,12 +306,19 @@  void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
 	}
 
 	TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) {
-		if (ifpga_probe_one_driver(drv, afu_dev)) {
-			ret = -1;
-			break;
-		}
+		ret = ifpga_probe_one_driver(drv, afu_dev);
+		if (ret < 0)
+			/* negative value is an error */
+			return ret;
+		if (ret > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
 	}
-	return ret;
+	if ((ret > 0) && (afu_dev->driver == NULL))
+		return 0;
+	else
+		return ret;
 }
 
 /*