Message ID | 20230310224128.2638078-5-u.kleine-koenig@pengutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp6761wrd; Fri, 10 Mar 2023 14:46:06 -0800 (PST) X-Google-Smtp-Source: AK7set8yYTLklMJN0YVCA9ZOZeR2FbI6StHrgHg5EAgUlm/cR2jHYcG3QV1y17GGFPUvYpYoCni2 X-Received: by 2002:a17:90a:12c4:b0:23a:f4e7:733d with SMTP id b4-20020a17090a12c400b0023af4e7733dmr11682503pjg.10.1678488366392; Fri, 10 Mar 2023 14:46:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678488366; cv=none; d=google.com; s=arc-20160816; b=eJa7DhHSq0EWUmfDDmQY6OFbYl35eIA2QOSyipPzyfK6fkk/Ei1SBFYxD3K9KQ9gPf YK9bgiXkV7VCmPZGG3wzHao7pLVv/jbL4+WLB64T88NgeBgHnRqTO1j75QkPzka0dEGv +LAcY6hwibr0BZ5PWiRXFAr5O4sjdo04z88ivJYIb7a2fFD+KBvTkNCOGASplLrKKC+3 XXRWRKPk27FPDvgGM7cHm9KQojAKEcdXnF5Rw+SgT1ennUH6qqXAWPt7y/3RNADwT71o AFToW7stJmrDoEpC87bJ65dUq5/nHstXatII+U8Lv6E+G3Dn92UZefpoNZD1bTQI/l3q 23dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ppFfa+Jsrx1+yLuL86+HmSXS+HPAoP5uwhJ49hrAPm8=; b=UfWa3tBCVq9FnZ3XqHaZ0iM/Xdxrj4fOTj90yXFKxQbpND1ftXdiZoqU+8A8DHAAqZ uNFk9gtn/yqFlCK0GF/1xIyl2E6kX8hyrHpJePmUxICX5a/bOrqLhyXZHNwSHkbh9ors vA2NeVA9VKMsdjHVrPfbjmLlwK09DVijM9PauG62bPyZigCupSAXzvJ/o5P5MTHr4Smq xoB+mg02vnTtrU979E6aLEVC7/jk+Qcj17FaHUd18/QW1xxF1w5y6x2161CFUoffbbIj WvCsmRtzyb6j58cLTVa4J4b4sABKzQY2TJ1FAe6h10YBvIhEbcYOPPUxysk1tNpFc7ch U3lQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o9-20020a17090a5b0900b00230ff98778dsi801776pji.144.2023.03.10.14.44.53; Fri, 10 Mar 2023 14:46:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231395AbjCJWmW (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Fri, 10 Mar 2023 17:42:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231764AbjCJWmG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Mar 2023 17:42:06 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76ECA14ACC8 for <linux-kernel@vger.kernel.org>; Fri, 10 Mar 2023 14:41:42 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <ukl@pengutronix.de>) id 1palQg-0002dD-Cl; Fri, 10 Mar 2023 23:41:38 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1palQf-003GqV-C4; Fri, 10 Mar 2023 23:41:37 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from <ukl@pengutronix.de>) id 1palQe-003uEe-HA; Fri, 10 Mar 2023 23:41:36 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de> To: Stuart Yoder <stuyoder@gmail.com>, Laurentiu Tudor <laurentiu.tudor@nxp.com> Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting Date: Fri, 10 Mar 2023 23:41:26 +0100 Message-Id: <20230310224128.2638078-5-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230310224128.2638078-1-u.kleine-koenig@pengutronix.de> References: <20230310224128.2638078-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=2224; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=m2h84BsJapWQ+IP/SZ8E8V7ar6wuL3BLup87a7Nixzk=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBkC7IM8pg2g6H3wvwxPUVPKdlZoGauxCIeCp/j2 I+Raw+nlGaJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCZAuyDAAKCRDB/BR4rcrs CZMuB/0eCfFruQMz0wK1d6qgSDIzcVBfL8c2MHcqYpHOhs7bWc+lEJKrSgHjislIyLjat3xR9U9 KQh+LY9ORGrQvlSYGaqFyjXqey6nvAgySQZE+f+S5WQ+5S565+iFn/N/uI4n2el+HXjUmCKo2JN upmv0FpP0qeguyBr0hdzTbzWmMRqvjy6HCLsQcEdVRytGzxKsARdV18dNl2iAtUnGc62gMAJTdi 2etKfkhATvuK3LQrjOb4blRVjhopNkTIiPAaD2sQSeihTc/d0Ntmd+oR8QXZdRdS8q/IgTL7iqN nQGF+UDm9vle4ilielCJ/htVNRkTud1SV0xGmgg08P/HHPCO X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760022617100620547?= X-GMAIL-MSGID: =?utf-8?q?1760022617100620547?= |
Series |
bus: fsl-mc: Make remove function return void
|
|
Commit Message
Uwe Kleine-König
March 10, 2023, 10:41 p.m. UTC
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(-)
Comments
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 >
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
> -----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
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
> -----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
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,