From: Jaehoon Chung <jh80.chung@samsung.com>
To: Huang Changming-R66093 <r66093@freescale.com>
Cc: Philip Rakity <prakity@marvell.com>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
Chris Ball <cjb@laptop.org>
Subject: Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card
Date: Thu, 15 Dec 2011 19:04:10 +0900 [thread overview]
Message-ID: <4EE9C61A.30103@samsung.com> (raw)
In-Reply-To: <8A2FC72B45BB5A4C9F801431E06AE48F1164F1EF@039-SN1MPN1-005.039d.mgd.msft.net>
On 12/15/2011 03:56 PM, Huang Changming-R66093 wrote:
>
>
>> -----Original Message-----
>> From: Philip Rakity [mailto:prakity@marvell.com]
>> Sent: Thursday, December 15, 2011 2:42 PM
>> To: Huang Changming-R66093
>> Cc: linux-mmc@vger.kernel.org; Chris Ball
>> Subject: Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect
>> the card
>>
>>
>> On Dec 14, 2011, at 6:32 PM, Huang Changming-R66093 wrote:
>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Philip Rakity [mailto:prakity@marvell.com]
>>>> Sent: Wednesday, December 14, 2011 12:52 PM
>>>> To: Huang Changming-R66093
>>>> Cc: linux-mmc@vger.kernel.org; Huang Changming-R66093; Chris Ball
>>>> Subject: Re: [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to
>>>> detect the card
>>>>
>>>>
>>>> On Dec 13, 2011, at 6:18 PM, <r66093@freescale.com> wrote:
>>>>
>>>>> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>>>
>>>>> Add callback function sdhci_get_cd to detect the card.
>>>>> And one new callback added to implement the card detect in sdhci
>>>> struncture.
>>>>> If special platform has the card detect callback, it will return the
>>>>> card state, the value zero is for absent cardi and one is for
>>>>> present
>>>> card.
>>>>> If the controller don't support card detect, sdhci_get_cd will
>>>>> return -
>>>> ENOSYS.
>>>>>
>>>>> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
>>>>> CC: Chris Ball <cjb@laptop.org>
>>>>> ---
>>>>> changes for v2:
>>>>> - when controller don't support get_cd, return -ENOSYS
>>>>> - add new callback for sdhci to detect the card
>>>>> - add the CC
>>>>> changes for v3:
>>>>> - use pin_lock only when get_cd defined changes for v4:
>>>>> - enalbe the controller clock in platform, instead of core changes
>>>>> for v5:
>>>>> - remove the copyright
>>>>>
>>>>> drivers/mmc/host/sdhci.c | 21 ++++++++++++++++++++++
>>>>> drivers/mmc/host/sdhci.h | 2 ++
>>>>> 2 files changed, 23 insertions(+), 0 deletions(-)
>>>>>
>>>>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>>>>> index
>>>>> 6d8eea3..fbe2f46 100644
>>>>> --- a/drivers/mmc/host/sdhci.c
>>>>> +++ b/drivers/mmc/host/sdhci.c
>>>>> @@ -1518,6 +1519,26 @@ static int sdhci_get_ro(struct mmc_host *mmc)
>>>>> return ret;
>>>>> }
>>>>>
>>>>> +/* Return values for the sdjco_get_cd callback:
>>>>> + * 0 for a absent card
>>>>> + * 1 for a present card
>>>>> + * -ENOSYS when not supported (equal to NULL callback)
>>>>> + */
>>>>> +static int sdhci_get_cd(struct mmc_host *mmc) {
>>>>> + struct sdhci_host *host = mmc_priv(mmc);
>>>>> + unsigned long flags;
>>>>> + int present = -ENOSYS;
>>>>> +
>>>>> + if (host->ops->get_cd) {
>>>>> + spin_lock_irqsave(&host->lock, flags);
>>>>> + present = host->ops->get_cd(host);
>>>>> + spin_unlock_irqrestore(&host->lock, flags);
>>>>> + }
>>>>> +
>>>>> + return present;
>>>>> +}
>>>>
>>>> In static void sdhci_request(struct mmc_host *mmc, struct
>>>> mmc_request
>>>> *mrq)
>>>>
>>>> there is code below to handle broken card detect.
>>>>
>>>> 1257
>>>> 1258 /* If polling, assume that the card is always present. */
>>>> 1259 if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
>>>> 1260 present = true;
>>>> 1261 else
>>>> 1262 present = sdhci_readl(host, SDHCI_PRESENT_STATE)
>> &
>>>> 1263 SDHCI_CARD_PRESENT;
>>>>
>>>> The problem with this code is that it assumes broken card detect is
>>>> broken since the present state register cannot be read.
>>>>
>>>> would it make more sense to do something like
>>>> if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) {
>>>> if (host->ops->get_cd)
>>>> present = present = host->ops->get_cd(host);
>>>> else
>>>> present = true;
>>>>
>>>> and adjust the code in host->ops->get_cd() to not -ENOSYS.
>>>
>>> I think we should not detect the card present state in sdhci_request
>>> function, Because if we do it, this detection will be performed with
>>> any command to card, which will down the performance.
>>>
>>> And if the quirks has SDHCI_QUIRK_BROKEN_CARD_DETECTION, that means
>>> the card is always present, We don't need to detect the card state.
I think SDHCI_QUIRK_BROKEN_CARD_DETECTION is just _assume_ "the card is present."
>>
>> currently WE do read the present state register on every request. All
>> the above suggestion does is try to use your code
>>
>> maybe we want something like
>>>> if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
>>>> present = true;
>>>> else if (host->ops->get_cd)
>>>> present = present = host->ops->get_cd(host);
>>>> else
>>>> present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
>>>> SDHCI_CARD_PRESENT;
>>
> I am very confused, why do we read the present state register on every request?
How long time read the present state register?
> My codes are added to the function mmc_sd_detect in file core/sd.c
> Function mmc_rescan has detect the card present state repeatedly, so I think we don't need to detect the card state on every request.
> So I think the codes to detect the card present state in sdhci_request should be removed to improve the performance.
How did you get the performance benefit?
And mmc_rescan is repeatedly for SD-card?
If mmc_rescan is repeatedly, that reason is the below code. (just my thinking)
if (host->caps & MMC_CAP_NEEDS_POLL)
mmc_schedule_delayed_work(&host->detect, HZ);
what is your point related with mmc_rescan?
I didn't understand yours..
Thanks,
Jaehoon Chung
>
>
> --
> 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
>
next prev parent reply other threads:[~2011-12-15 10:04 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 2:18 [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
2011-12-14 4:51 ` Philip Rakity
2011-12-15 2:32 ` Huang Changming-R66093
2011-12-15 6:41 ` Philip Rakity
2011-12-15 6:56 ` Huang Changming-R66093
2011-12-15 10:04 ` Jaehoon Chung [this message]
2011-12-16 3:25 ` Huang Changming-R66093
2011-12-16 4:05 ` Jaehoon Chung
2011-12-16 4:33 ` Huang Changming-R66093
2012-01-13 2:25 ` Huang Changming-R66093
2012-01-13 3:26 ` Aaron Lu
2012-01-13 4:50 ` Huang Changming-R66093
2012-01-13 6:20 ` Aaron Lu
2012-01-13 6:44 ` Huang Changming-R66093
-- strict thread matches above, loose matches on Subject: below --
2012-10-30 8:12 [PATCH 1/4 v3] MMC/core: Add f_min to mmc_power_on() r66093
2012-10-30 8:12 ` [PATCH 2/4 v4] MMC/SD: Add callback function to detect card r66093
2012-10-30 8:12 ` [PATCH 3/4 v5] SDHCI: add sdhci_get_cd callback to detect the card r66093
2012-11-19 2:50 ` Huang Changming-R66093
2012-11-19 2:58 ` Anton Vorontsov
2012-11-19 3:15 ` Huang Changming-R66093
2012-11-19 3:31 ` Anton Vorontsov
2012-11-19 3:38 ` Huang Changming-R66093
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=4EE9C61A.30103@samsung.com \
--to=jh80.chung@samsung.com \
--cc=cjb@laptop.org \
--cc=linux-mmc@vger.kernel.org \
--cc=prakity@marvell.com \
--cc=r66093@freescale.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).