lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1553271070-7509-1-git-send-email-gareth.williams.jx@renesas.com>
Date:   Fri, 22 Mar 2019 16:11:10 +0000
From:   Gareth Williams <gareth.williams.jx@...esas.com>
To:     Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
        Bjorn Helgaas <bhelgaas@...gle.com>
Cc:     Phil Edworthy <phil.edworthy@...esas.com>,
        linux-pci@...r.kernel.org, linux-renesas-soc@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Gareth Williams <gareth.williams.jx@...esas.com>
Subject: [PATCH] PCI: rcar-gen2: Ensure the mandatory clock is enabled

From: Phil Edworthy <phil.edworthy@...esas.com>

All SoC devices that use this driver have a module stop clock associated
with it that we must ensure is enabled. All SoCs enabled this clock
by default, so I guess no one noticed that the driver didn't enable it.

Signed-off-by: Phil Edworthy <phil.edworthy@...esas.com>
Signed-off-by: Gareth Williams <gareth.williams.jx@...esas.com>
---
Note: This change was tested on RZN1 and R-Car M2 hardware. NULL is
passed to devm_clk_get for backwards compatibility reasons with R-Car gen2
devices which do not name the clock.

DTS files for Renesas devices that use this driver have been checked to
ensure they specify a clock and do not name that clock.  
---
 drivers/pci/controller/pci-rcar-gen2.c | 35 +++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/controller/pci-rcar-gen2.c b/drivers/pci/controller/pci-rcar-gen2.c
index 326171c..4c94860 100644
--- a/drivers/pci/controller/pci-rcar-gen2.c
+++ b/drivers/pci/controller/pci-rcar-gen2.c
@@ -8,6 +8,7 @@
  * Author: Valentine Barshak <valentine.barshak@...entembedded.com>
  */
 
+#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -95,6 +96,7 @@
 
 struct rcar_pci_priv {
 	struct device *dev;
+	struct clk *clk;
 	void __iomem *reg;
 	struct resource mem_res;
 	struct resource *cfg_res;
@@ -340,6 +342,8 @@ static int rcar_pci_probe(struct platform_device *pdev)
 	void __iomem *reg;
 	struct hw_pci hw;
 	void *hw_private[1];
+	struct clk *clk;
+	int ret;
 
 	cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	reg = devm_ioremap_resource(dev, cfg_res);
@@ -376,7 +380,6 @@ static int rcar_pci_probe(struct platform_device *pdev)
 
 	if (dev->of_node) {
 		struct resource busnr;
-		int ret;
 
 		ret = of_pci_parse_bus_range(dev->of_node, &busnr);
 		if (ret < 0) {
@@ -397,6 +400,14 @@ static int rcar_pci_probe(struct platform_device *pdev)
 		priv->busnr = pdev->id;
 	}
 
+	clk = devm_clk_get(dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+	ret = clk_prepare_enable(clk);
+	if (ret)
+		return ret;
+	priv->clk = clk;
+
 	hw_private[0] = priv;
 	memset(&hw, 0, sizeof(hw));
 	hw.nr_controllers = ARRAY_SIZE(hw_private);
@@ -409,6 +420,27 @@ static int rcar_pci_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused pci_rcar_gen2_suspend_noirq(struct device *dev)
+{
+	struct rcar_pci_priv *priv = dev_get_drvdata(dev);
+
+	clk_disable_unprepare(priv->clk);
+	return 0;
+}
+
+static int __maybe_unused pci_rcar_gen2_resume_noirq(struct device *dev)
+{
+	struct rcar_pci_priv *priv = dev_get_drvdata(dev);
+
+	clk_prepare_enable(priv->clk);
+	return 0;
+}
+
+static const struct dev_pm_ops pci_rcar_gen2_pm_ops = {
+	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pci_rcar_gen2_suspend_noirq,
+				      pci_rcar_gen2_resume_noirq)
+};
+
 static const struct of_device_id rcar_pci_of_match[] = {
 	{ .compatible = "renesas,pci-r8a7790", },
 	{ .compatible = "renesas,pci-r8a7791", },
@@ -422,6 +454,7 @@ static struct platform_driver rcar_pci_driver = {
 		.name = "pci-rcar-gen2",
 		.suppress_bind_attrs = true,
 		.of_match_table = rcar_pci_of_match,
+		.pm = &pci_rcar_gen2_pm_ops,
 	},
 	.probe = rcar_pci_probe,
 };
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