linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] bus: fsl-mc: Make remove function return void
@ 2023-03-10 22:41 Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 1/6] bus: fsl-mc: Only warn once about errors on device unbind Uwe Kleine-König
                   ` (8 more replies)
  0 siblings, 9 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor, Roy Pledge, Li Yang,
	Horia Geantă,
	Pankaj Gupta, Gaurav Jain, Herbert Xu, David S. Miller,
	Vinod Koul, Ioana Ciornei, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Yangbo Lu, Diana Craciun, Alex Williamson,
	Richard Cochran
  Cc: kernel, linux-kernel, linuxppc-dev, linux-arm-kernel,
	linux-crypto, dmaengine, netdev, kvm

Hello,

many bus remove functions return an integer which is a historic
misdesign that makes driver authors assume that there is some kind of
error handling in the upper layers. This is wrong however and returning
and error code only yields an error message.

This series improves the fsl-mc bus by changing the remove callback to
return no value instead. As a preparation all drivers are changed to
return zero before so that they don't trigger the error message.

Best regards
Uwe

Uwe Kleine-König (6):
  bus: fsl-mc: Only warn once about errors on device unbind
  bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove()
  bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong
    condition
  bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  soc: fsl: dpio: Suppress duplicated error reporting on device remove
  bus: fsl-mc: Make remove function return void

 drivers/bus/fsl-mc/dprc-driver.c              | 12 ++++-----
 drivers/bus/fsl-mc/fsl-mc-allocator.c         | 27 ++++++++++---------
 drivers/bus/fsl-mc/fsl-mc-bus.c               |  7 +----
 drivers/crypto/caam/caamalg_qi2.c             |  4 +--
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c       |  4 +--
 .../net/ethernet/freescale/dpaa2/dpaa2-eth.c  |  4 +--
 .../net/ethernet/freescale/dpaa2/dpaa2-ptp.c  |  4 +--
 .../ethernet/freescale/dpaa2/dpaa2-switch.c   |  4 +--
 drivers/soc/fsl/dpio/dpio-driver.c            |  8 +-----
 drivers/vfio/fsl-mc/vfio_fsl_mc.c             |  3 +--
 include/linux/fsl/mc.h                        |  2 +-
 11 files changed, 28 insertions(+), 51 deletions(-)


base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
-- 
2.39.1


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

* [PATCH 1/6] bus: fsl-mc: Only warn once about errors on device unbind
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
@ 2023-03-10 22:41 ` Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 2/6] bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove() Uwe Kleine-König
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor; +Cc: kernel, linux-kernel

If a platform driver's remove function returns an error code, this
results in a (generic and little helpful) error message. Otherwise the
value is ignored.

As fsl_mc_driver_remove() already emit an error message, return 0 also
in the error case. The only effect is to suppress the device core's
error message.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 36cb091a33b4..1531e6101fb1 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -457,10 +457,8 @@ static int fsl_mc_driver_remove(struct device *dev)
 	int error;
 
 	error = mc_drv->remove(mc_dev);
-	if (error < 0) {
+	if (error < 0)
 		dev_err(dev, "%s failed: %d\n", __func__, error);
-		return error;
-	}
 
 	return 0;
 }
-- 
2.39.1


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

* [PATCH 2/6] bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove()
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 1/6] bus: fsl-mc: Only warn once about errors on device unbind Uwe Kleine-König
@ 2023-03-10 22:41 ` Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 3/6] bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong condition Uwe Kleine-König
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor; +Cc: kernel, linux-kernel

The error message emitted in fsl_mc_driver_remove() is very generic.
Replace it by a message that mentions the reason for the failure.

Returning zero instead of a negative value has no side effect apart from
suppressing the generic error message.

The first if condition in dprc_remove() can never be true, as this would
prevent successful probing of the device and then .remove wasn't called.
So this can just be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/fsl-mc/dprc-driver.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index 4c84be378bf2..ef4f43f67b80 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -839,11 +839,10 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
 {
 	struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 
-	if (!is_fsl_mc_bus_dprc(mc_dev))
-		return -EINVAL;
-
-	if (!mc_bus->irq_resources)
-		return -EINVAL;
+	if (!mc_bus->irq_resources) {
+		dev_err(&mc_dev->dev, "No irq resources, so unbinding the device failed\n");
+		return 0;
+	}
 
 	if (dev_get_msi_domain(&mc_dev->dev))
 		dprc_teardown_irq(mc_dev);
-- 
2.39.1


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

* [PATCH 3/6] bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong condition
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 1/6] bus: fsl-mc: Only warn once about errors on device unbind Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 2/6] bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove() Uwe Kleine-König
@ 2023-03-10 22:41 ` Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting Uwe Kleine-König
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor; +Cc: kernel, linux-kernel

If fsl_mc_is_allocatable(mc_dev) evaluates to false, the driver won't
have bound to that device and then fsl_mc_allocator_remove() is never
called for that device. fsl_mc_allocator_remove() is the only caller of
fsl_mc_resource_pool_remove_device(), so the same check can be removed
from there.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/fsl-mc/fsl-mc-allocator.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index dced427ca8ba..e60faf8edaa1 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -103,9 +103,6 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
 	struct fsl_mc_resource *resource;
 	int error = -EINVAL;
 
-	if (!fsl_mc_is_allocatable(mc_dev))
-		goto out;
-
 	resource = mc_dev->resource;
 	if (!resource || resource->data != mc_dev)
 		goto out;
