All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: tmio: Use mmc_can_gpio_cd() when validating for native hotplug
@ 2016-12-30 11:39 Ulf Hansson
  2017-01-05 11:50 ` Wolfram Sang
  0 siblings, 1 reply; 3+ messages in thread
From: Ulf Hansson @ 2016-12-30 11:39 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: Wolfram Sang, Simon Horman

To validate whether native hotplug is intended to be used, the tmio driver
checks whether the GPIO isr has been successfully assigned. This isn't
entirely correct, as GPIO could still be used for card detect, but in a
polling mode.

Therefore, let's convert to use the correct mmc interface,
mmc_can_gpio_cd() as it tells exactly what we need for the native hotplug
validation.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/host/tmio_mmc_pio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 3ca97f3..580ca9c 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1178,7 +1178,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
 	_host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
 				  mmc->caps & MMC_CAP_NEEDS_POLL ||
 				  !mmc_card_is_removable(mmc) ||
-				  mmc->slot.cd_irq >= 0);
+				  mmc_can_gpio_cd(mmc));
 
 	/*
 	 * On Gen2+, eMMC with NONREMOVABLE currently fails because native
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: tmio: Use mmc_can_gpio_cd() when validating for native hotplug
  2016-12-30 11:39 [PATCH] mmc: tmio: Use mmc_can_gpio_cd() when validating for native hotplug Ulf Hansson
@ 2017-01-05 11:50 ` Wolfram Sang
  2017-01-10 15:09   ` Ulf Hansson
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2017-01-05 11:50 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc, Wolfram Sang, Simon Horman

On Fri, Dec 30, 2016 at 12:39:45PM +0100, Ulf Hansson wrote:
> To validate whether native hotplug is intended to be used, the tmio driver
> checks whether the GPIO isr has been successfully assigned. This isn't
> entirely correct, as GPIO could still be used for card detect, but in a
> polling mode.

Isn't that checked with MMC_CAP_NEEDS_POLL? Could we maybe get rid of
that then?

> 
> Therefore, let's convert to use the correct mmc interface,
> mmc_can_gpio_cd() as it tells exactly what we need for the native hotplug
> validation.
> 
> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/host/tmio_mmc_pio.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index 3ca97f3..580ca9c 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -1178,7 +1178,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
>  	_host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
>  				  mmc->caps & MMC_CAP_NEEDS_POLL ||
>  				  !mmc_card_is_removable(mmc) ||
> -				  mmc->slot.cd_irq >= 0);
> +				  mmc_can_gpio_cd(mmc));
>  
>  	/*
>  	 * On Gen2+, eMMC with NONREMOVABLE currently fails because native
> -- 
> 1.9.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mmc: tmio: Use mmc_can_gpio_cd() when validating for native hotplug
  2017-01-05 11:50 ` Wolfram Sang
@ 2017-01-10 15:09   ` Ulf Hansson
  0 siblings, 0 replies; 3+ messages in thread
From: Ulf Hansson @ 2017-01-10 15:09 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-mmc, Wolfram Sang, Simon Horman

On 5 January 2017 at 12:50, Wolfram Sang <wsa@the-dreams.de> wrote:
> On Fri, Dec 30, 2016 at 12:39:45PM +0100, Ulf Hansson wrote:
>> To validate whether native hotplug is intended to be used, the tmio driver
>> checks whether the GPIO isr has been successfully assigned. This isn't
>> entirely correct, as GPIO could still be used for card detect, but in a
>> polling mode.
>
> Isn't that checked with MMC_CAP_NEEDS_POLL? Could we maybe get rid of
> that then?

I am not sure it's a good idea... I had second and closer look at the
related code. Then I realized it isn't doing what we expect. Let me
elaborate more below.

>
>>
>> Therefore, let's convert to use the correct mmc interface,
>> mmc_can_gpio_cd() as it tells exactly what we need for the native hotplug
>> validation.
>>
>> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
>> ---
>>  drivers/mmc/host/tmio_mmc_pio.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
>> index 3ca97f3..580ca9c 100644
>> --- a/drivers/mmc/host/tmio_mmc_pio.c
>> +++ b/drivers/mmc/host/tmio_mmc_pio.c
>> @@ -1178,7 +1178,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
>>       _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
>>                                 mmc->caps & MMC_CAP_NEEDS_POLL ||
>>                                 !mmc_card_is_removable(mmc) ||
>> -                               mmc->slot.cd_irq >= 0);

At this point mmc->slot.cd_irq is always == -EINVAL, which is because
mmc_gpiod_request_cd_irq() has not yet been called. The call to
mmc_gpiod_request_cd_irq() is done later in tmio_mmc_host_probe(),
either explicitly for the TMIO_MMC_USE_GPIO_CD case, or via calling
mmc_add_host().

Due to this, the check for "mmc->slot.cd_irq >= 0" is redundant and
can be removed. Allow me to re-post an updated patch, because I want
to get rid of the layering violation (the host is accessing
"slot.cd_irq").

A proper solution, requires ->native_hotplug to be properly set, which
likely need to consider that the mmc core may enable
MMC_CAP_NEEDS_POLL when mmc_gpiod_request_cd_irq() is called. Perhaps
that in combination of using mmc_can_gpio_cd() will do the trick!?

>> +                               mmc_can_gpio_cd(mmc));
>>
>>       /*
>>        * On Gen2+, eMMC with NONREMOVABLE currently fails because native
>> --
>> 1.9.1
>>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-10 15:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30 11:39 [PATCH] mmc: tmio: Use mmc_can_gpio_cd() when validating for native hotplug Ulf Hansson
2017-01-05 11:50 ` Wolfram Sang
2017-01-10 15:09   ` Ulf Hansson

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.