Skip to contentSkip to conversation

ARM: integrator: multiplatform advancements

PATCH New Linus Walleij 4 participants 11 messages Feb 14, 2014 – Mar 5, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ARM: integrator: multiplatform advancements

This takes some steps towards enabling multiplatform support for the Integrator. This also removes some minor strings attached to the Versatile and RealView platforms to help them advancing.

File movement is trivial, but I need some advice on the memory.h removal patch which is more of a puzzle due to lack of history with this header on my behalf.

What remains for multiplatform afte this is just one
thing: <plat/clcd.h>. That is the only dependency toward plat-versatile and the <plat/*> inclusion hierarchy remaining for the Integrator.

This is a display database and timing set-up callback driver where the Versatile family looks up settings for VGA and similar displays.

I'm tempted to attempt to just move this down into drivers/video alongside the CLCD driver with some platform data header in <linux/platform_data/video-clcd.h>.

The *real* solution, one might argue is to convert the CLCD driver to DRM and add device tree bindings, but it appears that this is an orthogonal goal that has been attempted by other with mixed results.

I have tested all patches on the Integrator/AP and Integrator/CP, but I'd appreciate help testing some PCI traffic as well if you (Will!) have an Integrator/AP with working PCI set-up.

Since this is based on other patches from me, here is a pullable branch based on v3.14-rc2:

git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-integrator.git multiplatform

Linus Walleij (6):
ARM: integrator: localize the lm.h header
ARM: integrator: localize the impd1.h header
ARM: integrator: merge platform.h to hardware.h
ARM: integrator: localize the hardware.h header
ARM: integrator: register sched_clock directly
RFC: ARM: integrator: get rid of <mach/memory.h>

 arch/arm/Kconfig                                 |   1 -
 arch/arm/mach-integrator/core.c                  |   4 +-
 arch/arm/mach-integrator/hardware.h              | 354 +++++++++++++++++++++
 arch/arm/mach-integrator/impd1.c                 |   4 +-
 arch/arm/mach-integrator/impd1.h                 |  14 +
 arch/arm/mach-integrator/include/mach/hardware.h |  45 ---
 arch/arm/mach-integrator/include/mach/impd1.h    |  18 --
 arch/arm/mach-integrator/include/mach/lm.h       |  23 --
 arch/arm/mach-integrator/include/mach/memory.h   |  34 --
 arch/arm/mach-integrator/include/mach/platform.h | 382 -----------------------
 arch/arm/mach-integrator/integrator_ap.c         |   6 +-
 arch/arm/mach-integrator/integrator_cp.c         |  17 +-
 arch/arm/mach-integrator/leds.c                  |   4 +-
 arch/arm/mach-integrator/lm.c                    |   2 +-
 arch/arm/mach-integrator/lm.h                    |  23 ++
 arch/arm/mach-integrator/pci_v3.c                |   4 +-
 drivers/clk/versatile/clk-impd1.c                |   6 +-
 17 files changed, 411 insertions(+), 530 deletions(-)
 create mode 100644 arch/arm/mach-integrator/hardware.h
 create mode 100644 arch/arm/mach-integrator/impd1.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/hardware.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/impd1.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/lm.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/memory.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/platform.h
 create mode 100644 arch/arm/mach-integrator/lm.h
Signature · 1 line
1.8.5.3
#1 lore raw

PATCH 1/6 ARM: integrator: localize the lm.h header

As we move toward multiplatform support for the Integrator family we need to localize all <mach/*> headers. This moves the lm.h header down to the machine folder as it is not used outside it anyway.

Cc Will Deacon <[email protected]>
Cc Jonathan Austin <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mach-integrator/impd1.c           |  2 +-
 arch/arm/mach-integrator/include/mach/lm.h | 23 -----------------------
 arch/arm/mach-integrator/integrator_ap.c   |  3 +--
 arch/arm/mach-integrator/integrator_cp.c   |  3 ---
 arch/arm/mach-integrator/lm.c              |  2 +-
 arch/arm/mach-integrator/lm.h              | 23 +++++++++++++++++++++++
 6 files changed, 26 insertions(+), 30 deletions(-)
 delete mode 100644 arch/arm/mach-integrator/include/mach/lm.h
 create mode 100644 arch/arm/mach-integrator/lm.h
arch/arm/mach-integrator/impd1.c +1 -1
index d9b784824808..a90e83fe8776 100644
@@ -25,9 +25,9 @@
 #include <linux/slab.h>
 #include <linux/irqchip/arm-vic.h>
 
-#include <mach/lm.h>
 #include <mach/impd1.h>
 #include <asm/sizes.h>
+#include "lm.h"
 
 static int module_id;
 
arch/arm/mach-integrator/include/mach/lm.h deleted +0 -23
deleted file mode 100644
index 28186b6f2c09..000000000000
@@ -1,23 +0,0 @@
-
-struct lm_device {
-	struct device		dev;
-	struct resource		resource;
-	unsigned int		irq;
-	unsigned int		id;
-};
-
-struct lm_driver {
-	struct device_driver	drv;
-	int			(*probe)(struct lm_device *);
-	void			(*remove)(struct lm_device *);
-	int			(*suspend)(struct lm_device *, pm_message_t);
-	int			(*resume)(struct lm_device *);
-};
-
-int lm_driver_register(struct lm_driver *drv);
-void lm_driver_unregister(struct lm_driver *drv);
-
-int lm_device_register(struct lm_device *dev);
-
-#define lm_get_drvdata(lm)	dev_get_drvdata(&(lm)->dev)
-#define lm_set_drvdata(lm,d)	dev_set_drvdata(&(lm)->dev, d)
arch/arm/mach-integrator/integrator_ap.c +1 -2
index fedcd2fab094..f4ef41707046 100644
@@ -51,8 +51,6 @@
 #include <asm/param.h>		/* HZ */
 #include <asm/mach-types.h>
 
