Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Saravana Kannan <saravanak@google.com>, Arnd Bergmann <arnd@arndb.de>
Cc: linux-arm-kernel@lists.infradead.org, kernel@dh-electronics.com,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Fabio Estevam <festevam@gmail.com>,
	Jeff Johnson <quic_jjohnson@quicinc.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Shawn Guo <shawnguo@kernel.org>,
	imx@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] soc: imx8m: Probe the SoC driver as platform driver
Date: Thu, 26 Sep 2024 23:26:45 +0200	[thread overview]
Message-ID: <ac403563-34ee-4ba1-b658-06f8df0f5f90@denx.de> (raw)
In-Reply-To: <CAGETcx8opbQ=+dBkSWwfCoqGsvUBftJm7VaGULZhC5DNyuktJQ@mail.gmail.com>

On 9/26/24 7:36 PM, Saravana Kannan wrote:
> On Wed, Sep 25, 2024 at 11:28 PM Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> On Wed, Sep 25, 2024, at 22:04, Marek Vasut wrote:
>>> With driver_async_probe=* on kernel command line, the following trace is
>>> produced because on i.MX8M Plus hardware because the soc-imx8m.c driver
>>> calls of_clk_get_by_name() which returns -EPROBE_DEFER because the clock
>>> driver is not yet probed. This was not detected during regular testing
>>> without driver_async_probe.
>>>
>>> Convert the SoC code to platform driver and instantiate a platform device
>>> in its current device_initcall() to probe the platform driver. Rework
>>> .soc_revision callback to always return valid error code and return SoC
>>> revision via parameter. This way, if anything in the .soc_revision callback
>>> return -EPROBE_DEFER, it gets propagated to .probe and the .probe will get
>>> retried later.
>>
>> Thanks for the new version, that was quick!
>>
>>> +static struct platform_driver imx8m_soc_driver = {
>>> +     .probe = imx8m_soc_probe,
>>> +     .driver = {
>>> +             .name = "imx8m-soc",
>>> +     },
>>> +};
>>> +module_platform_driver(imx8m_soc_driver);
>>> +
>>> +static int __init imx8_soc_init(void)
>>> +{
>>> +     struct platform_device *pdev;
>>> +
>>> +     pdev = platform_device_register_simple("imx8m-soc", -1, NULL, 0);
>>> +
>>> +     return IS_ERR(pdev) ? PTR_ERR(pdev) : 0;
>>> +}
>>>   device_initcall(imx8_soc_init);
>>
>> Did you run into problems with the method I suggested first?
>>
>> I don't like the way that this version still registers both the
>> device and driver regardless of the hardware it runs on, I'd
>> prefer to leave the platform check in the initcall and
>> only register them if we are actually on an imx8 machine.
>>
>> Having two initcalls also makes it impossible to build this
>> as a loadable module, which is why I suggested
>> platform_create_bundle().
> 
> That particular helper doesn't seem to like probe deferral because it
> allows for some of the code to be in init sections. So, it gets
> dropped after module load is complete. So, Marek will still have to
> register the device and driver separately. But I agree that it might
> be better to NOT register the device and driver if the basic
> conditions aren't met.
Fixed in V3.

  reply	other threads:[~2024-09-26 21:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 22:04 [PATCH v2] soc: imx8m: Probe the SoC driver as platform driver Marek Vasut
2024-09-25 23:03 ` Saravana Kannan
2024-09-26 21:35   ` Marek Vasut
2024-09-26  6:28 ` Arnd Bergmann
2024-09-26 17:36   ` Saravana Kannan
2024-09-26 21:26     ` Marek Vasut [this message]
2024-09-28  8:24 ` kernel test robot

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=ac403563-34ee-4ba1-b658-06f8df0f5f90@denx.de \
    --to=marex@denx.de \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=arnd@arndb.de \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@dh-electronics.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_jjohnson@quicinc.com \
    --cc=s.hauer@pengutronix.de \
    --cc=saravanak@google.com \
    --cc=shawnguo@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