From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Petr Mladek <pmladek@suse.com>
Cc: John Ogness <john.ogness@linutronix.de>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-acpi@vger.kernel.org, rafael@kernel.org,
mika.westerberg@linux.intel.com
Subject: Re: [PATCH 0/3] Get device's parent from parent field, fix sleeping IRQs disabled
Date: Wed, 3 Nov 2021 19:07:13 +0200 [thread overview]
Message-ID: <YYLBwX3HN2pT6ZkD@smile.fi.intel.com> (raw)
In-Reply-To: <YYKvIPp6BEMXBJZs@alley>
On Wed, Nov 03, 2021 at 04:47:44PM +0100, Petr Mladek wrote:
> On Wed 2021-11-03 15:50:04, John Ogness wrote:
> > On 2021-11-03, Sakari Ailus <sakari.ailus@linux.intel.com> wrote:
> > > This set changes getting fwnode's parent on ACPI fwnode so it no longer
> > > needs a semaphore, using struct acpi_device->parent field instead of
> > > calling acpi_get_parent(). The semaphore is being acquired when the
> > > device's full path is printed which now takes place local IRQs disabled:
> > >
> > > --------8<------------------------
> > > BUG: sleeping function called from invalid context at kernel/locking/semaphore.c:163
> > >
> > > ...
> > >
> > > Call Trace:
> > > <TASK>
> > > dump_stack_lvl+0x57/0x7d
> > > __might_resched.cold+0xf4/0x12f
> > > down_timeout+0x21/0x70
> > > acpi_os_wait_semaphore+0x63/0x180
> > > acpi_ut_acquire_mutex+0x123/0x1ba
> > > acpi_get_parent+0x30/0x71
> > > acpi_node_get_parent+0x64/0x90
> > > ? lock_acquire+0x1a0/0x300
> > > fwnode_count_parents+0x6d/0xb0
> > > fwnode_full_name_string+0x18/0x90
> > > fwnode_string+0xd7/0x140
> > > vsnprintf+0x1ec/0x4f0
> > > va_format.constprop.0+0x6a/0x130
> > > vsnprintf+0x1ec/0x4f0
> > > vprintk_store+0x271/0x5a0
> > > ? rcu_read_lock_sched_held+0x12/0x70
> > > ? lock_release+0x228/0x310
> > > ? acpi_initialize_hp_context+0x50/0x50
> > > vprintk_emit+0xd5/0x340
> > > _printk+0x58/0x6f
> > ...
> > > --------8<------------------------
> > >
> > > I guess one could argue it wasn't great to begin with that getting
> > > fwnode's parent required a semaphore to begin with, nevertheless John's
> > > patch made it a concrete problem. Added Cc: stable, too.
>
> It looks like a generic problem.
>
> If I get it properly, we should make sure that any struct
> fwnode_operations implementation will _not_ use sleeping locks in
> the .get_parent() callback. Or anything that is called indirectly
> from from vsprintf.
Not sure how I may help here, but if there is a requirement to all *printf()
to be non-sleepable, then yes, this should be done in that way. I'm not sure
if every single %p extension does this...
It may require to update fwnode (source code) documentation to reflect the
requirement. Also might_sleep() / migth_sleep_if() in the API calls may
shed a light on (potential) issues.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-11-03 17:16 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-03 13:34 [PATCH 0/3] Get device's parent from parent field, fix sleeping IRQs disabled Sakari Ailus
2021-11-03 13:34 ` [PATCH 1/3] ACPI: Make acpi_fwnode_handle safer Sakari Ailus
2021-11-03 16:58 ` Andy Shevchenko
2021-11-03 17:55 ` Rafael J. Wysocki
2021-11-04 12:48 ` Sakari Ailus
2021-11-04 13:16 ` Sakari Ailus
2021-11-03 13:34 ` [PATCH 2/3] ACPI: Get acpi_device's parent from the parent field Sakari Ailus
2021-11-03 17:01 ` Andy Shevchenko
2021-11-03 17:48 ` Rafael J. Wysocki
2021-11-04 12:52 ` Sakari Ailus
2021-11-03 13:34 ` [PATCH 3/3] ACPI: Make acpi_node_get_parent() local Sakari Ailus
2021-11-03 17:02 ` Andy Shevchenko
2021-11-04 13:09 ` Sakari Ailus
2021-11-03 14:44 ` [PATCH 0/3] Get device's parent from parent field, fix sleeping IRQs disabled John Ogness
2021-11-03 15:47 ` Petr Mladek
2021-11-03 17:07 ` Andy Shevchenko [this message]
2021-11-04 12:45 ` Sakari Ailus
2021-11-03 15:49 ` Petr Mladek
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=YYLBwX3HN2pT6ZkD@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=john.ogness@linutronix.de \
--cc=linux-acpi@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=pmladek@suse.com \
--cc=rafael@kernel.org \
--cc=sakari.ailus@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