All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Versatile Express fixes for 3.15
@ 2014-04-24 16:40 Pawel Moll
  2014-04-24 16:40 ` [PATCH 1/4] clk: vexpress: NULL dereference on error path Pawel Moll
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Pawel Moll @ 2014-04-24 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hello Arnd, Kevin, Olof,

This is a short set of Versatile Express fixes for 3.15. I've re-posted
them, because the last one wasn't reviewed publicly yet.

It is pretty straight forward, so if you feel comfortable about it,
please pull from the tag below. If not, I'll rebase the series on rc3
next week and send a normal pull request.

Thanks!

Pawel


The following changes since commit a798c10faf62a505d24e5f6213fbaf904a39623f:

  Linux 3.15-rc2 (2014-04-20 11:08:50 -0700)

are available in the git repository at:

  git://git.linaro.org/people/pawel.moll/linux.git tags/vexpress/fixes-for-3.15

for you to fetch changes up to cf2e0a73ca9ad376825c013ebaa145608abc27d7:

  ARM: vexpress/TC2: Convert OPP voltage to uV before storing (2014-04-24 17:20:50 +0100)

----------------------------------------------------------------
ARM Versatile Express fixes for 3.15

This series contains straight-forward fixes for different
Versatile Express infrastructure drivers:

- NULL pointer dereference on the error path in the clk driver
- out of boundary array access in the dcscb driver
- broken restart/power off implementation
- mis-interpreted voltage unit in the spc driver

----------------------------------------------------------------
Dan Carpenter (1):
      clk: vexpress: NULL dereference on error path

Heinrich Schuchardt (1):
      arm/mach-vexpress: array accessed out of bounds

Pawel Moll (1):
      power/reset: vexpress: Fix restart/power off operation

Punit Agrawal (1):
      ARM: vexpress/TC2: Convert OPP voltage to uV before storing

 arch/arm/mach-vexpress/dcscb.c           |  7 +++++--
 arch/arm/mach-vexpress/spc.c             |  4 ++--
 drivers/clk/versatile/clk-vexpress-osc.c |  2 +-
 drivers/power/reset/vexpress-poweroff.c  | 19 ++++++++++---------
 4 files changed, 18 insertions(+), 14 deletions(-)

-- 
1.8.3.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/4] clk: vexpress: NULL dereference on error path
  2014-04-24 16:40 [PATCH 0/4] Versatile Express fixes for 3.15 Pawel Moll
@ 2014-04-24 16:40 ` Pawel Moll
  2014-04-24 16:40 ` [PATCH 2/4] arm/mach-vexpress: array accessed out of bounds Pawel Moll
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Pawel Moll @ 2014-04-24 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Dan Carpenter <dan.carpenter@oracle.com>

If the allocation fails then we dereference the NULL in the error path.
Just return directly.

Fixes: ed27ff1db869 ('clk: Versatile Express clock generators ("osc") driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/clk/versatile/clk-vexpress-osc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/versatile/clk-vexpress-osc.c b/drivers/clk/versatile/clk-vexpress-osc.c
index 2dc8b41..a535c7b 100644
--- a/drivers/clk/versatile/clk-vexpress-osc.c
+++ b/drivers/clk/versatile/clk-vexpress-osc.c
@@ -102,7 +102,7 @@ void __init vexpress_osc_of_setup(struct device_node *node)
 
 	osc = kzalloc(sizeof(*osc), GFP_KERNEL);
 	if (!osc)
-		goto error;
+		return;
 
 	osc->func = vexpress_config_func_get_by_node(node);
 	if (!osc->func) {
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] arm/mach-vexpress: array accessed out of bounds
  2014-04-24 16:40 [PATCH 0/4] Versatile Express fixes for 3.15 Pawel Moll
  2014-04-24 16:40 ` [PATCH 1/4] clk: vexpress: NULL dereference on error path Pawel Moll
