From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A397EC31E44 for ; Mon, 17 Jun 2019 05:57:27 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7426B21882 for ; Mon, 17 Jun 2019 05:57:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fmdhvY7w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7426B21882 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ypJ2vAVWUD4NnwYzLPPKwnBEH3HqL5N30uIdLLKd2oA=; b=fmdhvY7wQdohGN hKQh/RjmTzhk4OTQtxwkf428VBfpaPniKmLhDPRUgmMhSTXxP5cB5Twy78igeVb1YKkfWlo4l0BVu LggO9Yl4Wkcr9eiRIwYBYL0OKbTF80W0j/DOWYMhcxO1StuiXZAJJqPkeO6PvWWiRWTLItbt7b26F I2mi69sSoCjQNDm9f/oRiInZe/Syi5ki3AG3SGSXXUzTyckwgJjRcfvVWpZz3jntwaDX//TZ+TT4v HUsBkKqofD4eqVolJSeDU3+FOoYZV3Ufmc5H8f/j8ozirprnmx4vuTvAxn7ABhC+3txPCXUQ1B/cy VOQ7dbCB+hqlEQEQC2yw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hckdt-0007qI-N3; Mon, 17 Jun 2019 05:57:21 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hckdo-0007on-D1; Mon, 17 Jun 2019 05:57:18 +0000 X-UUID: f727c30043fa477b8ea731a0c8a35c63-20190616 X-UUID: f727c30043fa477b8ea731a0c8a35c63-20190616 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 1216551598; Sun, 16 Jun 2019 21:57:10 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 16 Jun 2019 22:57:08 -0700 Received: from MTKCAS36.mediatek.inc (172.27.4.186) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 17 Jun 2019 13:57:03 +0800 Received: from [10.17.3.153] (172.27.4.253) by MTKCAS36.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 17 Jun 2019 13:57:01 +0800 Message-ID: <1560751020.3103.25.camel@mhfsdcap03> Subject: Re: [PATCH 1/2] mmc: mediatek: fix SDIO IRQ interrupt handle flow From: jjian zhou To: Ulf Hansson Date: Mon, 17 Jun 2019 13:57:00 +0800 In-Reply-To: References: <1560489970-30467-1-git-send-email-jjian.zhou@mediatek.com> X-Mailer: Evolution 3.10.4-0ubuntu2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190616_225716_454505_35672E50 X-CRM114-Status: GOOD ( 20.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: srv_heupstream , "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List , Yong Mao =?UTF-8?Q?=28=E6=AF=9B=E5=8B=87=29?= , "linux-mediatek@lists.infradead.org" , Chaotian Jing =?UTF-8?Q?=28=E4=BA=95=E6=9C=9D=E5=A4=A9=29?= , Matthias Brugger , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 2019-06-14 at 17:46 +0800, Ulf Hansson wrote: > On Fri, 14 Jun 2019 at 07:26, Jjian Zhou wrote: > > > > From: jjian zhou > > > > 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 > > Signed-off-by: Chaotian Jing > > Signed-off-by: Yong Mao > > --- > > 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