-#include <mach/lm.h>
-
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
@@ -61,6 +59,7 @@
 #include "cm.h"
 #include "common.h"
 #include "pci_v3.h"
+#include "lm.h"
 
 /* Base address to the AP system controller */
 void __iomem *ap_syscon_base;
arch/arm/mach-integrator/integrator_cp.c +0 -3
index 0ad5f60598c8..9af1ed995faa 100644
@@ -32,9 +32,6 @@
 #include <mach/platform.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
-
-#include <mach/lm.h>
-
 #include <asm/mach/arch.h>
 #include <asm/mach/irq.h>
 #include <asm/mach/map.h>
arch/arm/mach-integrator/lm.c +1 -1
index f52c7af31eaa..3f9e9f043168 100644
@@ -12,7 +12,7 @@
 #include <linux/device.h>
 #include <linux/slab.h>
 
-#include <mach/lm.h>
+#include "lm.h"
 
 #define to_lm_device(d)	container_of(d, struct lm_device, dev)
 #define to_lm_driver(d)	container_of(d, struct lm_driver, drv)
arch/arm/mach-integrator/lm.h new file +23 -0
new file mode 100644
index 000000000000..28186b6f2c09
@@ -0,0 +1,23 @@
+
+struct lm_device {
+	struct device		dev;
+	struct resource		resource;
+	unsigned int		irq;
+	unsigned int		id;
+};
+
+struct lm_driver {
+	struct device_driver	drv;
+	int			(*probe)(struct lm_device *);
+	void			(*remove)(struct lm_device *);
+	int			(*suspend)(struct lm_device *, pm_message_t);
+	int			(*resume)(struct lm_device *);
+};
+
+int lm_driver_register(struct lm_driver *drv);
+void lm_driver_unregister(struct lm_driver *drv);
+
+int lm_device_register(struct lm_device *dev);
+
+#define lm_get_drvdata(lm)	dev_get_drvdata(&(lm)->dev)
+#define lm_set_drvdata(lm,d)	dev_set_drvdata(&(lm)->dev, d)
Signature · 1 line
1.8.5.3
#2 lore raw

PATCH 2/6 ARM: integrator: localize the impd1.h header

In reply to Linus Walleij

