* [PATCH 0/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers @ 2017-04-19 13:09 Adrian Hunter 2017-04-19 13:09 ` [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq Adrian Hunter 2017-04-19 13:09 ` [PATCH 2/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers Adrian Hunter 0 siblings, 2 replies; 9+ messages in thread From: Adrian Hunter @ 2017-04-19 13:09 UTC (permalink / raw) To: Ulf Hansson; +Cc: linux-mmc Hi Here are 2 small patches to enable card detect wake for Intel BYT-related SD card host controllers. Adrian Hunter (2): mmc: slot-gpio: Add support to enable irq wake on cd_irq mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers drivers/mmc/core/core.c | 5 ++++- drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ drivers/mmc/host/sdhci-pci-core.c | 3 +++ drivers/mmc/host/sdhci-pci.h | 1 + include/linux/mmc/host.h | 1 + include/linux/mmc/slot-gpio.h | 1 + 6 files changed, 22 insertions(+), 1 deletion(-) Regards Adrian ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-19 13:09 [PATCH 0/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers Adrian Hunter @ 2017-04-19 13:09 ` Adrian Hunter 2017-04-25 11:46 ` Adrian Hunter 2017-06-13 9:53 ` Ulf Hansson 2017-04-19 13:09 ` [PATCH 2/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers Adrian Hunter 1 sibling, 2 replies; 9+ messages in thread From: Adrian Hunter @ 2017-04-19 13:09 UTC (permalink / raw) To: Ulf Hansson; +Cc: linux-mmc Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the card detect irq. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> --- drivers/mmc/core/core.c | 5 ++++- drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ include/linux/mmc/host.h | 1 + include/linux/mmc/slot-gpio.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 0bb39795d484..6987976252ad 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -2828,8 +2828,11 @@ void mmc_stop_host(struct mmc_host *host) host->removed = 1; spin_unlock_irqrestore(&host->lock, flags); #endif - if (host->slot.cd_irq >= 0) + if (host->slot.cd_irq >= 0) { + if (host->slot.cd_wake_enabled) + disable_irq_wake(host->slot.cd_irq); disable_irq(host->slot.cd_irq); + } host->rescan_disable = 1; cancel_delayed_work_sync(&host->detect); diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index a8450a8701e4..56e4edb9e63a 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -25,6 +25,7 @@ struct mmc_gpio { struct gpio_desc *cd_gpio; bool override_ro_active_level; bool override_cd_active_level; + bool cd_wake; irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); char *ro_label; char cd_label[0]; @@ -118,6 +119,15 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) } EXPORT_SYMBOL(mmc_gpio_request_ro); +void mmc_gpio_cd_enable_wake(struct mmc_host *host) +{ + struct mmc_gpio *ctx = host->slot.handler_priv; + + if (ctx && ctx->cd_gpio) + ctx->cd_wake = true; +} +EXPORT_SYMBOL(mmc_gpio_cd_enable_wake); + void mmc_gpiod_request_cd_irq(struct mmc_host *host) { struct mmc_gpio *ctx = host->slot.handler_priv; @@ -151,6 +161,8 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) if (irq < 0) host->caps |= MMC_CAP_NEEDS_POLL; + else if (ctx->cd_wake && !enable_irq_wake(irq)) + host->slot.cd_wake_enabled = true; } EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 21385ac0c9b1..78c544e296cd 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -184,6 +184,7 @@ struct mmc_async_req { */ struct mmc_slot { int cd_irq; + bool cd_wake_enabled; void *handler_priv; }; diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h index 82f0d289f110..6af681d33a53 100644 --- a/include/linux/mmc/slot-gpio.h +++ b/include/linux/mmc/slot-gpio.h @@ -33,5 +33,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, irqreturn_t (*isr)(int irq, void *dev_id)); void mmc_gpiod_request_cd_irq(struct mmc_host *host); bool mmc_can_gpio_cd(struct mmc_host *host); +void mmc_gpio_cd_enable_wake(struct mmc_host *host); #endif -- 1.9.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-19 13:09 ` [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq Adrian Hunter @ 2017-04-25 11:46 ` Adrian Hunter 2017-04-25 20:02 ` Ulf Hansson 2017-06-13 9:53 ` Ulf Hansson 1 sibling, 1 reply; 9+ messages in thread From: Adrian Hunter @ 2017-04-25 11:46 UTC (permalink / raw) To: Ulf Hansson; +Cc: linux-mmc On 19/04/17 16:09, Adrian Hunter wrote: > Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the > card detect irq. > > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Any comments on this? > --- > drivers/mmc/core/core.c | 5 ++++- > drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ > include/linux/mmc/host.h | 1 + > include/linux/mmc/slot-gpio.h | 1 + > 4 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > index 0bb39795d484..6987976252ad 100644 > --- a/drivers/mmc/core/core.c > +++ b/drivers/mmc/core/core.c > @@ -2828,8 +2828,11 @@ void mmc_stop_host(struct mmc_host *host) > host->removed = 1; > spin_unlock_irqrestore(&host->lock, flags); > #endif > - if (host->slot.cd_irq >= 0) > + if (host->slot.cd_irq >= 0) { > + if (host->slot.cd_wake_enabled) > + disable_irq_wake(host->slot.cd_irq); > disable_irq(host->slot.cd_irq); > + } > > host->rescan_disable = 1; > cancel_delayed_work_sync(&host->detect); > diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c > index a8450a8701e4..56e4edb9e63a 100644 > --- a/drivers/mmc/core/slot-gpio.c > +++ b/drivers/mmc/core/slot-gpio.c > @@ -25,6 +25,7 @@ struct mmc_gpio { > struct gpio_desc *cd_gpio; > bool override_ro_active_level; > bool override_cd_active_level; > + bool cd_wake; > irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); > char *ro_label; > char cd_label[0]; > @@ -118,6 +119,15 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) > } > EXPORT_SYMBOL(mmc_gpio_request_ro); > > +void mmc_gpio_cd_enable_wake(struct mmc_host *host) > +{ > + struct mmc_gpio *ctx = host->slot.handler_priv; > + > + if (ctx && ctx->cd_gpio) > + ctx->cd_wake = true; > +} > +EXPORT_SYMBOL(mmc_gpio_cd_enable_wake); > + > void mmc_gpiod_request_cd_irq(struct mmc_host *host) > { > struct mmc_gpio *ctx = host->slot.handler_priv; > @@ -151,6 +161,8 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) > > if (irq < 0) > host->caps |= MMC_CAP_NEEDS_POLL; > + else if (ctx->cd_wake && !enable_irq_wake(irq)) > + host->slot.cd_wake_enabled = true; > } > EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h > index 21385ac0c9b1..78c544e296cd 100644 > --- a/include/linux/mmc/host.h > +++ b/include/linux/mmc/host.h > @@ -184,6 +184,7 @@ struct mmc_async_req { > */ > struct mmc_slot { > int cd_irq; > + bool cd_wake_enabled; > void *handler_priv; > }; > > diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h > index 82f0d289f110..6af681d33a53 100644 > --- a/include/linux/mmc/slot-gpio.h > +++ b/include/linux/mmc/slot-gpio.h > @@ -33,5 +33,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, > irqreturn_t (*isr)(int irq, void *dev_id)); > void mmc_gpiod_request_cd_irq(struct mmc_host *host); > bool mmc_can_gpio_cd(struct mmc_host *host); > +void mmc_gpio_cd_enable_wake(struct mmc_host *host); > > #endif > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-25 11:46 ` Adrian Hunter @ 2017-04-25 20:02 ` Ulf Hansson 2017-04-28 7:38 ` Adrian Hunter 0 siblings, 1 reply; 9+ messages in thread From: Ulf Hansson @ 2017-04-25 20:02 UTC (permalink / raw) To: Adrian Hunter; +Cc: linux-mmc On 25 April 2017 at 13:46, Adrian Hunter <adrian.hunter@intel.com> wrote: > On 19/04/17 16:09, Adrian Hunter wrote: >> Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the >> card detect irq. >> >> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > > Any comments on this? Not yet. I need some more thinking about this. However, at first glance it seems very reasonable to make the core to help with cd wakeup irqs. Related topic: I have a plan of avoiding the mmc_pm_notify() to punt a work at resume, in case the host has enabled cd wakeup irqs. The reason is that we are sometimes resuming removable cards, just to find out that those are still there. I would be interesting to know how $subject change can help with this as well. I intend to keep this in mind while I review this, just so you know. :-) Kind regards Uffe > >> --- >> drivers/mmc/core/core.c | 5 ++++- >> drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ >> include/linux/mmc/host.h | 1 + >> include/linux/mmc/slot-gpio.h | 1 + >> 4 files changed, 18 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c >> index 0bb39795d484..6987976252ad 100644 >> --- a/drivers/mmc/core/core.c >> +++ b/drivers/mmc/core/core.c >> @@ -2828,8 +2828,11 @@ void mmc_stop_host(struct mmc_host *host) >> host->removed = 1; >> spin_unlock_irqrestore(&host->lock, flags); >> #endif >> - if (host->slot.cd_irq >= 0) >> + if (host->slot.cd_irq >= 0) { >> + if (host->slot.cd_wake_enabled) >> + disable_irq_wake(host->slot.cd_irq); >> disable_irq(host->slot.cd_irq); >> + } >> >> host->rescan_disable = 1; >> cancel_delayed_work_sync(&host->detect); >> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c >> index a8450a8701e4..56e4edb9e63a 100644 >> --- a/drivers/mmc/core/slot-gpio.c >> +++ b/drivers/mmc/core/slot-gpio.c >> @@ -25,6 +25,7 @@ struct mmc_gpio { >> struct gpio_desc *cd_gpio; >> bool override_ro_active_level; >> bool override_cd_active_level; >> + bool cd_wake; >> irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); >> char *ro_label; >> char cd_label[0]; >> @@ -118,6 +119,15 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) >> } >> EXPORT_SYMBOL(mmc_gpio_request_ro); >> >> +void mmc_gpio_cd_enable_wake(struct mmc_host *host) >> +{ >> + struct mmc_gpio *ctx = host->slot.handler_priv; >> + >> + if (ctx && ctx->cd_gpio) >> + ctx->cd_wake = true; >> +} >> +EXPORT_SYMBOL(mmc_gpio_cd_enable_wake); >> + >> void mmc_gpiod_request_cd_irq(struct mmc_host *host) >> { >> struct mmc_gpio *ctx = host->slot.handler_priv; >> @@ -151,6 +161,8 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) >> >> if (irq < 0) >> host->caps |= MMC_CAP_NEEDS_POLL; >> + else if (ctx->cd_wake && !enable_irq_wake(irq)) >> + host->slot.cd_wake_enabled = true; >> } >> EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); >> >> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h >> index 21385ac0c9b1..78c544e296cd 100644 >> --- a/include/linux/mmc/host.h >> +++ b/include/linux/mmc/host.h >> @@ -184,6 +184,7 @@ struct mmc_async_req { >> */ >> struct mmc_slot { >> int cd_irq; >> + bool cd_wake_enabled; >> void *handler_priv; >> }; >> >> diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h >> index 82f0d289f110..6af681d33a53 100644 >> --- a/include/linux/mmc/slot-gpio.h >> +++ b/include/linux/mmc/slot-gpio.h >> @@ -33,5 +33,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, >> irqreturn_t (*isr)(int irq, void *dev_id)); >> void mmc_gpiod_request_cd_irq(struct mmc_host *host); >> bool mmc_can_gpio_cd(struct mmc_host *host); >> +void mmc_gpio_cd_enable_wake(struct mmc_host *host); >> >> #endif >> > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-25 20:02 ` Ulf Hansson @ 2017-04-28 7:38 ` Adrian Hunter 2017-04-28 10:27 ` Ulf Hansson 0 siblings, 1 reply; 9+ messages in thread From: Adrian Hunter @ 2017-04-28 7:38 UTC (permalink / raw) To: Ulf Hansson; +Cc: linux-mmc On 25/04/17 23:02, Ulf Hansson wrote: > On 25 April 2017 at 13:46, Adrian Hunter <adrian.hunter@intel.com> wrote: >> On 19/04/17 16:09, Adrian Hunter wrote: >>> Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the >>> card detect irq. >>> >>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> >> >> Any comments on this? > > Not yet. I need some more thinking about this. How is the thinking going ;-) > > However, at first glance it seems very reasonable to make the core to > help with cd wakeup irqs. > > Related topic: I have a plan of avoiding the mmc_pm_notify() to punt a > work at resume, in case the host has enabled cd wakeup irqs. The > reason is that we are sometimes resuming removable cards, just to find > out that those are still there. I would be interesting to know how > $subject change can help with this as well. I intend to keep this in > mind while I review this, just so you know. :-) > > Kind regards > Uffe > >> >>> --- >>> drivers/mmc/core/core.c | 5 ++++- >>> drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ >>> include/linux/mmc/host.h | 1 + >>> include/linux/mmc/slot-gpio.h | 1 + >>> 4 files changed, 18 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c >>> index 0bb39795d484..6987976252ad 100644 >>> --- a/drivers/mmc/core/core.c >>> +++ b/drivers/mmc/core/core.c >>> @@ -2828,8 +2828,11 @@ void mmc_stop_host(struct mmc_host *host) >>> host->removed = 1; >>> spin_unlock_irqrestore(&host->lock, flags); >>> #endif >>> - if (host->slot.cd_irq >= 0) >>> + if (host->slot.cd_irq >= 0) { >>> + if (host->slot.cd_wake_enabled) >>> + disable_irq_wake(host->slot.cd_irq); >>> disable_irq(host->slot.cd_irq); >>> + } >>> >>> host->rescan_disable = 1; >>> cancel_delayed_work_sync(&host->detect); >>> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c >>> index a8450a8701e4..56e4edb9e63a 100644 >>> --- a/drivers/mmc/core/slot-gpio.c >>> +++ b/drivers/mmc/core/slot-gpio.c >>> @@ -25,6 +25,7 @@ struct mmc_gpio { >>> struct gpio_desc *cd_gpio; >>> bool override_ro_active_level; >>> bool override_cd_active_level; >>> + bool cd_wake; >>> irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); >>> char *ro_label; >>> char cd_label[0]; >>> @@ -118,6 +119,15 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) >>> } >>> EXPORT_SYMBOL(mmc_gpio_request_ro); >>> >>> +void mmc_gpio_cd_enable_wake(struct mmc_host *host) >>> +{ >>> + struct mmc_gpio *ctx = host->slot.handler_priv; >>> + >>> + if (ctx && ctx->cd_gpio) >>> + ctx->cd_wake = true; >>> +} >>> +EXPORT_SYMBOL(mmc_gpio_cd_enable_wake); >>> + >>> void mmc_gpiod_request_cd_irq(struct mmc_host *host) >>> { >>> struct mmc_gpio *ctx = host->slot.handler_priv; >>> @@ -151,6 +161,8 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) >>> >>> if (irq < 0) >>> host->caps |= MMC_CAP_NEEDS_POLL; >>> + else if (ctx->cd_wake && !enable_irq_wake(irq)) >>> + host->slot.cd_wake_enabled = true; >>> } >>> EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); >>> >>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h >>> index 21385ac0c9b1..78c544e296cd 100644 >>> --- a/include/linux/mmc/host.h >>> +++ b/include/linux/mmc/host.h >>> @@ -184,6 +184,7 @@ struct mmc_async_req { >>> */ >>> struct mmc_slot { >>> int cd_irq; >>> + bool cd_wake_enabled; >>> void *handler_priv; >>> }; >>> >>> diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h >>> index 82f0d289f110..6af681d33a53 100644 >>> --- a/include/linux/mmc/slot-gpio.h >>> +++ b/include/linux/mmc/slot-gpio.h >>> @@ -33,5 +33,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, >>> irqreturn_t (*isr)(int irq, void *dev_id)); >>> void mmc_gpiod_request_cd_irq(struct mmc_host *host); >>> bool mmc_can_gpio_cd(struct mmc_host *host); >>> +void mmc_gpio_cd_enable_wake(struct mmc_host *host); >>> >>> #endif >>> >> > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-28 7:38 ` Adrian Hunter @ 2017-04-28 10:27 ` Ulf Hansson 2017-05-17 11:44 ` Adrian Hunter 0 siblings, 1 reply; 9+ messages in thread From: Ulf Hansson @ 2017-04-28 10:27 UTC (permalink / raw) To: Adrian Hunter; +Cc: linux-mmc On 28 April 2017 at 09:38, Adrian Hunter <adrian.hunter@intel.com> wrote: > On 25/04/17 23:02, Ulf Hansson wrote: >> On 25 April 2017 at 13:46, Adrian Hunter <adrian.hunter@intel.com> wrote: >>> On 19/04/17 16:09, Adrian Hunter wrote: >>>> Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the >>>> card detect irq. >>>> >>>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> >>> >>> Any comments on this? >> >> Not yet. I need some more thinking about this. > > How is the thinking going ;-) To many things at the moment. Anyway, to me this is material for 4.13. I will get back to it as soon as I can. Kind regards Uffe > >> >> However, at first glance it seems very reasonable to make the core to >> help with cd wakeup irqs. >> >> Related topic: I have a plan of avoiding the mmc_pm_notify() to punt a >> work at resume, in case the host has enabled cd wakeup irqs. The >> reason is that we are sometimes resuming removable cards, just to find >> out that those are still there. I would be interesting to know how >> $subject change can help with this as well. I intend to keep this in >> mind while I review this, just so you know. :-) >> >> Kind regards >> Uffe >> >>> >>>> --- >>>> drivers/mmc/core/core.c | 5 ++++- >>>> drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ >>>> include/linux/mmc/host.h | 1 + >>>> include/linux/mmc/slot-gpio.h | 1 + >>>> 4 files changed, 18 insertions(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c >>>> index 0bb39795d484..6987976252ad 100644 >>>> --- a/drivers/mmc/core/core.c >>>> +++ b/drivers/mmc/core/core.c >>>> @@ -2828,8 +2828,11 @@ void mmc_stop_host(struct mmc_host *host) >>>> host->removed = 1; >>>> spin_unlock_irqrestore(&host->lock, flags); >>>> #endif >>>> - if (host->slot.cd_irq >= 0) >>>> + if (host->slot.cd_irq >= 0) { >>>> + if (host->slot.cd_wake_enabled) >>>> + disable_irq_wake(host->slot.cd_irq); >>>> disable_irq(host->slot.cd_irq); >>>> + } >>>> >>>> host->rescan_disable = 1; >>>> cancel_delayed_work_sync(&host->detect); >>>> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c >>>> index a8450a8701e4..56e4edb9e63a 100644 >>>> --- a/drivers/mmc/core/slot-gpio.c >>>> +++ b/drivers/mmc/core/slot-gpio.c >>>> @@ -25,6 +25,7 @@ struct mmc_gpio { >>>> struct gpio_desc *cd_gpio; >>>> bool override_ro_active_level; >>>> bool override_cd_active_level; >>>> + bool cd_wake; >>>> irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); >>>> char *ro_label; >>>> char cd_label[0]; >>>> @@ -118,6 +119,15 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) >>>> } >>>> EXPORT_SYMBOL(mmc_gpio_request_ro); >>>> >>>> +void mmc_gpio_cd_enable_wake(struct mmc_host *host) >>>> +{ >>>> + struct mmc_gpio *ctx = host->slot.handler_priv; >>>> + >>>> + if (ctx && ctx->cd_gpio) >>>> + ctx->cd_wake = true; >>>> +} >>>> +EXPORT_SYMBOL(mmc_gpio_cd_enable_wake); >>>> + >>>> void mmc_gpiod_request_cd_irq(struct mmc_host *host) >>>> { >>>> struct mmc_gpio *ctx = host->slot.handler_priv; >>>> @@ -151,6 +161,8 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) >>>> >>>> if (irq < 0) >>>> host->caps |= MMC_CAP_NEEDS_POLL; >>>> + else if (ctx->cd_wake && !enable_irq_wake(irq)) >>>> + host->slot.cd_wake_enabled = true; >>>> } >>>> EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); >>>> >>>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h >>>> index 21385ac0c9b1..78c544e296cd 100644 >>>> --- a/include/linux/mmc/host.h >>>> +++ b/include/linux/mmc/host.h >>>> @@ -184,6 +184,7 @@ struct mmc_async_req { >>>> */ >>>> struct mmc_slot { >>>> int cd_irq; >>>> + bool cd_wake_enabled; >>>> void *handler_priv; >>>> }; >>>> >>>> diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h >>>> index 82f0d289f110..6af681d33a53 100644 >>>> --- a/include/linux/mmc/slot-gpio.h >>>> +++ b/include/linux/mmc/slot-gpio.h >>>> @@ -33,5 +33,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, >>>> irqreturn_t (*isr)(int irq, void *dev_id)); >>>> void mmc_gpiod_request_cd_irq(struct mmc_host *host); >>>> bool mmc_can_gpio_cd(struct mmc_host *host); >>>> +void mmc_gpio_cd_enable_wake(struct mmc_host *host); >>>> >>>> #endif >>>> >>> >> > ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-28 10:27 ` Ulf Hansson @ 2017-05-17 11:44 ` Adrian Hunter 0 siblings, 0 replies; 9+ messages in thread From: Adrian Hunter @ 2017-05-17 11:44 UTC (permalink / raw) To: Ulf Hansson; +Cc: linux-mmc On 28/04/17 13:27, Ulf Hansson wrote: > On 28 April 2017 at 09:38, Adrian Hunter <adrian.hunter@intel.com> wrote: >> On 25/04/17 23:02, Ulf Hansson wrote: >>> On 25 April 2017 at 13:46, Adrian Hunter <adrian.hunter@intel.com> wrote: >>>> On 19/04/17 16:09, Adrian Hunter wrote: >>>>> Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the >>>>> card detect irq. >>>>> >>>>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> >>>> >>>> Any comments on this? >>> >>> Not yet. I need some more thinking about this. >> >> How is the thinking going ;-) > > To many things at the moment. Anyway, to me this is material for 4.13. > I will get back to it as soon as I can. Any update on this? ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq 2017-04-19 13:09 ` [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq Adrian Hunter 2017-04-25 11:46 ` Adrian Hunter @ 2017-06-13 9:53 ` Ulf Hansson 1 sibling, 0 replies; 9+ messages in thread From: Ulf Hansson @ 2017-06-13 9:53 UTC (permalink / raw) To: Adrian Hunter; +Cc: linux-mmc On 19 April 2017 at 15:09, Adrian Hunter <adrian.hunter@intel.com> wrote: > Add mmc_gpio_cd_enable_wake() to allow drivers to enable irq wake on the > card detect irq. Adrian, again apologize for the delay. As stated earlier, this is a very good idea. See some more comments below. > > Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> > --- > drivers/mmc/core/core.c | 5 ++++- > drivers/mmc/core/slot-gpio.c | 12 ++++++++++++ > include/linux/mmc/host.h | 1 + > include/linux/mmc/slot-gpio.h | 1 + > 4 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > index 0bb39795d484..6987976252ad 100644 > --- a/drivers/mmc/core/core.c > +++ b/drivers/mmc/core/core.c > @@ -2828,8 +2828,11 @@ void mmc_stop_host(struct mmc_host *host) > host->removed = 1; > spin_unlock_irqrestore(&host->lock, flags); > #endif > - if (host->slot.cd_irq >= 0) > + if (host->slot.cd_irq >= 0) { > + if (host->slot.cd_wake_enabled) > + disable_irq_wake(host->slot.cd_irq); > disable_irq(host->slot.cd_irq); > + } > > host->rescan_disable = 1; > cancel_delayed_work_sync(&host->detect); > diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c > index a8450a8701e4..56e4edb9e63a 100644 > --- a/drivers/mmc/core/slot-gpio.c > +++ b/drivers/mmc/core/slot-gpio.c > @@ -25,6 +25,7 @@ struct mmc_gpio { > struct gpio_desc *cd_gpio; > bool override_ro_active_level; > bool override_cd_active_level; > + bool cd_wake; > irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); > char *ro_label; > char cd_label[0]; > @@ -118,6 +119,15 @@ int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) > } > EXPORT_SYMBOL(mmc_gpio_request_ro); > > +void mmc_gpio_cd_enable_wake(struct mmc_host *host) > +{ > + struct mmc_gpio *ctx = host->slot.handler_priv; > + > + if (ctx && ctx->cd_gpio) > + ctx->cd_wake = true; > +} > +EXPORT_SYMBOL(mmc_gpio_cd_enable_wake); I am wondering whether we really need a new slot API for this. Couldn't we just add new host caps for this and use that instead of the bool cd_awake? The reason why I think that would make sense, is because it would simplify for mmc host drivers. Especially in the case of DT, as potentially we could deal with this from mmc_of_parse(). > + > void mmc_gpiod_request_cd_irq(struct mmc_host *host) > { > struct mmc_gpio *ctx = host->slot.handler_priv; > @@ -151,6 +161,8 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host) > > if (irq < 0) > host->caps |= MMC_CAP_NEEDS_POLL; > + else if (ctx->cd_wake && !enable_irq_wake(irq)) > + host->slot.cd_wake_enabled = true; > } > EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h > index 21385ac0c9b1..78c544e296cd 100644 > --- a/include/linux/mmc/host.h > +++ b/include/linux/mmc/host.h > @@ -184,6 +184,7 @@ struct mmc_async_req { > */ > struct mmc_slot { > int cd_irq; > + bool cd_wake_enabled; > void *handler_priv; > }; > > diff --git a/include/linux/mmc/slot-gpio.h b/include/linux/mmc/slot-gpio.h > index 82f0d289f110..6af681d33a53 100644 > --- a/include/linux/mmc/slot-gpio.h > +++ b/include/linux/mmc/slot-gpio.h > @@ -33,5 +33,6 @@ void mmc_gpio_set_cd_isr(struct mmc_host *host, > irqreturn_t (*isr)(int irq, void *dev_id)); > void mmc_gpiod_request_cd_irq(struct mmc_host *host); > bool mmc_can_gpio_cd(struct mmc_host *host); > +void mmc_gpio_cd_enable_wake(struct mmc_host *host); > > #endif > -- > 1.9.1 > Otherwise this looks great to me! One reason to the delay in review, was that I wanted to think about how this affects how mmc use device wakeups in general (device_may_wakeup()) during system suspend. In general userspace should be given the option to control whether device wakeups should be enabled or not (which driver then checks via calling device_may_wakeup()), however I don't think we need to give user space the option in this cases, as it's not really the device that wakes up the system, but a GPIO pin. Kind regards Uffe ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers 2017-04-19 13:09 [PATCH 0/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers Adrian Hunter 2017-04-19 13:09 ` [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq Adrian Hunter @ 2017-04-19 13:09 ` Adrian Hunter 1 sibling, 0 replies; 9+ messages in thread From: Adrian Hunter @ 2017-04-19 13:09 UTC (permalink / raw) To: Ulf Hansson; +Cc: linux-mmc Enable card detect wake for Intel BYT-related SD card host controllers. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> --- drivers/mmc/host/sdhci-pci-core.c | 3 +++ drivers/mmc/host/sdhci-pci.h | 1 + 2 files changed, 4 insertions(+) diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 833072b8453e..57d6f50b73dc 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -634,6 +634,7 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot) MMC_CAP_AGGRESSIVE_PM; slot->cd_idx = 0; slot->cd_override_level = true; + slot->cd_wake = true; if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXT_SD || slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXTM_SD || slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD || @@ -1989,6 +1990,8 @@ static struct sdhci_pci_slot *sdhci_pci_probe_slot( if (ret) { dev_warn(&pdev->dev, "failed to setup card detect gpio\n"); slot->cd_idx = -1; + } else if (slot->cd_wake) { + mmc_gpio_cd_enable_wake(host->mmc); } } diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h index 37766d20a600..6029fb314421 100644 --- a/drivers/mmc/host/sdhci-pci.h +++ b/drivers/mmc/host/sdhci-pci.h @@ -91,6 +91,7 @@ struct sdhci_pci_slot { int cd_idx; bool cd_override_level; + bool cd_wake; void (*hw_reset)(struct sdhci_host *host); unsigned long private[0] ____cacheline_aligned; -- 1.9.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-06-13 9:53 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-04-19 13:09 [PATCH 0/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers Adrian Hunter 2017-04-19 13:09 ` [PATCH 1/2] mmc: slot-gpio: Add support to enable irq wake on cd_irq Adrian Hunter 2017-04-25 11:46 ` Adrian Hunter 2017-04-25 20:02 ` Ulf Hansson 2017-04-28 7:38 ` Adrian Hunter 2017-04-28 10:27 ` Ulf Hansson 2017-05-17 11:44 ` Adrian Hunter 2017-06-13 9:53 ` Ulf Hansson 2017-04-19 13:09 ` [PATCH 2/2] mmc: sdhci-pci: Enable card detect wake for Intel BYT-related SD card host controllers Adrian Hunter
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.