Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
To: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
	"Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: "Michal Simek" <michal.simek@amd.com>,
	"Andi Shyti" <andi.shyti@kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-i2c@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] i2c: xiic: restore non-managed runtime PM to fix clk WARN flood
Date: Wed, 19 Aug 2026 09:46:01 -0700	[thread overview]
Message-ID: <DKT2MHJFPM96.3Q0I52V3283ER@nexthop.ai> (raw)
In-Reply-To: <aoVRpS7EmL3YYBWH@ashevche-desk.local>

On Tue Aug 18, 2026 at 11:48 PM PDT, Andy Shevchenko wrote:
> On Wed, Aug 19, 2026 at 09:45:41AM +0300, Andy Shevchenko wrote:
>> On Tue, Aug 18, 2026 at 08:35:10AM -0700, Abdurrahman Hussain wrote:
>
> ...
>
>> >  	pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
>> >  	pm_runtime_use_autosuspend(dev);
>> > -	ret = devm_pm_runtime_set_active_enabled(dev);
>> > -	if (ret)
>> > -		return ret;
>> > +	/*
>> > +	 * Enable runtime PM by hand: devm_pm_runtime_set_active_enabled()
>> > +	 * tears down in an order that races the devm-enabled clock release and
>> > +	 * makes clk_core_disable() WARN (see xiic_i2c_remove()).
>> > +	 */
>> > +	pm_runtime_set_active(dev);
>> > +	pm_runtime_enable(dev);
>> >  
>> >  	/* SCL frequency configuration */
>> >  	i2c->input_clk = clk_get_rate(i2c->clk);
>> 
>> >  	ret = devm_request_threaded_irq(dev, irq, NULL, xiic_process,
>> >  					IRQF_ONESHOT, pdev->name, i2c);
>> >  	if (ret)
>> > -		return ret;
>> > +		goto err_pm_disable;
>> 
>> This might be problematic now. You need to unwind the IRQ request in non-devm
>> manner as well. Scenario is that IRQ comes exactly after PM is disabled
>> in the error path. Is it a problem today? What about tomorrow (assuming some
>> new chips / code is added)?
>
> (To be clear: I'm talking about next call(s) that may fail, like xiic_reinit()
>  later in the probe.)
>
>> The rule of thumb is that, no devm_*() call should be followed by a goto.

Makes sense. I haven't hit it on our hardware yet, but I understand the
concern: once the probe unwinds runtime PM by hand via goto, the
devm-registered handler stays live across that teardown (and across any
future failing step added after it). I'll switch to
request_threaded_irq()/free_irq() and free it explicitly in the probe
error path and in remove() for v4.

Thanks for careful review!

Best regards,
Abdurrahman


      reply	other threads:[~2026-08-19 16:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-18 15:35 [PATCH v3] i2c: xiic: restore non-managed runtime PM to fix clk WARN flood Abdurrahman Hussain
2026-08-19  6:45 ` Andy Shevchenko
2026-08-19  6:48   ` Andy Shevchenko
2026-08-19 16:46     ` Abdurrahman Hussain [this message]

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=DKT2MHJFPM96.3Q0I52V3283ER@nexthop.ai \
    --to=abdurrahman@nexthop.ai \
    --cc=andi.shyti@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@amd.com \
    /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