As we move toward multiplatform support for the Integrator family we need to localize all <mach/*> headers. This moves the impd1.h header down to the machine folder, copying the the three defines only used by the clock driver down into the clock driver.

Cc Will Deacon <[email protected]>
Cc Jonathan Austin <[email protected]>
Cc Russell King <[email protected]>
Cc Mike Turquette <[email protected]>

---
Hi Mike, looking for an ACK on this patch.

---
 arch/arm/mach-integrator/impd1.c              |  2 +-
 arch/arm/mach-integrator/impd1.h              | 14 ++++++++++++++
 arch/arm/mach-integrator/include/mach/impd1.h | 18 ------------------
 drivers/clk/versatile/clk-impd1.c             |  6 ++++--
 4 files changed, 19 insertions(+), 21 deletions(-)
 create mode 100644 arch/arm/mach-integrator/impd1.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/impd1.h
arch/arm/mach-integrator/impd1.c +1 -1
index a90e83fe8776..0e870ea818c4 100644
@@ -25,9 +25,9 @@
 #include <linux/slab.h>
 #include <linux/irqchip/arm-vic.h>
 
-#include <mach/impd1.h>
 #include <asm/sizes.h>
 #include "lm.h"
+#include "impd1.h"
 
 static int module_id;
 
arch/arm/mach-integrator/impd1.h new file +14 -0
new file mode 100644
index 000000000000..76de4dc9bee4
@@ -0,0 +1,14 @@
+#define IMPD1_LEDS	0x0c
+#define IMPD1_INT	0x10
+#define IMPD1_SW	0x14
+#define IMPD1_CTRL	0x18
+
+#define IMPD1_CTRL_DISP_LCD	(0 << 0)
+#define IMPD1_CTRL_DISP_VGA	(1 << 0)
+#define IMPD1_CTRL_DISP_LCD1	(2 << 0)
+#define IMPD1_CTRL_DISP_ENABLE	(1 << 2)
+#define IMPD1_CTRL_DISP_MASK	(7 << 0)
+
+struct device;
+
+void impd1_tweak_control(struct device *dev, u32 mask, u32 val);
arch/arm/mach-integrator/include/mach/impd1.h deleted +0 -18
deleted file mode 100644
index d75de4b14237..000000000000
@@ -1,18 +0,0 @@
-#define IMPD1_OSC1	0x00
-#define IMPD1_OSC2	0x04
-#define IMPD1_LOCK	0x08
-#define IMPD1_LEDS	0x0c
-#define IMPD1_INT	0x10
-#define IMPD1_SW	0x14
-#define IMPD1_CTRL	0x18
-
-#define IMPD1_CTRL_DISP_LCD	(0 << 0)
-#define IMPD1_CTRL_DISP_VGA	(1 << 0)
-#define IMPD1_CTRL_DISP_LCD1	(2 << 0)
-#define IMPD1_CTRL_DISP_ENABLE	(1 << 2)
-#define IMPD1_CTRL_DISP_MASK	(7 << 0)
-
-struct device;
-
-void impd1_tweak_control(struct device *dev, u32 mask, u32 val);
-
drivers/clk/versatile/clk-impd1.c +4 -2
index 6d8b8e1a080a..31b44f025f9e 100644
@@ -13,10 +13,12 @@
 #include <linux/io.h>
 #include <linux/platform_data/clk-integrator.h>
 
-#include <mach/impd1.h>
-
 #include "clk-icst.h"
 
+#define IMPD1_OSC1	0x00
+#define IMPD1_OSC2	0x04
+#define IMPD1_LOCK	0x08
+
 struct impd1_clk {
 	char *vco1name;
 	struct clk *vco1clk;
Signature · 1 line
1.8.5.3
#3 lore raw

PATCH 3/6 ARM: integrator: merge platform.h to hardware.h

In reply to Linus Walleij

There is no need to have the two separate headers <mach/platform.h> and <mach/hardware.h>, especially since we are now going to make them local files. There is not one single driver outside the mach-integrator folder referencing any of the files.

Cc Will Deacon <[email protected]>
Cc Jonathan Austin <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mach-integrator/core.c                  |   1 -
 arch/arm/mach-integrator/include/mach/hardware.h | 327 ++++++++++++++++++-
 arch/arm/mach-integrator/include/mach/platform.h | 382 -----------------------
 arch/arm/mach-integrator/integrator_ap.c         |   1 -
 arch/arm/mach-integrator/integrator_cp.c         |   1 -
 arch/arm/mach-integrator/leds.c                  |   1 -
 arch/arm/mach-integrator/pci_v3.c                |   1 -
 7 files changed, 318 insertions(+), 396 deletions(-)
 delete mode 100644 arch/arm/mach-integrator/include/mach/platform.h
arch/arm/mach-integrator/core.c +0 -1
index 00ddf20ed91b..7a330f541a9d 100644
@@ -26,7 +26,6 @@
 #include <linux/of_address.h>
 
 #include <mach/hardware.h>
-#include <mach/platform.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/time.h>
arch/arm/mach-integrator/include/mach/hardware.h +318 -9

348 lines not on this page · raw message

arch/arm/mach-integrator/include/mach/platform.h deleted +0 -382

382 lines not on this page · raw message

arch/arm/mach-integrator/integrator_ap.c +0 -1
index f4ef41707046..33d62de18a95 100644
@@ -45,7 +45,6 @@
 #include <linux/clk-provider.h>
 
 #include <mach/hardware.h>
-#include <mach/platform.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/setup.h>
 #include <asm/param.h>		/* HZ */