@ 2014-04-24 16:40 ` Pawel Moll
  2014-04-24 16:40 ` [PATCH 3/4] power/reset: vexpress: Fix restart/power off operation Pawel Moll
  2014-04-24 16:40 ` [PATCH 4/4] ARM: vexpress/TC2: Convert OPP voltage to uV before storing Pawel Moll
  3 siblings, 0 replies; 5+ messages in thread
From: Pawel Moll @ 2014-04-24 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Heinrich Schuchardt <xypron.glpk@gmx.de>

dcscb_allcpus_mask is an array of size 2.

The index variable cluster has to be checked against this limit
before accessing the array.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 arch/arm/mach-vexpress/dcscb.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-vexpress/dcscb.c b/arch/arm/mach-vexpress/dcscb.c
index 788495d..30b9933 100644
--- a/arch/arm/mach-vexpress/dcscb.c
+++ b/arch/arm/mach-vexpress/dcscb.c
@@ -51,12 +51,14 @@ static int dcscb_allcpus_mask[2];
 static int dcscb_power_up(unsigned int cpu, unsigned int cluster)
 {
 	unsigned int rst_hold, cpumask = (1 << cpu);
-	unsigned int all_mask = dcscb_allcpus_mask[cluster];
+	unsigned int all_mask;
 
 	pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
 	if (cpu >= 4 || cluster >= 2)
 		return -EINVAL;
 
+	all_mask = dcscb_allcpus_mask[cluster];
+
 	/*
 	 * Since this is called with IRQs enabled, and no arch_spin_lock_irq
 	 * variant exists, we need to disable IRQs manually here.
@@ -101,11 +103,12 @@ static void dcscb_power_down(void)
 	cpu = MPIDR_AFFINITY_LEVEL(mpidr, 0);
 	cluster = MPIDR_AFFINITY_LEVEL(mpidr, 1);
 	cpumask = (1 << cpu);
-	all_mask = dcscb_allcpus_mask[cluster];
 
 	pr_debug("%s: cpu %u cluster %u\n", __func__, cpu, cluster);
 	BUG_ON(cpu >= 4 || cluster >= 2);
 
+	all_mask = dcscb_allcpus_mask[cluster];
+
 	__mcpm_cpu_going_down(cpu, cluster);
 
 	arch_spin_lock(&dcscb_lock);
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] power/reset: vexpress: Fix restart/power off operation
  2014-04-24 16:40 [PATCH 0/4] Versatile Express fixes for 3.15 Pawel Moll
  2014-04-24 16:40 ` [PATCH 1/4] clk: vexpress: NULL dereference on error path Pawel Moll
  2014-04-24 16:40 ` [PATCH 2/4] arm/mach-vexpress: array accessed out of bounds Pawel Moll
@ 2014-04-24 16:40 ` Pawel Moll
  2014-04-24 16:40 ` [PATCH 4/4] ARM: vexpress/TC2: Convert OPP voltage to uV before storing Pawel Moll
  3 siblings, 0 replies; 5+ messages in thread
From: Pawel Moll @ 2014-04-24 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

The restart/power off implementation in the vexpress driver
used to obtain the config function when necessary. This was
wrong in two respects:

1. It required memory allocation with disabled interrupts
(it worked, but lockdep - when enabled - reported warnings).

2. Used jiffies-based timeout, while jiffies are not running
at this stage of system shutdown (therefore a config
transaction error - if happened - would have never be reported).

Fixed by pre-allocating the config function per device
and using mdelay for timeout.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 drivers/power/reset/vexpress-poweroff.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c
index 476aa49..b95cf71 100644
--- a/drivers/power/reset/vexpress-poweroff.c
+++ b/drivers/power/reset/vexpress-poweroff.c
@@ -11,7 +11,7 @@
  * Copyright (C) 2012 ARM Limited
  */
 
-#include <linux/jiffies.h>
+#include <linux/delay.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
@@ -23,17 +23,12 @@
 static void vexpress_reset_do(struct device *dev, const char *what)
 {
 	int err = -ENOENT;
-	struct vexpress_config_func *func =
-			vexpress_config_func_get_by_dev(dev);
+	struct vexpress_config_func *func = dev_get_drvdata(dev);
 
 	if (func) {
-		unsigned long timeout;
-
 		err = vexpress_config_write(func, 0, 0);
-
-		timeout = jiffies + HZ;
-		while (time_before(jiffies, timeout))
-			cpu_relax();
+		if (!err)
+			mdelay(1000);
 	}
 
 	dev_emerg(dev, "Unable to %s (%d)\n", what, err);
@@ -96,12 +91,18 @@ static int vexpress_reset_probe(struct platform_device *pdev)
 	enum vexpress_reset_func func;
 	const struct of_device_id *match =
 			of_match_device(vexpress_reset_of_match, &pdev->dev);
+	struct vexpress_config_func *config_func;
 
 	if (match)
 		func = (enum vexpress_reset_func)match->data;
 	else
 		func = pdev->id_entry->driver_data;
 
+	config_func = vexpress_config_func_get_by_dev(&pdev->dev);
+	if (!config_func)
+		return -EINVAL;
+	dev_set_drvdata(&pdev->dev, config_func);
+
 	switch (func) {
 	case FUNC_SHUTDOWN:
 		vexpress_power_off_device = &pdev->dev;
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] ARM: vexpress/TC2: Convert OPP voltage to uV before storing
  2014-04-24 16:40 [PATCH 0/4] Versatile Express fixes for 3.15 Pawel Moll
                   ` (2 preceding siblings ...)
  2014-04-24 16:40 ` [PATCH 3/4] power/reset: vexpress: Fix restart/power off operation Pawel Moll
@ 2014-04-24 16:40 ` Pawel Moll
  3 siblings, 0 replies; 5+ messages in thread
