linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: zynq: Reserve not DMAable space in front of the kernel
@ 2014-01-31 12:08 Michal Simek
  2014-01-31 17:38 ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2014-01-31 12:08 UTC (permalink / raw)
  To: Jason Gunthorpe, Guennadi Liakhovetski, Russell King - ARM Linux
  Cc: linux-arm-kernel, monstr, Josh Cartwright, Steffen Trumtrar,
	Rob Herring, Peter Crosthwaite, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

Reserve space from 0x0 - __pa(swapper_pg_dir),
if kernel is loaded from 0, which is not DMAable.
It is causing problem with MMC driver and others
which want to add dma buffers to this space.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Jason: I don't think it is worth to bring 0x8000 magic
value and count minimum from it and phys_addr of swapper_pg_dir.
Full 512k of memory shouldn't be used by DMA.

---
 arch/arm/mach-zynq/common.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
index 1db2a5ca..8c09a83 100644
--- a/arch/arm/mach-zynq/common.c
+++ b/arch/arm/mach-zynq/common.c
@@ -25,6 +25,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/of.h>
+#include <linux/memblock.h>
 #include <linux/irqchip.h>
 #include <linux/irqchip/arm-gic.h>

@@ -41,6 +42,18 @@

 void __iomem *zynq_scu_base;

+/**
+ * zynq_memory_init - Initialize special memory
+ *
+ * We need to stop things allocating the low memory as DMA can't work in
+ * the 1st 512K of memory.
+ */
+static void __init zynq_memory_init(void)
+{
+	if (!__pa(PAGE_OFFSET))
+		memblock_reserve(__pa(PAGE_OFFSET), __pa(swapper_pg_dir));
+}
+
 static struct platform_device zynq_cpuidle_device = {
 	.name = "cpuidle-zynq",
 };
@@ -117,5 +130,6 @@ DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
 	.init_machine	= zynq_init_machine,
 	.init_time	= zynq_timer_init,
 	.dt_compat	= zynq_dt_match,
+	.reserve	= zynq_memory_init,
 	.restart	= zynq_system_reset,
 MACHINE_END
--
1.8.2.3


[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH] ARM: zynq: Reserve not DMAable space in front of the kernel
  2014-01-31 12:08 [PATCH] ARM: zynq: Reserve not DMAable space in front of the kernel Michal Simek
@ 2014-01-31 17:38 ` Rob Herring
  2014-02-03 12:13   ` Michal Simek
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2014-01-31 17:38 UTC (permalink / raw)
  To: Michal Simek
  Cc: Jason Gunthorpe, Guennadi Liakhovetski, Russell King - ARM Linux,
	linux-arm-kernel, Michal Simek, Josh Cartwright,
	Steffen Trumtrar, Peter Crosthwaite, linux-kernel

On Fri, Jan 31, 2014 at 6:08 AM, Michal Simek <michal.simek@xilinx.com> wrote:
> Reserve space from 0x0 - __pa(swapper_pg_dir),
> if kernel is loaded from 0, which is not DMAable.
> It is causing problem with MMC driver and others
> which want to add dma buffers to this space.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Jason: I don't think it is worth to bring 0x8000 magic
> value and count minimum from it and phys_addr of swapper_pg_dir.
> Full 512k of memory shouldn't be used by DMA.
>
> ---
>  arch/arm/mach-zynq/common.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)

The existing DT reserved range can't be used for this purpose?

Rob

>
> diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
> index 1db2a5ca..8c09a83 100644
> --- a/arch/arm/mach-zynq/common.c
> +++ b/arch/arm/mach-zynq/common.c
> @@ -25,6 +25,7 @@
>  #include <linux/of_irq.h>
>  #include <linux/of_platform.h>
>  #include <linux/of.h>
> +#include <linux/memblock.h>
>  #include <linux/irqchip.h>
>  #include <linux/irqchip/arm-gic.h>
>
> @@ -41,6 +42,18 @@
>
>  void __iomem *zynq_scu_base;
>
> +/**
> + * zynq_memory_init - Initialize special memory
> + *
> + * We need to stop things allocating the low memory as DMA can't work in
> + * the 1st 512K of memory.
> + */
> +static void __init zynq_memory_init(void)
> +{
> +       if (!__pa(PAGE_OFFSET))
> +               memblock_reserve(__pa(PAGE_OFFSET), __pa(swapper_pg_dir));
> +}
> +
>  static struct platform_device zynq_cpuidle_device = {
>         .name = "cpuidle-zynq",
>  };
> @@ -117,5 +130,6 @@ DT_MACHINE_START(XILINX_EP107, "Xilinx Zynq Platform")
>         .init_machine   = zynq_init_machine,
>         .init_time      = zynq_timer_init,
>         .dt_compat      = zynq_dt_match,
> +       .reserve        = zynq_memory_init,
>         .restart        = zynq_system_reset,
>  MACHINE_END
> --
> 1.8.2.3
>

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

* Re: [PATCH] ARM: zynq: Reserve not DMAable space in front of the kernel
  2014-01-31 17:38 ` Rob Herring
@ 2014-02-03 12:13   ` Michal Simek
  0 siblings, 0 replies; 3+ messages in thread
From: Michal Simek @ 2014-02-03 12:13 UTC (permalink / raw)
  To: Rob Herring
  Cc: Michal Simek, Jason Gunthorpe, Guennadi Liakhovetski,
	Russell King - ARM Linux, linux-arm-kernel, Josh Cartwright,
	Steffen Trumtrar, Peter Crosthwaite, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2054 bytes --]

On 01/31/2014 06:38 PM, Rob Herring wrote:
> On Fri, Jan 31, 2014 at 6:08 AM, Michal Simek <michal.simek@xilinx.com> wrote:
>> Reserve space from 0x0 - __pa(swapper_pg_dir),
>> if kernel is loaded from 0, which is not DMAable.
>> It is causing problem with MMC driver and others
>> which want to add dma buffers to this space.
>>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> Jason: I don't think it is worth to bring 0x8000 magic
>> value and count minimum from it and phys_addr of swapper_pg_dir.
>> Full 512k of memory shouldn't be used by DMA.
>>
>> ---
>>  arch/arm/mach-zynq/common.c | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
> 
> The existing DT reserved range can't be used for this purpose?

I expect you are talking about memreserve.

Two cases which are valid for us which have the same DTS file
with this setup.

memreserve 0 - 0x4000
memory node 0x0 - 0x40000000


1. standard
kernel starting addr is 0x8000 and kernel is using 1GB memory which just works

2. AMP which we are also using
kernel starting for example from 0x10008000 and use just 768MB, 256MB for remoteproc.
With memreserve in DTS this ends in mark_bootmem BUG because reserved memory is not in memory
which Linux can handle (at least this is my theory).

Case 2 require one small fix which Russell is aware of,
I have to check status on it.

But with this current implementation both cases just work
without changing dts file because for both cases
dts file is just the same and user decides where kernel is placed
and how much memory user wants to use.

If you know how to fix this with any better dt description please
let me know. I am not aware about it.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

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

end of thread, other threads:[~2014-02-03 12:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 12:08 [PATCH] ARM: zynq: Reserve not DMAable space in front of the kernel Michal Simek
2014-01-31 17:38 ` Rob Herring
2014-02-03 12:13   ` Michal Simek

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).