arch/arm/mach-integrator/integrator_cp.c +0 -1
index 9af1ed995faa..6734a4efe710 100644
@@ -29,7 +29,6 @@
 #include <linux/sys_soc.h>
 
 #include <mach/hardware.h>
-#include <mach/platform.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
arch/arm/mach-integrator/leds.c +0 -1
index cb6ac58f5e07..e2b1b3a4c5d3 100644
@@ -12,7 +12,6 @@
 #include <linux/leds.h>
 
 #include <mach/hardware.h>
-#include <mach/platform.h>
 
 #include "cm.h"
 
arch/arm/mach-integrator/pci_v3.c +0 -1
index c5e01b24d9fb..27d88afc4e2a 100644
@@ -35,7 +35,6 @@
 #include <video/vga.h>
 
 #include <mach/hardware.h>
-#include <mach/platform.h>
 
 #include <asm/mach/map.h>
 #include <asm/signal.h>
Signature · 1 line
1.8.5.3
#4 lore raw

PATCH 4/6 ARM: integrator: localize the hardware.h header

In reply to Linus Walleij

As we move toward multiplatform support for the Integrator family we need to localize all <mach/*> headers. This moves the hardware.h header down to the machine folder. There are no users outside the machine in the kernel.

Cc Will Deacon <[email protected]>
Cc Jonathan Austin <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mach-integrator/core.c                  |   3 +-
 arch/arm/mach-integrator/hardware.h              | 354 +++++++++++++++++++++++
 arch/arm/mach-integrator/include/mach/hardware.h | 354 -----------------------
 arch/arm/mach-integrator/integrator_ap.c         |   2 +-
 arch/arm/mach-integrator/integrator_cp.c         |   2 +-
 arch/arm/mach-integrator/leds.c                  |   3 +-
 arch/arm/mach-integrator/pci_v3.c                |   3 +-
 7 files changed, 359 insertions(+), 362 deletions(-)
 create mode 100644 arch/arm/mach-integrator/hardware.h
 delete mode 100644 arch/arm/mach-integrator/include/mach/hardware.h
arch/arm/mach-integrator/core.c +1 -2
index 7a330f541a9d..e3f3aca43efb 100644
@@ -25,12 +25,11 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 
-#include <mach/hardware.h>
-
 #include <asm/mach-types.h>
 #include <asm/mach/time.h>
 #include <asm/pgtable.h>
 
+#include "hardware.h"
 #include "cm.h"
 #include "common.h"
 
arch/arm/mach-integrator/hardware.h new file +354 -0

354 lines not on this page · raw message

arch/arm/mach-integrator/include/mach/hardware.h deleted +0 -354

354 lines not on this page · raw message

arch/arm/mach-integrator/integrator_ap.c +1 -1
index 33d62de18a95..9d5d6386aaee 100644
@@ -44,7 +44,6 @@
 #include <linux/sched_clock.h>
 #include <linux/clk-provider.h>
 
-#include <mach/hardware.h>
 #include <asm/hardware/arm_timer.h>
 #include <asm/setup.h>
 #include <asm/param.h>		/* HZ */
@@ -55,6 +54,7 @@
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 
+#include "hardware.h"
 #include "cm.h"
 #include "common.h"
 #include "pci_v3.h"
