public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] omap_hsmmc - use threaded irq handler for card-detect.
@ 2011-12-30  1:35 NeilBrown
  2011-12-30  7:18 ` Kishore Kadiyala
  0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2011-12-30  1:35 UTC (permalink / raw)
  To: Chris Ball, Tony Lindgren
  Cc: linux-mmc, linux-omap, Felipe Balbi, Grazvydas Ignotas

[-- Attachment #1: Type: text/plain, Size: 3711 bytes --]



As the card-detect irq handler just schedules work to be done by
a thread, we can use request_threaded_irq to do much of the work for
us.  This means that interrupts which arrive by handle_nested_irq
actually work.

Reviewed-by: Felipe Balbi <balbi@ti.com>
Tested-by: Grazvydas Ignotas <notasas@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index d5fe43d..56f6cfc 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -24,7 +24,6 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/platform_device.h>
-#include <linux/workqueue.h>
 #include <linux/timer.h>
 #include <linux/clk.h>
 #include <linux/mmc/host.h>
@@ -163,7 +162,6 @@ struct omap_hsmmc_host {
 	 */
 	struct	regulator	*vcc;
 	struct	regulator	*vcc_aux;
-	struct	work_struct	mmc_carddetect_work;
 	void	__iomem		*base;
 	resource_size_t		mapbase;
 	spinlock_t		irq_lock; /* Prevent races with irq handler */
@@ -1280,17 +1278,16 @@ static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
 }
 
 /*
- * Work Item to notify the core about card insertion/removal
+ * irq handler to notify the core about card insertion/removal
  */
-static void omap_hsmmc_detect(struct work_struct *work)
+static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
 {
-	struct omap_hsmmc_host *host =
-		container_of(work, struct omap_hsmmc_host, mmc_carddetect_work);
+	struct omap_hsmmc_host *host = dev_id;
 	struct omap_mmc_slot_data *slot = &mmc_slot(host);
 	int carddetect;
 
 	if (host->suspended)
-		return;
+		return IRQ_HANDLED;
 
 	sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
 
@@ -1305,19 +1302,6 @@ static void omap_hsmmc_detect(struct work_struct *work)
 		mmc_detect_change(host->mmc, (HZ * 200) / 1000);
 	else
 		mmc_detect_change(host->mmc, (HZ * 50) / 1000);
-}
-
-/*
- * ISR for handling card insertion and removal
- */
-static irqreturn_t omap_hsmmc_cd_handler(int irq, void *dev_id)
-{
-	struct omap_hsmmc_host *host = (struct omap_hsmmc_host *)dev_id;
-
-	if (host->suspended)
-		return IRQ_HANDLED;
-	schedule_work(&host->mmc_carddetect_work);
-
 	return IRQ_HANDLED;
 }
 
@@ -1919,7 +1903,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
 	host->next_data.cookie = 1;
 
 	platform_set_drvdata(pdev, host);
-	INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect);
 
 	mmc->ops	= &omap_hsmmc_ops;
 
@@ -2047,10 +2030,11 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
 
 	/* Request IRQ for card detect */
 	if ((mmc_slot(host).card_detect_irq)) {
-		ret = request_irq(mmc_slot(host).card_detect_irq,
-				  omap_hsmmc_cd_handler,
-				  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-				  mmc_hostname(mmc), host);
+		ret = request_threaded_irq(mmc_slot(host).card_detect_irq,
+					   NULL,
+					   omap_hsmmc_detect,
+					   IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+					   mmc_hostname(mmc), host);
 		if (ret) {
 			dev_dbg(mmc_dev(host->mmc),
 				"Unable to grab MMC CD IRQ\n");
@@ -2129,7 +2113,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
 		free_irq(host->irq, host);
 		if (mmc_slot(host).card_detect_irq)
 			free_irq(mmc_slot(host).card_detect_irq, host);
-		flush_work_sync(&host->mmc_carddetect_work);
 
 		pm_runtime_put_sync(host->dev);
 		pm_runtime_disable(host->dev);
@@ -2176,7 +2159,6 @@ static int omap_hsmmc_suspend(struct device *dev)
 				return ret;
 			}
 		}
-		cancel_work_sync(&host->mmc_carddetect_work);
 		ret = mmc_suspend_host(host->mmc);
 
 		if (ret == 0) {

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH] omap_hsmmc - use threaded irq handler for card-detect.
  2011-12-30  1:35 [PATCH] omap_hsmmc - use threaded irq handler for card-detect NeilBrown
@ 2011-12-30  7:18 ` Kishore Kadiyala
  2012-01-03  0:17   ` Chris Ball
  0 siblings, 1 reply; 3+ messages in thread
From: Kishore Kadiyala @ 2011-12-30  7:18 UTC (permalink / raw)
  To: NeilBrown
  Cc: Chris Ball, Tony Lindgren, linux-mmc, linux-omap, Felipe Balbi,
	Grazvydas Ignotas

On Thu, Dec 29, 2011 at 8:35 PM, NeilBrown <neilb@suse.de> wrote:
>
>
> As the card-detect irq handler just schedules work to be done by
> a thread, we can use request_threaded_irq to do much of the work for
> us.  This means that interrupts which arrive by handle_nested_irq
> actually work.
>
> Reviewed-by: Felipe Balbi <balbi@ti.com>
> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
> Signed-off-by: NeilBrown <neilb@suse.de>

I have done some thing similar but didn't pushed it  :-(
Anyways
Acked-by:  Kishore Kadiyala <kishorek.kadiyala@gmail.com>

>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index d5fe43d..56f6cfc 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -24,7 +24,6 @@
>  #include <linux/delay.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/platform_device.h>
> -#include <linux/workqueue.h>
>  #include <linux/timer.h>
>  #include <linux/clk.h>
>  #include <linux/mmc/host.h>
> @@ -163,7 +162,6 @@ struct omap_hsmmc_host {
>         */
>        struct  regulator       *vcc;
>        struct  regulator       *vcc_aux;
> -       struct  work_struct     mmc_carddetect_work;
>        void    __iomem         *base;
>        resource_size_t         mapbase;
>        spinlock_t              irq_lock; /* Prevent races with irq handler */
> @@ -1280,17 +1278,16 @@ static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
>  }
>
>  /*
> - * Work Item to notify the core about card insertion/removal
> + * irq handler to notify the core about card insertion/removal
>  */
> -static void omap_hsmmc_detect(struct work_struct *work)
> +static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
>  {
> -       struct omap_hsmmc_host *host =
> -               container_of(work, struct omap_hsmmc_host, mmc_carddetect_work);
> +       struct omap_hsmmc_host *host = dev_id;
>        struct omap_mmc_slot_data *slot = &mmc_slot(host);
>        int carddetect;
>
>        if (host->suspended)
> -               return;
> +               return IRQ_HANDLED;
>
>        sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
>
> @@ -1305,19 +1302,6 @@ static void omap_hsmmc_detect(struct work_struct *work)
>                mmc_detect_change(host->mmc, (HZ * 200) / 1000);
>        else
>                mmc_detect_change(host->mmc, (HZ * 50) / 1000);
> -}
> -
> -/*
> - * ISR for handling card insertion and removal
> - */
> -static irqreturn_t omap_hsmmc_cd_handler(int irq, void *dev_id)
> -{
> -       struct omap_hsmmc_host *host = (struct omap_hsmmc_host *)dev_id;
> -
> -       if (host->suspended)
> -               return IRQ_HANDLED;
> -       schedule_work(&host->mmc_carddetect_work);
> -
>        return IRQ_HANDLED;
>  }
>
> @@ -1919,7 +1903,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
>        host->next_data.cookie = 1;
>
>        platform_set_drvdata(pdev, host);
> -       INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect);
>
>        mmc->ops        = &omap_hsmmc_ops;
>
> @@ -2047,10 +2030,11 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev)
>
>        /* Request IRQ for card detect */
>        if ((mmc_slot(host).card_detect_irq)) {
> -               ret = request_irq(mmc_slot(host).card_detect_irq,
> -                                 omap_hsmmc_cd_handler,
> -                                 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
> -                                 mmc_hostname(mmc), host);
> +               ret = request_threaded_irq(mmc_slot(host).card_detect_irq,
> +                                          NULL,
> +                                          omap_hsmmc_detect,
> +                                          IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
> +                                          mmc_hostname(mmc), host);
>                if (ret) {
>                        dev_dbg(mmc_dev(host->mmc),
>                                "Unable to grab MMC CD IRQ\n");
> @@ -2129,7 +2113,6 @@ static int omap_hsmmc_remove(struct platform_device *pdev)
>                free_irq(host->irq, host);
>                if (mmc_slot(host).card_detect_irq)
>                        free_irq(mmc_slot(host).card_detect_irq, host);
> -               flush_work_sync(&host->mmc_carddetect_work);
>
>                pm_runtime_put_sync(host->dev);
>                pm_runtime_disable(host->dev);
> @@ -2176,7 +2159,6 @@ static int omap_hsmmc_suspend(struct device *dev)
>                                return ret;
>                        }
>                }
> -               cancel_work_sync(&host->mmc_carddetect_work);
>                ret = mmc_suspend_host(host->mmc);
>
>                if (ret == 0) {
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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] 3+ messages in thread

* Re: [PATCH] omap_hsmmc - use threaded irq handler for card-detect.
  2011-12-30  7:18 ` Kishore Kadiyala
