From: Alexis Belmonte <alexbelm48@gmail.com>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, W_Armin@gmx.de, hdegoede@redhat.com
Subject: Re: [PATCHv9] platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops
Date: Sat, 6 Jul 2024 16:31:44 +0200 [thread overview]
Message-ID: <ZolVUBcjoJm_6NYN@alexis-pc> (raw)
In-Reply-To: <75b64561-db2b-9fa2-ecdd-d0b573f9b67e@linux.intel.com>
Hi Ilpo,
On Sat, Jul 06, 2024 at 04:02:10PM +0300, Ilpo Järvinen wrote:
> > +
> > + err = unregister_acpi_notifier(&platform_power_source_nb);
> > +
> > + if (err < 0)
> > + pr_err("Failed to remove ACPI power source notify handler\n");
>
> Do we really need this? I don't think deinit paths in general log errors
> (or handle them either).
>
This is something that we discussed with Armin in an earlier revision of
the patch:
On Thu, Jun 20, 2024 at 10:12:21PM +0200, Armin Wolf wrote:
> > On Thu, Jun 27, 2024 at 07:55:26PM +0200, Armin Wolf wrote:
> >>> static void __exit hp_wmi_exit(void)
> >>> {
> >>> + if (is_omen_thermal_profile() || is_victus_thermal_profile())
> >>> + omen_unregister_powersource_event_handler();
> >> You have to check if the event handler was registered successfully before
> >> unregistering it.
> >>
> > Out of curiosity, I did a grep on the kernel drivers source code for
> > register_acpi_notifier/unregister_acpi_notifier and it seems that the
> > common practice is to not check for the return value at all (check out
> > drivers/gpu/drm/radeon/radeon_acpi.c:785 for example).
> >
> > Should I still check for the return value? I also believe there's no
> > proper method to check if a handler is registered or not, so I would
> > believe that I need to keep track of it myself; but since most kernel
> > drivers do not even care about the return value, I am not sure about
> > this.
>
> This seems to me like a very fragile construct, but i believe that error
> checking should be done here regardless.
>
> Maybe you should abort loading of the module when registration fails, so
> hp_wmi_exit() is only called when the notifier was registered successfully.
>
It made sense for me to abort during module loading, so that's what I ended up
doing.
I did a little bit of investigation on unregister_acpi_notifier which
relies on a blocking notifier chain internally. This brings me to
notifier_chain_unregister:
47:static int notifier_chain_unregister(struct notifier_block **nl,
48- struct notifier_block *n)
49-{
50- while ((*nl) != NULL) {
51- if ((*nl) == n) {
52- rcu_assign_pointer(*nl, n->next);
53- trace_notifier_unregister((void *)n->notifier_call);
54- return 0;
55- }
56- nl = &((*nl)->next);
57- }
58- return -ENOENT;
59-}
So it seems that the only error that can be raised from this function is
when the notifier is not found in the chain. This cannot be the case
here, so I understand why most modules do not check for the return
value, at least when unregistering the ACPI notifier.
If Armin is okay with this, I'll remove the error handling and the error
message.
I've taken into account your other comments, and will send a V10 once
everything's good.
Thanks for your time! :]
Alexis
next prev parent reply other threads:[~2024-07-06 14:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-05 10:58 [PATCHv9] platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops Alexis Belmonte
2024-07-05 11:00 ` Alexis Belmonte
2024-07-06 13:02 ` Ilpo Järvinen
2024-07-06 14:31 ` Alexis Belmonte [this message]
2024-07-07 18:53 ` Armin Wolf
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=ZolVUBcjoJm_6NYN@alexis-pc \
--to=alexbelm48@gmail.com \
--cc=W_Armin@gmx.de \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=platform-driver-x86@vger.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