From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13ACAEB64D9 for ; Tue, 27 Jun 2023 08:51:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231886AbjF0Ivl (ORCPT ); Tue, 27 Jun 2023 04:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231713AbjF0Ivj (ORCPT ); Tue, 27 Jun 2023 04:51:39 -0400 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 A8EAD132 for ; Tue, 27 Jun 2023 01:51:37 -0700 (PDT) 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 ) id 1qE4Og-0007V2-F6; Tue, 27 Jun 2023 10:50:02 +0200 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 ) id 1qE4OT-00AOye-Qh; Tue, 27 Jun 2023 10:49:49 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qE4OS-000CFt-WF; Tue, 27 Jun 2023 10:49:49 +0200 Date: Tue, 27 Jun 2023 10:49:48 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Yangtao Li Cc: miquel.raynal@bootlin.com, rafael@kernel.org, daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com, mmayer@broadcom.com, bcm-kernel-feedback-list@broadcom.com, florian.fainelli@broadcom.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, thara.gopinath@gmail.com, heiko@sntech.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, thierry.reding@gmail.com, jonathanh@nvidia.com, tglx@linutronix.de, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, srinivas.pandruvada@linux.intel.com, DLG-Adam.Ward.opensource@dm.renesas.com, shangxiaojing@huawei.com, bchihi@baylibre.com, wenst@chromium.org, hayashi.kunihiko@socionext.com, niklas.soderlund+renesas@ragnatech.se, chi.minghao@zte.com.cn, johan+linaro@kernel.org, jernej.skrabec@gmail.com, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Message-ID: <20230627084948.nwp7gmwpdtadcfhk@pengutronix.de> References: <20230627071707.77659-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fbpfi3z6hsdafixb" Content-Disposition: inline In-Reply-To: <20230627071707.77659-1-frank.li@vivo.com> 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-tegra@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org --fbpfi3z6hsdafixb Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, On Tue, Jun 27, 2023 at 03:16:52PM +0800, Yangtao Li wrote: > Ensure that all error handling branches print error information. In this > way, when this function fails, the upper-layer functions can directly > return an error code without missing debugging information. Otherwise, > the error message will be printed redundantly or missing. >=20 > There are more than 700 calls to the devm_request_threaded_irq method. > If error messages are printed everywhere, more than 1000 lines of code > can be saved by removing the msg in the driver. >=20 > Signed-off-by: Yangtao Li > --- > kernel/irq/devres.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c > index f6e5515ee077..94039a915218 100644 > --- a/kernel/irq/devres.c > +++ b/kernel/irq/devres.c > @@ -58,8 +58,10 @@ int devm_request_threaded_irq(struct device *dev, unsi= gned int irq, > =20 > dr =3D devres_alloc(devm_irq_release, sizeof(struct irq_devres), > GFP_KERNEL); > - if (!dr) > + if (!dr) { > + dev_err(dev, "Failed to allocate device resource data\n"); > return -ENOMEM; > + } > =20 > if (!devname) > devname =3D dev_name(dev); > @@ -67,6 +69,7 @@ int devm_request_threaded_irq(struct device *dev, unsig= ned int irq, > rc =3D request_threaded_irq(irq, handler, thread_fn, irqflags, devname, > dev_id); > if (rc) { > + dev_err(dev, "Failed to request threaded irq\n"); > devres_free(dr); > return rc; > } My personal opinion is that generic allocation functions should be silent. The reason is that the consuming driver is in a better position to emit a helpful error message. While there is some room to improvment in this generic variant (by mentioning the error code and maybe also the irq number), consider a device that has up to 3 irqs and sometimes only 1. So the driver might want to handle some irq requesting silently. And also for non-optional irqs mybus:mydev: Failed to request TX irq (EBUSY) is much more helpful than mybus:mydev: Failed to request threaded irq (Hint: "threaded" is not a helpful information here either.) Yes, a message in the driver has the downside of making the kernel image (or module) bigger, but the added value is IMHO worth that. Also you might want to handle -EPROBE_DEFER and not emit a message then? (Not sure if request_threaded_irq can return that.) Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --fbpfi3z6hsdafixb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmSaoqwACgkQj4D7WH0S /k66Lwf9Hq5nC1KErm/UPzhqFFiQaUkm5tlRfhc0HKwY231RXIl8U/sEUzFOmVp1 QoBQ3HUogIHlgELx2qVVR9friYW9RRjYQUIFa1Sr1AtICCHEbmveRdjqF07bZTdw czHwMp90yKmH9mbGpEb7JfmhP+Gl3EJHkFZsfr9AniTRYyiDRNnKIOY8GbHv+Uvz vtzJx3uAlv/rcGSMxY+OKqTl24TYEQAoL6nWjp2tDuv2qgqUyCXBFsNG3/NfKsED ldiOz1Wlgger5JmYqUI2EikRolCllLBqEhUMZVTFdtckl0N82zUG+SKNhaSK37yP Q6KBysmk81RWjCHUIWVmIbxhxxgdUQ== =Okxi -----END PGP SIGNATURE----- --fbpfi3z6hsdafixb--