arch/arm/mach-integrator/integrator_cp.c +1 -1
index 6734a4efe710..c97ab88897cf 100644
@@ -28,7 +28,6 @@
 #include <linux/of_platform.h>
 #include <linux/sys_soc.h>
 
-#include <mach/hardware.h>
 #include <asm/setup.h>
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -39,6 +38,7 @@
 #include <plat/clcd.h>
 #include <plat/sched_clock.h>
 
+#include "hardware.h"
 #include "cm.h"
 #include "common.h"
 
arch/arm/mach-integrator/leds.c +1 -2
index e2b1b3a4c5d3..f1dcb57a59e2 100644
@@ -11,8 +11,7 @@
 #include <linux/slab.h>
 #include <linux/leds.h>
 
-#include <mach/hardware.h>
-
+#include "hardware.h"
 #include "cm.h"
 
 #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS)
arch/arm/mach-integrator/pci_v3.c +1 -2
index 27d88afc4e2a..05e1f73a1e8d 100644
@@ -34,14 +34,13 @@
 #include <linux/of_pci.h>
 #include <video/vga.h>
 
-#include <mach/hardware.h>
-
 #include <asm/mach/map.h>
 #include <asm/signal.h>
 #include <asm/mach/pci.h>
 #include <asm/irq_regs.h>
 
 #include "pci_v3.h"
+#include "hardware.h"
 
 /*
  * Where in the memory map does PCI live?
Signature · 1 line
1.8.5.3
#5 lore raw

PATCH 5/6 ARM: integrator: register sched_clock directly

In reply to Linus Walleij

The detour through plat-versatile/sched-clock.c is hard to migrate to multiplatform set-up and it's very little code being duplicated so let's just inline the sched_clock registration and cut one more dependency to plat-versatile.

This also makes this sched_clock implementation compulsory.

Cc Will Deacon <[email protected]>
Cc Jonathan Austin <[email protected]>
Cc Russell King <[email protected]>
---
 arch/arm/mach-integrator/integrator_cp.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
arch/arm/mach-integrator/integrator_cp.c +7 -4
index c97ab88897cf..a938242b0c95 100644
@@ -27,6 +27,7 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/sys_soc.h>
+#include <linux/sched_clock.h>
 
 #include <asm/setup.h>
 #include <asm/mach-types.h>
@@ -36,7 +37,6 @@
 #include <asm/mach/time.h>
 
 #include <plat/clcd.h>
-#include <plat/sched_clock.h>
 
 #include "hardware.h"
 #include "cm.h"
@@ -225,11 +225,14 @@ static struct clcd_board clcd_data = {
 
 #define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28)
 
+static u64 notrace intcp_read_sched_clock(void)
+{
+	return readl(REFCOUNTER);
+}
+
 static void __init intcp_init_early(void)
 {
-#ifdef CONFIG_PLAT_VERSATILE_SCHED_CLOCK
-	versatile_sched_clock_init(REFCOUNTER, 24000000);
-#endif
+	sched_clock_register(intcp_read_sched_clock, 32, 24000000);
 }
 
 static const struct of_device_id fpga_irq_of_match[] __initconst = {
Signature · 1 line
1.8.5.3
#6 lore raw

PATCH 6/6 RFC: ARM: integrator: get rid of <mach/memory.h>

In reply to Linus Walleij

The Integrator has a custom <mach/memory.h> header defining the BUS_OFFSET for *_to_bus and bus_to_* operations as offset from 0x80000000.

I have searched the documentation and cannot find any clue to this set-up. The Integrators have no intrinsic DMA engine(s) that need to perform any bus translations. The only thing I can think of is the PCIv3 host found in the Integrator/AP. After searching its documentation I cannot find any hint whatsoever saying that it would perform DMA operations to memory offset to 0x80000000. The PCIv3 driver does not configure anything for DMA, and the hardware contains registers to configure the local (CPU) side address translation. When I dump the default values of these registers (the Linux driver does not touch them) they contain zeroes meaning a 1-to-1 mapping to the bus.

So patch the mapping to use the kernel default.

Cc Will Deacon <[email protected]>
Cc Jonathan Austin <[email protected]>
Cc Russell King <[email protected]>

---
Admittedly I'm not certain about how DMA works in PCI scenarios (only experienced with DMA engines) so some input here would be appreciated. Like if DMA support is compulory for PCI hosts or if it's somehow even unused on the PCIv3. And if someone has ever tested some DMA:ing PCI card on this machine.

---
 arch/arm/Kconfig                               |  1 -
 arch/arm/mach-integrator/include/mach/memory.h | 34 --------------------------
 2 files changed, 35 deletions(-)
 delete mode 100644 arch/arm/mach-integrator/include/mach/memory.h
arch/arm/Kconfig +0 -1
index e25419817791..c4094131314e 100644
@@ -325,7 +325,6 @@ config ARCH_INTEGRATOR
 	select HAVE_TCM
 	select ICST
 	select MULTI_IRQ_HANDLER
-	select NEED_MACH_MEMORY_H
 	select PLAT_VERSATILE
 	select SPARSE_IRQ
 	select USE_OF
arch/arm/mach-integrator/include/mach/memory.h deleted +0 -34
deleted file mode 100644
index 334d5e271889..000000000000
@@ -1,34 +0,0 @@
-/*
- *  arch/arm/mach-integrator/include/mach/memory.h
- *
- *  Copyright (C) 1999 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-#ifndef __ASM_ARCH_MEMORY_H
-#define __ASM_ARCH_MEMORY_H
-
-/*
- * Physical DRAM offset.
- */
-#define PLAT_PHYS_OFFSET	UL(0x00000000)
-
-#define BUS_OFFSET	UL(0x80000000)
-#define __virt_to_bus(x)	((x) - PAGE_OFFSET + BUS_OFFSET)
-#define __bus_to_virt(x)	((x) - BUS_OFFSET + PAGE_OFFSET)
-#define __pfn_to_bus(x)		(__pfn_to_phys(x) + (BUS_OFFSET - PHYS_OFFSET))
-#define __bus_to_pfn(x)		__phys_to_pfn((x) - (BUS_OFFSET - PHYS_OFFSET))
-
-#endif
Signature · 1 line
1.8.5.3
#7 lore raw

