From: Nathan Chancellor <nathan@kernel.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Stuart Yoder <stuyoder@gmail.com>,
Laurentiu Tudor <laurentiu.tudor@nxp.com>,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Leo Li <leoyang.li@nxp.com>
Subject: Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting
Date: Thu, 1 Jun 2023 08:41:01 -0700 [thread overview]
Message-ID: <20230601154101.GA2368233@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20230310224128.2638078-5-u.kleine-koenig@pengutronix.de>
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
>
next prev parent reply other threads:[~2023-06-01 15:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230601154101.GA2368233@dev-arch.thelio-3990X \
--to=nathan@kernel.org \
--cc=kernel@pengutronix.de \
--cc=laurentiu.tudor@nxp.com \
--cc=leoyang.li@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=stuyoder@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®