linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
       [not found] ` <82dc5efc-35fe-15ff-d0ea-e1a19da71c5c@linaro.org>
@ 2023-07-03  9:10   ` Yangtao Li
  2023-07-03 11:38     ` Krzysztof Kozlowski
  0 siblings, 1 reply; 2+ messages in thread
From: Yangtao Li @ 2023-07-03  9:10 UTC (permalink / raw)
  To: Krzysztof Kozlowski, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	shawnguo, s.hauer, kernel, festevam, linux-imx, agross, andersson,
	konrad.dybcio, thara.gopinath, heiko, mcoquelin.stm32,
	alexandre.torgue, thierry.reding, jonathanh, tglx, matthias.bgg,
	angelogioacchino.delregno, srinivas.pandruvada,
	DLG-Adam.Ward.opensource, shangxiaojing, bchihi, wenst,
	u.kleine-koenig, hayashi.kunihiko, niklas.soderlund+renesas,
	chi.minghao, johan+linaro, jernej.skrabec
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, linux-stm32, linux-tegra, linux-mediatek

On 2023/6/27 15:43, Krzysztof Kozlowski wrote:

> On 27/06/2023 09:16, 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.
>>
>> 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.
>>
>> Signed-off-by: Yangtao Li <frank.li@vivo.com>
>> ---
>>   kernel/irq/devres.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> 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, unsigned int irq,
>>   
>>   	dr = 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");
> Just like any memory allocation, I don't think we print anything for
> devres failures. Why do you think we should start doing it?


And tglx point out that:

Having proper and consistent information why the device cannot be used 
_is_ useful.

>
>>   		return -ENOMEM;
>> +	}
>>   
>>   	if (!devname)
>>   		devname = dev_name(dev);
>> @@ -67,6 +69,7 @@ int devm_request_threaded_irq(struct device *dev, unsigned int irq,
>>   	rc = request_threaded_irq(irq, handler, thread_fn, irqflags, devname,
>>   				  dev_id);
>>   	if (rc) {
>> +		dev_err(dev, "Failed to request threaded irq\n");
> I don't like that one path - devm() managed - prints error, but regular
> path does not. Code should be here consistent. Also error message is too
> generic. You need to print at least irq number, maybe also devname?


v3 has been added.


Thx,

Yangtao


>
> Best regards,
> Krzysztof
>


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

* Re: [PATCH 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq()
  2023-07-03  9:10   ` [PATCH 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Yangtao Li
@ 2023-07-03 11:38     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2023-07-03 11:38 UTC (permalink / raw)
  To: Yangtao Li, miquel.raynal, rafael, daniel.lezcano, amitk,
	rui.zhang, mmayer, bcm-kernel-feedback-list, florian.fainelli,
	shawnguo, s.hauer, kernel, festevam, linux-imx, agross, andersson,
	konrad.dybcio, thara.gopinath, heiko, mcoquelin.stm32,
	alexandre.torgue, thierry.reding, jonathanh, tglx, matthias.bgg,
	angelogioacchino.delregno, srinivas.pandruvada,
	DLG-Adam.Ward.opensource, shangxiaojing, bchihi, wenst,
	u.kleine-koenig, hayashi.kunihiko, niklas.soderlund+renesas,
	chi.minghao, johan+linaro, jernej.skrabec
  Cc: linux-pm, linux-kernel, linux-arm-kernel, linux-arm-msm,
	linux-rockchip, linux-stm32, linux-tegra, linux-mediatek

On 03/07/2023 11:10, Yangtao Li wrote:
> On 2023/6/27 15:43, Krzysztof Kozlowski wrote:
> 
>> On 27/06/2023 09:16, 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.
>>>
>>> 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.
>>>
>>> Signed-off-by: Yangtao Li <frank.li@vivo.com>
>>> ---
>>>   kernel/irq/devres.c | 5 ++++-
>>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>>
>>> 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, unsigned int irq,
>>>   
>>>   	dr = 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");
>> Just like any memory allocation, I don't think we print anything for
>> devres failures. Why do you think we should start doing it?
> 
> 
> And tglx point out that:
> 
> Having proper and consistent information why the device cannot be used 
> _is_ useful.

Where did tglx suggest printing devres allocation ENOMEM errors?

Best regards,
Krzysztof



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

end of thread, other threads:[~2023-07-03 11:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230627071707.77659-1-frank.li@vivo.com>
     [not found] ` <82dc5efc-35fe-15ff-d0ea-e1a19da71c5c@linaro.org>
2023-07-03  9:10   ` [PATCH 01/15] genirq/devres: Add error information printing for devm_request_threaded_irq() Yangtao Li
2023-07-03 11:38     ` Krzysztof Kozlowski

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