PATCH 6/6 RFC: ARM: integrator: get rid of <mach/memory.h>

Quoted 4 lines · On Friday 14 February 2014 11:29:31 Linus Walleij wrote:

The Integrator has a custom <mach/memory.h> header defining the BUS_OFFSET for *_to_bus and bus_to_* operations as offset from 0x80000000.

Quoted 12 lines

I have searched the documentation and cannot find any clue to this set-up. The Integrators have no intrinsic DMA engine(s) that need to perform any bus translations. The only thing I can think of is the PCIv3 host found in the Integrator/AP. After searching its documentation I cannot find any hint whatsoever saying that it would perform DMA operations to memory offset to 0x80000000. The PCIv3 driver does not configure anything for DMA, and the hardware contains registers to configure the local (CPU) side address translation. When I dump the default values of these registers (the Linux driver does not touch them) they contain zeroes meaning a 1-to-1 mapping to the bus.

I think this will be break bus-mastering PCI adapters. In theory any PCI add-on card can be a bus-master and write to the host memory. An offset of 0x80000000 in the PCI host is not uncommon for this. Basically what the PCI host does is forward any PCI transaction with a destination below 2GB to the PCI bus so it can target an MMIO register, and forward transactions above 2GB to the parent bus, flipping the high-order bit in the process.

