* [PATCH 0/4] Few corner case fixes for ti-sysc
@ 2018-08-08 8:07 Tony Lindgren
2018-08-08 8:07 ` [PATCH 1/4] ARM: OMAP2+: Fix null hwmod for ti-sysc debug Tony Lindgren
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Tony Lindgren @ 2018-08-08 8:07 UTC (permalink / raw)
To: linux-arm-kernel
Hi all,
Here are few corner case fixes for ti-sysc.
Regards,
Tony
Tony Lindgren (4):
ARM: OMAP2+: Fix null hwmod for ti-sysc debug
ARM: OMAP2+: Fix module address for modules using mpu_rt_idx
bus: ti-sysc: Fix module register ioremap for larger offsets
bus: ti-sysc: Fix no_console_suspend handling
arch/arm/mach-omap2/omap_hwmod.c | 39 +++++++++++++++++++++++++++++++-
drivers/bus/ti-sysc.c | 35 ++++++++++++++--------------
2 files changed, 55 insertions(+), 19 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] ARM: OMAP2+: Fix null hwmod for ti-sysc debug
2018-08-08 8:07 [PATCH 0/4] Few corner case fixes for ti-sysc Tony Lindgren
@ 2018-08-08 8:07 ` Tony Lindgren
2018-08-08 8:07 ` [PATCH 2/4] ARM: OMAP2+: Fix module address for modules using mpu_rt_idx Tony Lindgren
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2018-08-08 8:07 UTC (permalink / raw)
To: linux-arm-kernel
We may call omap_hwmod_parse_module_range() with no hwmod allocated yet
and may have debug enabled. Let's fix this by checking for hwmod before
trying to use it's name.
Fixes: 6c72b3550672 ("ARM: OMAP2+: Parse module IO range from dts for legacy
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/mach-omap2/omap_hwmod.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2220,7 +2220,7 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
size = be32_to_cpup(ranges);
pr_debug("omap_hwmod: %s %s at 0x%llx size 0x%llx\n",
- oh->name, np->name, base, size);
+ oh ? oh->name : "", np->name, base, size);
res->start = base;
res->end = base + size - 1;
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] ARM: OMAP2+: Fix module address for modules using mpu_rt_idx
2018-08-08 8:07 [PATCH 0/4] Few corner case fixes for ti-sysc Tony Lindgren
2018-08-08 8:07 ` [PATCH 1/4] ARM: OMAP2+: Fix null hwmod for ti-sysc debug Tony Lindgren
@ 2018-08-08 8:07 ` Tony Lindgren
2018-08-08 8:07 ` [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets Tony Lindgren
2018-08-08 8:07 ` [PATCH 4/4] bus: ti-sysc: Fix no_console_suspend handling Tony Lindgren
3 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2018-08-08 8:07 UTC (permalink / raw)
To: linux-arm-kernel
If we use device tree data for a module interconnect target we want
to map the control registers from the module start. Legacy hwmod platform
data however is using child IP offsets for cpsw module with mpu_rt_idx.
In cases where we have the interconnect target module already using device
tree data with legacy hwmod platform data still around, the sysc register
area is not adjusted for mpu_rt_idx causing wrong registers being accessed.
Let's fix the issue for mixed dts and platform data mode by ioremapping
the module registers using child IP offset if mpu_rt_idx is set. For
device tree only data there's no reason to use mpu_rt_idx.
Fixes: 6c72b3550672 ("ARM: OMAP2+: Parse module IO range from dts for legacy
"ti,hwmods" support")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
arch/arm/mach-omap2/omap_hwmod.c | 37 ++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2160,6 +2160,37 @@ static int of_dev_hwmod_lookup(struct device_node *np,
return -ENODEV;
}
+/**
+ * omap_hwmod_fix_mpu_rt_idx - fix up mpu_rt_idx register offsets
+ *
+ * @oh: struct omap_hwmod *
+ * @np: struct device_node *
+ *
+ * Fix up module register offsets for modules with mpu_rt_idx.
+ * Only needed for cpsw with interconnect target module defined
+ * in device tree while still using legacy hwmod platform data
+ * for rev, sysc and syss registers.
+ *
+ * Can be removed when all cpsw hwmod platform data has been
+ * dropped.
+ */
+static void omap_hwmod_fix_mpu_rt_idx(struct omap_hwmod *oh,
+ struct device_node *np,
+ struct resource *res)
+{
+ struct device_node *child = NULL;
+ int error;
+
+ child = of_get_next_child(np, child);
+ if (!child)
+ return;
+
+ error = of_address_to_resource(child, oh->mpu_rt_idx, res);
+ if (error)
+ pr_err("%s: error mapping mpu_rt_idx: %i\n",
+ __func__, error);
+}
+
/**
* omap_hwmod_parse_module_range - map module IO range from device tree
* @oh: struct omap_hwmod *
@@ -2222,6 +2253,12 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
pr_debug("omap_hwmod: %s %s at 0x%llx size 0x%llx\n",
oh ? oh->name : "", np->name, base, size);
+ if (oh && oh->mpu_rt_idx) {
+ omap_hwmod_fix_mpu_rt_idx(oh, np, res);
+
+ return 0;
+ }
+
res->start = base;
res->end = base + size - 1;
res->flags = IORESOURCE_MEM;
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets
2018-08-08 8:07 [PATCH 0/4] Few corner case fixes for ti-sysc Tony Lindgren
2018-08-08 8:07 ` [PATCH 1/4] ARM: OMAP2+: Fix null hwmod for ti-sysc debug Tony Lindgren
2018-08-08 8:07 ` [PATCH 2/4] ARM: OMAP2+: Fix module address for modules using mpu_rt_idx Tony Lindgren
@ 2018-08-08 8:07 ` Tony Lindgren
2018-08-22 16:44 ` Tony Lindgren
2018-08-08 8:07 ` [PATCH 4/4] bus: ti-sysc: Fix no_console_suspend handling Tony Lindgren
3 siblings, 1 reply; 6+ messages in thread
From: Tony Lindgren @ 2018-08-08 8:07 UTC (permalink / raw)
To: linux-arm-kernel
We can have the interconnect target module control registers pretty
much anywhere within the module range. The current code attempts an
incomplete optimization of the ioremap size but does it wrong and
it only works for registers at the beginning of the module.
Let's just use the largest control register to calculate the ioremap
size. The ioremapped range is for most part cached anyways so there
is no need for size optimization. Let's also update the comments
accordingly.
Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect
target driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/bus/ti-sysc.c | 29 ++++++++++++++---------------
1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -498,28 +498,27 @@ static int sysc_check_registers(struct sysc *ddata)
/**
* syc_ioremap - ioremap register space for the interconnect target module
- * @ddata: deviec driver data
+ * @ddata: device driver data
*
* Note that the interconnect target module registers can be anywhere
- * within the first child device address space. For example, SGX has
- * them at offset 0x1fc00 in the 32MB module address space. We just
- * what we need around the interconnect target module registers.
+ * within the interconnect target module range. For example, SGX has
+ * them at offset 0x1fc00 in the 32MB module address space. And cpsw
+ * has them at offset 0x1200 in the CPSW_WR child. Usually the
+ * the interconnect target module registers are at the beginning of
+ * the module range though.
*/
static int sysc_ioremap(struct sysc *ddata)
{
- u32 size = 0;
-
- if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
- size = ddata->offsets[SYSC_SYSSTATUS];
- else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
- size = ddata->offsets[SYSC_SYSCONFIG];
- else if (ddata->offsets[SYSC_REVISION] >= 0)
- size = ddata->offsets[SYSC_REVISION];
- else
+ u32 size;
+
+ size = max3(ddata->offsets[SYSC_REVISION],
+ ddata->offsets[SYSC_SYSCONFIG],
+ ddata->offsets[SYSC_SYSSTATUS]);
+
+ if (size < 0)
return -EINVAL;
- size &= 0xfff00;
- size += SZ_256;
+ size += 4;
ddata->module_va = devm_ioremap(ddata->dev,
ddata->module_pa,
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 4/4] bus: ti-sysc: Fix no_console_suspend handling
2018-08-08 8:07 [PATCH 0/4] Few corner case fixes for ti-sysc Tony Lindgren
` (2 preceding siblings ...)
2018-08-08 8:07 ` [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets Tony Lindgren
@ 2018-08-08 8:07 ` Tony Lindgren
3 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2018-08-08 8:07 UTC (permalink / raw)
To: linux-arm-kernel
If no_console_suspend is set, we should keep console enabled during suspend.
Lets fix this by only producing a warning if we can't idle hardware during
suspend.
Fixes: ef55f8215a78 ("bus: ti-sysc: Improve suspend and resume handling")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/bus/ti-sysc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -1255,10 +1255,10 @@ static int sysc_child_suspend_noirq(struct device *dev)
if (!pm_runtime_status_suspended(dev)) {
error = pm_generic_runtime_suspend(dev);
if (error) {
- dev_err(dev, "%s error at %i: %i\n",
- __func__, __LINE__, error);
+ dev_warn(dev, "%s busy at %i: %i\n",
+ __func__, __LINE__, error);
- return error;
+ return 0;
}
error = sysc_runtime_suspend(ddata->dev);
--
2.17.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets
2018-08-08 8:07 ` [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets Tony Lindgren
@ 2018-08-22 16:44 ` Tony Lindgren
0 siblings, 0 replies; 6+ messages in thread
From: Tony Lindgren @ 2018-08-22 16:44 UTC (permalink / raw)
To: linux-arm-kernel
* Tony Lindgren <tony@atomide.com> [180808 08:11]:
> static int sysc_ioremap(struct sysc *ddata)
> {
> - u32 size = 0;
> -
> - if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
> - size = ddata->offsets[SYSC_SYSSTATUS];
> - else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
> - size = ddata->offsets[SYSC_SYSCONFIG];
> - else if (ddata->offsets[SYSC_REVISION] >= 0)
> - size = ddata->offsets[SYSC_REVISION];
> - else
> + u32 size;
> +
> + size = max3(ddata->offsets[SYSC_REVISION],
> + ddata->offsets[SYSC_SYSCONFIG],
> + ddata->offsets[SYSC_SYSSTATUS]);
Above should use int size, not u32 size as we can have
-ENODEV for non-existing registers. And we should also
check the registeroffset is not beyond the module range
as pointed out by Dan Carpenter.
Updated patch below with these issues fixed.
Regards,
Tony
8< -----------
>From tony Mon Sep 17 00:00:00 2001
From: Tony Lindgren <tony@atomide.com>
Date: Wed, 8 Aug 2018 01:07:05 -0700
Subject: [PATCH] bus: ti-sysc: Fix module register ioremap for larger
offsets
We can have the interconnect target module control registers pretty
much anywhere within the module range. The current code attempts an
incomplete optimization of the ioremap size but does it wrong and
it only works for registers at the beginning of the module.
Let's just use the largest control register to calculate the ioremap
size. The ioremapped range is for most part cached anyways so there
is no need for size optimization. Let's also update the comments
accordingly.
Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect
target driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
drivers/bus/ti-sysc.c | 31 ++++++++++++++-----------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -490,32 +490,29 @@ static int sysc_check_registers(struct sysc *ddata)
/**
* syc_ioremap - ioremap register space for the interconnect target module
- * @ddata: deviec driver data
+ * @ddata: device driver data
*
* Note that the interconnect target module registers can be anywhere
- * within the first child device address space. For example, SGX has
- * them at offset 0x1fc00 in the 32MB module address space. We just
- * what we need around the interconnect target module registers.
+ * within the interconnect target module range. For example, SGX has
+ * them at offset 0x1fc00 in the 32MB module address space. And cpsw
+ * has them at offset 0x1200 in the CPSW_WR child. Usually the
+ * the interconnect target module registers are at the beginning of
+ * the module range though.
*/
static int sysc_ioremap(struct sysc *ddata)
{
- u32 size = 0;
-
- if (ddata->offsets[SYSC_SYSSTATUS] >= 0)
- size = ddata->offsets[SYSC_SYSSTATUS];
- else if (ddata->offsets[SYSC_SYSCONFIG] >= 0)
- size = ddata->offsets[SYSC_SYSCONFIG];
- else if (ddata->offsets[SYSC_REVISION] >= 0)
- size = ddata->offsets[SYSC_REVISION];
- else
- return -EINVAL;
+ int size;
- size &= 0xfff00;
- size += SZ_256;
+ size = max3(ddata->offsets[SYSC_REVISION],
+ ddata->offsets[SYSC_SYSCONFIG],
+ ddata->offsets[SYSC_SYSSTATUS]);
+
+ if (size < 0 || (size + sizeof(u32)) > ddata->module_size)
+ return -EINVAL;
ddata->module_va = devm_ioremap(ddata->dev,
ddata->module_pa,
- size);
+ size + sizeof(u32));
if (!ddata->module_va)
return -EIO;
--
2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-08-22 16:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-08 8:07 [PATCH 0/4] Few corner case fixes for ti-sysc Tony Lindgren
2018-08-08 8:07 ` [PATCH 1/4] ARM: OMAP2+: Fix null hwmod for ti-sysc debug Tony Lindgren
2018-08-08 8:07 ` [PATCH 2/4] ARM: OMAP2+: Fix module address for modules using mpu_rt_idx Tony Lindgren
2018-08-08 8:07 ` [PATCH 3/4] bus: ti-sysc: Fix module register ioremap for larger offsets Tony Lindgren
2018-08-22 16:44 ` Tony Lindgren
2018-08-08 8:07 ` [PATCH 4/4] bus: ti-sysc: Fix no_console_suspend handling Tony Lindgren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).