@@ -613,9 +610,6 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
 {
 	int error;
 
-	if (!fsl_mc_is_allocatable(mc_dev))
-		return -EINVAL;
-
 	if (mc_dev->resource) {
 		error = fsl_mc_resource_pool_remove_device(mc_dev);
 		if (error < 0)
-- 
2.39.1


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

* [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (2 preceding siblings ...)
  2023-03-10 22:41 ` [PATCH 3/6] bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong condition Uwe Kleine-König
@ 2023-03-10 22:41 ` Uwe Kleine-König
  2023-06-01 15:41   ` Nathan Chancellor
  2023-03-10 22:41 ` [PATCH 5/6] soc: fsl: dpio: Suppress duplicated error reporting on device remove Uwe Kleine-König
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor; +Cc: kernel, linux-kernel

Instead of silently returning an error in the remove callback (which yields
a generic and little informing error message), annotate each error path of
fsl_mc_resource_pool_remove_device() with an error message and return zero
in the remove callback to suppress the error message.

Note that changing the return value has no other effect than suppressing
the error message by the fsl_mc bus driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/fsl-mc/fsl-mc-allocator.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index e60faf8edaa1..36f70e5e418b 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -104,22 +104,30 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
 	int error = -EINVAL;
 
 	resource = mc_dev->resource;
-	if (!resource || resource->data != mc_dev)
+	if (!resource || resource->data != mc_dev) {
+		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
 		goto out;
+	}
 
 	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
 	mc_bus = to_fsl_mc_bus(mc_bus_dev);
 	res_pool = resource->parent_pool;
-	if (res_pool != &mc_bus->resource_pools[resource->type])
+	if (res_pool != &mc_bus->resource_pools[resource->type]) {
+		dev_err(&mc_bus_dev->dev, "pool mismatch\n");
 		goto out;
+	}
 
 	mutex_lock(&res_pool->mutex);
 
-	if (res_pool->max_count <= 0)
+	if (res_pool->max_count <= 0) {
+		dev_err(&mc_bus_dev->dev, "max_count underflow\n");
 		goto out_unlock;
+	}
 	if (res_pool->free_count <= 0 ||
-	    res_pool->free_count > res_pool->max_count)
+	    res_pool->free_count > res_pool->max_count) {
+		dev_err(&mc_bus_dev->dev, "free_count mismatch\n");
 		goto out_unlock;
+	}
 
 	/*
 	 * If the device is currently allocated, its resource is not
@@ -613,7 +621,7 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
 	if (mc_dev->resource) {
 		error = fsl_mc_resource_pool_remove_device(mc_dev);
 		if (error < 0)
-			return error;
+			return 0;
 	}
 
 	dev_dbg(&mc_dev->dev,
-- 
2.39.1


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

* [PATCH 5/6] soc: fsl: dpio: Suppress duplicated error reporting on device remove
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (3 preceding siblings ...)
  2023-03-10 22:41 ` [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting Uwe Kleine-König
@ 2023-03-10 22:41 ` Uwe Kleine-König
  2023-03-10 22:41 ` [PATCH 6/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Roy Pledge, Li Yang; +Cc: kernel, linux-kernel, linuxppc-dev, linux-arm-kernel

Returning an error code from a fsl_mc_driver's remove callback results
in a generic error message, otherwise the value is ignored and the device
gets unbound.

As the only error path in dpaa2_dpio_remove() already emits an error
message, return zero unconditionally to suppress another (less helpful)
error report.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/soc/fsl/dpio/dpio-driver.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c
index 74eace3109a1..09df5302d255 100644
--- a/drivers/soc/fsl/dpio/dpio-driver.c
+++ b/drivers/soc/fsl/dpio/dpio-driver.c
@@ -297,14 +297,10 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
 
 	dpio_close(dpio_dev->mc_io, 0, dpio_dev->mc_handle);
 
-	fsl_mc_portal_free(dpio_dev->mc_io);
-
-	return 0;
-
 err_open:
 	fsl_mc_portal_free(dpio_dev->mc_io);
 
-	return err;
+	return 0;
 }
 
 static const struct fsl_mc_device_id dpaa2_dpio_match_id_table[] = {
-- 
2.39.1


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

* [PATCH 6/6] bus: fsl-mc: Make remove function return void
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (4 preceding siblings ...)
  2023-03-10 22:41 ` [PATCH 5/6] soc: fsl: dpio: Suppress duplicated error reporting on device remove Uwe Kleine-König
@ 2023-03-10 22:41 ` Uwe Kleine-König
  2023-03-13 13:46 ` [PATCH 0/6] " Ioana Ciornei
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 22+ messages in thread
From: Uwe Kleine-König @ 2023-03-10 22:41 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor, Horia Geantă,
	Pankaj Gupta, Gaurav Jain, Herbert Xu, David S. Miller,
	Vinod Koul, Ioana Ciornei, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Yangbo Lu, Roy Pledge, Li Yang, Diana Craciun,
	Alex Williamson, Richard Cochran
  Cc: Uwe Kleine-König, kernel, linux-kernel, linux-crypto,
	dmaengine, netdev, linuxppc-dev, linux-arm-kernel, kvm

From: Uwe Kleine-König <uwe@kleine-koenig.org>

The value returned by an fsl-mc driver's remove function is mostly
ignored.  (Only an error message is printed if the value is non-zero
and then device removal continues unconditionally.)

So change the prototype of the remove function to return no value. This
way driver authors are not tempted to assume that passing an error to
the upper layer is a good idea. All drivers are adapted accordingly.
There is no intended change of behaviour, all callbacks were prepared to
return 0 before.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/bus/fsl-mc/dprc-driver.c                    | 5 ++---
 drivers/bus/fsl-mc/fsl-mc-allocator.c               | 5 ++---
 drivers/bus/fsl-mc/fsl-mc-bus.c                     | 5 +----
 drivers/crypto/caam/caamalg_qi2.c                   | 4 +---
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c             | 4 +---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c    | 4 +---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c    | 4 +---
 drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 4 +---
 drivers/soc/fsl/dpio/dpio-driver.c                  | 4 +---
 drivers/vfio/fsl-mc/vfio_fsl_mc.c                   | 3 +--
 include/linux/fsl/mc.h                              | 2 +-
 11 files changed, 13 insertions(+), 31 deletions(-)

diff --git a/drivers/bus/fsl-mc/dprc-driver.c b/drivers/bus/fsl-mc/dprc-driver.c
index ef4f43f67b80..595d4cecd041 100644
--- a/drivers/bus/fsl-mc/dprc-driver.c
+++ b/drivers/bus/fsl-mc/dprc-driver.c
@@ -835,13 +835,13 @@ EXPORT_SYMBOL_GPL(dprc_cleanup);
  * It tears down the interrupts that were configured for the DPRC device.
  * It destroys the interrupt pool associated with this MC bus.
  */
-static int dprc_remove(struct fsl_mc_device *mc_dev)
+static void dprc_remove(struct fsl_mc_device *mc_dev)
 {
 	struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev);
 
 	if (!mc_bus->irq_resources) {
 		dev_err(&mc_dev->dev, "No irq resources, so unbinding the device failed\n");
-		return 0;
+		return;
 	}
 
 	if (dev_get_msi_domain(&mc_dev->dev))
@@ -852,7 +852,6 @@ static int dprc_remove(struct fsl_mc_device *mc_dev)
 	dprc_cleanup(mc_dev);
 
 	dev_info(&mc_dev->dev, "DPRC device unbound from driver");
-	return 0;
 }
 
 static const struct fsl_mc_device_id match_id_table[] = {
diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index 36f70e5e418b..0ad68099684e 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -614,19 +614,18 @@ static int fsl_mc_allocator_probe(struct fsl_mc_device *mc_dev)
  * fsl_mc_allocator_remove - callback invoked when an allocatable device is
  * being removed from the system
  */
-static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
+static void fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
 {
 	int error;
 
 	if (mc_dev->resource) {
 		error = fsl_mc_resource_pool_remove_device(mc_dev);
 		if (error < 0)
-			return 0;
+			return;
 	}
 
 	dev_dbg(&mc_dev->dev,
 		"Allocatable fsl-mc device unbound from fsl_mc_allocator driver");
-	return 0;
 }
 
 static const struct fsl_mc_device_id match_id_table[] = {
diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c
index 1531e6101fb1..08b7dc8f2181 100644
--- a/drivers/bus/fsl-mc/fsl-mc-bus.c
+++ b/drivers/bus/fsl-mc/fsl-mc-bus.c
@@ -454,11 +454,8 @@ static int fsl_mc_driver_remove(struct device *dev)
 {
 	struct fsl_mc_driver *mc_drv = to_fsl_mc_driver(dev->driver);
 	struct fsl_mc_device *mc_dev = to_fsl_mc_device(dev);
-	int error;
 
-	error = mc_drv->remove(mc_dev);
-	if (error < 0)
-		dev_err(dev, "%s failed: %d\n", __func__, error);
+	mc_drv->remove(mc_dev);
 
 	return 0;
 }
diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c
index 5c8d35edaa1c..9156bbe038b7 100644
--- a/drivers/crypto/caam/caamalg_qi2.c
+++ b/drivers/crypto/caam/caamalg_qi2.c
@@ -5402,7 +5402,7 @@ static int dpaa2_caam_probe(struct fsl_mc_device *dpseci_dev)
 	return err;
 }
 
-static int __cold dpaa2_caam_remove(struct fsl_mc_device *ls_dev)
+static void __cold dpaa2_caam_remove(struct fsl_mc_device *ls_dev)
 {
 	struct device *dev;
 	struct dpaa2_caam_priv *priv;
@@ -5443,8 +5443,6 @@ static int __cold dpaa2_caam_remove(struct fsl_mc_device *ls_dev)
 	free_percpu(priv->ppriv);
 	fsl_mc_portal_free(priv->mc_io);
 	kmem_cache_destroy(qi_cache);
-
-	return 0;
 }
 
 int dpaa2_caam_enqueue(struct device *dev, struct caam_request *req)
diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
index 8dd40d00a672..a42a37634881 100644
--- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
+++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
@@ -765,7 +765,7 @@ static int dpaa2_qdma_probe(struct fsl_mc_device *dpdmai_dev)
 	return err;
 }
 
-static int dpaa2_qdma_remove(struct fsl_mc_device *ls_dev)
+static void dpaa2_qdma_remove(struct fsl_mc_device *ls_dev)
 {
 	struct dpaa2_qdma_engine *dpaa2_qdma;
 	struct dpaa2_qdma_priv *priv;
@@ -787,8 +787,6 @@ static int dpaa2_qdma_remove(struct fsl_mc_device *ls_dev)
 	dma_async_device_unregister(&dpaa2_qdma->dma_dev);
 	kfree(priv);
 	kfree(dpaa2_qdma);
-
-	return 0;
 }
 
 static void dpaa2_qdma_shutdown(struct fsl_mc_device *ls_dev)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
index a62cffaf6ff1..a9676d0dece8 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
@@ -5025,7 +5025,7 @@ static int dpaa2_eth_probe(struct fsl_mc_device *dpni_dev)
 	return err;
 }
 
