From patchwork Tue May 17 07:53:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chuanxiao.Dong" X-Patchwork-Id: 790752 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4H841vM029622 for ; Tue, 17 May 2011 08:04:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730Ab1EQIEA (ORCPT ); Tue, 17 May 2011 04:04:00 -0400 Received: from mga11.intel.com ([192.55.52.93]:2660 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752624Ab1EQID6 (ORCPT ); Tue, 17 May 2011 04:03:58 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 17 May 2011 01:03:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.65,224,1304319600"; d="scan'208";a="2660232" Received: from unknown (HELO intel.com) ([172.16.120.198]) by fmsmga002.fm.intel.com with ESMTP; 17 May 2011 01:03:57 -0700 Date: Tue, 17 May 2011 15:53:52 +0800 From: Chuanxiao Dong To: linux-mmc@vger.kernel.org Cc: bo.he@intel.com Subject: [RFC]mmc: fix dead lock issue when system entering S3 Message-ID: <20110517075352.GA3992@intel.com> Reply-To: Chuanxiao Dong MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 17 May 2011 08:04:01 +0000 (UTC) Hi all, I encountered a dead lock issue. Two threads try to claim host, unfortunately one thread needs to sync with the other. I encountered this issue with SD card when testing system entering S3. Does anybody encounter the same issue? Environment: 1. without CONFIG_MMC_UNSAFE_RESUME operation 2. the SD card mounted During system tried to enter S3, mmc_pm_notifier will be called first to remove SD card. So calling sequence in SD remove thread is like this: mmc_claim_host bus_ops->remove .... .... mmc_cleanup_queue kthread_stop(mq->thread) ... ... Mean while, mmc_cleanup_queue wakes up mq->thread, the calling sequence in mq->thread is like this: mmc_queue_thread mq->issue_fn (mmc_blk_issue_rq) mmc_claim_host (dead lock) .... .... Since mmc_claim_host is called in mq->thread (not SD remove thread) again, unfortunately right now host is already claimed by SD remove thread which is also waiting for mq->thread finished, so cause a dead lock here. Move the mmc_claim_host(in mmc_pm_notifier) after bus_ops->remove can resolve this dead lock. mmc_suspend_host() is using the same way to claim host. Need to know your suggestions. Signed-off-by: He Bo Signed-off-by: Chuanxiao Dong --- drivers/mmc/core/core.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 68091dd..1e27588 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1850,11 +1850,10 @@ int mmc_pm_notify(struct notifier_block *notify_block, if (!host->bus_ops || host->bus_ops->suspend) break; - mmc_claim_host(host); - if (host->bus_ops->remove) host->bus_ops->remove(host); + mmc_claim_host(host); mmc_detach_bus(host); mmc_release_host(host); host->pm_flags = 0;