public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Kiwoong Kim" <kwmad.kim@samsung.com>
To: "'Ulf Hansson'" <ulf.hansson@linaro.org>,
	<linux-mmc@vger.kernel.org>,
	"'Rafael J . Wysocki'" <rjw@rjwysocki.net>
Cc: "'Adrian Hunter'" <adrian.hunter@intel.com>,
	"'Linus Walleij'" <linus.walleij@linaro.org>,
	"'Wolfram Sang'" <wsa+renesas@sang-engineering.com>,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	"'Android Kernel Team'" <kernel-team@android.com>,
	stable@vger.kernel.org, 이상현 <sh425.lee@samsung.com>,
	서승철 <sc.suh@samsung.com>, 서호영 <hy50.seo@samsung.com>,
	김병훈 <bhoon95.kim@samsung.com>
Subject: RE: [PATCH] mmc: core: Fix hanging on I/O during system suspend for removable cards
Date: Mon, 22 Mar 2021 16:21:13 +0900	[thread overview]
Message-ID: <006b01d71eeb$f16c6680$d4453380$@samsung.com> (raw)
In-Reply-To: <20210310152900.149380-1-ulf.hansson@linaro.org>

> The mmc core uses a PM notifier to temporarily during system suspend, turn
> off the card detection mechanism for removal/insertion of (e)MMC/SD/SDIO
> cards. Additionally, the notifier may be used to remove an SDIO card
> entirely, if a corresponding SDIO functional driver don't have the system
> suspend/resume callbacks assigned. This behaviour has been around for a
> very long time.
> 
> However, a recent bug report tells us there are problems with this
> approach. More precisely, when receiving the PM_SUSPEND_PREPARE
> notification, we may end up hanging on I/O to be completed, thus also
> preventing the system from getting suspended.
> 
> In the end what happens, is that the cancel_delayed_work_sync() in
> mmc_pm_notify() ends up waiting for mmc_rescan() to complete - and since
> mmc_rescan() wants to claim the host, it needs to wait for the I/O to be
> completed first.
> 
> Typically, this problem is triggered in Android, if there is ongoing I/O
> while the user decides to suspend, resume and then suspend the system
> again. This due to that after the resume, an mmc_rescan() work gets punted
> to the workqueue, which job is to verify that the card remains inserted
> after the system has resumed.
> 
> To fix this problem, userspace needs to become frozen to suspend the I/O,
> prior to turning off the card detection mechanism. Therefore, let's drop
> the PM notifiers for mmc subsystem altogether and rely on the card
> detection to be turned off/on as a part of the system_freezable_wq, that
> we are already using.
> 
> Moreover, to allow and SDIO card to be removed during system suspend,
> let's manage this from a ->prepare() callback, assigned at the
> mmc_host_class level. In this way, we can use the parent device (the
> mmc_host_class device), to remove the card device that is the child, in
> the
> device_prepare() phase.
> 
> Reported-by: Kiwoong Kim <kwmad.kim@samsung.com>
> Cc: stable@vger.kernel.org
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>


Reviewed-by: Kiwoong Kim <kwmad.kim@samsung.com>

Thanks.
Kiwoong Kim


      parent reply	other threads:[~2021-03-22  7:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210310152931epcas2p1be7719eeaca8d14bf7a8244ff389bd39@epcas2p1.samsung.com>
2021-03-10 15:29 ` [PATCH] mmc: core: Fix hanging on I/O during system suspend for removable cards Ulf Hansson
2021-03-11  1:01   ` Linus Walleij
2021-03-22  7:21   ` Kiwoong Kim [this message]

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='006b01d71eeb$f16c6680$d4453380$@samsung.com' \
    --to=kwmad.kim@samsung.com \
    --cc=adrian.hunter@intel.com \
    --cc=bhoon95.kim@samsung.com \
    --cc=hy50.seo@samsung.com \
    --cc=kernel-team@android.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sc.suh@samsung.com \
    --cc=sh425.lee@samsung.com \
    --cc=stable@vger.kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.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