Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp978641rwd; Thu, 1 Jun 2023 08:56:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4RidA1hj/7fmjrL46nlGhg0rpq322vEzOODsQ8svYewpegBgWVzy27+aNVqAPPZONoQ7Rp X-Received: by 2002:a05:6a20:7346:b0:10c:d3e5:1953 with SMTP id v6-20020a056a20734600b0010cd3e51953mr8168078pzc.3.1685634996273; Thu, 01 Jun 2023 08:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685634996; cv=none; d=google.com; s=arc-20160816; b=uVMv86gZwWsMKgARM6ojXUj9zb0jBKJABtVgAywA6VboQEPU8ebkQUNutQd1aC916V MsmHG9yhL4O9hWBoSE7uVEPnsxKFaF+VwlK2YOLT2XPi+W8C4xWkT8Xst/sWVaSDdMoW 83nRB366ig0x86qx7UPjIPyr3ZlPFxbsxnkQzfM8weVnq20tcf94UzKtL51udtK+1PUv zOy3IWguQqcD7RFSA0Bv9yo9AQ5kVuiPIna4KpHP1tEaqlzVCrzKh8pSlGilx2X3aE+2 zpLMHPUk+iB8w5At8pC2zUEULgj9g1N04/tRKILQBpIGc1aeh0MEWds3bKhNmG/BlEgn W0OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZRThRCU8AdU40wLHZzb3FJvaENPfXFnXZsFUr1OZmjk=; b=fXDEGvBieRUNj1aPMllyTPKvLls8knLEZxVsV3KPzG/emiIqz1s6mh5DeHVRsMgDkJ 44HxKU5vjuRqrzXlgN16rg+cjyEhhW2h1zwpfvwKFtZbhE1YWu7jqOZaUGGQQdFkRpqX 98X7QaGEQYdwH5YI73upDe1I9efaeW93bgVP56hwxY4AM7C61Jy5sooNFlMimQFvtTqT OQ3dsXZSl7ylNJpCmeVXfE8JQQgP9mEdwb+3vddVeY+mEN8U0JobbWXtWF7ZAXjhOHwR MFZ7eXFTI8jy+z7sLsJEyody9iFfHjhHr31ybV6sO3fEmq7IUUeBUIaVLPtn5qbYv9Ta QY2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qCFsc6RC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a637105000000b005342966f497si2806501pgc.712.2023.06.01.08.56.16; Thu, 01 Jun 2023 08:56:36 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qCFsc6RC; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234444AbjFAPlH (ORCPT + 99 others); Thu, 1 Jun 2023 11:41:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233403AbjFAPlG (ORCPT ); Thu, 1 Jun 2023 11:41:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7531312C for ; Thu, 1 Jun 2023 08:41:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0799563A24 for ; Thu, 1 Jun 2023 15:41:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E0BC433D2; Thu, 1 Jun 2023 15:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685634063; bh=7xY+u4JxmBE6NT/YTHi3IL1X1Lgg7woZjL73nmOBOnU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qCFsc6RCloNkVlMfcUoDOwSCGeYHgmOnqTtFxLj9omS1r7XEk+SSHCF7owrpZAv33 wiYZPZ0XH6r/Xp/p4XCPPWQpnoODOcnHdnKn78Xhv3hT7rbrO7RcHAorVeTpN6fLqM XCnXp1jkUliSdID0oPET9ocblTY5mvGoqQ8MjEfNJau5w6I0u3VVkrqj5MsTHrjVI3 FIQn4rz5pL8HFtBjgNXcr1k7Q0fwhAmwr30dYa26GpzymzmTMDdgf1rZj1Ht0u2EO/ Gg6jWugKIbTtz5HlBmN0Md6ro6199VPQ+XGHRlD9vzLHqrgOeBKT+dSbzl3eVE/cca dmE28sECzdjLw== Date: Thu, 1 Jun 2023 08:41:01 -0700 From: Nathan Chancellor To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Stuart Yoder , Laurentiu Tudor , kernel@pengutronix.de, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Leo Li Subject: Re: [PATCH 4/6] bus: fsl-mc: fsl-mc-allocator: Improve error reporting Message-ID: <20230601154101.GA2368233@dev-arch.thelio-3990X> References: <20230310224128.2638078-1-u.kleine-koenig@pengutronix.de> <20230310224128.2638078-5-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230310224128.2638078-5-u.kleine-koenig@pengutronix.de> X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 >