Skip to contentSkip to conversation

/driver/bus/ifpga: fix driver probe failure handler

DPDK Applied AndyPei 4 participants 6 messages Jan 14, 2019 – Jan 18, 2019

lore
Share & tools
lore

AndyPei

author
#0 lore raw

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.

---
 drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +12 -5
index e4b7b6f..55d3abf 100644
@@ -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;
 }
 
 /*
Signature · 1 line
1.8.3.1
Acked-by
#1 lore raw
Quoted 56 lines

-----Original Message-----
From: Pei, Andy
Sent: Monday, January 14, 2019 9:41
To: [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; Pei, Andy <[email protected]>
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.

---
 drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +12 -5
index e4b7b6f..55d3abf 100644
@@ -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;
 }
 
Quoted 3 lines

/*
--
1.8.3.1

#2 lore raw
In reply to AndyPei

Hi Andy,

Quoted 8 lines

-----Original Message-----
From: Pei, Andy
Sent: Monday, January 14, 2019 9:41
To: [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Tianfei <[email protected]>; Pei, Andy <[email protected]>
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

Quoted 1 line

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

Quoted 1 line

list does not support this device, a error is returned.

an error will return

Quoted 1 line

After this patch, a device wil try to match driver in the driver list one by one

With this patch, a device will......

Quoted 5 lines

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

Quoted 3 lines

Don't need these cc, pls only Cc: [email protected]

Quoted 37 lines
---
 drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +12 -5
index e4b7b6f..55d3abf 100644
@@ -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

author
#3 lore raw

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

In reply to AndyPei

From: AndyPei <[email protected]>

In the original code, when an AFU device probe a driver, if the first driver in the driver list does not support this device or some error happens, an error is returned. With this patch, a device wil try to match driver in the driver list one by one until an appropriate driver is found. If some error happens, the error is returned. If the current driver does not support the device, just try the next driver in the list. If all the drivers in the list are tried and no driver matches, 0 is returned. Otherwise, the error code is returned.

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")
---
 drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +12 -5
index e4b7b6f..55d3abf 100644
@@ -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;
 }
 
 /*
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH v2 1/1 bus/ifpga: fix ifpga afu driver probe failure handler

From: Andy Pei <[email protected]>

In the original code, when an AFU device probe a driver, if the first driver in the driver list does not support this device or some error happens, bus probe returns an error.

With this patch, a device will try to match driver in the driver list one by one until an appropriate driver is found.

If some error happens, the error is returned. If the current driver does not support the device, just try the next driver in the list.

If all the drivers in the list are tried and no driver matches, 0 is returned. Otherwise, the error code is returned.

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")
---
 drivers/bus/ifpga/ifpga_bus.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +12 -5
index e4b7b6f50..55d3abf9f 100644
@@ -306,12 +306,19 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
 	}
 
 	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;
 }
 
 /*
Signature · 1 line
2.17.2
#5 lore raw

Re: [dpdk-stable] [PATCH v2] bus/ifpga: fix ifpga afu driver probe failure handler

18/01/2019 12:12, Ferruh Yigit:

Quoted 15 lines

From: Andy Pei <[email protected]>

In the original code, when an AFU device probe a driver, if the first driver in the driver list does not support this device or some error happens, bus probe returns an error.

With this patch, a device will try to match driver in the driver list one by one until an appropriate driver is found.

If some error happens, the error is returned. If the current driver does not support the device, just try the next driver in the list.

If all the drivers in the list are tried and no driver matches, 0 is returned. Otherwise, the error code is returned.

Quoted 6 lines
Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")

Applied, thanks