diff options
author | David Daney <david.daney@cavium.com> | 2015-03-05 09:31:30 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-04-01 11:21:43 -0400 |
commit | 8c1e6b14e27d78fcea4aa6ba09e56c41f528f1cc (patch) | |
tree | ce651a479d315214e1270a026628689486cae762 /arch/mips/cavium-octeon | |
parent | 24d4e7f642882a8a13da170b4ba86eec8fa91bf2 (diff) |
MIPS: OCTEON: Protect accesses to bootbus flash with octeon_bootbus_sem.
Without this, we get bus errors.
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Aleksey Makarov <aleksey.makarov@auriga.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/9460/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/cavium-octeon')
-rw-r--r-- | arch/mips/cavium-octeon/flash_setup.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/arch/mips/cavium-octeon/flash_setup.c b/arch/mips/cavium-octeon/flash_setup.c index 237e5b1a72d8..39e26dfe7d8d 100644 --- a/arch/mips/cavium-octeon/flash_setup.c +++ b/arch/mips/cavium-octeon/flash_setup.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/export.h> | 11 | #include <linux/export.h> |
12 | #include <linux/semaphore.h> | ||
12 | #include <linux/mtd/mtd.h> | 13 | #include <linux/mtd/mtd.h> |
13 | #include <linux/mtd/map.h> | 14 | #include <linux/mtd/map.h> |
14 | #include <linux/mtd/partitions.h> | 15 | #include <linux/mtd/partitions.h> |
@@ -25,6 +26,41 @@ static const char *part_probe_types[] = { | |||
25 | NULL | 26 | NULL |
26 | }; | 27 | }; |
27 | 28 | ||
29 | static map_word octeon_flash_map_read(struct map_info *map, unsigned long ofs) | ||
30 | { | ||
31 | map_word r; | ||
32 | |||
33 | down(&octeon_bootbus_sem); | ||
34 | r = inline_map_read(map, ofs); | ||
35 | up(&octeon_bootbus_sem); | ||
36 | |||
37 | return r; | ||
38 | } | ||
39 | |||
40 | static void octeon_flash_map_write(struct map_info *map, const map_word datum, | ||
41 | unsigned long ofs) | ||
42 | { | ||
43 | down(&octeon_bootbus_sem); | ||
44 | inline_map_write(map, datum, ofs); | ||
45 | up(&octeon_bootbus_sem); | ||
46 | } | ||
47 | |||
48 | static void octeon_flash_map_copy_from(struct map_info *map, void *to, | ||
49 | unsigned long from, ssize_t len) | ||
50 | { | ||
51 | down(&octeon_bootbus_sem); | ||
52 | inline_map_copy_from(map, to, from, len); | ||
53 | up(&octeon_bootbus_sem); | ||
54 | } | ||
55 | |||
56 | static void octeon_flash_map_copy_to(struct map_info *map, unsigned long to, | ||
57 | const void *from, ssize_t len) | ||
58 | { | ||
59 | down(&octeon_bootbus_sem); | ||
60 | inline_map_copy_to(map, to, from, len); | ||
61 | up(&octeon_bootbus_sem); | ||
62 | } | ||
63 | |||
28 | /** | 64 | /** |
29 | * Module/ driver initialization. | 65 | * Module/ driver initialization. |
30 | * | 66 | * |
@@ -56,7 +92,11 @@ static int __init flash_init(void) | |||
56 | flash_map.virt = ioremap(flash_map.phys, flash_map.size); | 92 | flash_map.virt = ioremap(flash_map.phys, flash_map.size); |
57 | pr_notice("Bootbus flash: Setting flash for %luMB flash at " | 93 | pr_notice("Bootbus flash: Setting flash for %luMB flash at " |
58 | "0x%08llx\n", flash_map.size >> 20, flash_map.phys); | 94 | "0x%08llx\n", flash_map.size >> 20, flash_map.phys); |
59 | simple_map_init(&flash_map); | 95 | WARN_ON(!map_bankwidth_supported(flash_map.bankwidth)); |
96 | flash_map.read = octeon_flash_map_read; | ||
97 | flash_map.write = octeon_flash_map_write; | ||
98 | flash_map.copy_from = octeon_flash_map_copy_from; | ||
99 | flash_map.copy_to = octeon_flash_map_copy_to; | ||
60 | mymtd = do_map_probe("cfi_probe", &flash_map); | 100 | mymtd = do_map_probe("cfi_probe", &flash_map); |
61 | if (mymtd) { | 101 | if (mymtd) { |
62 | mymtd->owner = THIS_MODULE; | 102 | mymtd->owner = THIS_MODULE; |