* [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow
@ 2019-06-14 5:26 Jjian Zhou
2019-06-14 5:26 ` [PATCH 2/2] mmc: mediatek: fix SDIO IRQ detection issue Jjian Zhou
2019-06-14 9:46 ` [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Ulf Hansson
0 siblings, 2 replies; 5+ messages in thread
From: Jjian Zhou @ 2019-06-14 5:26 UTC (permalink / raw)
To: ulf.hansson, chaotian.jing, matthias.bgg, linux-mmc,
linux-arm-kernel, linux-mediatek, linux-kernel
Cc: jjian zhou, srv_heupstream, yong.mao
From: jjian zhou <jjian.zhou@mediatek.com>
SDIO IRQ is triggered by low level. It need disable SDIO IRQ
detected function. Otherwise the interrupt register can't be cleared.
It will process the interrupt more.
Signed-off-by: Jjian Zhou <jjian.zhou@mediatek.com>
Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Signed-off-by: Yong Mao <yong.mao@mediatek.com>
---
drivers/mmc/host/mtk-sd.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index c518cc2..29992ae 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -1389,10 +1389,12 @@ static void __msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
struct msdc_host *host = mmc_priv(mmc);
spin_lock_irqsave(&host->lock, flags);
- if (enb)
+ if (enb) {
sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
- else
+ sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
+ } else {
sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
+ }
spin_unlock_irqrestore(&host->lock, flags);
}
@@ -1422,6 +1424,8 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
spin_lock_irqsave(&host->lock, flags);
events = readl(host->base + MSDC_INT);
event_mask = readl(host->base + MSDC_INTEN);
+ if ((events & event_mask) & MSDC_INT_SDIOIRQ)
+ sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
/* clear interrupts */
writel(events & event_mask, host->base + MSDC_INT);
@@ -1572,10 +1576,7 @@ static void msdc_init_hw(struct msdc_host *host)
sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO);
/* Config SDIO device detect interrupt function */
- if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
- sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
- else
- sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
+ sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
/* Configure to default data timeout */
sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3);
--
1.9.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] mmc: mediatek: fix SDIO IRQ detection issue
2019-06-14 5:26 [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Jjian Zhou
@ 2019-06-14 5:26 ` Jjian Zhou
2019-06-14 9:46 ` [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Ulf Hansson
1 sibling, 0 replies; 5+ messages in thread
From: Jjian Zhou @ 2019-06-14 5:26 UTC (permalink / raw)
To: ulf.hansson, chaotian.jing, matthias.bgg, linux-mmc,
linux-arm-kernel, linux-mediatek, linux-kernel
Cc: jjian zhou, srv_heupstream, yong.mao
From: jjian zhou <jjian.zhou@mediatek.com>
If cmd19 timeout or response crcerr occurs during execute_tuning(),
it need invoke msdc_reset_hw(). Otherwise SDIO IRQ can't be detected.
Signed-off-by: jjian zhou <jjian.zhou@mediatek.com>
Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
Signed-off-by: Yong Mao <yong.mao@mediatek.com>
---
drivers/mmc/host/mtk-sd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 29992ae..df8f09d 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -1031,6 +1031,8 @@ static void msdc_request_done(struct msdc_host *host, struct mmc_request *mrq)
msdc_track_cmd_data(host, mrq->cmd, mrq->data);
if (mrq->data)
msdc_unprepare_data(host, mrq);
+ if (host->error)
+ msdc_reset_hw(host);
mmc_request_done(host->mmc, mrq);
}
--
1.9.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow
2019-06-14 5:26 [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Jjian Zhou
2019-06-14 5:26 ` [PATCH 2/2] mmc: mediatek: fix SDIO IRQ detection issue Jjian Zhou
@ 2019-06-14 9:46 ` Ulf Hansson
2019-06-17 5:57 ` jjian zhou
1 sibling, 1 reply; 5+ messages in thread
From: Ulf Hansson @ 2019-06-14 9:46 UTC (permalink / raw)
To: Jjian Zhou
Cc: srv_heupstream, linux-mmc, Linux Kernel Mailing List, Yong Mao,
linux-mediatek, Chaotian Jing, Matthias Brugger, Linux ARM
On Fri, 14 Jun 2019 at 07:26, Jjian Zhou <jjian.zhou@mediatek.com> wrote:
>
> From: jjian zhou <jjian.zhou@mediatek.com>
>
> SDIO IRQ is triggered by low level. It need disable SDIO IRQ
> detected function. Otherwise the interrupt register can't be cleared.
> It will process the interrupt more.
>
> Signed-off-by: Jjian Zhou <jjian.zhou@mediatek.com>
> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> Signed-off-by: Yong Mao <yong.mao@mediatek.com>
> ---
> drivers/mmc/host/mtk-sd.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index c518cc2..29992ae 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -1389,10 +1389,12 @@ static void __msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
> struct msdc_host *host = mmc_priv(mmc);
>
> spin_lock_irqsave(&host->lock, flags);
> - if (enb)
> + if (enb) {
> sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
> - else
> + sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> + } else {
> sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
Rather than clearing SDC_CFG_SDIOIDE in the irq handler, you need to
do it here. As otherwise when the mmc core calls
host->ops->enable_sdio_irq() to disable the SDIO IRQ, it may stay
enabled.
> + }
> spin_unlock_irqrestore(&host->lock, flags);
> }
>
> @@ -1422,6 +1424,8 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
> spin_lock_irqsave(&host->lock, flags);
> events = readl(host->base + MSDC_INT);
> event_mask = readl(host->base + MSDC_INTEN);
> + if ((events & event_mask) & MSDC_INT_SDIOIRQ)
> + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
As stated above, I suggest you move this into __msdc_enable_sdio_irq()
and thus call that function from here instead. Well, that doesn't work
as is, because of the spin lock, so you rather need to make a
sub-function of __msdc_enable_sdio_irq, that don't take/releases the
lock.
I hope that was clear. If not, I can post a patch to show you what I mean.
> /* clear interrupts */
> writel(events & event_mask, host->base + MSDC_INT);
>
> @@ -1572,10 +1576,7 @@ static void msdc_init_hw(struct msdc_host *host)
> sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO);
>
> /* Config SDIO device detect interrupt function */
> - if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
> - sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> - else
> - sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
>
> /* Configure to default data timeout */
> sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3);
> --
> 1.9.1
>
Kind regards
Uffe
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow
2019-06-14 9:46 ` [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Ulf Hansson
@ 2019-06-17 5:57 ` jjian zhou
2019-06-17 7:47 ` Ulf Hansson
0 siblings, 1 reply; 5+ messages in thread
From: jjian zhou @ 2019-06-17 5:57 UTC (permalink / raw)
To: Ulf Hansson
Cc: srv_heupstream, linux-mmc, Linux Kernel Mailing List,
Yong Mao (毛勇),
linux-mediatek, Chaotian Jing (井朝天),
Matthias Brugger, Linux ARM
On Fri, 2019-06-14 at 17:46 +0800, Ulf Hansson wrote:
> On Fri, 14 Jun 2019 at 07:26, Jjian Zhou <jjian.zhou@mediatek.com> wrote:
> >
> > From: jjian zhou <jjian.zhou@mediatek.com>
> >
> > SDIO IRQ is triggered by low level. It need disable SDIO IRQ
> > detected function. Otherwise the interrupt register can't be cleared.
> > It will process the interrupt more.
> >
> > Signed-off-by: Jjian Zhou <jjian.zhou@mediatek.com>
> > Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> > Signed-off-by: Yong Mao <yong.mao@mediatek.com>
> > ---
> > drivers/mmc/host/mtk-sd.c | 13 +++++++------
> > 1 file changed, 7 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> > index c518cc2..29992ae 100644
> > --- a/drivers/mmc/host/mtk-sd.c
> > +++ b/drivers/mmc/host/mtk-sd.c
> > @@ -1389,10 +1389,12 @@ static void __msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
> > struct msdc_host *host = mmc_priv(mmc);
> >
> > spin_lock_irqsave(&host->lock, flags);
> > - if (enb)
> > + if (enb) {
> > sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
> > - else
> > + sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> > + } else {
> > sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
>
> Rather than clearing SDC_CFG_SDIOIDE in the irq handler, you need to
> do it here. As otherwise when the mmc core calls
> host->ops->enable_sdio_irq() to disable the SDIO IRQ, it may stay
> enabled.
>
Thank you for your review.
I remove the spin lock in "__msdc_enable_sdio_irq" and add
spin lock in "msdc_enable_sdio_irq". The modification of
"__msdc_enable_sdio_irq" and "msdc_enable_sdio_irq" is as following.
static void __msdc_enable_sdio_irq(struct msdc_host *host, int enb)
{
if (enb) {
sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
} else {
sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
}
}
static void msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
{
unsigned long flags;
struct msdc_host *host = mmc_priv(mmc);
spin_lock_irqsave(&host->lock, flags);;
__msdc_enable_sdio_irq(host, enb);
spin_unlock_irqrestore(&host->lock, flags);
if (enb)
pm_runtime_get_noresume(host->dev);
else
pm_runtime_get_noidle(host->dev);
}
> > + }
> > spin_unlock_irqrestore(&host->lock, flags);
> > }
> >
> > @@ -1422,6 +1424,8 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
> > spin_lock_irqsave(&host->lock, flags);
> > events = readl(host->base + MSDC_INT);
> > event_mask = readl(host->base + MSDC_INTEN);
> > + if ((events & event_mask) & MSDC_INT_SDIOIRQ)
> > + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
>
> As stated above, I suggest you move this into __msdc_enable_sdio_irq()
> and thus call that function from here instead. Well, that doesn't work
> as is, because of the spin lock, so you rather need to make a
> sub-function of __msdc_enable_sdio_irq, that don't take/releases the
> lock.
>
> I hope that was clear. If not, I can post a patch to show you what I mean.
>
I also modify this part handler in msdc_irq.
spin_lock_irqsave(&host->lock, flags);
events = readl(host->base + MSDC_INT);
event_mask = readl(host->base + MSDC_INTEN);
if ((events & event_mask) & MSDC_INT_SDIOIRQ)
__msdc_enable_sdio_irq(host, 0);
/* clear interrupts */
writel(events & event_mask, host->base + MSDC_INT);
mrq = host->mrq;
cmd = host->cmd;
data = host->data;
spin_unlock_irqrestore(&host->lock, flags);
if ((events & event_mask) & MSDC_INT_SDIOIRQ)
sdio_signal_irq(host->mmc);
I also will add spin lock in the "msdc_ack_sdio_irq".
Looking forward to your suggestions.
>
> > /* clear interrupts */
> > writel(events & event_mask, host->base + MSDC_INT);
> >
> > @@ -1572,10 +1576,7 @@ static void msdc_init_hw(struct msdc_host *host)
> > sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO);
> >
> > /* Config SDIO device detect interrupt function */
> > - if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
> > - sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> > - else
> > - sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> > + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> >
> > /* Configure to default data timeout */
> > sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3);
> > --
> > 1.9.1
> >
>
> Kind regards
> Uffe
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow
2019-06-17 5:57 ` jjian zhou
@ 2019-06-17 7:47 ` Ulf Hansson
0 siblings, 0 replies; 5+ messages in thread
From: Ulf Hansson @ 2019-06-17 7:47 UTC (permalink / raw)
To: jjian zhou
Cc: srv_heupstream, linux-mmc, Linux Kernel Mailing List,
Yong Mao (毛勇),
linux-mediatek, Chaotian Jing (井朝天),
Matthias Brugger, Linux ARM
On Mon, 17 Jun 2019 at 07:57, jjian zhou <jjian.zhou@mediatek.com> wrote:
>
> On Fri, 2019-06-14 at 17:46 +0800, Ulf Hansson wrote:
> > On Fri, 14 Jun 2019 at 07:26, Jjian Zhou <jjian.zhou@mediatek.com> wrote:
> > >
> > > From: jjian zhou <jjian.zhou@mediatek.com>
> > >
> > > SDIO IRQ is triggered by low level. It need disable SDIO IRQ
> > > detected function. Otherwise the interrupt register can't be cleared.
> > > It will process the interrupt more.
> > >
> > > Signed-off-by: Jjian Zhou <jjian.zhou@mediatek.com>
> > > Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> > > Signed-off-by: Yong Mao <yong.mao@mediatek.com>
> > > ---
> > > drivers/mmc/host/mtk-sd.c | 13 +++++++------
> > > 1 file changed, 7 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> > > index c518cc2..29992ae 100644
> > > --- a/drivers/mmc/host/mtk-sd.c
> > > +++ b/drivers/mmc/host/mtk-sd.c
> > > @@ -1389,10 +1389,12 @@ static void __msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
> > > struct msdc_host *host = mmc_priv(mmc);
> > >
> > > spin_lock_irqsave(&host->lock, flags);
> > > - if (enb)
> > > + if (enb) {
> > > sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
> > > - else
> > > + sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> > > + } else {
> > > sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
> >
> > Rather than clearing SDC_CFG_SDIOIDE in the irq handler, you need to
> > do it here. As otherwise when the mmc core calls
> > host->ops->enable_sdio_irq() to disable the SDIO IRQ, it may stay
> > enabled.
> >
>
> Thank you for your review.
>
> I remove the spin lock in "__msdc_enable_sdio_irq" and add
> spin lock in "msdc_enable_sdio_irq". The modification of
> "__msdc_enable_sdio_irq" and "msdc_enable_sdio_irq" is as following.
>
> static void __msdc_enable_sdio_irq(struct msdc_host *host, int enb)
> {
> if (enb) {
> sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
> sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> } else {
> sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ);
> sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> }
> }
>
> static void msdc_enable_sdio_irq(struct mmc_host *mmc, int enb)
> {
> unsigned long flags;
> struct msdc_host *host = mmc_priv(mmc);
> spin_lock_irqsave(&host->lock, flags);;
> __msdc_enable_sdio_irq(host, enb);
> spin_unlock_irqrestore(&host->lock, flags);
>
> if (enb)
> pm_runtime_get_noresume(host->dev);
> else
> pm_runtime_get_noidle(host->dev);
> }
>
> > > + }
> > > spin_unlock_irqrestore(&host->lock, flags);
> > > }
> > >
> > > @@ -1422,6 +1424,8 @@ static irqreturn_t msdc_irq(int irq, void *dev_id)
> > > spin_lock_irqsave(&host->lock, flags);
> > > events = readl(host->base + MSDC_INT);
> > > event_mask = readl(host->base + MSDC_INTEN);
> > > + if ((events & event_mask) & MSDC_INT_SDIOIRQ)
> > > + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE);
> >
> > As stated above, I suggest you move this into __msdc_enable_sdio_irq()
> > and thus call that function from here instead. Well, that doesn't work
> > as is, because of the spin lock, so you rather need to make a
> > sub-function of __msdc_enable_sdio_irq, that don't take/releases the
> > lock.
> >
> > I hope that was clear. If not, I can post a patch to show you what I mean.
> >
>
> I also modify this part handler in msdc_irq.
>
> spin_lock_irqsave(&host->lock, flags);
> events = readl(host->base + MSDC_INT);
> event_mask = readl(host->base + MSDC_INTEN);
> if ((events & event_mask) & MSDC_INT_SDIOIRQ)
> __msdc_enable_sdio_irq(host, 0);
> /* clear interrupts */
> writel(events & event_mask, host->base + MSDC_INT);
>
> mrq = host->mrq;
> cmd = host->cmd;
> data = host->data;
> spin_unlock_irqrestore(&host->lock, flags);
>
> if ((events & event_mask) & MSDC_INT_SDIOIRQ)
> sdio_signal_irq(host->mmc);
>
> I also will add spin lock in the "msdc_ack_sdio_irq".
>
> Looking forward to your suggestions.
Seems reasonable, please post a new version, then I will review again.
[...]
Kind regards
Uffe
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-17 7:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 5:26 [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Jjian Zhou
2019-06-14 5:26 ` [PATCH 2/2] mmc: mediatek: fix SDIO IRQ detection issue Jjian Zhou
2019-06-14 9:46 ` [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow Ulf Hansson
2019-06-17 5:57 ` jjian zhou
2019-06-17 7:47 ` 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).