In the old days, we had virt_to_bus() and bus_to_virt() as interfaces for drivers to convert between a kernel pointer and an address that can be used for DMA. We have long ago (except for a handful of drivers that depend on CONFIG_TO_BUS and won't build on integrator or multiplatform) stopped using those in drivers, since the translation may be dependent on the specific device (e.g. different offsets), or may be nonlinear in case of an IOMMU.

The interface that drivers use now is defined in dma-mapping.h and abstracted through dma_map_ops on ARM and some other architectures. What you need for a multiplatform kernel to work on integrator is to set the dma_map_ops for all PCI devices to an implementation that adds the correct offset.

One way to do this would be to define an integrator specific dma_map_ops struct that adds a constant value for each operation and then calls into the regular arm_dma_ops. That would be an easy way out, but would not help the next person with the same problem.
A more sophisticated approach, following what we did on powerpc, would be to add an offset field to struct dev_archdata and apply that in pfn_to_dma/dma_to_pfn/dma_to_virt/virt_to_dma so it gets used by all dma_map_ops implementations. For PCI devices, you probably have to copy the offset from the parent in the pcibios_add_device() function in that case, while for devices probed through DT (only the pci host bridge in this case), you have to parse the "dma_ranges" property.

Arnd

#8 lore raw

cover ARM: integrator: multiplatform advancements

In reply to Linus Walleij
Quoted 4 lines · Linus Walleij

The *real* solution, one might argue is to convert the CLCD driver to DRM and add device tree bindings, but it appears that this is an orthogonal goal that has been attempted by other with mixed results.

What mixed results? You know, I find it rather sick that people run around trying to do this to a driver that I authored and maintain without one comment to me about it. It sometimes feels like people think I don't exist anymore.

The biggest complaint I've heard against DRM is the amount of code required. That's partly because we haven't - until now - had a good way to separate the "connectors" as stand-alone implementations separate from the core DRM drivers. I'm hopeful that by 3.15, we will see some implementations (imx-drm and armada) start making use of this.

Also, remember that DRM is Direct Rendering Manager, which incorporates Kernel Mode Setting. It's the KMS part which is most relevant to things like CLCD since it has no GPU. However, the non-KMS bits also are when you have something like a Mali GPU or other GPU.

We /really/ need these GPUs to move over to DRM - any ARM platform using a GPU today is inherently insecure since they all have been coded to push physical addresses around everywhere, which basically means userspace can use the GPU to access parts of the system such as overwriting bits of the kernel.

It's useless write-protecting the vectors page and/or the kernel text in a vain attempt to provide additional security if the GPU can be used from userspace to write to that RAM.

Having everything under DRM eliminates that problem because userspace only gets to deal with handles to the various buffers rather than physical addresses, which ensures that you can't specify an address for a buffer you don't own.

Signature · 3 lines
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".
#9 lore raw

cover ARM: integrator: multiplatform advancements

Quoted 10 lines · Russell King - ARM Linux
Quoted 4 lines · Linus Walleij

The *real* solution, one might argue is to convert the CLCD driver to DRM and add device tree bindings, but it appears that this is an orthogonal goal that has been attempted by other with mixed results.

What mixed results? You know, I find it rather sick that people run around trying to do this to a driver that I authored and maintain without one comment to me about it. It sometimes feels like people think I don't exist anymore.

Sorry, I was referring to this driver for PL111:
http://marc.info/?l=linux-arm-kernel&m=137477285809710&w=2

So I take it that the PL111 is a totally different beast from PL110 except for the single digit difference in the name. Whereas PL180 and PL181 are essentially the same piece of hardware...

Then there is this patch set for DT support for the CLCD which appears to be orthogonal:
http://marc.info/?l=linux-arm-kernel&m=137968689722364&w=2

Pawel, is this coming along?

Yours,
Linus Walleij

#10 lore raw

cover ARM: integrator: multiplatform advancements

Quoted 21 lines · Linus Walleij
Quoted 10 lines · Russell King - ARM Linux
Quoted 4 lines · Linus Walleij

The *real* solution, one might argue is to convert the CLCD driver to DRM and add device tree bindings, but it appears that this is an orthogonal goal that has been attempted by other with mixed results.

What mixed results? You know, I find it rather sick that people run around trying to do this to a driver that I authored and maintain without one comment to me about it. It sometimes feels like people think I don't exist anymore.

Sorry, I was referring to this driver for PL111:
http://marc.info/?l=linux-arm-kernel&m=137477285809710&w=2

So I take it that the PL111 is a totally different beast from PL110 except for the single digit difference in the name. Whereas PL180 and PL181 are essentially the same piece of hardware...

Quoted 5 lines

Then there is this patch set for DT support for the CLCD which appears to be orthogonal:
http://marc.info/?l=linux-arm-kernel&m=137968689722364&w=2

Pawel, is this coming along?

Last week I was about to answer that this was my last word in the subject ;-) but then I decided to give it another go, trying to address the last - I think - controversial bit, being the pads property. Made it much simpler and optional, so it should be in anybody's (namely the DRM driver and bindings) way.

Will post in a second.

Pawel