From: Pawel Moll @ 2014-04-24 16:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Punit Agrawal <punit.agrawal@arm.com>

The SPC stores voltage in mV while the code assumes it was returning
uV. Convert the returned voltage to uV before storing. Also fix the
comment depicting voltage to uV.

Signed-off-by: Punit Agrawal <punit.agrawal@arm.com>
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 arch/arm/mach-vexpress/spc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index c26ef5b..2c2754e 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -392,7 +392,7 @@ static irqreturn_t ve_spc_irq_handler(int irq, void *data)
  *  +--------------------------+
  *  | 31      20 | 19        0 |
  *  +--------------------------+
- *  |   u_volt   |  freq(kHz)  |
+ *  |   m_volt   |  freq(kHz)  |
  *  +--------------------------+
  */
 #define MULT_FACTOR	20
@@ -414,7 +414,7 @@ static int ve_spc_populate_opps(uint32_t cluster)
 		ret = ve_spc_read_sys_cfg(SYSCFG_SCC, off, &data);
 		if (!ret) {
 			opps->freq = (data & FREQ_MASK) * MULT_FACTOR;
-			opps->u_volt = data >> VOLT_SHIFT;
+			opps->u_volt = (data >> VOLT_SHIFT) * 1000;
 		} else {
 			break;
 		}
-- 
1.8.3.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-24 16:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 16:40 [PATCH 0/4] Versatile Express fixes for 3.15 Pawel Moll
2014-04-24 16:40 ` [PATCH 1/4] clk: vexpress: NULL dereference on error path Pawel Moll
2014-04-24 16:40 ` [PATCH 2/4] arm/mach-vexpress: array accessed out of bounds Pawel Moll
2014-04-24 16:40 ` [PATCH 3/4] power/reset: vexpress: Fix restart/power off operation Pawel Moll
2014-04-24 16:40 ` [PATCH 4/4] ARM: vexpress/TC2: Convert OPP voltage to uV before storing Pawel Moll

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.