All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: vaibhav.hiremath@linaro.org (Vaibhav Hiremath)
To: linux-arm-kernel@lists.infradead.org
Subject: sdhci: runtime suspend/resume on card insert/removal
Date: Mon, 14 Sep 2015 14:49:29 +0530	[thread overview]
Message-ID: <55F69121.3030700@linaro.org> (raw)
In-Reply-To: <20150914161804.101dfc55@xhacker>



On Monday 14 September 2015 01:48 PM, Jisheng Zhang wrote:
> On Mon, 14 Sep 2015 13:43:32 +0530
> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> wrote:
>
>>
>>
>> On Monday 14 September 2015 11:58 AM, Jisheng Zhang wrote:
>>> On Mon, 14 Sep 2015 11:55:56 +0530
>>> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> wrote:
>>>
>>>>
>>>>
>>>> On Thursday 10 September 2015 01:34 PM, Jisheng Zhang wrote:
>>>>> Hi Russell,
>>>>>
>>>>> On Thu, 10 Sep 2015 09:02:33 +0100
>>>>> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>>>>>
>>>>>> On Thu, Sep 10, 2015 at 03:31:29PM +0800, Jisheng Zhang wrote:
>>>>>>> Hi Vaibhav,
>>>>>>>
>>>>>>> On Thu, 10 Sep 2015 12:40:48 +0530
>>>>>>> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> wrote:
>>>>>>>
>>>>>>>> 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.
>>>>>>>
>>>>>>> AFAIK, card insertion => wakeup irq, this irq doesn't come from SDHCI
>>>>>>
>>>>>> Wakeup IRQs are what happens when the _system_ is in suspend, not
>>>>>> when the device is runtime suspended.
>>>>>
>>>>> Oh, yes. Sorry for misleading, I didn't express myself clearly. What
>>>>> I really means is that the card insertion/remove irq which could finally
>>>>> cause sdhci host resumed.
>>>>>
>>>>
>>>> So Jisheng,
>>>>
>>>> You are ok with above change, right?
>>>
>>> Nope. the above is just to clarify my mixing "wakeup IRQs" and the card
>>> insertion/remove irq that brings sdhci host resumed.
>>>
>>> IMHO, your patch is still not necessary and perhaps wrong.
>>>
>>
>> Don't be in hurry to conclude,
>> Let's understand the technical aspect fist.
>>
>>
>> Let me clarify once again here,
>>
>>
>> The card detect interrupt is coming from SDHCI controller itself,
>
> But how the SDHCI controller generate CD interrupt when it's in runtime suspended
> state, i.e clock gated or power gated?
>

Due to lack of detailed Documentation its difficult to conclude here


>> I have confirmed that the runtime PM is working perfectly fine,
>> clock is gated/disabled on card removal.
>
> But seems we still didn't know the sdhci host is clock gated or power gated.
>

Register above is
SDIO Host 1 Clock/Reset Control Register

And bit 3 & 4 says

BIT 3:

SD Host 1 Peripheral Clock Enable
   0x1: Peripheral clock enabled
   0x0: Peripheral clock disabled

BIT4:

SD Host 1 AXI Clock Enable
   0x1: AXI clock enabled
   0x0: AXI clock disabled


>>
>>
>> Clock Gating:
>> =============
>> #
>> # devmem 0xd4282854
>> 0x0000181B
>> # [ 1318.948460] mmc1: card 1234 removed
>>
>> #
>> # devmem 0xd4282854
>> 0x00001800
>> #
>
> Can you plz read the SDHCI host registers after this step? If the host is
> clock gated, we should get "asynchronous external abort" in theory.
>

Ok, that's another way. I can cross check on this.

Thanks,
Vaibhav

WARNING: multiple messages have this Message-ID (diff)
From: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
To: Jisheng Zhang <jszhang@marvell.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
	ulf.hansson@linaro.org,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	nico@fluxnic.net
Subject: Re: sdhci: runtime suspend/resume on card insert/removal
Date: Mon, 14 Sep 2015 14:49:29 +0530	[thread overview]
Message-ID: <55F69121.3030700@linaro.org> (raw)
In-Reply-To: <20150914161804.101dfc55@xhacker>



