From: James Morse <james.morse@arm.com>
To: luanshi <zhangliguang@linux.alibaba.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] firmware: arm_sdei: fix possible deadlock
Date: Mon, 6 Jan 2020 15:56:51 +0000 [thread overview]
Message-ID: <0f122a88-e2e1-2139-1c2d-095f684a5701@arm.com> (raw)
In-Reply-To: <1577110975-54782-1-git-send-email-zhangliguang@linux.alibaba.com>
Hi Luanshi!
On 23/12/2019 14:22, luanshi wrote:
> From: Liguang Zhang <zhangliguang@linux.alibaba.com>
>
> We call sdei_reregister_event() with sdei_list_lock held but
> _sdei_event_register() and sdei_event_destroy() also acquires
> sdei_list_lock thus creating A-A deadlock.
Ooer. This was clearly never tested properly!
The hibernate support got plenty of testing, but it must have been with only private
events. Hibernate+SDEI with a side-order of cpuhp is a niche sport.
> diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c
> index a479023..b122927 100644
> --- a/drivers/firmware/arm_sdei.c
> +++ b/drivers/firmware/arm_sdei.c
> @@ -651,20 +651,19 @@ static int sdei_reregister_event(struct sdei_event *event)
>
> lockdep_assert_held(&sdei_events_lock);
>
> - err = _sdei_event_register(event);
> + err = sdei_api_event_register(event->event_num,
> + sdei_entry_point,
> + event->registered,
> + SDEI_EVENT_REGISTER_RM_ANY, 0);
I don't like pushing these 'api' calls further out creating more of them...
The root of the problem is the reregister/reenable values are protected by the same lock
as the list, _sdei_event_register() needs to manipulate these, which it can't do from
something that is walking the list.
The list lock is a spin_lock() because the cpuhp callbacks happen too early for taking
mutexes, (fairly sure). Those callbacks don't hit this because they skip shared events.
As the simplest fix for stable, could we add another spin_lock inside struct sdei_event to
independently protect the reregister/renable values? This would always be taken last, and
removes the double-lock.
Was this from inspection, or is there some tool I should be running?!
(my testing obviously missed it)
Thanks,
James
next prev parent reply other threads:[~2020-01-06 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-23 14:22 luanshi
2019-12-23 14:22 ` [PATCH 2/3] firmware: arm_sdei: Removed multiple white lines luanshi
2019-12-23 14:22 ` [PATCH 3/3] firmware: arm_sdei: clean up sdei_event_create() luanshi
2020-01-06 15:56 ` James Morse [this message]
2020-01-16 1:54 ` [PATCH 1/3] firmware: arm_sdei: fix possible deadlock 乱石
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=0f122a88-e2e1-2139-1c2d-095f684a5701@arm.com \
--to=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zhangliguang@linux.alibaba.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
Powered by JetHome