From: Tony Lindgren <tony@atomide.com>
To: "H. Nikolaus Schaller" <hns@goldelico.com>
Cc: Christ van Willegen <cvwillegen@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
kernel@pyra-handheld.com,
Discussions about the Letux Kernel <letux-kernel@openphoenux.org>
Subject: Re: [Letux-kernel] BUG: drivers/pinctrl/core: races in pinctrl_groups and deferred probing
Date: Mon, 18 Jun 2018 21:34:08 -0700 [thread overview]
Message-ID: <20180619043408.GT112168@atomide.com> (raw)
In-Reply-To: <404C63D9-169E-4051-88E0-2856F3602A72@goldelico.com>
* H. Nikolaus Schaller <hns@goldelico.com> [180618 18:33]:
> >> So code just needs group cleanup on failed probing and fixing the mutex around pinctrl_generic_add_group().
> >>
> >> I think we need the mutex because a race still can happen when create_pinctrl() is calling pcs_dt_node_to_map()
> >> and pinctrl_generic_add_group() w/o being locked on pinctrl_maps_mutex.
> >>
> >> The race I suspect is that two drivers are trying to insert the same name and may come
> >> both to the conclusion that it does not yet exist. And both insert into the radix tree.
> >>
> >> The window of risk is small though... It is in pinctrl_generic_add_group() between calling
> >> pinctrl_generic_group_name_to_selector() and radix_tree_insert() so we probably won't
> >> see it in real hardware tests.
> >
> > Hmm but that race should be already fixed with mutex held
> > by the pin controller drivers with these fixes? Or am I
> > missing something still?
>
> Hm. Maybe we refer to a different mutex?
Yes I think that's the case, you're talking about a different
mutex here :)
> I had seen the call sequence
>
> create_pinctrl()-> pinctrl_dt_to_map() -> pcs_dt_node_to_map() -> pinctrl_generic_add_group()
>
> w/o any lock inside.
>
> There is a mutex_lock(&pinctrl_maps_mutex); in create_pinctrl(), but locked after that.
>
> Or is there a lock outside of create_pinctrl()?
>
> If I look into the stack dumps, call nesting is
>
> driver_probe_device() -> pinctrl_bind_pins() -> devm_pinctrl_get() -> create_pinctrl()
>
> They all do no locking.
>
> Maybe I am missing something.
Can you please post a patch for that as you already have it
debugged? That's easier to understand than reading a verbal
patch :)
Regards,
Tony
next prev parent reply other threads:[~2018-06-19 4:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 12:39 BUG: drivers/pinctrl/core: races in pinctrl_groups and deferred probing H. Nikolaus Schaller
2018-06-14 12:01 ` Tony Lindgren
2018-06-14 12:12 ` H. Nikolaus Schaller
2018-06-15 6:58 ` Tony Lindgren
2018-06-15 11:13 ` Tony Lindgren
2018-06-15 11:18 ` H. Nikolaus Schaller
2018-06-16 11:07 ` [Letux-kernel] " H. Nikolaus Schaller
2018-06-18 6:46 ` Tony Lindgren
2018-06-18 8:22 ` Andy Shevchenko
2018-06-18 9:14 ` Tony Lindgren
2018-06-18 9:29 ` H. Nikolaus Schaller
2018-06-18 9:54 ` Tony Lindgren
2018-06-18 9:59 ` H. Nikolaus Schaller
[not found] ` <CA+Ot1OxNj30KgHWJHXgWbnXYkNXTNvd_t-b6+uG3u=z8+pZf2Q@mail.gmail.com>
2018-06-18 11:51 ` Tony Lindgren
2018-06-18 16:43 ` H. Nikolaus Schaller
2018-06-18 18:17 ` Tony Lindgren
2018-06-18 18:30 ` H. Nikolaus Schaller
2018-06-19 4:34 ` Tony Lindgren [this message]
2018-06-19 4:51 ` H. Nikolaus Schaller
2018-06-19 6:11 ` Tony Lindgren
2018-06-19 6:39 ` H. Nikolaus Schaller
2018-06-19 7:15 ` Tony Lindgren
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=20180619043408.GT112168@atomide.com \
--to=tony@atomide.com \
--cc=andy.shevchenko@gmail.com \
--cc=cvwillegen@gmail.com \
--cc=hns@goldelico.com \
--cc=kernel@pyra-handheld.com \
--cc=letux-kernel@openphoenux.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@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.