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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 453AFC433FE for ; Mon, 17 Jan 2022 07:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237557AbiAQHgC (ORCPT ); Mon, 17 Jan 2022 02:36:02 -0500 Received: from mailgw01.mediatek.com ([60.244.123.138]:34772 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232208AbiAQHgA (ORCPT ); Mon, 17 Jan 2022 02:36:00 -0500 X-UUID: 0248352516b94cd1a40ba274f513aa84-20220117 X-UUID: 0248352516b94cd1a40ba274f513aa84-20220117 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1741393476; Mon, 17 Jan 2022 15:35:55 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Mon, 17 Jan 2022 15:35:54 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 17 Jan 2022 15:35:53 +0800 Message-ID: <2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com> Subject: Re: [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq From: Axe Yang To: Andy Shevchenko CC: Ulf Hansson , Rob Herring , Chaotian Jing , Matthias Brugger , Adrian Hunter , "Yoshihiro Shimoda" , Satya Tangirala , Wolfram Sang , "Lucas Stach" , Eric Biggers , Andrew Jeffery , Stephen Boyd , Kiwoong Kim , Yue Hu , Tian Tao , , , , , Date: Mon, 17 Jan 2022 15:35:53 +0800 In-Reply-To: References: <20220111014046.5864-1-axe.yang@mediatek.com> <20220111014046.5864-4-axe.yang@mediatek.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Andy, patchset v3 is uploaded. I fixed most of the defect you pointed out. And in msdc_sdio_eint_irq(), you asked why do we need flags, the flags is for spin lock irq save/restore, so I keep it. On Tue, 2022-01-11 at 13:46 +0200, Andy Shevchenko wrote: > On Tue, Jan 11, 2022 at 09:40:46AM +0800, Axe Yang wrote: > > Add support for eint irq when MSDC is used as an SDIO host. This > > IRQ > > > feature requires SDIO device support async irq function. With this > > IRQ > > > feature,SDIO host can be awakened by SDIO card in suspend state, > > feature, SDIO > > > without additional pin. > > > > MSDC driver will time-share the SDIO DAT1 pin. During suspend, MSDC > > turn off clock and switch SDIO DAT1 pin to GPIO mode. And during > > resume, switch GPIO function back to DAT1 mode then turn on clock. > > > > Some device tree property should be added or modified in msdc node > > MSDC > > > to support SDIO eint irq. Pinctrls named state_dat1 and state_eint > > IRQ > > > are mandatory. And cap-sdio-async-irq flag is necessary since this > > feature depends on asynchronous interrupt: > > &mmcX { > > ... > > pinctrl-names = "default", "state_uhs", > > "state_eint", > > "state_dat1"; > > ... > > pinctrl-2 = <&mmc2_pins_eint>; > > pinctrl-3 = <&mmc2_pins_dat1>; > > ... > > cap-sdio-async-irq; > > ... > > }; > > ... > > > - * Copyright (c) 2014-2015 MediaTek Inc. > > + * Copyright (c) 2014-2022 MediaTek Inc. > > Shouldn't it be rather like > > * Copyright (c) 2014-2015,2022 MediaTek Inc. > > ? > > ... > > > +static irqreturn_t msdc_sdio_eint_irq(int irq, void *dev_id) > > +{ > > + unsigned long flags; > > + struct msdc_host *host = (struct msdc_host *)dev_id; > > No casting is needed. > > > + struct mmc_host *mmc = mmc_from_priv(host); > > Perhaps reversed xmas tree order > > struct msdc_host *host = dev_id; > struct mmc_host *mmc = mmc_from_priv(host); > unsigned long flags; > > ? > > But hey, why do you need flags? falgs is for spin lock irq save/restore. > > > + spin_lock_irqsave(&host->lock, flags); > > + if (likely(host->sdio_irq_cnt > 0)) { > > + disable_irq_nosync(host->eint_irq); > > + disable_irq_wake(host->eint_irq); > > + host->sdio_irq_cnt--; > > + } > > + spin_unlock_irqrestore(&host->lock, flags); > > + > > + sdio_signal_irq(mmc); > > + > > + return IRQ_HANDLED; > > +} > > ... > > > +static int msdc_request_dat1_eint_irq(struct msdc_host *host) > > +{ > > + struct gpio_desc *desc; > > + int irq, ret; > > + > > + desc = devm_gpiod_get(host->dev, "eint", GPIOD_IN); > > + if (IS_ERR(desc)) > > + return PTR_ERR(desc); > > + > > + ret = gpiod_to_irq(desc); > > + if (ret < 0) > > + return ret; > > + > > + irq = ret; > > + ret = devm_request_threaded_irq(host->dev, irq, NULL, > > msdc_sdio_eint_irq, > > + IRQF_TRIGGER_LOW | IRQF_ONESHOT > > | IRQF_NO_AUTOEN, > > + "sdio-eint", host); > > + > > Redundant blank line. > > > + if (!ret) > > + host->eint_irq = irq; > > + > > + return ret; > > I guess I have already commented on this, i.e. use standard pattern > > if (ret) > return ret; > > ... > return 0; > > > +} > > ... > > > + host->pins_eint = pinctrl_lookup_state(host->pinctrl, > > "state_eint"); > > + if (IS_ERR(host->pins_eint)) { > > + dev_dbg(&pdev->dev, "Cannot find pinctrl > > eint!\n"); > > In debug mode of pin control this will bring a duplicate message. > > > + } else { > > + host->pins_dat1 = pinctrl_lookup_state(host- > > >pinctrl, "state_dat1"); > > + if (IS_ERR(host->pins_dat1)) { > > + ret = dev_err_probe(&pdev->dev, > > PTR_ERR(host->pins_dat1), > > + "Cannot find > > pinctrl dat1!\n"); > > + goto host_free; > > + } > > + > > + host->sdio_eint_ready = true; > > + } > > + } > > 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B3058C433F5 for ; Mon, 17 Jan 2022 07:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:CC: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=LBFQfQxZy6Fr+rBuvtm+YkcEb82KF6GtONW3qrnS4+E=; b=naskfMtTQbA0fE 9ZvgpwK48XW37BI6Zd0mk2KnhCRl+4/oMHJK7HPmN3yR/hvrEvOAopXMyHXzUGTIakhvdDnDQFBaO GMTIUy/e9Ux8iLJw3EneRhjjhY4NlXrlvLjsaamPwvELGTbjN9SvxsHGf4lMZRF8DU8yWGgy8UuAR V6bQ7QhpZNSoksOGFie5LIFWYQc0Wekf1ulVs8dCHU2lwuMmVarpYyg4HWyEmahTvvIVPNHmpKzaY BsmCJfh9iDe/SG2VotvkvaniF8jUlZhn1fWHVCl3yJ0mMJF4K/pfUl/PFQYfKK3JbacueiPBZ45rG o5BqoM6WihYLn6px8uNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9MYb-00DvvH-LS; Mon, 17 Jan 2022 07:36:01 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9MYZ-00DvuH-9y; Mon, 17 Jan 2022 07:36:00 +0000 X-UUID: 491c1599af0745a28588a37b8be78e91-20220117 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=H6ReXx4yE6tld3maYxfIDGQtHTSOvcYmQuJ0B+XGa1k=; b=JgzmT8vTAakjCHOW8Abbm80GiNHjHNgv2TAkS72qtNFaSq6NsLlxpjTv261hKxn9uVVUKkhHe9ADVlfUP7Xqtf1uHq1I0HuQsMztoTZEOBIBGMis7ZfipEinAvhiqtsIs5HagZ783z8VRP1BVtDkSoJkYVf7UDORFHcyDWP2Wis=; X-UUID: 491c1599af0745a28588a37b8be78e91-20220117 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1143419954; Mon, 17 Jan 2022 00:35:57 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 16 Jan 2022 23:35:56 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Mon, 17 Jan 2022 15:35:54 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 17 Jan 2022 15:35:53 +0800 Message-ID: <2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com> Subject: Re: [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq From: Axe Yang To: Andy Shevchenko CC: Ulf Hansson , Rob Herring , Chaotian Jing , Matthias Brugger , Adrian Hunter , "Yoshihiro Shimoda" , Satya Tangirala , Wolfram Sang , "Lucas Stach" , Eric Biggers , Andrew Jeffery , Stephen Boyd , Kiwoong Kim , Yue Hu , Tian Tao , , , , , Date: Mon, 17 Jan 2022 15:35:53 +0800 In-Reply-To: References: <20220111014046.5864-1-axe.yang@mediatek.com> <20220111014046.5864-4-axe.yang@mediatek.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220116_233559_390067_44829BCA X-CRM114-Status: GOOD ( 28.69 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Andy, patchset v3 is uploaded. I fixed most of the defect you pointed out. And in msdc_sdio_eint_irq(), you asked why do we need flags, the flags is for spin lock irq save/restore, so I keep it. On Tue, 2022-01-11 at 13:46 +0200, Andy Shevchenko wrote: > On Tue, Jan 11, 2022 at 09:40:46AM +0800, Axe Yang wrote: > > Add support for eint irq when MSDC is used as an SDIO host. This > > IRQ > > > feature requires SDIO device support async irq function. With this > > IRQ > > > feature,SDIO host can be awakened by SDIO card in suspend state, > > feature, SDIO > > > without additional pin. > > > > MSDC driver will time-share the SDIO DAT1 pin. During suspend, MSDC > > turn off clock and switch SDIO DAT1 pin to GPIO mode. And during > > resume, switch GPIO function back to DAT1 mode then turn on clock. > > > > Some device tree property should be added or modified in msdc node > > MSDC > > > to support SDIO eint irq. Pinctrls named state_dat1 and state_eint > > IRQ > > > are mandatory. And cap-sdio-async-irq flag is necessary since this > > feature depends on asynchronous interrupt: > > &mmcX { > > ... > > pinctrl-names = "default", "state_uhs", > > "state_eint", > > "state_dat1"; > > ... > > pinctrl-2 = <&mmc2_pins_eint>; > > pinctrl-3 = <&mmc2_pins_dat1>; > > ... > > cap-sdio-async-irq; > > ... > > }; > > ... > > > - * Copyright (c) 2014-2015 MediaTek Inc. > > + * Copyright (c) 2014-2022 MediaTek Inc. > > Shouldn't it be rather like > > * Copyright (c) 2014-2015,2022 MediaTek Inc. > > ? > > ... > > > +static irqreturn_t msdc_sdio_eint_irq(int irq, void *dev_id) > > +{ > > + unsigned long flags; > > + struct msdc_host *host = (struct msdc_host *)dev_id; > > No casting is needed. > > > + struct mmc_host *mmc = mmc_from_priv(host); > > Perhaps reversed xmas tree order > > struct msdc_host *host = dev_id; > struct mmc_host *mmc = mmc_from_priv(host); > unsigned long flags; > > ? > > But hey, why do you need flags? falgs is for spin lock irq save/restore. > > > + spin_lock_irqsave(&host->lock, flags); > > + if (likely(host->sdio_irq_cnt > 0)) { > > + disable_irq_nosync(host->eint_irq); > > + disable_irq_wake(host->eint_irq); > > + host->sdio_irq_cnt--; > > + } > > + spin_unlock_irqrestore(&host->lock, flags); > > + > > + sdio_signal_irq(mmc); > > + > > + return IRQ_HANDLED; > > +} > > ... > > > +static int msdc_request_dat1_eint_irq(struct msdc_host *host) > > +{ > > + struct gpio_desc *desc; > > + int irq, ret; > > + > > + desc = devm_gpiod_get(host->dev, "eint", GPIOD_IN); > > + if (IS_ERR(desc)) > > + return PTR_ERR(desc); > > + > > + ret = gpiod_to_irq(desc); > > + if (ret < 0) > > + return ret; > > + > > + irq = ret; > > + ret = devm_request_threaded_irq(host->dev, irq, NULL, > > msdc_sdio_eint_irq, > > + IRQF_TRIGGER_LOW | IRQF_ONESHOT > > | IRQF_NO_AUTOEN, > > + "sdio-eint", host); > > + > > Redundant blank line. > > > + if (!ret) > > + host->eint_irq = irq; > > + > > + return ret; > > I guess I have already commented on this, i.e. use standard pattern > > if (ret) > return ret; > > ... > return 0; > > > +} > > ... > > > + host->pins_eint = pinctrl_lookup_state(host->pinctrl, > > "state_eint"); > > + if (IS_ERR(host->pins_eint)) { > > + dev_dbg(&pdev->dev, "Cannot find pinctrl > > eint!\n"); > > In debug mode of pin control this will bring a duplicate message. > > > + } else { > > + host->pins_dat1 = pinctrl_lookup_state(host- > > >pinctrl, "state_dat1"); > > + if (IS_ERR(host->pins_dat1)) { > > + ret = dev_err_probe(&pdev->dev, > > PTR_ERR(host->pins_dat1), > > + "Cannot find > > pinctrl dat1!\n"); > > + goto host_free; > > + } > > + > > + host->sdio_eint_ready = true; > > + } > > + } > > _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 14F0DC433EF for ; Mon, 17 Jan 2022 07:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:CC: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=FLrkrk4wEmrlLnphpP7YCQaUp5HDccLkn/iBOn23sQE=; b=alOqMGJFsn/lTY g51YDZwtwa6c4IU7Xzg2WQaBQQUgYqsEaTMAaJQ3WVng8Vsiro81G3Qy8VecXbqZoj4sZekvxlbjl eU9FLoIqlLsIyocoDoq95mWd5u5fGPF+OTC8AxV+VFK8L1zZREuCiKX3pW/SHopHe47+PLXBm8fZf 4WU+mj69YY7xJqzczh1mN31+eMHpboKN1FbtuhYPmnojfGDXdB7TCXDMwVuWcHiMGwH7vEP0LJh4V 3fd8xbPT5yk7OC1CMttexQnrgpqU98+OYhDeB5xa2Ruqy0q4ZkN+z+4xzC7N+815FmqF6Xr8j8bEo J2gl5+DoCK/L7oBszkBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9MYe-00DvvS-8w; Mon, 17 Jan 2022 07:36:04 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9MYZ-00DvuH-9y; Mon, 17 Jan 2022 07:36:00 +0000 X-UUID: 491c1599af0745a28588a37b8be78e91-20220117 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=H6ReXx4yE6tld3maYxfIDGQtHTSOvcYmQuJ0B+XGa1k=; b=JgzmT8vTAakjCHOW8Abbm80GiNHjHNgv2TAkS72qtNFaSq6NsLlxpjTv261hKxn9uVVUKkhHe9ADVlfUP7Xqtf1uHq1I0HuQsMztoTZEOBIBGMis7ZfipEinAvhiqtsIs5HagZ783z8VRP1BVtDkSoJkYVf7UDORFHcyDWP2Wis=; X-UUID: 491c1599af0745a28588a37b8be78e91-20220117 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1143419954; Mon, 17 Jan 2022 00:35:57 -0700 Received: from mtkmbs10n2.mediatek.inc (172.21.101.183) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 16 Jan 2022 23:35:56 -0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Mon, 17 Jan 2022 15:35:54 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 17 Jan 2022 15:35:53 +0800 Message-ID: <2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com> Subject: Re: [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq From: Axe Yang To: Andy Shevchenko CC: Ulf Hansson , Rob Herring , Chaotian Jing , Matthias Brugger , Adrian Hunter , "Yoshihiro Shimoda" , Satya Tangirala , Wolfram Sang , "Lucas Stach" , Eric Biggers , Andrew Jeffery , Stephen Boyd , Kiwoong Kim , Yue Hu , Tian Tao , , , , , Date: Mon, 17 Jan 2022 15:35:53 +0800 In-Reply-To: References: <20220111014046.5864-1-axe.yang@mediatek.com> <20220111014046.5864-4-axe.yang@mediatek.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220116_233559_390067_44829BCA X-CRM114-Status: GOOD ( 28.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Andy, patchset v3 is uploaded. I fixed most of the defect you pointed out. And in msdc_sdio_eint_irq(), you asked why do we need flags, the flags is for spin lock irq save/restore, so I keep it. On Tue, 2022-01-11 at 13:46 +0200, Andy Shevchenko wrote: > On Tue, Jan 11, 2022 at 09:40:46AM +0800, Axe Yang wrote: > > Add support for eint irq when MSDC is used as an SDIO host. This > > IRQ > > > feature requires SDIO device support async irq function. With this > > IRQ > > > feature,SDIO host can be awakened by SDIO card in suspend state, > > feature, SDIO > > > without additional pin. > > > > MSDC driver will time-share the SDIO DAT1 pin. During suspend, MSDC > > turn off clock and switch SDIO DAT1 pin to GPIO mode. And during > > resume, switch GPIO function back to DAT1 mode then turn on clock. > > > > Some device tree property should be added or modified in msdc node > > MSDC > > > to support SDIO eint irq. Pinctrls named state_dat1 and state_eint > > IRQ > > > are mandatory. And cap-sdio-async-irq flag is necessary since this > > feature depends on asynchronous interrupt: > > &mmcX { > > ... > > pinctrl-names = "default", "state_uhs", > > "state_eint", > > "state_dat1"; > > ... > > pinctrl-2 = <&mmc2_pins_eint>; > > pinctrl-3 = <&mmc2_pins_dat1>; > > ... > > cap-sdio-async-irq; > > ... > > }; > > ... > > > - * Copyright (c) 2014-2015 MediaTek Inc. > > + * Copyright (c) 2014-2022 MediaTek Inc. > > Shouldn't it be rather like > > * Copyright (c) 2014-2015,2022 MediaTek Inc. > > ? > > ... > > > +static irqreturn_t msdc_sdio_eint_irq(int irq, void *dev_id) > > +{ > > + unsigned long flags; > > + struct msdc_host *host = (struct msdc_host *)dev_id; > > No casting is needed. > > > + struct mmc_host *mmc = mmc_from_priv(host); > > Perhaps reversed xmas tree order > > struct msdc_host *host = dev_id; > struct mmc_host *mmc = mmc_from_priv(host); > unsigned long flags; > > ? > > But hey, why do you need flags? falgs is for spin lock irq save/restore. > > > + spin_lock_irqsave(&host->lock, flags); > > + if (likely(host->sdio_irq_cnt > 0)) { > > + disable_irq_nosync(host->eint_irq); > > + disable_irq_wake(host->eint_irq); > > + host->sdio_irq_cnt--; > > + } > > + spin_unlock_irqrestore(&host->lock, flags); > > + > > + sdio_signal_irq(mmc); > > + > > + return IRQ_HANDLED; > > +} > > ... > > > +static int msdc_request_dat1_eint_irq(struct msdc_host *host) > > +{ > > + struct gpio_desc *desc; > > + int irq, ret; > > + > > + desc = devm_gpiod_get(host->dev, "eint", GPIOD_IN); > > + if (IS_ERR(desc)) > > + return PTR_ERR(desc); > > + > > + ret = gpiod_to_irq(desc); > > + if (ret < 0) > > + return ret; > > + > > + irq = ret; > > + ret = devm_request_threaded_irq(host->dev, irq, NULL, > > msdc_sdio_eint_irq, > > + IRQF_TRIGGER_LOW | IRQF_ONESHOT > > | IRQF_NO_AUTOEN, > > + "sdio-eint", host); > > + > > Redundant blank line. > > > + if (!ret) > > + host->eint_irq = irq; > > + > > + return ret; > > I guess I have already commented on this, i.e. use standard pattern > > if (ret) > return ret; > > ... > return 0; > > > +} > > ... > > > + host->pins_eint = pinctrl_lookup_state(host->pinctrl, > > "state_eint"); > > + if (IS_ERR(host->pins_eint)) { > > + dev_dbg(&pdev->dev, "Cannot find pinctrl > > eint!\n"); > > In debug mode of pin control this will bring a duplicate message. > > > + } else { > > + host->pins_dat1 = pinctrl_lookup_state(host- > > >pinctrl, "state_dat1"); > > + if (IS_ERR(host->pins_dat1)) { > > + ret = dev_err_probe(&pdev->dev, > > PTR_ERR(host->pins_dat1), > > + "Cannot find > > pinctrl dat1!\n"); > > + goto host_free; > > + } > > + > > + host->sdio_eint_ready = true; > > + } > > + } > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel