mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sherry Sun <sherry.sun@nxp.com>
To: Lucas Stach <l.stach@pengutronix.de>,
	Hongxing Zhu <hongxing.zhu@nxp.com>,
	"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
	"kw@linux.com" <kw@linux.com>,
	"robh@kernel.org" <robh@kernel.org>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"krzysztof.kozlowski+dt@linaro.org" 
	<krzysztof.kozlowski+dt@linaro.org>,
	"conor+dt@kernel.org" <conor+dt@kernel.org>,
	"shawnguo@kernel.org" <shawnguo@kernel.org>,
	"s.hauer@pengutronix.de" <s.hauer@pengutronix.de>,
	"kernel@pengutronix.de" <kernel@pengutronix.de>,
	"festevam@gmail.com" <festevam@gmail.com>
Cc: dl-linux-imx <linux-imx@nxp.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 1/4] PCI: imx6: Add pci host wakeup support on imx platforms.
Date: Mon, 11 Dec 2023 10:18:11 +0000	[thread overview]
Message-ID: <AS8PR04MB8404B2D7CBC562AA0ED2BFD4928FA@AS8PR04MB8404.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <0cd40cf388e70b101b3857220fd7a74cf75cfa81.camel@pengutronix.de>



> -----Original Message-----
> From: Lucas Stach <l.stach@pengutronix.de>
> Sent: 2023年12月8日 18:16
> To: Sherry Sun <sherry.sun@nxp.com>; Hongxing Zhu
> <hongxing.zhu@nxp.com>; lpieralisi@kernel.org; kw@linux.com;
> robh@kernel.org; bhelgaas@google.com; krzysztof.kozlowski+dt@linaro.org;
> conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de;
> kernel@pengutronix.de; festevam@gmail.com
> Cc: dl-linux-imx <linux-imx@nxp.com>; linux-pci@vger.kernel.org; linux-arm-
> kernel@lists.infradead.org; devicetree@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH 1/4] PCI: imx6: Add pci host wakeup support on imx
> platforms.
> 
> Am Freitag, dem 08.12.2023 um 17:13 +0800 schrieb Sherry Sun:
> > Add pci host wakeup feature for imx platforms.
> > Example of configuring the corresponding dts property under the PCI
> > node:
> > host-wake-gpio = <&gpio5 21 GPIO_ACTIVE_LOW>;
> >
> > Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
> > Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com>
> > ---
> >  drivers/pci/controller/dwc/pci-imx6.c | 69
> > +++++++++++++++++++++++++++
> >  1 file changed, 69 insertions(+)
> >
> > diff --git a/drivers/pci/controller/dwc/pci-imx6.c
> > b/drivers/pci/controller/dwc/pci-imx6.c
> > index 74703362aeec..050c9140f4a3 100644
> > --- a/drivers/pci/controller/dwc/pci-imx6.c
> > +++ b/drivers/pci/controller/dwc/pci-imx6.c
> > @@ -72,6 +72,7 @@ struct imx6_pcie_drvdata {  struct imx6_pcie {
> >  	struct dw_pcie		*pci;
> >  	int			reset_gpio;
> > +	int			host_wake_irq;
> >  	bool			gpio_active_high;
> >  	bool			link_is_up;
> >  	struct clk		*pcie_bus;
> > @@ -1237,11 +1238,46 @@ static int imx6_pcie_resume_noirq(struct
> device *dev)
> >  	return 0;
> >  }
> >
> > +static int imx6_pcie_suspend(struct device *dev) {
> > +	struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev);
> > +
> > +	if (imx6_pcie->host_wake_irq >= 0)
> > +		enable_irq_wake(imx6_pcie->host_wake_irq);
> > +
> > +	return 0;
> > +}
> > +
> > +static int imx6_pcie_resume(struct device *dev) {
> > +	struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev);
> > +
> > +	if (imx6_pcie->host_wake_irq >= 0)
> > +		disable_irq_wake(imx6_pcie->host_wake_irq);
> > +
> > +	return 0;
> > +}
> > +
> >  static const struct dev_pm_ops imx6_pcie_pm_ops = {
> >  	NOIRQ_SYSTEM_SLEEP_PM_OPS(imx6_pcie_suspend_noirq,
> >  				  imx6_pcie_resume_noirq)
> > +	SYSTEM_SLEEP_PM_OPS(imx6_pcie_suspend, imx6_pcie_resume)
> >  };
> >
> > +irqreturn_t host_wake_irq_handler(int irq, void *priv) {
> > +	struct imx6_pcie *imx6_pcie = priv;
> > +	struct device *dev = imx6_pcie->pci->dev;
> > +
> > +	dev_dbg(dev, "%s: host wakeup by pcie", __func__);
> > +
> Not sure how much value this debug print carries. If you want to keep it,
> drop the __func__. There is no other place in this driver handling the wakeup,
> so the function name in the print is pure noise.

Ok, will remove the debug print info here.

> 
> > +	/* Notify PM core we are wakeup source */
> > +	pm_wakeup_event(dev, 0);
> > +	pm_system_wakeup();
> > +
> > +	return IRQ_HANDLED;
> > +}
> > +
> >  static int imx6_pcie_probe(struct platform_device *pdev)  {
> >  	struct device *dev = &pdev->dev;
> > @@ -1250,6 +1286,7 @@ static int imx6_pcie_probe(struct
> platform_device *pdev)
> >  	struct device_node *np;
> >  	struct resource *dbi_base;
> >  	struct device_node *node = dev->of_node;
> > +	struct gpio_desc *host_wake_gpio;
> >  	int ret;
> >  	u16 val;
> >
> > @@ -1457,6 +1494,32 @@ static int imx6_pcie_probe(struct
> platform_device *pdev)
> >  			val |= PCI_MSI_FLAGS_ENABLE;
> >  			dw_pcie_writew_dbi(pci, offset + PCI_MSI_FLAGS,
> val);
> >  		}
> > +
> > +		/* host wakeup support */
> > +		imx6_pcie->host_wake_irq = -1;
> > +		host_wake_gpio = devm_gpiod_get_optional(dev, "host-
> wake", GPIOD_IN);
> > +		if (IS_ERR(host_wake_gpio))
> > +			return PTR_ERR(host_wake_gpio);
> > +
> > +		if (host_wake_gpio != NULL) {
> > +			imx6_pcie->host_wake_irq =
> gpiod_to_irq(host_wake_gpio);
> > +			ret = devm_request_threaded_irq(dev, imx6_pcie-
> >host_wake_irq, NULL,
> > +
> 	host_wake_irq_handler,
> > +							IRQF_ONESHOT |
> IRQF_TRIGGER_FALLING,
> > +							"host_wake",
> imx6_pcie);
> > +			if (ret) {
> > +				dev_err(dev, "Failed to request
> host_wake_irq %d (%d)\n",
> > +					imx6_pcie->host_wake_irq, ret);
> > +				imx6_pcie->host_wake_irq = -1;
> 
> What's the point of resetting host_wake_irq to -1 in those error paths?
> Nobody is going to access this member anymore after the error. Just drop
> this.
> 
> You could simplify all those error paths to if (err)
>     return dev_err_probe(...);

Sounds reasonable, I will remove the host_wake_irq resetting here and use dev_err_probe() instead, thanks!

Best Regards
Sherry

  reply	other threads:[~2023-12-11 10:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-08  9:13 [PATCH 0/4] PCI: imx6: Add pci host wakeup support Sherry Sun
2023-12-08  9:13 ` [PATCH 1/4] PCI: imx6: Add pci host wakeup support on imx platforms Sherry Sun
2023-12-08 10:16   ` Lucas Stach
2023-12-11 10:18     ` Sherry Sun [this message]
2023-12-08  9:13 ` [PATCH 2/4] dt-bindings: imx6q-pcie: Add host-wake-gpio property Sherry Sun
2023-12-08 10:00   ` Lucas Stach
2023-12-08 20:55     ` Rob Herring
2023-12-08 22:27       ` Bjorn Helgaas
2023-12-11 10:52       ` Sherry Sun
2023-12-11  9:14     ` Sherry Sun
2023-12-08  9:13 ` [PATCH 3/4] arm64: dts: imx8mp-evk: add host-wake-gpio property for pci bus Sherry Sun
2023-12-08  9:13 ` [PATCH 4/4] arm64: dts: imx8mq-evk: " Sherry Sun

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=AS8PR04MB8404B2D7CBC562AA0ED2BFD4928FA@AS8PR04MB8404.eurprd04.prod.outlook.com \
    --to=sherry.sun@nxp.com \
    --cc=bhelgaas@google.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=hongxing.zhu@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kw@linux.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®