From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: EnDe Tan <ende.tan@starfivetech.com>, Andi Shyti <andi.shyti@kernel.org>
Cc: "linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"andriy.shevchenko@linux.intel.com"
<andriy.shevchenko@linux.intel.com>,
"mika.westerberg@linux.intel.com"
<mika.westerberg@linux.intel.com>,
"jsd@semihalf.com" <jsd@semihalf.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Leyfoon Tan <leyfoon.tan@starfivetech.com>,
"endeneer@gmail.com" <endeneer@gmail.com>
Subject: Re: [1/1] i2c: designware: Ensure runtime suspend is invoked during rapid slave unregistration and registration
Date: Thu, 8 May 2025 14:55:57 +0300 [thread overview]
Message-ID: <fc3703cd-50b7-4b6e-8073-23bd636ff61f@linux.intel.com> (raw)
In-Reply-To: <NTZPR01MB1018FD0E9913437D4B34E751F88B2@NTZPR01MB1018.CHNPR01.prod.partner.outlook.cn>
On 5/8/25 11:30 AM, EnDe Tan wrote:
> Hi Andi and Jarkko, thank you for the feedback.
>
>> -----Original Message-----
>> From: Andi Shyti <andi.shyti@kernel.org>
>> Sent: Tuesday, 6 May, 2025 5:49 AM
>> To: Jarkko Nikula <jarkko.nikula@linux.intel.com>
>> Cc: EnDe Tan <ende.tan@starfivetech.com>; linux-i2c@vger.kernel.org;
> ...
>>> Good explanation and could you add it the commit log together with the
>>> example?
>>
>> If you want you can paste the new commit log as reply to this e-mail.
>
> Here is the new commit log, feel free to let me know if further changes are required:
>
> Replaced pm_runtime_put() with pm_runtime_put_sync_suspend() to ensure
> the runtime suspend is invoked immediately when unregistering a slave.
> This prevents a race condition where suspend was skipped when
> unregistering and registering slave in quick succession.
>
> For example, consider the rapid sequence of
> `delete_device -> new_device -> delete_device -> new_device`.
> In this sequence, it is observed that the dw_i2c_plat_runtime_suspend() might
> not be invoked after `delete_device` operation.
>
> This is because after `delete_device` operation, when the
> pm_runtime_put() is about to trigger suspend, the following `new_device`
> operation might race and cancel the suspend.
>
> If that happens, during the `new_device` operation,
> dw_i2c_plat_runtime_resume() is skipped (since there was no suspend), which
> means `i_dev->init()`, i.e. i2c_dw_init_slave(), is skipped.
> Since i2c_dw_init_slave() is skipped, i2c_dw_configure_fifo_slave() is
> skipped too, which leaves `DW_IC_INTR_MASK` unconfigured. If we inspect
> the interrupt mask register using devmem, it will show as zero.
>
> Example shell script to reproduce the issue:
> ```
> #!/bin/sh
>
> SLAVE_LADDR=0x1010
> SLAVE_BUS=13
> NEW_DEVICE=/sys/bus/i2c/devices/i2c-$SLAVE_BUS/new_device
> DELETE_DEVICE=/sys/bus/i2c/devices/i2c-$SLAVE_BUS/delete_device
>
> # Create initial device
> echo slave-24c02 $SLAVE_LADDR > $NEW_DEVICE
> sleep 2
>
> # Rapid sequence of
> # delete_device -> new_device -> delete_device -> new_device
> echo $SLAVE_LADDR > $DELETE_DEVICE
> echo slave-24c02 $SLAVE_LADDR > $NEW_DEVICE
> echo $SLAVE_LADDR > $DELETE_DEVICE
> echo slave-24c02 $SLAVE_LADDR > $NEW_DEVICE
>
> # Using devmem to inspect IC_INTR_MASK will show as zero
> ```
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
next prev parent reply other threads:[~2025-05-08 11:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-12 2:33 [1/1] i2c: designware: Ensure runtime suspend is invoked during rapid slave unregistration and registration ende.tan
2025-04-15 13:57 ` Jarkko Nikula
2025-04-20 3:31 ` EnDe Tan
2025-05-02 11:03 ` Jarkko Nikula
2025-05-05 21:48 ` Andi Shyti
2025-05-08 8:30 ` EnDe Tan
2025-05-08 11:55 ` Jarkko Nikula [this message]
2025-05-12 23:29 ` Andi Shyti
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=fc3703cd-50b7-4b6e-8073-23bd636ff61f@linux.intel.com \
--to=jarkko.nikula@linux.intel.com \
--cc=andi.shyti@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ende.tan@starfivetech.com \
--cc=endeneer@gmail.com \
--cc=jsd@semihalf.com \
--cc=leyfoon.tan@starfivetech.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.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