public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: avoid reload of p state in interation
@ 2023-11-14  8:52 Maria Yu
  2023-11-14  8:56 ` kernel test robot
  2023-11-14 13:21 ` Linus Walleij
  0 siblings, 2 replies; 6+ messages in thread
From: Maria Yu @ 2023-11-14  8:52 UTC (permalink / raw)
  To: linus.walleij; +Cc: Maria Yu, linux-gpio, linux-kernel, kernel, stable

When in the list_for_each_entry interation, reload of p->state->settings
with a local setting from old_state will makes the list interation in a
infite loop.

Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
---
 drivers/pinctrl/core.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 1fa89be29b8f..f2977eb65522 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1262,17 +1262,17 @@ static void pinctrl_link_add(struct pinctrl_dev *pctldev,
 static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
 {
 	struct pinctrl_setting *setting, *setting2;
-	struct pinctrl_state *old_state = p->state;
+	struct pinctrl_state *old_state = READ_ONCE(p->state);
 	int ret;
 
-	if (p->state) {
+	if (old_state) {
 		/*
 		 * For each pinmux setting in the old state, forget SW's record
 		 * of mux owner for that pingroup. Any pingroups which are
 		 * still owned by the new state will be re-acquired by the call
 		 * to pinmux_enable_setting() in the loop below.
 		 */
-		list_for_each_entry(setting, &p->state->settings, node) {
+		list_for_each_entry(setting, &old_state->settings, node) {
 			if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
 				continue;
 			pinmux_disable_setting(setting);

base-commit: 9bacdd8996c77c42ca004440be610692275ff9d0
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: avoid reload of p state in interation
  2023-11-14  8:52 [PATCH] pinctrl: avoid reload of p state in interation Maria Yu
@ 2023-11-14  8:56 ` kernel test robot
  2023-11-14 13:21 ` Linus Walleij
  1 sibling, 0 replies; 6+ messages in thread
From: kernel test robot @ 2023-11-14  8:56 UTC (permalink / raw)
  To: Maria Yu; +Cc: stable, oe-kbuild-all

Hi,

Thanks for your patch.

FYI: kernel test robot notices the stable kernel rule is not satisfied.

The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1

Rule: add the tag "Cc: stable@vger.kernel.org" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH] pinctrl: avoid reload of p state in interation
Link: https://lore.kernel.org/stable/20231114085258.2378-1-quic_aiquny%40quicinc.com

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: avoid reload of p state in interation
  2023-11-14  8:52 [PATCH] pinctrl: avoid reload of p state in interation Maria Yu
  2023-11-14  8:56 ` kernel test robot
@ 2023-11-14 13:21 ` Linus Walleij
  2023-11-15  0:56   ` Aiqun(Maria) Yu
  1 sibling, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2023-11-14 13:21 UTC (permalink / raw)
  To: Maria Yu; +Cc: linux-gpio, linux-kernel, kernel, stable

Hi Maria,

thanks for your patch!

On Tue, Nov 14, 2023 at 9:54 AM Maria Yu <quic_aiquny@quicinc.com> wrote:

> When in the list_for_each_entry interation, reload of p->state->settings
> with a local setting from old_state will makes the list interation in a
> infite loop.
>
> Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>

This makes sense in a way, since this is a compiler-dependent problem,
can you state in the commit message which compiler and architecture
you see this on?

If it is a regression, should this also be queued for stable? (I guess so?)

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: avoid reload of p state in interation
  2023-11-14 13:21 ` Linus Walleij
@ 2023-11-15  0:56   ` Aiqun(Maria) Yu
  2023-11-15  2:07     ` andy.shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Aiqun(Maria) Yu @ 2023-11-15  0:56 UTC (permalink / raw)
  To: Linus Walleij; +Cc: linux-gpio, linux-kernel, kernel, stable

On 11/14/2023 9:21 PM, Linus Walleij wrote:
> Hi Maria,
> 
> thanks for your patch!
> 
> On Tue, Nov 14, 2023 at 9:54 AM Maria Yu <quic_aiquny@quicinc.com> wrote:
> 
>> When in the list_for_each_entry interation, reload of p->state->settings
>> with a local setting from old_state will makes the list interation in a
>> infite loop.
>>
>> Signed-off-by: Maria Yu <quic_aiquny@quicinc.com>
> 
> This makes sense in a way, since this is a compiler-dependent problem,
> can you state in the commit message which compiler and architecture
> you see this on?
I have a crash dump which caused by this issue which is using Clang 
10.0, arm64, Linux Version 4.19.
Thx for your suggestion, I will put this information in the commit message.
> 
> If it is a regression, should this also be queued for stable? (I guess so?)
This is a corner case which is very hard to reproduce in product, I 
suggest this fix to be queued for stable.
> 
> Yours,
> Linus Walleij

-- 
Thx and BRs,
Aiqun(Maria) Yu


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: avoid reload of p state in interation
  2023-11-15  0:56   ` Aiqun(Maria) Yu
@ 2023-11-15  2:07     ` andy.shevchenko
  2023-11-15  3:05       ` Aiqun(Maria) Yu
  0 siblings, 1 reply; 6+ messages in thread
From: andy.shevchenko @ 2023-11-15  2:07 UTC (permalink / raw)
  To: Aiqun(Maria) Yu; +Cc: Linus Walleij, linux-gpio, linux-kernel, kernel, stable

Wed, Nov 15, 2023 at 08:56:35AM +0800, Aiqun(Maria) Yu kirjoitti:
> On 11/14/2023 9:21 PM, Linus Walleij wrote:
> > On Tue, Nov 14, 2023 at 9:54 AM Maria Yu <quic_aiquny@quicinc.com> wrote:

...

> > This makes sense in a way, since this is a compiler-dependent problem,
> > can you state in the commit message which compiler and architecture
> > you see this on?
> I have a crash dump which caused by this issue which is using Clang 10.0,
> arm64, Linux Version 4.19.
> Thx for your suggestion, I will put this information in the commit message.

Please, also add a kernel version and a few (most important) lines from the crash.

> > If it is a regression, should this also be queued for stable? (I guess so?)
> This is a corner case which is very hard to reproduce in product, I suggest
> this fix to be queued for stable.

Please, provide a respective Fixes tag.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] pinctrl: avoid reload of p state in interation
  2023-11-15  2:07     ` andy.shevchenko
@ 2023-11-15  3:05       ` Aiqun(Maria) Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Aiqun(Maria) Yu @ 2023-11-15  3:05 UTC (permalink / raw)
  To: andy.shevchenko; +Cc: Linus Walleij, linux-gpio, linux-kernel, kernel, stable

On 11/15/2023 10:07 AM, andy.shevchenko@gmail.com wrote:
> Wed, Nov 15, 2023 at 08:56:35AM +0800, Aiqun(Maria) Yu kirjoitti:
>> On 11/14/2023 9:21 PM, Linus Walleij wrote:
>>> On Tue, Nov 14, 2023 at 9:54 AM Maria Yu <quic_aiquny@quicinc.com> wrote:
> 
> ...
> 
>>> This makes sense in a way, since this is a compiler-dependent problem,
>>> can you state in the commit message which compiler and architecture
>>> you see this on?
>> I have a crash dump which caused by this issue which is using Clang 10.0,
>> arm64, Linux Version 4.19.
>> Thx for your suggestion, I will put this information in the commit message.
> 
> Please, also add a kernel version and a few (most important) lines from the crash.
Thx for the suggetion. Will add kernel version as well.
> 
>>> If it is a regression, should this also be queued for stable? (I guess so?)
>> This is a corner case which is very hard to reproduce in product, I suggest
>> this fix to be queued for stable.
> 
> Please, provide a respective Fixes tag.
Thx for remind. Will do.
> 

-- 
Thx and BRs,
Aiqun(Maria) Yu


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-15  3:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-14  8:52 [PATCH] pinctrl: avoid reload of p state in interation Maria Yu
2023-11-14  8:56 ` kernel test robot
2023-11-14 13:21 ` Linus Walleij
2023-11-15  0:56   ` Aiqun(Maria) Yu
2023-11-15  2:07     ` andy.shevchenko
2023-11-15  3:05       ` Aiqun(Maria) Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox