From: "Kurt Borja" <kuurtb@gmail.com>
To: "Mark Pearson" <mpearson-lenovo@squebb.ca>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Limonciello, Mario" <mario.limonciello@amd.com>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: Fix registration of tpacpi platform driver
Date: Sat, 08 Feb 2025 08:54:41 -0500 [thread overview]
Message-ID: <D7N45UX5LBMY.NCG1A7Y0SKXF@gmail.com> (raw)
In-Reply-To: <aee5fbe6-4309-450f-bea3-c0842172b043@app.fastmail.com>
On Sat Feb 8, 2025 at 11:26 AM -05, Mark Pearson wrote:
> Thanks Kurt,
>
> On Fri, Feb 7, 2025, at 11:56 PM, Kurt Borja wrote:
>> Hi Mark,
>>
>> On Sat Feb 8, 2025 at 4:14 AM -05, Mark Pearson wrote:
>>> When reviewing and testing the recent platform profile changes I had
>>> missed that they prevent the tpacpi platform driver from registering.
>>> This error is seen in the kernel logs, and the various tpacpi entries
>>> are not created:
>>> [ 7550.642171] platform thinkpad_acpi: Resources present before probing
>>
>> This happens because in thinkpad_acpi_module_init(), ibm_init() is
>> called before platform_driver_register(&tpacpi_pdriver), therefore
>> devm_platform_profile_register() is called before tpacpi_pdev probes.
>>
>> As you can verify in [1], in the probing sequence, the driver core
>> verifies the devres list is empty, which in this case is not because of
>> the devm_ call.
>>
>>>
>>> I believe this is because the platform_profile driver registers the
>>> device as part of it's initialisation in devm_platform_profile_register,
>>> and the thinkpad_acpi driver later fails as the resource is already used.
>>>
>>> Modified thinkpad_acpi so that it has a separate platform driver for the
>>> profile handling, leaving the existing tpacpi_pdev to register
>>> successfully.
>>
>> While this works, it does not address the problem directly. Also it is
>> discouraged to create "fake" platform devices [2].
>>
>> May I suggest moving tpacpi_pdriver registration before ibm_init()
>> instead, so ibm_init_struct's .init callbacks can use devres?
>>
>
> Yep - you're right. Moving it before the init does also fix it.
>
> I can't see any issues with this approach, but I'll test it out a bit more carefully and do an updated version with this approach.
Thinking about it a bit more. With this approach you should maybe create
the tpacpi_pdev with platform_create_bundle() (I'm pretty sure you can
pass a NULL (*probe) callback) to avoid races.
platform_create_bundle() only returns after the device has been
successfully bound to the driver.
~ Kurt
>
> Thanks for the pointer.
>
> Mark
next prev parent reply other threads:[~2025-02-08 13:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-08 9:14 [PATCH] platform/x86: thinkpad_acpi: Fix registration of tpacpi platform driver Mark Pearson
2025-02-08 4:56 ` Kurt Borja
2025-02-08 16:26 ` Mark Pearson
2025-02-08 13:54 ` Kurt Borja [this message]
2025-02-10 0:54 ` Mark Pearson
2025-02-10 1:18 ` Kurt Borja
2025-02-10 1:26 ` Mark Pearson
2025-02-10 2:10 ` Kurt Borja
2025-02-10 2:35 ` Mark Pearson
2025-02-10 3:04 ` Kurt Borja
2025-02-10 3:14 ` Mark Pearson
2025-02-10 3:28 ` Kurt Borja
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=D7N45UX5LBMY.NCG1A7Y0SKXF@gmail.com \
--to=kuurtb@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=mpearson-lenovo@squebb.ca \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.