Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301514 > unrolled thread

[PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar

Started byPhil Edworthy <phil.edworthy@renesas.com>
First post2016-01-05 14:10 +0100
Last post2016-01-06 10:00 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar Phil Edworthy <phil.edworthy@renesas.com> - 2016-01-05 14:10 +0100
    Re: [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar Wolfram Sang <wsa@the-dreams.de> - 2016-01-06 09:40 +0100
      Re: [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar Geert Uytterhoeven <geert@linux-m68k.org> - 2016-01-06 09:50 +0100
        Re: [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar Wolfram Sang <wsa@the-dreams.de> - 2016-01-06 10:00 +0100

#1301514 — [PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar

FromPhil Edworthy <phil.edworthy@renesas.com>
Date2016-01-05 14:10 +0100
Subject[PATCH v2 3/4] PCI: rcar: Add runtime PM support to pcie-rcar
Message-ID<qNzx9-3cW-15@gated-at.bofh.it>
If runtime PM is enabled in the kernel config, simply enable the
clocks once during probe.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
---
 v2:
   - No changes.
---
 drivers/pci/host/pcie-rcar.c | 44 ++++++++++++++++++++++++++++++++------------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 31ad93a..7e13fbb 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -27,6 +27,7 @@
 #include <linux/of_platform.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 
 #define DRV_NAME "rcar-pcie"
@@ -1025,32 +1026,51 @@ static int rcar_pcie_probe(struct platform_device *pdev)
 	 if (err)
 		return err;
 
-	if (IS_ENABLED(CONFIG_PCI_MSI)) {
-		err = rcar_pcie_enable_msi(pcie);
-		if (err < 0) {
-			dev_err(&pdev->dev,
-				"failed to enable MSI support: %d\n",
-				err);
-			return err;
-		}
-	}
-
 	of_id = of_match_device(rcar_pcie_of_match, pcie->dev);
 	if (!of_id || !of_id->data)
 		return -EINVAL;
 	hw_init_fn = of_id->data;
 
+	pm_runtime_enable(pcie->dev);
+	err = pm_runtime_get_sync(pcie->dev);
+	if (err < 0) {
+		dev_err(pcie->dev, "pm_runtime_get_sync failed\n");
+		goto err_pm_disable;
+	}
+
 	/* Failure to get a link might just be that no cards are inserted */
 	err = hw_init_fn(pcie);
 	if (err) {
 		dev_info(&pdev->dev, "PCIe link down\n");
-		return 0;
+		err = 0;
+		goto err_pm_put;
 	}
 
 	data = rcar_pci_read_reg(pcie, MACSR);
 	dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f);
 
-	return rcar_pcie_enable(pcie);
+	if (IS_ENABLED(CONFIG_PCI_MSI)) {
+		err = rcar_pcie_enable_msi(pcie);
+		if (err < 0) {
+			dev_err(&pdev->dev,
+				"failed to enable MSI support: %d\n",
+				err);
+			goto err_pm_put;
+		}
+	}
+
+	err = rcar_pcie_enable(pcie);
+	if (err)
+		goto err_pm_put;
+
+	return 0;
+
+err_pm_put:
+	pm_runtime_put(pcie->dev);
+
+err_pm_disable:
+	pm_runtime_disable(pcie->dev);
+	return err;
 }
 
 static struct platform_driver rcar_pcie_driver = {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1302473

FromWolfram Sang <wsa@the-dreams.de>
Date2016-01-06 09:40 +0100
Message-ID<qNRNp-763-21@gated-at.bofh.it>
In reply to#1301514

[Multipart message — attachments visible in raw view] — view raw

> +err_pm_put:
> +	pm_runtime_put(pcie->dev);
> +
> +err_pm_disable:
> +	pm_runtime_disable(pcie->dev);

What about put/disable in the remove part?

[toc] | [prev] | [next] | [standalone]


#1302475

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-01-06 09:50 +0100
Message-ID<qNRX5-7a9-7@gated-at.bofh.it>
In reply to#1302473
Hi Wolfram,

On Wed, Jan 6, 2016 at 9:35 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
>> +err_pm_put:
>> +     pm_runtime_put(pcie->dev);
>> +
>> +err_pm_disable:
>> +     pm_runtime_disable(pcie->dev);
>
> What about put/disable in the remove part?

Which remove part? (been there, done that ;-)

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1302478

FromWolfram Sang <wsa@the-dreams.de>
Date2016-01-06 10:00 +0100
Message-ID<qNS6J-7dw-3@gated-at.bofh.it>
In reply to#1302475

[Multipart message — attachments visible in raw view] — view raw

On Wed, Jan 06, 2016 at 09:45:46AM +0100, Geert Uytterhoeven wrote:
> Hi Wolfram,
> 
> On Wed, Jan 6, 2016 at 9:35 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> >> +err_pm_put:
> >> +     pm_runtime_put(pcie->dev);
> >> +
> >> +err_pm_disable:
> >> +     pm_runtime_disable(pcie->dev);
> >
> > What about put/disable in the remove part?
> 
> Which remove part? (been there, done that ;-)

:D Sorry for the noise then!

Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web