aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-03-27 07:11:21 -0400
committerArnd Bergmann <arnd@arndb.de>2018-03-27 07:11:21 -0400
commit66f3731f39970ad670ddba02cfb32740911d5da6 (patch)
treea38281240f7b1c99141af6be3947fa5da1e6de75
parentc27a2cbe3d450cb67812959d7359137ff6d488d9 (diff)
parenteb85a355c3afd9379f5953cfe2df73632d14c884 (diff)
Merge tag 'omap-for-v4.16/sram-fix-signed' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into fixes
Pull "Two fixes for omap variants for v4.16-rc cycle" from Tony Lindgren: Fix insecure W+X mapping warning for SRAM for omaps that don't yet use drivers/misc/*sram*.c code. An earlier attempt at fixing this turned out to cause problems with PM on omap3, this version works with PM on omap3. Also fix dmtimer probe for omap16xx devices that was noticed with the pending dmtimer move to drivers. It seems this has been broken for a while and is a non-critical for booting. It is needed for PM on omap16xx though. * tag 'omap-for-v4.16/sram-fix-signed' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: ARM: OMAP: Fix SRAM W+X mapping ARM: OMAP: Fix dmtimer init for omap1
-rw-r--r--arch/arm/plat-omap/dmtimer.c7
-rw-r--r--arch/arm/plat-omap/include/plat/sram.h11
-rw-r--r--arch/arm/plat-omap/sram.c36
3 files changed, 38 insertions, 16 deletions
diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
index d443e481c3e9..8805a59bae53 100644
--- a/arch/arm/plat-omap/dmtimer.c
+++ b/arch/arm/plat-omap/dmtimer.c
@@ -888,11 +888,8 @@ static int omap_dm_timer_probe(struct platform_device *pdev)
888 timer->irq = irq->start; 888 timer->irq = irq->start;
889 timer->pdev = pdev; 889 timer->pdev = pdev;
890 890
891 /* Skip pm_runtime_enable for OMAP1 */ 891 pm_runtime_enable(dev);
892 if (!(timer->capability & OMAP_TIMER_NEEDS_RESET)) { 892 pm_runtime_irq_safe(dev);
893 pm_runtime_enable(dev);
894 pm_runtime_irq_safe(dev);
895 }
896 893
897 if (!timer->reserved) { 894 if (!timer->reserved) {
898 ret = pm_runtime_get_sync(dev); 895 ret = pm_runtime_get_sync(dev);
diff --git a/arch/arm/plat-omap/include/plat/sram.h b/arch/arm/plat-omap/include/plat/sram.h
index fb061cf0d736..30a07730807a 100644
--- a/arch/arm/plat-omap/include/plat/sram.h
+++ b/arch/arm/plat-omap/include/plat/sram.h
@@ -5,13 +5,4 @@ void omap_map_sram(unsigned long start, unsigned long size,
5 unsigned long skip, int cached); 5 unsigned long skip, int cached);
6void omap_sram_reset(void); 6void omap_sram_reset(void);
7 7
8extern void *omap_sram_push_address(unsigned long size); 8extern void *omap_sram_push(void *funcp, unsigned long size);
9
10/* Macro to push a function to the internal SRAM, using the fncpy API */
11#define omap_sram_push(funcp, size) ({ \
12 typeof(&(funcp)) _res = NULL; \
13 void *_sram_address = omap_sram_push_address(size); \
14 if (_sram_address) \
15 _res = fncpy(_sram_address, &(funcp), size); \
16 _res; \
17})
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index a5bc92d7e476..921840acf65c 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -23,6 +23,7 @@
23#include <asm/fncpy.h> 23#include <asm/fncpy.h>
24#include <asm/tlb.h> 24#include <asm/tlb.h>
25#include <asm/cacheflush.h> 25#include <asm/cacheflush.h>
26#include <asm/set_memory.h>
26 27
27#include <asm/mach/map.h> 28#include <asm/mach/map.h>
28 29
@@ -42,7 +43,7 @@ static void __iomem *omap_sram_ceil;
42 * Note that fncpy requires the returned address to be aligned 43 * Note that fncpy requires the returned address to be aligned
43 * to an 8-byte boundary. 44 * to an 8-byte boundary.
44 */ 45 */
45void *omap_sram_push_address(unsigned long size) 46static void *omap_sram_push_address(unsigned long size)
46{ 47{
47 unsigned long available, new_ceil = (unsigned long)omap_sram_ceil; 48 unsigned long available, new_ceil = (unsigned long)omap_sram_ceil;
48 49
@@ -60,6 +61,30 @@ void *omap_sram_push_address(unsigned long size)
60 return (void *)omap_sram_ceil; 61 return (void *)omap_sram_ceil;
61} 62}
62 63
64void *omap_sram_push(void *funcp, unsigned long size)
65{
66 void *sram;
67 unsigned long base;
68 int pages;
69 void *dst = NULL;
70
71 sram = omap_sram_push_address(size);
72 if (!sram)
73 return NULL;
74
75 base = (unsigned long)sram & PAGE_MASK;
76 pages = PAGE_ALIGN(size) / PAGE_SIZE;
77
78 set_memory_rw(base, pages);
79
80 dst = fncpy(sram, funcp, size);
81
82 set_memory_ro(base, pages);
83 set_memory_x(base, pages);
84
85 return dst;
86}
87
63/* 88/*
64 * The SRAM context is lost during off-idle and stack 89 * The SRAM context is lost during off-idle and stack
65 * needs to be reset. 90 * needs to be reset.
@@ -75,6 +100,9 @@ void omap_sram_reset(void)
75void __init omap_map_sram(unsigned long start, unsigned long size, 100void __init omap_map_sram(unsigned long start, unsigned long size,
76 unsigned long skip, int cached) 101 unsigned long skip, int cached)
77{ 102{
103 unsigned long base;
104 int pages;
105
78 if (size == 0) 106 if (size == 0)
79 return; 107 return;
80 108
@@ -95,4 +123,10 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
95 */ 123 */
96 memset_io(omap_sram_base + omap_sram_skip, 0, 124 memset_io(omap_sram_base + omap_sram_skip, 0,
97 omap_sram_size - omap_sram_skip); 125 omap_sram_size - omap_sram_skip);
126
127 base = (unsigned long)omap_sram_base;
128 pages = PAGE_ALIGN(omap_sram_size) / PAGE_SIZE;
129
130 set_memory_ro(base, pages);
131 set_memory_x(base, pages);
98} 132}