-static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
+static void dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
 {
 	struct device *dev;
 	struct net_device *net_dev;
@@ -5073,8 +5073,6 @@ static int dpaa2_eth_remove(struct fsl_mc_device *ls_dev)
 	dev_dbg(net_dev->dev.parent, "Removed interface %s\n", net_dev->name);
 
 	free_netdev(net_dev);
-
-	return 0;
 }
 
 static const struct fsl_mc_device_id dpaa2_eth_match_id_table[] = {
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
index 90d23ab1ce9d..4497e3c0456d 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-ptp.c
@@ -219,7 +219,7 @@ static int dpaa2_ptp_probe(struct fsl_mc_device *mc_dev)
 	return err;
 }
 
-static int dpaa2_ptp_remove(struct fsl_mc_device *mc_dev)
+static void dpaa2_ptp_remove(struct fsl_mc_device *mc_dev)
 {
 	struct device *dev = &mc_dev->dev;
 	struct ptp_qoriq *ptp_qoriq;
@@ -232,8 +232,6 @@ static int dpaa2_ptp_remove(struct fsl_mc_device *mc_dev)
 	fsl_mc_free_irqs(mc_dev);
 	dprtc_close(mc_dev->mc_io, 0, mc_dev->mc_handle);
 	fsl_mc_portal_free(mc_dev->mc_io);
-
-	return 0;
 }
 
 static const struct fsl_mc_device_id dpaa2_ptp_match_id_table[] = {
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index f4ae4289c41a..21cc4e52425a 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -3221,7 +3221,7 @@ static void dpaa2_switch_teardown(struct fsl_mc_device *sw_dev)
 		dev_warn(dev, "dpsw_close err %d\n", err);
 }
 
-static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
+static void dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
 {
 	struct ethsw_port_priv *port_priv;
 	struct ethsw_core *ethsw;
@@ -3252,8 +3252,6 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
 	kfree(ethsw);
 
 	dev_set_drvdata(dev, NULL);
-
-	return 0;
 }
 
 static int dpaa2_switch_probe_port(struct ethsw_core *ethsw,
diff --git a/drivers/soc/fsl/dpio/dpio-driver.c b/drivers/soc/fsl/dpio/dpio-driver.c
index 09df5302d255..9e3fddd8f5a9 100644
--- a/drivers/soc/fsl/dpio/dpio-driver.c
+++ b/drivers/soc/fsl/dpio/dpio-driver.c
@@ -270,7 +270,7 @@ static void dpio_teardown_irqs(struct fsl_mc_device *dpio_dev)
 	fsl_mc_free_irqs(dpio_dev);
 }
 
-static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
+static void dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
 {
 	struct device *dev;
 	struct dpio_priv *priv;
@@ -299,8 +299,6 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev)
 
 err_open:
 	fsl_mc_portal_free(dpio_dev->mc_io);
-
-	return 0;
 }
 
 static const struct fsl_mc_device_id dpaa2_dpio_match_id_table[] = {
diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
index c89a047a4cd8..f2140e94d41e 100644
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
@@ -570,7 +570,7 @@ static void vfio_fsl_mc_release_dev(struct vfio_device *core_vdev)
 	mutex_destroy(&vdev->igate);
 }
 