@ 2012-01-03  0:17   ` Chris Ball
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Ball @ 2012-01-03  0:17 UTC (permalink / raw)
  To: Kishore Kadiyala
  Cc: NeilBrown, Tony Lindgren, linux-mmc, linux-omap, Felipe Balbi,
	Grazvydas Ignotas

Hi Neil,

On Fri, Dec 30 2011, Kishore Kadiyala wrote:
> On Thu, Dec 29, 2011 at 8:35 PM, NeilBrown <neilb@suse.de> wrote:
>>
>>
>> As the card-detect irq handler just schedules work to be done by
>> a thread, we can use request_threaded_irq to do much of the work for
>> us.  This means that interrupts which arrive by handle_nested_irq
>> actually work.
>>
>> Reviewed-by: Felipe Balbi <balbi@ti.com>
>> Tested-by: Grazvydas Ignotas <notasas@gmail.com>
>> Signed-off-by: NeilBrown <neilb@suse.de>
>
> I have done some thing similar but didn't pushed it  :-(
> Anyways
> Acked-by:  Kishore Kadiyala <kishorek.kadiyala@gmail.com>

Pushed with Kishore's ACK to mmc-next for 3.3, thanks.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

end of thread, other threads:[~2012-01-03  0:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-30  1:35 [PATCH] omap_hsmmc - use threaded irq handler for card-detect NeilBrown
2011-12-30  7:18 ` Kishore Kadiyala
2012-01-03  0:17   ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox