* [PATCH] mmc: mxs: fix card detection function for broken card detect
@ 2014-04-19 21:59 Daniel Willmann
2014-04-28 9:13 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Willmann @ 2014-04-19 21:59 UTC (permalink / raw)
To: Chris Ball, Ulf Hansson
Cc: linux-mmc, linux-kernel, Sascha Hauer, Shawn Guo, Daniel Willmann
Return -ENOSYS in get_cd if broken-cd is specified in the device tree.
Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
driver sets this flag unconditionally as it does not support a card
detect interrupt. Instead, broken-cd means that there is no card detect
signal connected.
The mmc core checks the get_cd function return value to determine if a
card is present. Only for a non-zero return value it will attempt to
initialize the card. So retuning -ENOSYS will allow the card to be
initialized.
For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
the card detect GPIO is not valid.
Signed-off-by: Daniel Willmann <daniel@totalueberwachung.de>
---
This might be relevant for stable kernels. The patch was tested with 3.14.1 on
olinuxino nano.
drivers/mmc/host/mxs-mmc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 073e871a0fc8..babfea03ba8a 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -70,6 +70,7 @@ struct mxs_mmc_host {
unsigned char bus_width;
spinlock_t lock;
int sdio_irq_en;
+ bool broken_cd;
};
static int mxs_mmc_get_cd(struct mmc_host *mmc)
@@ -78,6 +79,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
struct mxs_ssp *ssp = &host->ssp;
int present, ret;
+ if (host->broken_cd)
+ return -ENOSYS;
+
ret = mmc_gpio_get_cd(mmc);
if (ret >= 0)
return ret;
@@ -568,6 +572,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
{
const struct of_device_id *of_id =
of_match_device(mxs_mmc_dt_ids, &pdev->dev);
+ struct device_node *np = pdev->dev.of_node;
struct mxs_mmc_host *host;
struct mmc_host *mmc;
struct resource *iores;
@@ -634,6 +639,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
+ host->broken_cd = of_property_read_bool(np, "broken-cd");
+
mmc->f_min = 400000;
mmc->f_max = 288000000;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: mxs: fix card detection function for broken card detect
2014-04-19 21:59 [PATCH] mmc: mxs: fix card detection function for broken card detect Daniel Willmann
@ 2014-04-28 9:13 ` Sascha Hauer
2014-04-28 9:31 ` Ulf Hansson
0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2014-04-28 9:13 UTC (permalink / raw)
To: Daniel Willmann
Cc: Chris Ball, Ulf Hansson, linux-mmc, linux-kernel, Shawn Guo
On Sat, Apr 19, 2014 at 11:59:18PM +0200, Daniel Willmann wrote:
> Return -ENOSYS in get_cd if broken-cd is specified in the device tree.
>
> Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
> detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
> driver sets this flag unconditionally as it does not support a card
> detect interrupt. Instead, broken-cd means that there is no card detect
> signal connected.
>
> The mmc core checks the get_cd function return value to determine if a
> card is present. Only for a non-zero return value it will attempt to
> initialize the card. So retuning -ENOSYS will allow the card to be
> initialized.
> For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
> the card detect GPIO is not valid.
Short answer for fixing this regression:
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Long answer:
This is broken in the MMC OF parser. When the parser finds the
'broken-cd' property it just sets the MMC_CAP_NEEDS_POLL flag. This is
wrong. broken-cd means that we cannot rely on any card detection, but
instead have to talk to the card to find out if it's available.
Currently there is no flag to signal this situation, so the host driver
has to handle this by returning true in the get_cd callback, just like
the patch below does.
IMO the correct solution would be to add a MMC_CAP_CD_NEEDS_TALK_TO_CARD
flag to the core.
Sascha
>
> Signed-off-by: Daniel Willmann <daniel@totalueberwachung.de>
> ---
> This might be relevant for stable kernels. The patch was tested with 3.14.1 on
> olinuxino nano.
>
> drivers/mmc/host/mxs-mmc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 073e871a0fc8..babfea03ba8a 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -70,6 +70,7 @@ struct mxs_mmc_host {
> unsigned char bus_width;
> spinlock_t lock;
> int sdio_irq_en;
> + bool broken_cd;
> };
>
> static int mxs_mmc_get_cd(struct mmc_host *mmc)
> @@ -78,6 +79,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
> struct mxs_ssp *ssp = &host->ssp;
> int present, ret;
>
> + if (host->broken_cd)
> + return -ENOSYS;
> +
> ret = mmc_gpio_get_cd(mmc);
> if (ret >= 0)
> return ret;
> @@ -568,6 +572,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> {
> const struct of_device_id *of_id =
> of_match_device(mxs_mmc_dt_ids, &pdev->dev);
> + struct device_node *np = pdev->dev.of_node;
> struct mxs_mmc_host *host;
> struct mmc_host *mmc;
> struct resource *iores;
> @@ -634,6 +639,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
> mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
> MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
>
> + host->broken_cd = of_property_read_bool(np, "broken-cd");
> +
> mmc->f_min = 400000;
> mmc->f_max = 288000000;
>
> --
> 1.8.4.2
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: mxs: fix card detection function for broken card detect
2014-04-28 9:13 ` Sascha Hauer
@ 2014-04-28 9:31 ` Ulf Hansson
2014-04-28 9:36 ` Sascha Hauer
0 siblings, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2014-04-28 9:31 UTC (permalink / raw)
To: Sascha Hauer
Cc: Daniel Willmann, Chris Ball, linux-mmc,
linux-kernel@vger.kernel.org, Shawn Guo
On 28 April 2014 11:13, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Sat, Apr 19, 2014 at 11:59:18PM +0200, Daniel Willmann wrote:
>> Return -ENOSYS in get_cd if broken-cd is specified in the device tree.
>>
>> Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
>> detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
>> driver sets this flag unconditionally as it does not support a card
>> detect interrupt. Instead, broken-cd means that there is no card detect
>> signal connected.
>>
>> The mmc core checks the get_cd function return value to determine if a
>> card is present. Only for a non-zero return value it will attempt to
>> initialize the card. So retuning -ENOSYS will allow the card to be
>> initialized.
>> For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
>> the card detect GPIO is not valid.
>
> Short answer for fixing this regression:
>
> Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
>
> Long answer:
>
> This is broken in the MMC OF parser. When the parser finds the
> 'broken-cd' property it just sets the MMC_CAP_NEEDS_POLL flag. This is
> wrong. broken-cd means that we cannot rely on any card detection, but
> instead have to talk to the card to find out if it's available.
> Currently there is no flag to signal this situation, so the host driver
> has to handle this by returning true in the get_cd callback, just like
> the patch below does.
>
> IMO the correct solution would be to add a MMC_CAP_CD_NEEDS_TALK_TO_CARD
> flag to the core.
>
So if I understand correct, you want the host-ops->get_cd function to
be invoked from the mmc rescan - only when it actually can provide
useful information?
Kind regards
Ulf Hansson
> Sascha
>
>>
>> Signed-off-by: Daniel Willmann <daniel@totalueberwachung.de>
>> ---
>> This might be relevant for stable kernels. The patch was tested with 3.14.1 on
>> olinuxino nano.
>>
>> drivers/mmc/host/mxs-mmc.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
>> index 073e871a0fc8..babfea03ba8a 100644
>> --- a/drivers/mmc/host/mxs-mmc.c
>> +++ b/drivers/mmc/host/mxs-mmc.c
>> @@ -70,6 +70,7 @@ struct mxs_mmc_host {
>> unsigned char bus_width;
>> spinlock_t lock;
>> int sdio_irq_en;
>> + bool broken_cd;
>> };
>>
>> static int mxs_mmc_get_cd(struct mmc_host *mmc)
>> @@ -78,6 +79,9 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
>> struct mxs_ssp *ssp = &host->ssp;
>> int present, ret;
>>
>> + if (host->broken_cd)
>> + return -ENOSYS;
>> +
>> ret = mmc_gpio_get_cd(mmc);
>> if (ret >= 0)
>> return ret;
>> @@ -568,6 +572,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>> {
>> const struct of_device_id *of_id =
>> of_match_device(mxs_mmc_dt_ids, &pdev->dev);
>> + struct device_node *np = pdev->dev.of_node;
>> struct mxs_mmc_host *host;
>> struct mmc_host *mmc;
>> struct resource *iores;
>> @@ -634,6 +639,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>> mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
>> MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
>>
>> + host->broken_cd = of_property_read_bool(np, "broken-cd");
>> +
>> mmc->f_min = 400000;
>> mmc->f_max = 288000000;
>>
>> --
>> 1.8.4.2
>>
>>
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: mxs: fix card detection function for broken card detect
2014-04-28 9:31 ` Ulf Hansson
@ 2014-04-28 9:36 ` Sascha Hauer
2014-05-05 9:14 ` Ulf Hansson
0 siblings, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2014-04-28 9:36 UTC (permalink / raw)
To: Ulf Hansson
Cc: Daniel Willmann, Chris Ball, linux-mmc,
linux-kernel@vger.kernel.org, Shawn Guo
On Mon, Apr 28, 2014 at 11:31:03AM +0200, Ulf Hansson wrote:
> On 28 April 2014 11:13, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > On Sat, Apr 19, 2014 at 11:59:18PM +0200, Daniel Willmann wrote:
> >> Return -ENOSYS in get_cd if broken-cd is specified in the device tree.
> >>
> >> Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
> >> detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
> >> driver sets this flag unconditionally as it does not support a card
> >> detect interrupt. Instead, broken-cd means that there is no card detect
> >> signal connected.
> >>
> >> The mmc core checks the get_cd function return value to determine if a
> >> card is present. Only for a non-zero return value it will attempt to
> >> initialize the card. So retuning -ENOSYS will allow the card to be
> >> initialized.
> >> For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
> >> the card detect GPIO is not valid.
> >
> > Short answer for fixing this regression:
> >
> > Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
> >
> > Long answer:
> >
> > This is broken in the MMC OF parser. When the parser finds the
> > 'broken-cd' property it just sets the MMC_CAP_NEEDS_POLL flag. This is
> > wrong. broken-cd means that we cannot rely on any card detection, but
> > instead have to talk to the card to find out if it's available.
> > Currently there is no flag to signal this situation, so the host driver
> > has to handle this by returning true in the get_cd callback, just like
> > the patch below does.
> >
> > IMO the correct solution would be to add a MMC_CAP_CD_NEEDS_TALK_TO_CARD
> > flag to the core.
> >
>
> So if I understand correct, you want the host-ops->get_cd function to
> be invoked from the mmc rescan - only when it actually can provide
> useful information?
Yes.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mmc: mxs: fix card detection function for broken card detect
2014-04-28 9:36 ` Sascha Hauer
@ 2014-05-05 9:14 ` Ulf Hansson
0 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2014-05-05 9:14 UTC (permalink / raw)
To: Sascha Hauer, Daniel Willmann
Cc: Chris Ball, linux-mmc, linux-kernel@vger.kernel.org, Shawn Guo
On 28 April 2014 11:36, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Apr 28, 2014 at 11:31:03AM +0200, Ulf Hansson wrote:
>> On 28 April 2014 11:13, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> > On Sat, Apr 19, 2014 at 11:59:18PM +0200, Daniel Willmann wrote:
>> >> Return -ENOSYS in get_cd if broken-cd is specified in the device tree.
>> >>
>> >> Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
>> >> detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
>> >> driver sets this flag unconditionally as it does not support a card
>> >> detect interrupt. Instead, broken-cd means that there is no card detect
>> >> signal connected.
>> >>
>> >> The mmc core checks the get_cd function return value to determine if a
>> >> card is present. Only for a non-zero return value it will attempt to
>> >> initialize the card. So retuning -ENOSYS will allow the card to be
>> >> initialized.
>> >> For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
>> >> the card detect GPIO is not valid.
>> >
>> > Short answer for fixing this regression:
>> >
>> > Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
>> >
>> > Long answer:
>> >
>> > This is broken in the MMC OF parser. When the parser finds the
>> > 'broken-cd' property it just sets the MMC_CAP_NEEDS_POLL flag. This is
>> > wrong. broken-cd means that we cannot rely on any card detection, but
>> > instead have to talk to the card to find out if it's available.
>> > Currently there is no flag to signal this situation, so the host driver
>> > has to handle this by returning true in the get_cd callback, just like
>> > the patch below does.
>> >
>> > IMO the correct solution would be to add a MMC_CAP_CD_NEEDS_TALK_TO_CARD
>> > flag to the core.
>> >
>>
>> So if I understand correct, you want the host-ops->get_cd function to
>> be invoked from the mmc rescan - only when it actually can provide
>> useful information?
>
> Yes.
Until/if that happens, I suggest to go ahead with Daniel's patch as well.
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
>
> Sascha
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
> --
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-05 9:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-19 21:59 [PATCH] mmc: mxs: fix card detection function for broken card detect Daniel Willmann
2014-04-28 9:13 ` Sascha Hauer
2014-04-28 9:31 ` Ulf Hansson
2014-04-28 9:36 ` Sascha Hauer
2014-05-05 9:14 ` Ulf Hansson
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).