mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Coiby Xu <coiby.xu@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Darren Hart <dvhart@infradead.org>,
	Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andy Shevchenko <andy@infradead.org>,
	"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	"open list:X86 PLATFORM DRIVERS - ARCH" 
	<platform-driver-x86@vger.kernel.org>,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" 
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] power: supply: olpc_battery: remove unnecessary CONFIG_PM_SLEEP
Date: Thu, 29 Oct 2020 22:16:46 +0800	[thread overview]
Message-ID: <20201029141646.sijo6iuj44ekytg7@Rk> (raw)
In-Reply-To: <2c09e34a-3312-628e-c9cd-518e9f58efb4@redhat.com>

On Thu, Oct 29, 2020 at 12:09:23PM +0100, Hans de Goede wrote:
>Hi,
>
>On 10/29/20 11:59 AM, Coiby Xu wrote:
>> Hi Hans,
>>
>> Thank you for reviewing this patch!
>>
>> On Thu, Oct 29, 2020 at 11:04:36AM +0100, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 10/29/20 8:41 AM, Coiby Xu wrote:
>>>> SIMPLE_DEV_PM_OPS has already took good care of CONFIG_PM_CONFIG.
>>>
>>> No it does not, when CONFIG_PM_SLEEP is not set then the
>>> SET_SYSTEM_SLEEP_PM_OPS macro which SIMPLE_DEV_PM_OPS uses
>>> is a no-op, so nothing will reference xo15_sci_resume leading to
>>> a compiler warning when CONFIG_PM_SLEEP is not set.
>>>
>>> You could drop the ifdef and add __maybe_unused to the definition
>>> of xo15_sci_resume, but that feels like needless churn, best to
>>> just keep this as is IMHO.
>>>
>>
>> Actually, this is a tree-wide change by some semi-automation scripts.
>> Thank you for pointing out the issue to prevent me from releasing
>> another ~150 emails to flood other mailing lists.
>>
>> Currently there are 929 drivers has device PM callbacks,
>>
>> $ grep -rI "\.pm = &" --include=*.c  ./|wc -l
>> 929
>>
>> I put all files having device PM callbacks into four categories
>> based on weather a file has CONFIG_PM_SLEEP or PM macro like
>> SET_SYSTEM_SLEEP_PM_OPS, here are the statistics,
>>   1. have both CONFIG_PM_SLEEP and PM_OPS macro: 213
>>   2. have CONFIG_PM_SLEEP but no PM_OPS macro: 19
>>   3. have PM macro but not CONFIG_PM_SLEEP: 347
>>   4. no PM macro or CONFIG_PM_SLEEP: 302
>>
>> Some drivers which have PM macro but not CONFIG_PM_SLEEP like
>> sound/x86/intel_hdmi_audio.c indeed use __maybe_unused to eliminate
>> the compiling warning. In 2011, there's a patch proposing to remove
>> ONFIG_PM altogether but an objection was turning CONFIG_PM on would
>> increase the kernel size [1]. So __maybe_unused also have this issue.
>
>I would expect the compiler to remove the unused function, it knows
>it is unused, that is why __maybe_unused is necessary to suppress
>the warning and compilers are pretty smart and agressive wrt remove
>unnecessary code these days.
>
Then __maybe_unused is a good solution and there's also convincing
reason to prefer __maybe_unused over CONFIG_PM_SLEEP according to
Arnd Bergmann [2],

> > By and large, drivers handle this by using a CONFIG_PM_SLEEP ifdef.
> >
> > Unless you can make an extremely convincing argument why not to do
> > so here, I'd like you to handle it that way instead.
>
> [adding linux-pm to Cc]
>
> The main reason is that everyone gets the #ifdef wrong, I run into
> half a dozen new build regressions with linux-next every week on
> average, the typical problems being:
>
> - testing CONFIG_PM_SLEEP instead of CONFIG_PM, leading to an unused
>   function warning
> - testing CONFIG_PM instead of CONFIG_PM_SLEEP, leading to a build
>   failure
> - calling a function outside of the #ifdef only from inside an
>   otherwise correct #ifdef, again leading to an unused function
>   warning
> - causing a warning inside of the #ifdef but only testing if that
>   is disabled, leading to a problem if the macro is set (this is
>   rare these days for CONFIG_PM as that is normally enabled)
>
> Using __maybe_unused avoids all of the above.

>Regards,
>
>Hans
>

[2] https://lore.kernel.org/patchwork/comment/919944/

--
Best regards,
Coiby

  reply	other threads:[~2020-10-29 14:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29  7:41 Coiby Xu
2020-10-29 10:04 ` Hans de Goede
2020-10-29 10:59   ` Coiby Xu
2020-10-29 11:09     ` Hans de Goede
2020-10-29 14:16       ` Coiby Xu [this message]
2020-10-29 16:03         ` Hans de Goede

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=20201029141646.sijo6iuj44ekytg7@Rk \
    --to=coiby.xu@gmail.com \
    --cc=andy@infradead.org \
    --cc=bp@alien8.de \
    --cc=dvhart@infradead.org \
    --cc=hdegoede@redhat.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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®