All of lore.kernel.org
 help / color / mirror / Atom feed
From: Axe Yang <axe.yang@mediatek.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Chaotian Jing <chaotian.jing@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	Satya Tangirala <satyat@google.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	"Lucas Stach" <dev@lynxeye.de>,
	Eric Biggers <ebiggers@google.com>,
	Andrew Jeffery <andrew@aj.id.au>,
	Stephen Boyd <swboyd@chromium.org>,
	Kiwoong Kim <kwmad.kim@samsung.com>, Yue Hu <huyue2@yulong.com>,
	Tian Tao <tiantao6@hisilicon.com>, <linux-mmc@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq
Date: Mon, 17 Jan 2022 15:35:53 +0800	[thread overview]
Message-ID: <2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com> (raw)
In-Reply-To: <Yd1uJ+dX2CTEJfYY@smile.fi.intel.com>

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;
> > +		}
> > +	}
> 
> 


WARNING: multiple messages have this Message-ID
From: Axe Yang <axe.yang@mediatek.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Chaotian Jing <chaotian.jing@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	Satya Tangirala <satyat@google.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	"Lucas Stach" <dev@lynxeye.de>,
	Eric Biggers <ebiggers@google.com>,
	Andrew Jeffery <andrew@aj.id.au>,
	Stephen Boyd <swboyd@chromium.org>,
	Kiwoong Kim <kwmad.kim@samsung.com>, Yue Hu <huyue2@yulong.com>,
	Tian Tao <tiantao6@hisilicon.com>, <linux-mmc@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq
Date: Mon, 17 Jan 2022 15:35:53 +0800	[thread overview]
Message-ID: <2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com> (raw)
In-Reply-To: <Yd1uJ+dX2CTEJfYY@smile.fi.intel.com>

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

WARNING: multiple messages have this Message-ID
From: Axe Yang <axe.yang@mediatek.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Chaotian Jing <chaotian.jing@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	Satya Tangirala <satyat@google.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	"Lucas Stach" <dev@lynxeye.de>,
	Eric Biggers <ebiggers@google.com>,
	Andrew Jeffery <andrew@aj.id.au>,
	Stephen Boyd <swboyd@chromium.org>,
	Kiwoong Kim <kwmad.kim@samsung.com>, Yue Hu <huyue2@yulong.com>,
	Tian Tao <tiantao6@hisilicon.com>, <linux-mmc@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq
Date: Mon, 17 Jan 2022 15:35:53 +0800	[thread overview]
Message-ID: <2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com> (raw)
In-Reply-To: <Yd1uJ+dX2CTEJfYY@smile.fi.intel.com>

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

  parent reply	other threads:[~2022-01-17  7:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-11  1:40 [PATCH v2 0/3]mmc: mediatek: add support for SDIO async irq Axe Yang
2022-01-11  1:40 ` Axe Yang
2022-01-11  1:40 ` Axe Yang
2022-01-11  1:40 ` [PATCH v2 1/3] dt-bindings: mmc: add cap-sdio-async-irq flag Axe Yang
2022-01-11  1:40   ` Axe Yang
2022-01-11  1:40   ` Axe Yang
2022-01-11  1:40 ` [PATCH v2 2/3] mmc: core: Add support for SDIO async interrupt Axe Yang
2022-01-11  1:40   ` Axe Yang
2022-01-11  1:40   ` Axe Yang
2022-01-11  1:40 ` [PATCH v2 3/3] mmc: mediatek: add support for SDIO eint irq Axe Yang
2022-01-11  1:40   ` Axe Yang
2022-01-11  1:40   ` Axe Yang
2022-01-11 11:46   ` Andy Shevchenko
2022-01-11 11:46     ` Andy Shevchenko
2022-01-11 11:46     ` Andy Shevchenko
2022-01-13  7:58     ` Axe Yang
2022-01-13  7:58       ` Axe Yang
2022-01-13  7:58       ` Axe Yang
2022-01-13 10:47       ` Andy Shevchenko
2022-01-13 10:47         ` Andy Shevchenko
2022-01-13 10:47         ` Andy Shevchenko
2022-01-14  3:06         ` Axe Yang
2022-01-14  3:06           ` Axe Yang
2022-01-14  3:06           ` Axe Yang
2022-01-14 13:38           ` Andy Shevchenko
2022-01-14 13:38             ` Andy Shevchenko
2022-01-14 13:38             ` Andy Shevchenko
2022-01-17  7:35     ` Axe Yang [this message]
2022-01-17  7:35       ` Axe Yang
2022-01-17  7:35       ` Axe Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2205eedc9ecd10f83994138974b261baa0aee55a.camel@mediatek.com \
    --to=axe.yang@mediatek.com \
    --cc=adrian.hunter@intel.com \
    --cc=andrew@aj.id.au \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=chaotian.jing@mediatek.com \
    --cc=dev@lynxeye.de \
    --cc=devicetree@vger.kernel.org \
    --cc=ebiggers@google.com \
    --cc=huyue2@yulong.com \
    --cc=kwmad.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=satyat@google.com \
    --cc=swboyd@chromium.org \
    --cc=tiantao6@hisilicon.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.