From patchwork Thu Jan 8 10:06:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Yalin" X-Patchwork-Id: 5591651 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2C814BF6C3 for ; Thu, 8 Jan 2015 10:09:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C5532038A for ; Thu, 8 Jan 2015 10:09:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 53C0A20389 for ; Thu, 8 Jan 2015 10:09:53 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y99zy-0003tq-Fi; Thu, 08 Jan 2015 10:07:26 +0000 Received: from cnbjrel01.sonyericsson.com ([219.141.167.165]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y99zl-0003cd-4o for linux-arm-kernel@lists.infradead.org; Thu, 08 Jan 2015 10:07:14 +0000 From: "Wang, Yalin" To: "'chris@printf.net'" , "'ulf.hansson@linaro.org'" , "'tim.kryger@gmail.com'" , "'tgih.jun@samsung.com'" , "'johan.rudholm@axis.com'" , "'linux-mmc@vger.kernel.org'" , "'linux-kernel@vger.kernel.org'" , "'linux-arm-kernel@lists.infradead.org'" Date: Thu, 8 Jan 2015 18:06:32 +0800 Subject: [RFC] mmc:change mmc_init workqueue into a freezable workqueue Thread-Topic: [RFC] mmc:change mmc_init workqueue into a freezable workqueue Thread-Index: AdArKscTl4nihDsKS+OgMy1GnhD4tw== Message-ID: <35FD53F367049845BC99AC72306C23D103EDAF89E192@CNBJMBX05.corpusers.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150108_020713_444379_3D85BF3A X-CRM114-Status: UNSURE ( 7.13 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fix the mmc driver suspend/resume conflict problems, mmc workqueue will queue mmc_rescan(), and it will call some pm_runtime_* functions, this will conflict with suspend path sometimes, and will result in some strange behavior: Suspend path: -000 |context_switch(inline) -000 |__schedule() -001 |schedule_preempt_disabled() -002 |spin_lock(inline) -002 |__mutex_lock_common(inline) -002 |__mutex_lock_slowpath(lock_count = 0xEDCD0F48) -003 |__mutex_fastpath_lock(inline) -003 |mutex_lock(lock = 0xEDCD0F48) -004 |sdhci_do_set_ios(host = 0xEDCD0CC0, ios = 0xEDCD0A70) -005 |sdhci_set_ios(?, ios = 0xEDCD0A70) -006 |mmc_set_ios(host = 0xEDCD0800) -007 |mmc_delay(inline) -007 |mmc_power_off(host = 0xEDCD0800) -008 |mmc_suspend_host(inline) -008 |mmc_suspend_host(host = 0xEDCD0800) -009 |mmc_host_suspend(dev = 0xEDCD0808) -010 |dpm_run_callback(cb = 0xC0627A88, dev = 0xEDCD0808, state = (event = 2), info = 0xC0B6EF9B) -011 |__device_suspend(dev = 0xEDCD0808, state = (event = 2), ?) -012 |device_suspend(inline) -012 |dpm_suspend(state = (event = 2)) -013 |suspend_devices_and_enter(state = 3) -014 |enter_state(inline) -014 |pm_suspend(state = 3) -015 |try_to_suspend(?) -016 |static_key_false(inline) -016 |trace_workqueue_execute_end(inline) -016 |process_one_work(worker = 0xD5E87040, work = 0xC0E3FF54) -017 |worker_thread(__worker = 0xD5E87040) -018 |kthread(_create = 0xE9FFBF10) -019 |kernel_thread_exit(asm) --- |end of frame mmc_rescan() resume path: -000 |context_switch(inline) -000 |__schedule() -001 |do_undefinstr(regs = 0xD12242F0) -002 |__und_svc(asm) --> |exception -003 |sdhci_set_power(host = 0xEDCD0CC0, power = 0) -004 |sdhci_do_set_ios(host = 0xEDCD0CC0, ios = 0xEDCD0A70) -005 |sdhci_set_ios(?, ios = 0xEDCD0A70) -006 |mmc_set_ios(host = 0xEDCD0800) -007 |mmc_delay(inline) -007 |mmc_power_up(host = 0xEDCD0800) -008 |mmc_resume_bus(inline) -008 |mmc_resume_bus(host = 0xEDCD0800) -009 |mmc_rpm_hold(host = 0xEDCD0800, ?) -010 |mmc_rescan(work = 0xEDCD0AB0) -011 |static_key_false(inline) -011 |trace_workqueue_execute_end(inline) -011 |process_one_work(worker = 0xE5F0BBC0, work = 0xEDCD0AB0) -012 |worker_thread(__worker = 0xE5F0BBC0) -013 |kthread(_create = 0xD03A5F10) -014 |kernel_thread_exit(asm) --- |end of frame most mmc power callback function don't check this special case, and will cause problems, make sure the workqueue is stopped during suspend is more safe. --- drivers/mmc/core/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index a6c139d..ae8757f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -3881,7 +3881,7 @@ static int __init mmc_init(void) { int ret; - workqueue = alloc_ordered_workqueue("kmmcd", 0); + workqueue = alloc_ordered_workqueue("kmmcd", WQ_FREEZABLE); if (!workqueue) return -ENOMEM;