On Monday 14 September 2015 01:48 PM, Jisheng Zhang wrote:
> On Mon, 14 Sep 2015 13:43:32 +0530
> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> wrote:
>
>>
>>
>> On Monday 14 September 2015 11:58 AM, Jisheng Zhang wrote:
>>> On Mon, 14 Sep 2015 11:55:56 +0530
>>> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> wrote:
>>>
>>>>
>>>>
>>>> On Thursday 10 September 2015 01:34 PM, Jisheng Zhang wrote:
>>>>> Hi Russell,
>>>>>
>>>>> On Thu, 10 Sep 2015 09:02:33 +0100
>>>>> Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
>>>>>
>>>>>> On Thu, Sep 10, 2015 at 03:31:29PM +0800, Jisheng Zhang wrote:
>>>>>>> Hi Vaibhav,
>>>>>>>
>>>>>>> On Thu, 10 Sep 2015 12:40:48 +0530
>>>>>>> Vaibhav Hiremath <vaibhav.hiremath@linaro.org> wrote:
>>>>>>>
>>>>>>>> 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.
>>>>>>>
>>>>>>> AFAIK, card insertion => wakeup irq, this irq doesn't come from SDHCI
>>>>>>
>>>>>> Wakeup IRQs are what happens when the _system_ is in suspend, not
>>>>>> when the device is runtime suspended.
>>>>>
>>>>> Oh, yes. Sorry for misleading, I didn't express myself clearly. What
>>>>> I really means is that the card insertion/remove irq which could finally
>>>>> cause sdhci host resumed.
>>>>>
>>>>
>>>> So Jisheng,
>>>>
>>>> You are ok with above change, right?
>>>
>>> Nope. the above is just to clarify my mixing "wakeup IRQs" and the card
>>> insertion/remove irq that brings sdhci host resumed.
>>>
>>> IMHO, your patch is still not necessary and perhaps wrong.
>>>
>>
>> Don't be in hurry to conclude,
>> Let's understand the technical aspect fist.
>>
>>
>> Let me clarify once again here,
>>
>>
>> The card detect interrupt is coming from SDHCI controller itself,
>
> But how the SDHCI controller generate CD interrupt when it's in runtime suspended
> state, i.e clock gated or power gated?
>

Due to lack of detailed Documentation its difficult to conclude here


>> I have confirmed that the runtime PM is working perfectly fine,
>> clock is gated/disabled on card removal.
>
> But seems we still didn't know the sdhci host is clock gated or power gated.
>

Register above is
SDIO Host 1 Clock/Reset Control Register

And bit 3 & 4 says

BIT 3:

SD Host 1 Peripheral Clock Enable
   0x1: Peripheral clock enabled
   0x0: Peripheral clock disabled

BIT4:

SD Host 1 AXI Clock Enable
   0x1: AXI clock enabled
   0x0: AXI clock disabled


>>
>>
>> Clock Gating:
>> =============
>> #
>> # devmem 0xd4282854
>> 0x0000181B
>> # [ 1318.948460] mmc1: card 1234 removed
>>
>> #
>> # devmem 0xd4282854
>> 0x00001800
>> #
>
> Can you plz read the SDHCI host registers after this step? If the host is
> clock gated, we should get "asynchronous external abort" in theory.
>

Ok, that's another way. I can cross check on this.

Thanks,
Vaibhav

  reply	other threads:[~2015-09-14  9:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10  7:10 sdhci: runtime suspend/resume on card insert/removal Vaibhav Hiremath
2015-09-10  7:10 ` Vaibhav Hiremath
2015-09-10  7:31 ` Jisheng Zhang
2015-09-10  7:31   ` Jisheng Zhang
2015-09-10  7:51   ` Vaibhav Hiremath
2015-09-10  7:51     ` Vaibhav Hiremath
2015-09-10  7:57     ` Jisheng Zhang
2015-09-10  7:57       ` Jisheng Zhang
2015-09-10  8:02   ` Russell King - ARM Linux
2015-09-10  8:02     ` Russell King - ARM Linux
2015-09-10  8:04     ` Jisheng Zhang
2015-09-10  8:04       ` Jisheng Zhang
2015-09-14  6:25       ` Vaibhav Hiremath
2015-09-14  6:25         ` Vaibhav Hiremath
2015-09-14  6:28         ` Jisheng Zhang
2015-09-14  6:28           ` Jisheng Zhang
2015-09-14  8:13           ` Vaibhav Hiremath
2015-09-14  8:13             ` Vaibhav Hiremath
2015-09-14  8:18             ` Jisheng Zhang
2015-09-14  8:18               ` Jisheng Zhang
2015-09-14  9:19               ` Vaibhav Hiremath [this message]
2015-09-14  9:19                 ` Vaibhav Hiremath
2015-09-14 10:15                 ` Vaibhav Hiremath
2015-09-14 10:15                   ` Vaibhav Hiremath
2015-09-14 10:50                   ` Russell King - ARM Linux
2015-09-14 10:50                     ` Russell King - ARM Linux
2015-09-14 11:00                     ` Russell King - ARM Linux
2015-09-14 11:00                       ` Russell King - ARM Linux
2015-09-14 12:33                     ` Vaibhav Hiremath
2015-09-14 12:33                       ` Vaibhav Hiremath
2015-09-14 12:49                       ` Russell King - ARM Linux
2015-09-14 12:49                         ` Russell King - ARM Linux
2015-09-14 13:05                         ` Vaibhav Hiremath
2015-09-14 13:05                           ` Vaibhav Hiremath

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=55F69121.3030700@linaro.org \
    --to=vaibhav.hiremath@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.