From: Stefan Nilsson XK <[email protected]>
If there is only 1 function registered, and IRQ:s are supported and
currently enabled, call the callback handler directly
without checking the CCCR registers.
Signed-off-by: Stefan Nilsson XK <[email protected]>
Signed-off-by: Per Forlin <[email protected]>
---
drivers/mmc/core/sdio_irq.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
index b300161..25291bf 100644
--- a/drivers/mmc/core/sdio_irq.c
+++ b/drivers/mmc/core/sdio_irq.c
@@ -32,6 +32,20 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
int i, ret, count;
unsigned char pending;
+ /*
+ * If there is only 1 function registered
+ * call irq directly without checking the CCCR registers.
+ */
+ if ((card->host->caps & MMC_CAP_SDIO_IRQ) &&
+ card->host->sdio_irqs && (card->sdio_funcs == 1))
+ for (i = 0; i < SDIO_MAX_FUNCS; i++) {
+ struct sdio_func *func = card->sdio_func[i];
+ if (func && func->irq_handler) {
+ func->irq_handler(func);
+ return 1;
+ }
+ }
+
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
if (ret) {
printk(KERN_DEBUG "%s: error %d reading SDIO_CCCR_INTx\n",
--
1.7.4.1
On Tue, 3 May 2011, Per Forlin wrote:
> From: Stefan Nilsson XK <[email protected]>
>
> If there is only 1 function registered, and IRQ:s are supported and
> currently enabled, call the callback handler directly
> without checking the CCCR registers.
>
> Signed-off-by: Stefan Nilsson XK <[email protected]>
> Signed-off-by: Per Forlin <[email protected]>
Acked-by: Nicolas Pitre <[email protected]>
> ---
> drivers/mmc/core/sdio_irq.c | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
> index b300161..25291bf 100644
> --- a/drivers/mmc/core/sdio_irq.c
> +++ b/drivers/mmc/core/sdio_irq.c
> @@ -32,6 +32,20 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
> int i, ret, count;
> unsigned char pending;
>
> + /*
> + * If there is only 1 function registered
> + * call irq directly without checking the CCCR registers.
> + */
> + if ((card->host->caps & MMC_CAP_SDIO_IRQ) &&
> + card->host->sdio_irqs && (card->sdio_funcs == 1))
> + for (i = 0; i < SDIO_MAX_FUNCS; i++) {
> + struct sdio_func *func = card->sdio_func[i];
> + if (func && func->irq_handler) {
> + func->irq_handler(func);
> + return 1;
> + }
> + }
> +
> ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
> if (ret) {
> printk(KERN_DEBUG "%s: error %d reading SDIO_CCCR_INTx\n",
> --
> 1.7.4.1
>
>
> _______________________________________________
> linaro-dev mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/linaro-dev
>
On 4 May 2011 05:40, Nicolas Pitre <[email protected]> wrote:
> On Tue, 3 May 2011, Per Forlin wrote:
>
>> From: Stefan Nilsson XK <[email protected]>
>>
>> If there is only 1 function registered, and IRQ:s are supported and
>> currently enabled, call the callback handler directly
>> without checking the CCCR registers.
>>
>> Signed-off-by: Stefan Nilsson XK <[email protected]>
>> Signed-off-by: Per Forlin <[email protected]>
>
> Acked-by: Nicolas Pitre <[email protected]>
>
I am working o a patch version 2 after offline discussion with Ulf Hansson.
Instead of adding this code here.
Add sdio_single_func member in mmc_card. Set and reset this function
in sdio_claim_irq and sdio_release_irq.
process_sdio_pending_irqs would only check if sdio_single_func is !=
null and call it.
This will result in a bigger patch overall but the new code in
process_sdio_pending_irqs will be minimal.
>> ---
>> ?drivers/mmc/core/sdio_irq.c | ? 14 ++++++++++++++
>> ?1 files changed, 14 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
>> index b300161..25291bf 100644
>> --- a/drivers/mmc/core/sdio_irq.c
>> +++ b/drivers/mmc/core/sdio_irq.c
>> @@ -32,6 +32,20 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
>> ? ? ? int i, ret, count;
>> ? ? ? unsigned char pending;
>>
>> + ? ? /*
>> + ? ? ?* If there is only 1 function registered
>> + ? ? ?* call irq directly without checking the CCCR registers.
>> + ? ? ?*/
>> + ? ? if ((card->host->caps & MMC_CAP_SDIO_IRQ) &&
>> + ? ? ? ? card->host->sdio_irqs && (card->sdio_funcs == 1))
>> + ? ? ? ? ? ? for (i = 0; i < SDIO_MAX_FUNCS; i++) {
Minor adjustments.
card->sdio_funcs may be > 1 but still only one irq is registered.
No need to iterate more than "sdio_funcs" number of elements.
+ card->host->sdio_irqs == 1)
+ for (i = 0; i < card->sdio_funcs; i++) {
>> + ? ? ? ? ? ? ? ? ? ? struct sdio_func *func = card->sdio_func[i];
>> + ? ? ? ? ? ? ? ? ? ? if (func && func->irq_handler) {
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? func->irq_handler(func);
>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? return 1;
>> + ? ? ? ? ? ? ? ? ? ? }
>> + ? ? ? ? ? ? }
>> +
>> ? ? ? ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
>> ? ? ? if (ret) {
>> ? ? ? ? ? ? ? printk(KERN_DEBUG "%s: error %d reading SDIO_CCCR_INTx\n",
>> --
>> 1.7.4.1
>>
>>
>> _______________________________________________
>> linaro-dev mailing list
>> [email protected]
>> http://lists.linaro.org/mailman/listinfo/linaro-dev
>>
>
On Wed, 4 May 2011, Per Forlin wrote:
> On 4 May 2011 05:40, Nicolas Pitre <[email protected]> wrote:
> > On Tue, 3 May 2011, Per Forlin wrote:
> >
> >> From: Stefan Nilsson XK <[email protected]>
> >>
> >> If there is only 1 function registered, and IRQ:s are supported and
> >> currently enabled, call the callback handler directly
> >> without checking the CCCR registers.
> >>
> >> Signed-off-by: Stefan Nilsson XK <[email protected]>
> >> Signed-off-by: Per Forlin <[email protected]>
> >
> > Acked-by: Nicolas Pitre <[email protected]>
> >
> I am working o a patch version 2 after offline discussion with Ulf Hansson.
> Instead of adding this code here.
> Add sdio_single_func member in mmc_card. Set and reset this function
> in sdio_claim_irq and sdio_release_irq.
> process_sdio_pending_irqs would only check if sdio_single_func is !=
> null and call it.
Yes, that's what I was about to propose after thinking about it some
more.
> This will result in a bigger patch overall but the new code in
> process_sdio_pending_irqs will be minimal.
Something like this (untested) ?
diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c
index b300161..4552727 100644
--- a/drivers/mmc/core/sdio_irq.c
+++ b/drivers/mmc/core/sdio_irq.c
@@ -32,6 +32,12 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
int i, ret, count;
unsigned char pending;
+ if (card->sdio_single_irq) {
+ struct sdio_func *func = card->sdio_single_irq;
+ func->irq_handler(func);
+ return 1;
+ }
+
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
if (ret) {
printk(KERN_DEBUG "%s: error %d reading SDIO_CCCR_INTx\n",
@@ -166,6 +172,7 @@ static int sdio_card_irq_get(struct mmc_card *card)
host->sdio_irqs--;
return err;
}
+ return 1;
}
return 0;
@@ -183,7 +190,7 @@ static int sdio_card_irq_put(struct mmc_card *card)
kthread_stop(host->sdio_irq_thread);
}
- return 0;
+ return (host->sdio_irqs == 1);
}
/**
@@ -225,8 +232,12 @@ int sdio_claim_irq(struct sdio_func *func, sdio_irq_handler_t *handler)
func->irq_handler = handler;
ret = sdio_card_irq_get(func->card);
- if (ret)
+ if (ret < 0) {
func->irq_handler = NULL;
+ } else if (ret == 1) {
+ card->sdio_single_irq = func;
+ ret = 0;
+ }
return ret;
}
@@ -250,7 +261,17 @@ int sdio_release_irq(struct sdio_func *func)
if (func->irq_handler) {
func->irq_handler = NULL;
- sdio_card_irq_put(func->card);
+ if (sdio_card_irq_put(func->card) == 1) {
+ int i;
+ for (i = 0, i < 7; i++) {
+ if (func->card->sdio_func[i].irq_handler) {
+ func->card->sdio_single_irq =
+ func->card->sdio_func[i];
+ break;
+ }
+ }
+ } else
+ func->card->sdio_single_irq = NULL;
}
ret = mmc_io_rw_direct(func->card, 0, 0, SDIO_CCCR_IENx, 0, ®);
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index adb4888..fee3df3 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -145,6 +145,7 @@ struct mmc_card {
struct sdio_cccr cccr; /* common card info */
struct sdio_cis cis; /* common tuple info */
struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */
+ struct sdio_func *sdio_single_irq; /* SDIO function when only one IRQ active */
unsigned num_info; /* number of info strings */
const char **info; /* info strings */
struct sdio_func_tuple *tuples; /* unknown common tuples */
Nicolas
On 4 May 2011 17:20, Nicolas Pitre <[email protected]> wrote:
> On Wed, 4 May 2011, Per Forlin wrote:
>
>> On 4 May 2011 05:40, Nicolas Pitre <[email protected]> wrote:
>> > On Tue, 3 May 2011, Per Forlin wrote:
>> >
>> >> From: Stefan Nilsson XK <[email protected]>
>> >>
>> >> If there is only 1 function registered, and IRQ:s are supported and
>> >> currently enabled, call the callback handler directly
>> >> without checking the CCCR registers.
>> >>
>> >> Signed-off-by: Stefan Nilsson XK <[email protected]>
>> >> Signed-off-by: Per Forlin <[email protected]>
>> >
>> > Acked-by: Nicolas Pitre <[email protected]>
>> >
>> I am working o a patch version 2 after offline discussion with Ulf Hansson.
>> Instead of adding this code here.
>> Add sdio_single_func member in mmc_card. Set and reset this function
>> in sdio_claim_irq and sdio_release_irq.
>> process_sdio_pending_irqs would only check if sdio_single_func is !=
>> null and call it.
>
> Yes, that's what I was about to propose after thinking about it some
> more.
>
>> This will result in a bigger patch overall but the new code in
>> process_sdio_pending_irqs will be minimal.
>
> Something like this (untested) ?
>
What I had in mind is similar. Please let me know what you think. I am
about to post "patch v2"
Regards,
Per