-static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
+static void vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
 {
 	struct device *dev = &mc_dev->dev;
 	struct vfio_fsl_mc_device *vdev = dev_get_drvdata(dev);
@@ -578,7 +578,6 @@ static int vfio_fsl_mc_remove(struct fsl_mc_device *mc_dev)
 	vfio_unregister_group_dev(&vdev->vdev);
 	dprc_remove_devices(mc_dev, NULL, 0);
 	vfio_put_device(&vdev->vdev);
-	return 0;
 }
 
 static const struct vfio_device_ops vfio_fsl_mc_ops = {
diff --git a/include/linux/fsl/mc.h b/include/linux/fsl/mc.h
index a86115bc799c..a1b3de87a3d1 100644
--- a/include/linux/fsl/mc.h
+++ b/include/linux/fsl/mc.h
@@ -48,7 +48,7 @@ struct fsl_mc_driver {
 	struct device_driver driver;
 	const struct fsl_mc_device_id *match_id_table;
 	int (*probe)(struct fsl_mc_device *dev);
-	int (*remove)(struct fsl_mc_device *dev);
+	void (*remove)(struct fsl_mc_device *dev);
 	void (*shutdown)(struct fsl_mc_device *dev);
 	int (*suspend)(struct fsl_mc_device *dev, pm_message_t state);
 	int (*resume)(struct fsl_mc_device *dev);
-- 
2.39.1


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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (5 preceding siblings ...)
  2023-03-10 22:41 ` [PATCH 6/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
@ 2023-03-13 13:46 ` Ioana Ciornei
  2023-03-13 15:47 ` Laurentiu Tudor
  2023-04-12 17:10 ` Uwe Kleine-König
  8 siblings, 0 replies; 22+ messages in thread
From: Ioana Ciornei @ 2023-03-13 13:46 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Stuart Yoder, Laurentiu Tudor, Roy Pledge, Li Yang,
	Horia Geantă,
	Pankaj Gupta, Gaurav Jain, Herbert Xu, David S. Miller,
	Vinod Koul, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Yangbo Lu,
	Diana Craciun, Alex Williamson, Richard Cochran, kernel,
	linux-kernel, linuxppc-dev, linux-arm-kernel, linux-crypto,
	dmaengine, netdev, kvm

On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> many bus remove functions return an integer which is a historic
> misdesign that makes driver authors assume that there is some kind of
> error handling in the upper layers. This is wrong however and returning
> and error code only yields an error message.
> 
> This series improves the fsl-mc bus by changing the remove callback to
> return no value instead. As a preparation all drivers are changed to
> return zero before so that they don't trigger the error message.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (6):
>   bus: fsl-mc: Only warn once about errors on device unbind
>   bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove()
>   bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong
>     condition
>   bus: fsl-mc: fsl-mc-allocator: Improve error reporting
>   soc: fsl: dpio: Suppress duplicated error reporting on device remove
>   bus: fsl-mc: Make remove function return void
> 

Reviewed-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com> # sanity checks



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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (6 preceding siblings ...)
  2023-03-13 13:46 ` [PATCH 0/6] " Ioana Ciornei
@ 2023-03-13 15:47 ` Laurentiu Tudor
  2023-04-12 17:10 ` Uwe Kleine-König
  8 siblings, 0 replies; 22+ messages in thread
From: Laurentiu Tudor @ 2023-03-13 15:47 UTC (permalink / raw)
  To: Uwe Kleine-König, Stuart Yoder, Roy Pledge, Li Yang,
	Horia Geantă,
	Pankaj Gupta, Gaurav Jain, Herbert Xu, David S. Miller,
	Vinod Koul, Ioana Ciornei, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Yangbo Lu, Diana Craciun, Alex Williamson,
	Richard Cochran
  Cc: kernel, linux-kernel, linuxppc-dev, linux-arm-kernel,
	linux-crypto, dmaengine, netdev, kvm



On 3/11/2023 12:41 AM, Uwe Kleine-König wrote:
> Hello,
> 
> many bus remove functions return an integer which is a historic
> misdesign that makes driver authors assume that there is some kind of
> error handling in the upper layers. This is wrong however and returning
> and error code only yields an error message.
> 
> This series improves the fsl-mc bus by changing the remove callback to
> return no value instead. As a preparation all drivers are changed to
> return zero before so that they don't trigger the error message.
> 
> Best regards
> Uwe
> 
> Uwe Kleine-König (6):
>    bus: fsl-mc: Only warn once about errors on device unbind
>    bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove()
>    bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong
>      condition
>    bus: fsl-mc: fsl-mc-allocator: Improve error reporting
>    soc: fsl: dpio: Suppress duplicated error reporting on device remove
>    bus: fsl-mc: Make remove function return void
> 

Thanks for the series, Uwe. Did a quick boot test with ACPI, so:

Reviewed-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Tested-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>

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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
                   ` (7 preceding siblings ...)
  2023-03-13 15:47 ` Laurentiu Tudor
@ 2023-04-12 17:10 ` Uwe Kleine-König
  2023-04-12 21:30   ` Leo Li
  8 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-04-12 17:10 UTC (permalink / raw)
  To: Stuart Yoder, Laurentiu Tudor, Roy Pledge, Li Yang,
	Horia Geantă,
	Pankaj Gupta, Gaurav Jain, Herbert Xu, David S. Miller,
	Vinod Koul, Ioana Ciornei, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Yangbo Lu, Diana Craciun, Alex Williamson,
	Richard Cochran
  Cc: kvm, netdev, linux-kernel, linux-crypto, kernel, dmaengine,
	linuxppc-dev, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 849 bytes --]

Hello,

On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> Hello,
> 
> many bus remove functions return an integer which is a historic
> misdesign that makes driver authors assume that there is some kind of
> error handling in the upper layers. This is wrong however and returning
> and error code only yields an error message.
> 
> This series improves the fsl-mc bus by changing the remove callback to
> return no value instead. As a preparation all drivers are changed to
> return zero before so that they don't trigger the error message.

Who is supposed to pick up this patch series (or point out a good reason
for not taking it)?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-04-12 17:10 ` Uwe Kleine-König
@ 2023-04-12 21:30   ` Leo Li
  2023-04-13  6:00     ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Leo Li @ 2023-04-12 21:30 UTC (permalink / raw)
  To: Uwe Kleine-König, Stuart Yoder, Laurentiu Tudor, Roy Pledge,
	Horia Geanta, Pankaj Gupta, Gaurav Jain, Herbert Xu,
	David S. Miller, Vinod Koul, Ioana Ciornei, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Y.B. Lu,
	Diana Madalina Craciun (OSS),
	Alex Williamson, Richard Cochran
  Cc: kvm, netdev, linux-kernel, linux-crypto, kernel, dmaengine,
	linuxppc-dev, linux-arm-kernel



> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Wednesday, April 12, 2023 12:11 PM
> To: Stuart Yoder <stuyoder@gmail.com>; Laurentiu Tudor
> <laurentiu.tudor@nxp.com>; Roy Pledge <roy.pledge@nxp.com>; Leo Li
> <leoyang.li@nxp.com>; Horia Geanta <horia.geanta@nxp.com>; Pankaj
> Gupta <pankaj.gupta@nxp.com>; Gaurav Jain <gaurav.jain@nxp.com>;
> Herbert Xu <herbert@gondor.apana.org.au>; David S. Miller
> <davem@davemloft.net>; Vinod Koul <vkoul@kernel.org>; Ioana Ciornei
> <ioana.ciornei@nxp.com>; Eric Dumazet <edumazet@google.com>; Jakub
> Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Y.B. Lu
> <yangbo.lu@nxp.com>; Diana Madalina Craciun (OSS)
> <diana.craciun@oss.nxp.com>; Alex Williamson
> <alex.williamson@redhat.com>; Richard Cochran
> <richardcochran@gmail.com>
> Cc: kvm@vger.kernel.org; netdev@vger.kernel.org; linux-
> kernel@vger.kernel.org; linux-crypto@vger.kernel.org;
> kernel@pengutronix.de; dmaengine@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org
> Subject: Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
> 
> Hello,
> 
> On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> > Hello,
> >
> > many bus remove functions return an integer which is a historic
> > misdesign that makes driver authors assume that there is some kind of
> > error handling in the upper layers. This is wrong however and
> > returning and error code only yields an error message.
> >
> > This series improves the fsl-mc bus by changing the remove callback to
> > return no value instead. As a preparation all drivers are changed to
> > return zero before so that they don't trigger the error message.
> 
> Who is supposed to pick up this patch series (or point out a good reason for
> not taking it)?

Previously Greg KH picked up MC bus patches.

If no one is picking up them this time, I probably can take it through the fsl soc tree.

Regards,
Leo

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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-04-12 21:30   ` Leo Li
@ 2023-04-13  6:00     ` Uwe Kleine-König
  2023-05-08 13:43       ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-04-13  6:00 UTC (permalink / raw)
  To: Leo Li
  Cc: Stuart Yoder, Laurentiu Tudor, Roy Pledge, Horia Geanta,
	Pankaj Gupta, Gaurav Jain, Herbert Xu, David S. Miller,
	Vinod Koul, Ioana Ciornei, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Y.B. Lu, Diana Madalina Craciun (OSS),
	Alex Williamson, Richard Cochran, kvm, netdev, linux-kernel,
	linux-crypto, kernel, dmaengine, linuxppc-dev, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1337 bytes --]

Hello Leo,

On Wed, Apr 12, 2023 at 09:30:05PM +0000, Leo Li wrote:
> > On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> > > Hello,
> > >
> > > many bus remove functions return an integer which is a historic
> > > misdesign that makes driver authors assume that there is some kind of
> > > error handling in the upper layers. This is wrong however and
> > > returning and error code only yields an error message.
> > >
> > > This series improves the fsl-mc bus by changing the remove callback to
> > > return no value instead. As a preparation all drivers are changed to
> > > return zero before so that they don't trigger the error message.
> > 
> > Who is supposed to pick up this patch series (or point out a good reason for
> > not taking it)?
> 
> Previously Greg KH picked up MC bus patches.
> 
> If no one is picking up them this time, I probably can take it through
> the fsl soc tree.

I guess Greg won't pick up this series as he didn't get a copy of it :-)

Browsing through the history of drivers/bus/fsl-mc there is no
consistent maintainer to see. So if you can take it, that's very
appreciated.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-04-13  6:00     ` Uwe Kleine-König
@ 2023-05-08 13:43       ` Uwe Kleine-König
  2023-05-08 21:57         ` Li Yang
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-05-08 13:43 UTC (permalink / raw)
  To: Leo Li
  Cc: Stuart Yoder, Gaurav Jain, Roy Pledge,
	Diana Madalina Craciun (OSS),
	Eric Dumazet, Ioana Ciornei, kvm, Horia Geanta, Jakub Kicinski,
	Paolo Abeni, Laurentiu Tudor, Richard Cochran, Pankaj Gupta,
	Alex Williamson, linux-arm-kernel, Herbert Xu, netdev,
	linux-kernel, Vinod Koul, linux-crypto, kernel, Y.B. Lu,
	dmaengine, linuxppc-dev, David S. Miller

[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]

Hello Leo,

On Thu, Apr 13, 2023 at 08:00:04AM +0200, Uwe Kleine-König wrote:
> On Wed, Apr 12, 2023 at 09:30:05PM +0000, Leo Li wrote:
> > > On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> > > > Hello,
> > > >
> > > > many bus remove functions return an integer which is a historic
> > > > misdesign that makes driver authors assume that there is some kind of
> > > > error handling in the upper layers. This is wrong however and
> > > > returning and error code only yields an error message.
> > > >
> > > > This series improves the fsl-mc bus by changing the remove callback to
> > > > return no value instead. As a preparation all drivers are changed to
> > > > return zero before so that they don't trigger the error message.
> > > 
> > > Who is supposed to pick up this patch series (or point out a good reason for
> > > not taking it)?
> > 
> > Previously Greg KH picked up MC bus patches.
> > 
> > If no one is picking up them this time, I probably can take it through
> > the fsl soc tree.
> 
> I guess Greg won't pick up this series as he didn't get a copy of it :-)
> 
> Browsing through the history of drivers/bus/fsl-mc there is no
> consistent maintainer to see. So if you can take it, that's very
> appreciated.

My mail was meant encouraging, maybe it was too subtile? I'll try again:

Yes, please apply, that would be wonderful!

:-)

Thanks
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-05-08 13:43       ` Uwe Kleine-König
@ 2023-05-08 21:57         ` Li Yang
  2023-05-09  7:20           ` Michael Ellerman
  2023-05-30 13:50           ` Uwe Kleine-König
  0 siblings, 2 replies; 22+ messages in thread
From: Li Yang @ 2023-05-08 21:57 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: kvm, Gaurav Jain, Roy Pledge, Ioana Ciornei, Eric Dumazet,
	Diana Madalina Craciun (OSS),
	Stuart Yoder, Horia Geanta, Jakub Kicinski, Paolo Abeni,
	Laurentiu Tudor, Richard Cochran, Pankaj Gupta, Alex Williamson,
	linux-arm-kernel, Herbert Xu, netdev, linux-kernel, Vinod Koul,
	linux-crypto, kernel, Y.B. Lu, dmaengine, linuxppc-dev,
	David S. Miller

On Mon, May 8, 2023 at 8:44 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
>
> Hello Leo,
>
> On Thu, Apr 13, 2023 at 08:00:04AM +0200, Uwe Kleine-König wrote:
> > On Wed, Apr 12, 2023 at 09:30:05PM +0000, Leo Li wrote:
> > > > On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> > > > > Hello,
> > > > >
> > > > > many bus remove functions return an integer which is a historic
> > > > > misdesign that makes driver authors assume that there is some kind of
> > > > > error handling in the upper layers. This is wrong however and
> > > > > returning and error code only yields an error message.
> > > > >
> > > > > This series improves the fsl-mc bus by changing the remove callback to
> > > > > return no value instead. As a preparation all drivers are changed to
> > > > > return zero before so that they don't trigger the error message.
> > > >
> > > > Who is supposed to pick up this patch series (or point out a good reason for
> > > > not taking it)?
> > >
> > > Previously Greg KH picked up MC bus patches.
> > >
> > > If no one is picking up them this time, I probably can take it through
> > > the fsl soc tree.
> >
> > I guess Greg won't pick up this series as he didn't get a copy of it :-)
> >
> > Browsing through the history of drivers/bus/fsl-mc there is no
> > consistent maintainer to see. So if you can take it, that's very
> > appreciated.
>
> My mail was meant encouraging, maybe it was too subtile? I'll try again:
>
> Yes, please apply, that would be wonderful!

Sorry for missing your previous email.  I will do that.  Thanks.

Regards,
Leo

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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-05-08 21:57         ` Li Yang
@ 2023-05-09  7:20           ` Michael Ellerman
  2023-05-30 13:50           ` Uwe Kleine-König
  1 sibling, 0 replies; 22+ messages in thread
From: Michael Ellerman @ 2023-05-09  7:20 UTC (permalink / raw)
  To: Li Yang, Uwe Kleine-König
  Cc: kvm, Gaurav Jain, Roy Pledge, Ioana Ciornei, Eric Dumazet,
	Diana Madalina Craciun (OSS),
	Stuart Yoder, Horia Geanta, Jakub Kicinski, Paolo Abeni,
	Laurentiu Tudor, Richard Cochran, Pankaj Gupta, Alex Williamson,
	linux-arm-kernel, Herbert Xu, netdev, linux-kernel, Vinod Koul,
	linux-crypto, kernel, Y.B. Lu, dmaengine, linuxppc-dev,
	David S. Miller

Li Yang <leoyang.li@nxp.com> writes:
> On Mon, May 8, 2023 at 8:44 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
>>
>> Hello Leo,
>>
>> On Thu, Apr 13, 2023 at 08:00:04AM +0200, Uwe Kleine-König wrote:
>> > On Wed, Apr 12, 2023 at 09:30:05PM +0000, Leo Li wrote:
>> > > > On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
>> > > > > Hello,
>> > > > >
>> > > > > many bus remove functions return an integer which is a historic
>> > > > > misdesign that makes driver authors assume that there is some kind of
>> > > > > error handling in the upper layers. This is wrong however and
>> > > > > returning and error code only yields an error message.
>> > > > >
>> > > > > This series improves the fsl-mc bus by changing the remove callback to
>> > > > > return no value instead. As a preparation all drivers are changed to
>> > > > > return zero before so that they don't trigger the error message.
>> > > >
>> > > > Who is supposed to pick up this patch series (or point out a good reason for
>> > > > not taking it)?
>> > >
>> > > Previously Greg KH picked up MC bus patches.
>> > >
>> > > If no one is picking up them this time, I probably can take it through
>> > > the fsl soc tree.
>> >
>> > I guess Greg won't pick up this series as he didn't get a copy of it :-)
>> >
>> > Browsing through the history of drivers/bus/fsl-mc there is no
>> > consistent maintainer to see. So if you can take it, that's very
>> > appreciated.
>>
>> My mail was meant encouraging, maybe it was too subtile? I'll try again:
>>
>> Yes, please apply, that would be wonderful!
>
> Sorry for missing your previous email.  I will do that.  Thanks.

Does MAINTAINERS need updating?

It says:

QORIQ DPAA2 FSL-MC BUS DRIVER
M:	Stuart Yoder <stuyoder@gmail.com>
M:	Laurentiu Tudor <laurentiu.tudor@nxp.com>
L:	linux-kernel@vger.kernel.org
S:	Maintained
...
F:	drivers/bus/fsl-mc/


cheers

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

* Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-05-08 21:57         ` Li Yang
  2023-05-09  7:20           ` Michael Ellerman
@ 2023-05-30 13:50           ` Uwe Kleine-König
  2023-05-31  0:01             ` Leo Li
  1 sibling, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-05-30 13:50 UTC (permalink / raw)
  To: Li Yang
  Cc: Stuart Yoder, Gaurav Jain, Roy Pledge,
	Diana Madalina Craciun (OSS),
	Eric Dumazet, Ioana Ciornei, kvm, Horia Geanta, Jakub Kicinski,
	Paolo Abeni, Laurentiu Tudor, Richard Cochran, Pankaj Gupta,
	Alex Williamson, linux-arm-kernel, Herbert Xu, netdev,
	linux-kernel, Vinod Koul, linux-crypto, kernel, Y.B. Lu,
	dmaengine, linuxppc-dev, David S. Miller

[-- Attachment #1: Type: text/plain, Size: 2167 bytes --]

Hello,

On Mon, May 08, 2023 at 04:57:00PM -0500, Li Yang wrote:
> On Mon, May 8, 2023 at 8:44 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > On Thu, Apr 13, 2023 at 08:00:04AM +0200, Uwe Kleine-König wrote:
> > > On Wed, Apr 12, 2023 at 09:30:05PM +0000, Leo Li wrote:
> > > > > On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> > > > > > Hello,
> > > > > >
> > > > > > many bus remove functions return an integer which is a historic
> > > > > > misdesign that makes driver authors assume that there is some kind of
> > > > > > error handling in the upper layers. This is wrong however and
> > > > > > returning and error code only yields an error message.
> > > > > >
> > > > > > This series improves the fsl-mc bus by changing the remove callback to
> > > > > > return no value instead. As a preparation all drivers are changed to
> > > > > > return zero before so that they don't trigger the error message.
> > > > >
> > > > > Who is supposed to pick up this patch series (or point out a good reason for
> > > > > not taking it)?
> > > >
> > > > Previously Greg KH picked up MC bus patches.
> > > >
> > > > If no one is picking up them this time, I probably can take it through
> > > > the fsl soc tree.
> > >
> > > I guess Greg won't pick up this series as he didn't get a copy of it :-)
> > >
> > > Browsing through the history of drivers/bus/fsl-mc there is no
> > > consistent maintainer to see. So if you can take it, that's very
> > > appreciated.
> >
> > My mail was meant encouraging, maybe it was too subtile? I'll try again:
> >
> > Yes, please apply, that would be wonderful!
> 
> Sorry for missing your previous email.  I will do that.  Thanks.

Either you didn't apply this patch set yet, or your tree isn't in next.
Both variants would be great to be fixed.

I have another change pending for drivers/bus/fsl-mc/fsl-mc-bus.c, would
be great to see these base patches in next first.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH 0/6] bus: fsl-mc: Make remove function return void
  2023-05-30 13:50           ` Uwe Kleine-König
@ 2023-05-31  0:01             ` Leo Li
  0 siblings, 0 replies; 22+ messages in thread
From: Leo Li @ 2023-05-31  0:01 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Stuart Yoder, Gaurav Jain, Roy Pledge,
	Diana Madalina Craciun (OSS),
	Eric Dumazet, Ioana Ciornei, kvm, Horia Geanta, Jakub Kicinski,
	Paolo Abeni, Laurentiu Tudor, Richard Cochran, Pankaj Gupta,
	Alex Williamson, linux-arm-kernel, Herbert Xu, netdev,
	linux-kernel, Vinod Koul, linux-crypto, kernel, Y.B. Lu,
	dmaengine, linuxppc-dev, David S. Miller



> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Tuesday, May 30, 2023 8:51 AM
> To: Leo Li <leoyang.li@nxp.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>; Gaurav Jain
> <gaurav.jain@nxp.com>; Roy Pledge <roy.pledge@nxp.com>; Diana
> Madalina Craciun (OSS) <diana.craciun@oss.nxp.com>; Eric Dumazet
> <edumazet@google.com>; Ioana Ciornei <ioana.ciornei@nxp.com>;
> kvm@vger.kernel.org; Horia Geanta <horia.geanta@nxp.com>; Jakub
> Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Laurentiu
> Tudor <laurentiu.tudor@nxp.com>; Richard Cochran
> <richardcochran@gmail.com>; Pankaj Gupta <pankaj.gupta@nxp.com>; Alex
> Williamson <alex.williamson@redhat.com>; linux-arm-
> kernel@lists.infradead.org; Herbert Xu <herbert@gondor.apana.org.au>;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Vinod Koul
> <vkoul@kernel.org>; linux-crypto@vger.kernel.org; kernel@pengutronix.de;
> Y.B. Lu <yangbo.lu@nxp.com>; dmaengine@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; David S. Miller <davem@davemloft.net>
> Subject: Re: [PATCH 0/6] bus: fsl-mc: Make remove function return void
> 
> Hello,
> 
> On Mon, May 08, 2023 at 04:57:00PM -0500, Li Yang wrote:
> > On Mon, May 8, 2023 at 8:44 AM Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> wrote:
> > > On Thu, Apr 13, 2023 at 08:00:04AM +0200, Uwe Kleine-König wrote:
> > > > On Wed, Apr 12, 2023 at 09:30:05PM +0000, Leo Li wrote:
> > > > > > On Fri, Mar 10, 2023 at 11:41:22PM +0100, Uwe Kleine-König wrote:
> > > > > > > Hello,
> > > > > > >
> > > > > > > many bus remove functions return an integer which is a
> > > > > > > historic misdesign that makes driver authors assume that
> > > > > > > there is some kind of error handling in the upper layers.
> > > > > > > This is wrong however and returning and error code only yields an
> error message.
> > > > > > >
> > > > > > > This series improves the fsl-mc bus by changing the remove
> > > > > > > callback to return no value instead. As a preparation all
> > > > > > > drivers are changed to return zero before so that they don't
> trigger the error message.
> > > > > >
> > > > > > Who is supposed to pick up this patch series (or point out a
> > > > > > good reason for not taking it)?
> > > > >
> > > > > Previously Greg KH picked up MC bus patches.
> > > > >
> > > > > If no one is picking up them this time, I probably can take it
> > > > > through the fsl soc tree.
> > > >
> > > > I guess Greg won't pick up this series as he didn't get a copy of
> > > > it :-)
> > > >
> > > > Browsing through the history of drivers/bus/fsl-mc there is no
> > > > consistent maintainer to see. So if you can take it, that's very
> > > > appreciated.
> > >
> > > My mail was meant encouraging, maybe it was too subtile? I'll try again:
> > >
> > > Yes, please apply, that would be wonderful!
> >
> > Sorry for missing your previous email.  I will do that.  Thanks.
> 
> Either you didn't apply this patch set yet, or your tree isn't in next.
> Both variants would be great to be fixed.
> 
> I have another change pending for drivers/bus/fsl-mc/fsl-mc-bus.c, would be
> great to see these base patches in next first.

I have applied them to the next branch of my tree.  They will be part of the Linux-next soon.

Regards,
Leo

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

* Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  2023-03-10 22:41 ` [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting Uwe Kleine-König
@ 2023-06-01 15:41   ` Nathan Chancellor
  2023-06-01 16:59     ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Nathan Chancellor @ 2023-06-01 15:41 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Stuart Yoder, Laurentiu Tudor, kernel, linux-kernel, llvm, Leo Li

Hi Uwe,

On Fri, Mar 10, 2023 at 11:41:26PM +0100, Uwe Kleine-König wrote:
> Instead of silently returning an error in the remove callback (which yields
> a generic and little informing error message), annotate each error path of
> fsl_mc_resource_pool_remove_device() with an error message and return zero
> in the remove callback to suppress the error message.
> 
> Note that changing the return value has no other effect than suppressing
> the error message by the fsl_mc bus driver.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

I apologize if this has already been reported or fixed somewhere, I did
a search of lore.kernel.org and did not find anything. This change as
commit b3134039c5b3 ("bus: fsl-mc: fsl-mc-allocator: Improve error
reporting") causes the following warning/error with clang:

  drivers/bus/fsl-mc/fsl-mc-allocator.c:108:12: error: variable 'mc_bus_dev' is uninitialized when used here [-Werror,-Wuninitialized]
    108 |                 dev_err(&mc_bus_dev->dev, "resource mismatch\n");
        |                          ^~~~~~~~~~
  include/linux/dev_printk.h:144:44: note: expanded from macro 'dev_err'
    144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
        |                                                   ^~~
  include/linux/dev_printk.h:110:11: note: expanded from macro 'dev_printk_index_wrap'
    110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
        |                         ^~~
  drivers/bus/fsl-mc/fsl-mc-allocator.c:100:34: note: initialize the variable 'mc_bus_dev' to silence this warning
    100 |         struct fsl_mc_device *mc_bus_dev;
        |                                         ^
        |                                          = NULL
  1 error generated.

Should this be using mc_dev->dev or is there a different fix?

diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index 0ad68099684e..867ac3bbeae6 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -105,7 +105,7 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
 
 	resource = mc_dev->resource;
 	if (!resource || resource->data != mc_dev) {
-		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
+		dev_err(&mc_dev->dev, "resource mismatch\n");
 		goto out;
 	}
 

Cheers,
Nathan

> ---
>  drivers/bus/fsl-mc/fsl-mc-allocator.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> index e60faf8edaa1..36f70e5e418b 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> @@ -104,22 +104,30 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
>  	int error = -EINVAL;
>  
>  	resource = mc_dev->resource;
> -	if (!resource || resource->data != mc_dev)
> +	if (!resource || resource->data != mc_dev) {
> +		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
>  		goto out;
> +	}
>  
>  	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
>  	mc_bus = to_fsl_mc_bus(mc_bus_dev);
>  	res_pool = resource->parent_pool;
> -	if (res_pool != &mc_bus->resource_pools[resource->type])
> +	if (res_pool != &mc_bus->resource_pools[resource->type]) {
> +		dev_err(&mc_bus_dev->dev, "pool mismatch\n");
>  		goto out;
> +	}
>  
>  	mutex_lock(&res_pool->mutex);
>  
> -	if (res_pool->max_count <= 0)
> +	if (res_pool->max_count <= 0) {
> +		dev_err(&mc_bus_dev->dev, "max_count underflow\n");
>  		goto out_unlock;
> +	}
>  	if (res_pool->free_count <= 0 ||
> -	    res_pool->free_count > res_pool->max_count)
> +	    res_pool->free_count > res_pool->max_count) {
> +		dev_err(&mc_bus_dev->dev, "free_count mismatch\n");
>  		goto out_unlock;
> +	}
>  
>  	/*
>  	 * If the device is currently allocated, its resource is not
> @@ -613,7 +621,7 @@ static int fsl_mc_allocator_remove(struct fsl_mc_device *mc_dev)
>  	if (mc_dev->resource) {
>  		error = fsl_mc_resource_pool_remove_device(mc_dev);
>  		if (error < 0)
> -			return error;
> +			return 0;
>  	}
>  
>  	dev_dbg(&mc_dev->dev,
> -- 
> 2.39.1
> 

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

* Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  2023-06-01 15:41   ` Nathan Chancellor
@ 2023-06-01 16:59     ` Uwe Kleine-König
  2023-06-08 22:00       ` Leo Li
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-06-01 16:59 UTC (permalink / raw)
  To: Nathan Chancellor, Li Yang
  Cc: Stuart Yoder, llvm, linux-kernel, kernel, Laurentiu Tudor

[-- Attachment #1: Type: text/plain, Size: 3998 bytes --]

Hello,

On Thu, Jun 01, 2023 at 08:41:01AM -0700, Nathan Chancellor wrote:
> On Fri, Mar 10, 2023 at 11:41:26PM +0100, Uwe Kleine-König wrote:
> > Instead of silently returning an error in the remove callback (which yields
> > a generic and little informing error message), annotate each error path of
> > fsl_mc_resource_pool_remove_device() with an error message and return zero
> > in the remove callback to suppress the error message.
> > 
> > Note that changing the return value has no other effect than suppressing
> > the error message by the fsl_mc bus driver.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> I apologize if this has already been reported or fixed somewhere, I did
> a search of lore.kernel.org and did not find anything. This change as
> commit b3134039c5b3 ("bus: fsl-mc: fsl-mc-allocator: Improve error
> reporting") causes the following warning/error with clang:
> 
>   drivers/bus/fsl-mc/fsl-mc-allocator.c:108:12: error: variable 'mc_bus_dev' is uninitialized when used here [-Werror,-Wuninitialized]
>     108 |                 dev_err(&mc_bus_dev->dev, "resource mismatch\n");
>         |                          ^~~~~~~~~~
>   include/linux/dev_printk.h:144:44: note: expanded from macro 'dev_err'
>     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__)
>         |                                                   ^~~
>   include/linux/dev_printk.h:110:11: note: expanded from macro 'dev_printk_index_wrap'
>     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
>         |                         ^~~
>   drivers/bus/fsl-mc/fsl-mc-allocator.c:100:34: note: initialize the variable 'mc_bus_dev' to silence this warning
>     100 |         struct fsl_mc_device *mc_bus_dev;
>         |                                         ^
>         |                                          = NULL
>   1 error generated.
> 
> Should this be using mc_dev->dev or is there a different fix?
> 
> diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> index 0ad68099684e..867ac3bbeae6 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> @@ -105,7 +105,7 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
>  
>  	resource = mc_dev->resource;
>  	if (!resource || resource->data != mc_dev) {
> -		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
> +		dev_err(&mc_dev->dev, "resource mismatch\n");
>  		goto out;
>  	}

Hmm, clang seems to be right, and I just confirmed that gcc
(arm-linux-gnueabihf-gcc (Debian 12.2.0-14) 12.2.0) doesn't emit a
warning. :-\

My approach would be:

diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index 0ad68099684e..991273f956ce 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -103,14 +103,15 @@ static int __must_check fsl_mc_resource_pool_remove_device(struct fsl_mc_device
 	struct fsl_mc_resource *resource;
 	int error = -EINVAL;
 
+	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
+	mc_bus = to_fsl_mc_bus(mc_bus_dev);
+
 	resource = mc_dev->resource;
 	if (!resource || resource->data != mc_dev) {
 		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
 		goto out;
 	}
 
-	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
-	mc_bus = to_fsl_mc_bus(mc_bus_dev);
 	res_pool = resource->parent_pool;
 	if (res_pool != &mc_bus->resource_pools[resource->type]) {
 		dev_err(&mc_bus_dev->dev, "pool mismatch\n");


Should I prepare a proper patch, or is it possible to squash this change
into b3134039c5b3cf879841e3ec84c8cbf7675554ec?

@Li Yang: Please advice.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  2023-06-01 16:59     ` Uwe Kleine-König
@ 2023-06-08 22:00       ` Leo Li
  2023-06-08 22:53         ` Uwe Kleine-König
  0 siblings, 1 reply; 22+ messages in thread
From: Leo Li @ 2023-06-08 22:00 UTC (permalink / raw)
  To: Uwe Kleine-König, Nathan Chancellor
  Cc: Stuart Yoder, llvm, linux-kernel, kernel, Laurentiu Tudor



> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Thursday, June 1, 2023 12:00 PM
> To: Nathan Chancellor <nathan@kernel.org>; Leo Li <leoyang.li@nxp.com>
> Cc: Stuart Yoder <stuyoder@gmail.com>; llvm@lists.linux.dev; linux-
> kernel@vger.kernel.org; kernel@pengutronix.de; Laurentiu Tudor
> <laurentiu.tudor@nxp.com>
> Subject: Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error
> reporting
> 
> Hello,
> 
> On Thu, Jun 01, 2023 at 08:41:01AM -0700, Nathan Chancellor wrote:
> > On Fri, Mar 10, 2023 at 11:41:26PM +0100, Uwe Kleine-König wrote:
> > > Instead of silently returning an error in the remove callback (which
> > > yields a generic and little informing error message), annotate each
> > > error path of
> > > fsl_mc_resource_pool_remove_device() with an error message and
> > > return zero in the remove callback to suppress the error message.
> > >
> > > Note that changing the return value has no other effect than
> > > suppressing the error message by the fsl_mc bus driver.
> > >
> > > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >
> > I apologize if this has already been reported or fixed somewhere, I
> > did a search of lore.kernel.org and did not find anything. This change
> > as commit b3134039c5b3 ("bus: fsl-mc: fsl-mc-allocator: Improve error
> > reporting") causes the following warning/error with clang:
> >
> >   drivers/bus/fsl-mc/fsl-mc-allocator.c:108:12: error: variable 'mc_bus_dev'
> is uninitialized when used here [-Werror,-Wuninitialized]
> >     108 |                 dev_err(&mc_bus_dev->dev, "resource mismatch\n");
> >         |                          ^~~~~~~~~~
> >   include/linux/dev_printk.h:144:44: note: expanded from macro 'dev_err'
> >     144 |         dev_printk_index_wrap(_dev_err, KERN_ERR, dev,
> dev_fmt(fmt), ##__VA_ARGS__)
> >         |                                                   ^~~
> >   include/linux/dev_printk.h:110:11: note: expanded from macro
> 'dev_printk_index_wrap'
> >     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
> >         |                         ^~~
> >   drivers/bus/fsl-mc/fsl-mc-allocator.c:100:34: note: initialize the variable
> 'mc_bus_dev' to silence this warning
> >     100 |         struct fsl_mc_device *mc_bus_dev;
> >         |                                         ^
> >         |                                          = NULL
> >   1 error generated.
> >
> > Should this be using mc_dev->dev or is there a different fix?
> >
> > diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > index 0ad68099684e..867ac3bbeae6 100644
> > --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > @@ -105,7 +105,7 @@ static int __must_check
> > fsl_mc_resource_pool_remove_device(struct fsl_mc_device
> >
> >  	resource = mc_dev->resource;
> >  	if (!resource || resource->data != mc_dev) {
> > -		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
> > +		dev_err(&mc_dev->dev, "resource mismatch\n");
> >  		goto out;
> >  	}
> 
> Hmm, clang seems to be right, and I just confirmed that gcc (arm-linux-
> gnueabihf-gcc (Debian 12.2.0-14) 12.2.0) doesn't emit a warning. :-\
> 
> My approach would be:
> 
> diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-
> allocator.c
> index 0ad68099684e..991273f956ce 100644
> --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> @@ -103,14 +103,15 @@ static int __must_check
> fsl_mc_resource_pool_remove_device(struct fsl_mc_device
>  	struct fsl_mc_resource *resource;
>  	int error = -EINVAL;
> 
> +	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> +	mc_bus = to_fsl_mc_bus(mc_bus_dev);
> +
>  	resource = mc_dev->resource;
>  	if (!resource || resource->data != mc_dev) {
>  		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
>  		goto out;
>  	}
> 
> -	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> -	mc_bus = to_fsl_mc_bus(mc_bus_dev);
>  	res_pool = resource->parent_pool;
>  	if (res_pool != &mc_bus->resource_pools[resource->type]) {
>  		dev_err(&mc_bus_dev->dev, "pool mismatch\n");
> 
> 
> Should I prepare a proper patch, or is it possible to squash this change into
> b3134039c5b3cf879841e3ec84c8cbf7675554ec?
> 
> @Li Yang: Please advice.

This looks fine.  Please send a new patch and I can squash it to the original commit.

Regards,
Leo

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

* Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  2023-06-08 22:00       ` Leo Li
@ 2023-06-08 22:53         ` Uwe Kleine-König
  2023-06-08 23:10           ` Leo Li
  0 siblings, 1 reply; 22+ messages in thread
From: Uwe Kleine-König @ 2023-06-08 22:53 UTC (permalink / raw)
  To: Leo Li
  Cc: Nathan Chancellor, kernel, llvm, linux-kernel, Stuart Yoder,
	Laurentiu Tudor

[-- Attachment #1: Type: text/plain, Size: 2002 bytes --]

Hello,

On Thu, Jun 08, 2023 at 10:00:13PM +0000, Leo Li wrote:
> > Hmm, clang seems to be right, and I just confirmed that gcc (arm-linux-
> > gnueabihf-gcc (Debian 12.2.0-14) 12.2.0) doesn't emit a warning. :-\
> > 
> > My approach would be:
> > 
> > diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-
> > allocator.c
> > index 0ad68099684e..991273f956ce 100644
> > --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > @@ -103,14 +103,15 @@ static int __must_check
> > fsl_mc_resource_pool_remove_device(struct fsl_mc_device
> >  	struct fsl_mc_resource *resource;
> >  	int error = -EINVAL;
> > 
> > +	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> > +	mc_bus = to_fsl_mc_bus(mc_bus_dev);
> > +
> >  	resource = mc_dev->resource;
> >  	if (!resource || resource->data != mc_dev) {
> >  		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
> >  		goto out;
> >  	}
> > 
> > -	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> > -	mc_bus = to_fsl_mc_bus(mc_bus_dev);
> >  	res_pool = resource->parent_pool;
> >  	if (res_pool != &mc_bus->resource_pools[resource->type]) {
> >  		dev_err(&mc_bus_dev->dev, "pool mismatch\n");
> > 
> > 
> > Should I prepare a proper patch, or is it possible to squash this change into
> > b3134039c5b3cf879841e3ec84c8cbf7675554ec?
> > 
> > @Li Yang: Please advice.
> 
> This looks fine.  Please send a new patch and I can squash it to the original commit.

I did send a proper patch already, see 

	https://lore.kernel.org/all/20230605112025.80061-1-u.kleine-koenig@pengutronix.de

You can apply that on top of the broken commit, or if you prefer also
squash it into the offending commit. Note that in the above thread there
is another fix for an older commit.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* RE: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
  2023-06-08 22:53         ` Uwe Kleine-König
@ 2023-06-08 23:10           ` Leo Li
  0 siblings, 0 replies; 22+ messages in thread
From: Leo Li @ 2023-06-08 23:10 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Nathan Chancellor, kernel, llvm, linux-kernel, Stuart Yoder,
	Laurentiu Tudor



> -----Original Message-----
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Sent: Thursday, June 8, 2023 5:54 PM
> To: Leo Li <leoyang.li@nxp.com>
> Cc: Nathan Chancellor <nathan@kernel.org>; kernel@pengutronix.de;
> llvm@lists.linux.dev; linux-kernel@vger.kernel.org; Stuart Yoder
> <stuyoder@gmail.com>; Laurentiu Tudor <laurentiu.tudor@nxp.com>
> Subject: Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error
> reporting
> 
> Hello,
> 
> On Thu, Jun 08, 2023 at 10:00:13PM +0000, Leo Li wrote:
> > > Hmm, clang seems to be right, and I just confirmed that gcc
> > > (arm-linux- gnueabihf-gcc (Debian 12.2.0-14) 12.2.0) doesn't emit a
> > > warning. :-\
> > >
> > > My approach would be:
> > >
> > > diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > > b/drivers/bus/fsl-mc/fsl-mc- allocator.c index
> > > 0ad68099684e..991273f956ce 100644
> > > --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > > +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
> > > @@ -103,14 +103,15 @@ static int __must_check
> > > fsl_mc_resource_pool_remove_device(struct fsl_mc_device
> > >  	struct fsl_mc_resource *resource;
> > >  	int error = -EINVAL;
> > >
> > > +	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> > > +	mc_bus = to_fsl_mc_bus(mc_bus_dev);
> > > +
> > >  	resource = mc_dev->resource;
> > >  	if (!resource || resource->data != mc_dev) {
> > >  		dev_err(&mc_bus_dev->dev, "resource mismatch\n");
> > >  		goto out;
> > >  	}
> > >
> > > -	mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent);
> > > -	mc_bus = to_fsl_mc_bus(mc_bus_dev);
> > >  	res_pool = resource->parent_pool;
> > >  	if (res_pool != &mc_bus->resource_pools[resource->type]) {
> > >  		dev_err(&mc_bus_dev->dev, "pool mismatch\n");
> > >
> > >
> > > Should I prepare a proper patch, or is it possible to squash this
> > > change into b3134039c5b3cf879841e3ec84c8cbf7675554ec?
> > >
> > > @Li Yang: Please advice.
> >
> > This looks fine.  Please send a new patch and I can squash it to the original
> commit.
> 
> I did send a proper patch already, see
> 
> 	https://lore.kernel.org/all/20230605112025.80061-1-u.kleine-
> koenig@pengutronix.de
> 
> You can apply that on top of the broken commit, or if you prefer also squash
> it into the offending commit. Note that in the above thread there is another
> fix for an older commit.

Thanks.  Both look good.  Applied for next.

Regards,
Leo

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

end of thread, other threads:[~2023-06-08 23:10 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 22:41 [PATCH 0/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
2023-03-10 22:41 ` [PATCH 1/6] bus: fsl-mc: Only warn once about errors on device unbind Uwe Kleine-König
2023-03-10 22:41 ` [PATCH 2/6] bus: fsl-mc: dprc: Push down error message from fsl_mc_driver_remove() Uwe Kleine-König
2023-03-10 22:41 ` [PATCH 3/6] bus: fsl-mc: fsl-mc-allocator: Drop if block with always wrong condition Uwe Kleine-König
2023-03-10 22:41 ` [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting Uwe Kleine-König
2023-06-01 15:41   ` Nathan Chancellor
2023-06-01 16:59     ` Uwe Kleine-König
2023-06-08 22:00       ` Leo Li
2023-06-08 22:53         ` Uwe Kleine-König
2023-06-08 23:10           ` Leo Li
2023-03-10 22:41 ` [PATCH 5/6] soc: fsl: dpio: Suppress duplicated error reporting on device remove Uwe Kleine-König
2023-03-10 22:41 ` [PATCH 6/6] bus: fsl-mc: Make remove function return void Uwe Kleine-König
2023-03-13 13:46 ` [PATCH 0/6] " Ioana Ciornei
2023-03-13 15:47 ` Laurentiu Tudor
2023-04-12 17:10 ` Uwe Kleine-König
2023-04-12 21:30   ` Leo Li
2023-04-13  6:00     ` Uwe Kleine-König
2023-05-08 13:43       ` Uwe Kleine-König
2023-05-08 21:57         ` Li Yang
2023-05-09  7:20           ` Michael Ellerman
2023-05-30 13:50           ` Uwe Kleine-König
2023-05-31  0:01             ` Leo Li

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).