From patchwork Thu Sep 10 07:10:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 53369 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 78FAF22B26 for ; Thu, 10 Sep 2015 07:10:59 +0000 (UTC) Received: by lamp12 with SMTP id p12sf11016333lam.2 for ; Thu, 10 Sep 2015 00:10:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:to:from:subject:message-id:date :user-agent:mime-version:content-type:content-transfer-encoding :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=yyQ5NmX/yGBvCwBk1R7bWURORUxJVh9ZPQgpaLT0dLM=; b=UacwNzY8QOwI+lwpPQrhYVBaV5B7synmYWWB5WCTjhVQ1rugEKnMwBMW2o4GlG87Kc 5M7laiAlCqvbossu5g4GD8kMqnU5IWwi/K/hoFdoQggtNBqrBa8esv9RxEc4bX2mGJ4Y JWkJCEepaYHOKWvMIBHXqgix8JBlwSRILlaQpRsBcHPl9tNPvZoT5V6wyHjMVsMOqgwe 08evg1DOnG4DJqAmusmbPuGlX+5AhP706qgm2P4BTjGQ0LkJjqXt8ZEOGxxAvouPn1Up c7x2Bw+xzwYwi63TSZhXK9jOQeP348hZ0RqF46S1asNlInohlwjzt9ovjG+W67LH2W4s DnGg== X-Gm-Message-State: ALoCoQlFb7OUdk9uB8K5YOZHH/5qoxxXsdnCh1Vj6rjQjiCuvUZUgzVEnK1fmSusHaEhK9fBzXNK X-Received: by 10.180.9.104 with SMTP id y8mr374540wia.7.1441869058367; Thu, 10 Sep 2015 00:10:58 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.37 with SMTP id 5ls152275laz.24.gmail; Thu, 10 Sep 2015 00:10:57 -0700 (PDT) X-Received: by 10.152.30.37 with SMTP id p5mr35077968lah.102.1441869057914; Thu, 10 Sep 2015 00:10:57 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id li9si7505660lbc.121.2015.09.10.00.10.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2015 00:10:57 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laeb10 with SMTP id b10so22142521lae.1 for ; Thu, 10 Sep 2015 00:10:57 -0700 (PDT) X-Received: by 10.152.26.41 with SMTP id i9mr5900126lag.36.1441869057279; Thu, 10 Sep 2015 00:10:57 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp774753lbq; Thu, 10 Sep 2015 00:10:56 -0700 (PDT) X-Received: by 10.107.168.39 with SMTP id r39mr55041758ioe.42.1441869056280; Thu, 10 Sep 2015 00:10:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c188si9426775ioc.129.2015.09.10.00.10.55; Thu, 10 Sep 2015 00:10:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751294AbbIJHKy (ORCPT + 2 others); Thu, 10 Sep 2015 03:10:54 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33208 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750741AbbIJHKy (ORCPT ); Thu, 10 Sep 2015 03:10:54 -0400 Received: by pacex6 with SMTP id ex6so34873280pac.0 for ; Thu, 10 Sep 2015 00:10:53 -0700 (PDT) X-Received: by 10.66.163.227 with SMTP id yl3mr70679640pab.10.1441869053510; Thu, 10 Sep 2015 00:10:53 -0700 (PDT) Received: from [192.168.0.100] ([202.62.93.141]) by smtp.googlemail.com with ESMTPSA id td5sm1327327pab.1.2015.09.10.00.10.50 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Sep 2015 00:10:52 -0700 (PDT) To: "linux-mmc@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , nico@fluxnic.net, ulf.hansson@linaro.org From: Vaibhav Hiremath Subject: sdhci: runtime suspend/resume on card insert/removal Message-ID: <55F12CF8.50003@linaro.org> Date: Thu, 10 Sep 2015 12:40:48 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: vaibhav.hiremath@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Hi, During my testing of SDHCI-PXAV3 driver on Marvell's pxa1928 based platform, I observed that runtime PM suspend/resume is having issues with card insertion and removal. Let me try to explain it using execution sequence - During boot: MMC SD card gets detected as expected. [ 2.431012] mmc1: new high speed SDHC card at address 1234 [ 2.437235] mmcblk1: mmc1:1234 SA04G 3.63 GiB [ 2.444841] mmcblk1: p1 Now after coming to the linux prompt, if card removal event occurs then the call sequence is - sdhci_irq() --> -> sdhci_thread_irq(): host->thread_isr - 0x80 -> sdhci_card_event() -> mmc_detect_change() --> _mmc_detect_change() ---> mmc_sd_detect() mmc_sd_remove() mmc_remove_card() mmc_bus_remove() mmc_power_off() mmc_set_initial_state() sdhci_set_ios() ... sdhci_pxav3_runtime_suspend() sdhci_runtime_suspend_host() Till here everything looks perfect :) (if I got it right) Now on card insertion again, the expectation is, runtime resume should get called as part of interrupt trigger from the SDHCI controller on card insertion. But what I am observing here is, no interrupt is generated, as it is not enabled at all. And the reason being sdhci_runtime_suspend_host() int sdhci_runtime_suspend_host(struct sdhci_host *host) { .... spin_lock_irqsave(&host->lock, flags); host->ier &= SDHCI_INT_CARD_INT; sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); spin_unlock_irqrestore(&host->lock, flags); ... } In my case, I see SDHCI_INT_CARD_INT is not ON and with above step we are not ensuring that it is enabled either. Also we are not enabling card insertion and removal interrupts. I have done following change to the code - synchronize_hardirq(host->irq); And things started working as expected. The execution sequence of irq and sdhci_runtime_resume both looks ok to me. Card insertion event = sdhci_irq() --> -> sdhci_thread_irq: host->thread_isr - 40 --> sdhci_card_event() --> mmc_detect_change() ---> _mmc_detect_change() ... -> sdhci_pxav3_runtime_resume() --> sdhci_do_set_ios:1438 I see card getting enumerated as expected - [ 15.116098] mmc1: mmc_rescan_try_freq: trying to init card at 400000 Hz [ 15.356473] mmc1: new high speed SDHC card at address 1234 [ 15.363962] mmcblk1: mmc1:1234 SA04G 3.63 GiB [ 15.371043] sdhci_thread_irq:2642 host->thread_isr - 100 [ 15.376492] mmcblk1: p1 I believe (based on my understanding) the change I have done is right. I am not sure how other platforms using sdhci.c working so far, probably no runtime_pm support? Not sure though Please let me know if I am missing something here. And not, and everyone is ok with this, I will submit the patch fixing this issue. Thanks, Vaibhav --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 418f381..3129292 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2783,9 +2783,12 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host) mmc_retune_needed(host->mmc); spin_lock_irqsave(&host->lock, flags); - host->ier &= SDHCI_INT_CARD_INT; + + host->flags |= SDHCI_SDIO_IRQ_ENABLED; + host->ier |= SDHCI_INT_CARD_INT; sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); + spin_unlock_irqrestore(&host->lock, flags);