From patchwork Thu Mar 10 10:30:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ludovic Desroches X-Patchwork-Id: 8555121 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 80B339F7CA for ; Thu, 10 Mar 2016 10:30:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAC7E20340 for ; Thu, 10 Mar 2016 10:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 76E97202BE for ; Thu, 10 Mar 2016 10:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754720AbcCJKaj (ORCPT ); Thu, 10 Mar 2016 05:30:39 -0500 Received: from eusmtp01.atmel.com ([212.144.249.243]:36892 "EHLO eusmtp01.atmel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753618AbcCJKah (ORCPT ); Thu, 10 Mar 2016 05:30:37 -0500 Received: from ibiza.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.3.235.1; Thu, 10 Mar 2016 11:30:23 +0100 From: Ludovic Desroches To: , CC: , , , , , , Ludovic Desroches Subject: [PATCH] mmc: sdhci-of-at91: fix wakeup issue when using runtime pm Date: Thu, 10 Mar 2016 11:30:58 +0100 Message-ID: <1457605858-30907-1-git-send-email-ludovic.desroches@atmel.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <20160309163809.GM2690@odux.rfo.atmel.com> References: <20160309163809.GM2690@odux.rfo.atmel.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 It was impossible to wake-up on card detect event because when sdhci controller is runtime suspend, it is assumed that all the clocks are disabled so we can't get irqs. If the device is removable and there is no gpio to manage the card detection then card detection polling is used. Signed-off-by: Ludovic Desroches --- Hi Ulf, Adrian, Following the discussion, I need to fix my issue. I think we could both agree on this patch that I see more as temporary workaround. I will try to change the muxing of the card detect pio in order to no more use the sdhci controller to manage it but a gpio. If it do not work then I may send another patch in the spirit of the previous one (keeping one clock enabled and not calling sdhci_runtime_suspend_host()). Regards drivers/mmc/host/sdhci-of-at91.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index 35c02fc..dac8508 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -204,6 +205,21 @@ static int sdhci_at91_probe(struct platform_device *pdev) if (ret) goto pm_runtime_disable; + /* + * When calling sdhci_runtime_suspend_host(), the sdhci layer makes + * the assumption that all the clocks of the controller are disabled. + * It means we can't get irq from it when it is runtime suspended. + * For that reason, it is not planned to wake-up on a card detect irq + * from the controller. + * If we want to use runtime PM and to be able to wake-up on card + * insertion, we have to use a GPIO for the card detection or we can + * use polling for the card detection. Be aware that using polling + * will resume/suspend the controller between each attempt. + */ + if (!(host->mmc->caps & MMC_CAP_NONREMOVABLE) && + IS_ERR_VALUE(mmc_gpio_get_cd(host->mmc))) + host->mmc->caps |= MMC_CAP_NEEDS_POLL; + pm_runtime_put_autosuspend(&pdev->dev); return 0;