Skip to contentSkip to conversation

IP32 memory patch

PATCH Ilya A. Volynets-Evenbakh 1 participant 3 messages Jan 8, 2005 – Jan 10, 2005 MIPS

lore
Share & tools
lore
#0 lore raw

Hi all,

Here is patch to allow IP32 to access full 1G of memory. I was able to boot an O2 with 576M of ram using NFS-root.

Two notes:
1. This patch will only work with latest linux-mips.org CVS tree
2. Seems that PCI support is messed up by this patch, so SCSI doesn't work.

If someone can see something obvious regarding #2, I'll be glad to hear it.

Ilya.

Index: arch/mips/sgi-ip32/Makefile
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/Makefile,v retrieving revision 1.9

mips/sgi-ip32/Makefile 8 Jan 2005 23:04:07 -0000 renamed from mips/sgi-ip32/Makefile 26 Feb 2004 09:09:09 -0000 1.9 +0 -0
diff -u -r1.9 Makefile
@@ -4,6 +4,6 @@

#

obj-y += ip32-berr.o ip32-irq.o ip32-irq-glue.o ip32-setup.o ip32-reset.o \
- crime.o
+ crime.o ip32-memory.o

EXTRA_AFLAGS := $(CFLAGS)
Index: arch/mips/sgi-ip32/crime.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/crime.c,v retrieving revision 1.6

mips/sgi-ip32/crime.c 8 Jan 2005 23:04:07 -0000 renamed from mips/sgi-ip32/crime.c 31 Aug 2004 16:49:32 -0000 1.6 +0 -0
diff -u -r1.6 crime.c
@@ -24,7 +24,8 @@
{
       unsigned int id, rev;
       const int field = 2 * sizeof(unsigned long);
-
+
+       set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));
       crime = ioremap(CRIME_BASE, sizeof(struct sgi_crime));
       mace = ioremap(MACE_BASE, sizeof(struct sgi_mace));

Index: arch/mips/sgi-ip32/ip32-setup.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/ip32-setup.c,v retrieving revision 1.22

mips/sgi-ip32/ip32-setup.c 8 Jan 2005 23:04:07 -0000 renamed from mips/sgi-ip32/ip32-setup.c 31 Aug 2004 16:49:32 -0000 1.22 +0 -0
diff -u -r1.22 ip32-setup.c
@@ -94,10 +94,6 @@
 

static int __init ip32_setup(void)
{
- set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));
-
- crime_init();
-

       board_be_init = ip32_be_init;

       rtc_get_time = mc146818_get_cmos_time;

Index: include/asm-mips/mach-ip32/spaces.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/mach-ip32/spaces.h,v retrieving revision 1.1

asm-mips/mach-ip32/spaces.h 8 Jan 2005 23:04:25 -0000 renamed from asm-mips/mach-ip32/spaces.h 15 Oct 2004 02:09:12 -0000 1.1 +0 -0
diff -u -r1.1 spaces.h
@@ -12,10 +12,6 @@
 

#include <linux/config.h>

-/*
- * This handles the memory map.
- */
-#define PAGE_OFFSET 0xffffffff80000000

/*
* Memory above this physical address will be considered highmem.
@@ -39,4 +35,9 @@

#define TO_CAC(x)              (CAC_BASE   | ((x) & TO_PHYS_MASK))
#define TO_UNCAC(x)            (UNCAC_BASE | ((x) & TO_PHYS_MASK))

+/*
+ * This handles the memory map.
+ */
+#define PAGE_OFFSET CAC_BASE
+
#endif /* __ASM_MACH_IP32_SPACES_H */

mips/sgi-ip32/ip32-memory.c 2005-01-08 14:15:20 -0800 renamed from dev/null 1969-12-31 16:00:00 -0800 +55 -0

55 lines not on this page · raw message

asm/mach-ip32/cpu-feature-overrides.h 2005-01-08 10:44:46 -0800 renamed from dev/null 1969-12-31 16:00:00 -0800 +15 -0
@@ -0,0 +1,15 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2003 Ralf Baechle
+ */
+#ifndef __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H
+
+#if defined(CONFIG_CPU_R5000) && defined(CONFIG_MIPS64)
+#define cpu_has_llsc   0
+#endif
+
+#endif /* __ASM_MACH_GENERIC_CPU_FEATURE_OVERRIDES_H */
#1 lore raw
Quoted 5 lines · Ilya A. Volynets-Evenbakh

Hi all,

Here is patch to allow IP32 to access full 1G of memory. I was able to boot an O2 with 576M of ram using NFS-root.

Quoted 8 lines

Two notes:
1. This patch will only work with latest linux-mips.org CVS tree
2. Seems that PCI support is messed up by this patch, so SCSI doesn't work.

If someone can see something obvious regarding #2, I'll be glad to hear it.

Ilya.

So, I found the problem.
Memory above 256M is mapped at 0x40000000+256M in IP32. However, PCI sees whole 1G as contiguous chunk at offset 0. This means we have to translate dma addreses differently, depending on wether they fall within first 256M or not.

So, I created separate implemetation of pci_dma_* routines.

Index: arch/mips/Kconfig
===================================================================
RCS file: /home/cvs/linux/arch/mips/Kconfig,v
retrieving revision 1.126

mips/Kconfig 10 Jan 2005 00:02:10 -0000 renamed from mips/Kconfig 27 Dec 2004 18:23:53 -0000 1.126 +2 -0
diff -u -r1.126 Kconfig
@@ -541,6 +541,8 @@
       select ARC
       select ARC32
       select BOOT_ELF32
+       select OWN_DMA
+       select DMA_IP32
       select DMA_NONCOHERENT
       select HW_HAS_PCI
       select R5000_CPU_SCACHE
@@ -926,6 +928,12 @@

config DMA_IP27
bool

+config DMA_IP32
+ bool
+
+config OWN_DMA
+ bool
+
config DMA_NONCOHERENT
bool
Index: arch/mips/mm/Makefile
===================================================================
RCS file: /home/cvs/linux/arch/mips/mm/Makefile,v
retrieving revision 1.74

mips/mm/Makefile 9 Jan 2005 23:53:54 -0000 renamed from mips/mm/Makefile 7 Jan 2005 18:58:34 -0000 1.74 +0 -0
diff -u -r1.74 Makefile
@@ -34,8 +34,11 @@

#
# Choose one DMA coherency model
#
+ifndef CONFIG_OWN_DMA
obj-$(CONFIG_DMA_COHERENT) += dma-coherent.o
obj-$(CONFIG_DMA_NONCOHERENT) += dma-noncoherent.o +endif
obj-$(CONFIG_DMA_IP27) += dma-ip27.o
+obj-$(CONFIG_DMA_IP32) += dma-ip32.o

EXTRA_AFLAGS := $(CFLAGS)

Index: arch/mips/sgi-ip32/Makefile
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/Makefile,v retrieving revision 1.9

mips/sgi-ip32/Makefile 9 Jan 2005 23:53:55 -0000 renamed from mips/sgi-ip32/Makefile 26 Feb 2004 09:09:09 -0000 1.9 +0 -0
diff -u -r1.9 Makefile
@@ -4,6 +4,6 @@

#

obj-y += ip32-berr.o ip32-irq.o ip32-irq-glue.o ip32-setup.o ip32-reset.o \
- crime.o
+ crime.o ip32-memory.o

EXTRA_AFLAGS := $(CFLAGS)
Index: arch/mips/sgi-ip32/crime.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/crime.c,v retrieving revision 1.6

mips/sgi-ip32/crime.c 9 Jan 2005 23:53:55 -0000 renamed from mips/sgi-ip32/crime.c 31 Aug 2004 16:49:32 -0000 1.6 +0 -0
diff -u -r1.6 crime.c
@@ -24,7 +24,8 @@
{
       unsigned int id, rev;
       const int field = 2 * sizeof(unsigned long);
-
+
+       set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));
       crime = ioremap(CRIME_BASE, sizeof(struct sgi_crime));
       mace = ioremap(MACE_BASE, sizeof(struct sgi_mace));

Index: include/asm-mips/ip32/crime.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/ip32/crime.h,v retrieving revision 1.6

asm-mips/ip32/crime.h 9 Jan 2005 23:54:26 -0000 renamed from asm-mips/ip32/crime.h 4 Dec 2004 18:16:09 -0000 1.6 +0 -0
diff -u -r1.6 crime.h
@@ -156,4 +156,6 @@
 

extern struct sgi_crime *crime;

+#define CRIME_HI_MEM_BASE 0x40000000 /* this is where whole 1G of RAM is mapped */
+
#endif /* __ASM_CRIME_H__ */
Index: include/asm-mips/mach-ip32/spaces.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/mach-ip32/spaces.h,v retrieving revision 1.1

asm-mips/mach-ip32/spaces.h 9 Jan 2005 23:54:26 -0000 renamed from asm-mips/mach-ip32/spaces.h 15 Oct 2004 02:09:12 -0000 1.1 +0 -0
diff -u -r1.1 spaces.h
@@ -12,10 +12,6 @@
 

#include <linux/config.h>

-/*
- * This handles the memory map.
- */
-#define PAGE_OFFSET 0xffffffff80000000

/*
* Memory above this physical address will be considered highmem.
@@ -26,11 +22,7 @@
#define HIGHMEM_START (1UL << 59UL)
#endif

-#ifdef CONFIG_DMA_NONCOHERENT
#define CAC_BASE 0x9800000000000000
-#else
-#define CAC_BASE 0xa800000000000000
-#endif
#define IO_BASE 0x9000000000000000
#define UNCAC_BASE 0x9000000000000000
#define MAP_BASE 0xc000000000000000
@@ -39,4 +31,9 @@

#define TO_CAC(x)              (CAC_BASE   | ((x) & TO_PHYS_MASK))
#define TO_UNCAC(x)            (UNCAC_BASE | ((x) & TO_PHYS_MASK))

+/*
+ * This handles the memory map.
+ */
+#define PAGE_OFFSET CAC_BASE
+
#endif /* __ASM_MACH_IP32_SPACES_H */

mips/sgi-ip32/ip32-memory.c 2005-01-09 16:25:59 -0800 renamed from dev/null 1969-12-31 16:00:00 -0800 +53 -0

53 lines not on this page · raw message

mips/mm/dma-ip32.c 2005-01-09 16:28:56 -0800 renamed from dev/null 1969-12-31 16:00:00 -0800 +367 -0

367 lines not on this page · raw message

asm-mips/mach-ip32/cpu-feature-overrides.h 2005-01-08 21:59:51 -0800 renamed from dev/null 1969-12-31 16:00:00 -0800 +22 -0
@@ -0,0 +1,22 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004 Ilya A. Volynets-Evenbakh (Total Knowledge)
+ */
+#ifndef __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * R5000 has an interesting "restriction":  ll(d)/sc(d)
+ * instructions to XKPHYS region simply do uncached bus
+ * requests. This breaks all the atomic bitops functions.
+ * so, for 64bit IP32 kernel we just don't use ll/sc.
+ * This does not affect luserland.
+ */
+#if defined(CONFIG_CPU_R5000) && defined(CONFIG_MIPS64)
+#define cpu_has_llsc   0
+#endif
+
+#endif /* __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H */

Index: arch/mips/sgi-ip32/ip32-setup.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/ip32-setup.c,v retrieving revision 1.22

mips/sgi-ip32/ip32-setup.c 10 Jan 2005 00:18:02 -0000 renamed from mips/sgi-ip32/ip32-setup.c 31 Aug 2004 16:49:32 -0000 1.22 +0 -0
diff -u -r1.22 ip32-setup.c
@@ -94,10 +94,6 @@
 

static int __init ip32_setup(void)
{
- set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));
-
- crime_init();
-

       board_be_init = ip32_be_init;

       rtc_get_time = mc146818_get_cmos_time;
#2 lore raw

Seems my mailer broke the patch, so I'm sending it as attachement.

Quoted 13 lines · Ilya A. Volynets-Evenbakh
Quoted 11 lines · Ilya A. Volynets-Evenbakh

Hi all,

Here is patch to allow IP32 to access full 1G of memory. I was able to boot an O2 with 576M of ram using NFS-root.

Two notes:
1. This patch will only work with latest linux-mips.org CVS tree
2. Seems that PCI support is messed up by this patch, so SCSI doesn't work.

If someone can see something obvious regarding #2, I'll be glad to hear it.

Quoted 9 lines
Quoted 2 lines

Ilya.

So, I found the problem.
Memory above 256M is mapped at 0x40000000+256M in IP32. However, PCI sees whole 1G as contiguous chunk at offset 0. This means we have to translate dma addreses differently, depending on wether they fall within first 256M or not.

So, I created separate implemetation of pci_dma_* routines.

Index: arch/mips/Kconfig
===================================================================
RCS file: /home/cvs/linux/arch/mips/Kconfig,v
retrieving revision 1.126

mips/Kconfig +8 -0
diff -u -r1.126 Kconfig
@@ -541,6 +541,8 @@
 	select ARC
 	select ARC32
 	select BOOT_ELF32
+	select OWN_DMA
+	select DMA_IP32
 	select DMA_NONCOHERENT
 	select HW_HAS_PCI
 	select R5000_CPU_SCACHE
@@ -926,6 +928,12 @@
 config	DMA_IP27
 	bool
 
+config	DMA_IP32
+	bool
+
+config	OWN_DMA
+	bool
+
 config	DMA_NONCOHERENT
 	bool

Index: arch/mips/mm/Makefile
===================================================================
RCS file: /home/cvs/linux/arch/mips/mm/Makefile,v
retrieving revision 1.74

mips/mm/Makefile +3 -0
diff -u -r1.74 Makefile
@@ -34,8 +34,11 @@
 #
 # Choose one DMA coherency model
 #
+ifndef CONFIG_OWN_DMA
 obj-$(CONFIG_DMA_COHERENT)	+= dma-coherent.o
 obj-$(CONFIG_DMA_NONCOHERENT)	+= dma-noncoherent.o
+endif
 obj-$(CONFIG_DMA_IP27)		+= dma-ip27.o
+obj-$(CONFIG_DMA_IP32)		+= dma-ip32.o
 
 EXTRA_AFLAGS := $(CFLAGS)

Index: arch/mips/sgi-ip32/Makefile
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/Makefile,v retrieving revision 1.9

mips/sgi-ip32/Makefile +1 -1
diff -u -r1.9 Makefile
@@ -4,6 +4,6 @@
 #
 
 obj-y	+= ip32-berr.o ip32-irq.o ip32-irq-glue.o ip32-setup.o ip32-reset.o \
-	   crime.o
+	   crime.o ip32-memory.o
 
 EXTRA_AFLAGS := $(CFLAGS)

Index: arch/mips/sgi-ip32/crime.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/crime.c,v retrieving revision 1.6

mips/sgi-ip32/crime.c +2 -1
diff -u -r1.6 crime.c
@@ -24,7 +24,8 @@
 {
 	unsigned int id, rev;
 	const int field = 2 * sizeof(unsigned long);
-	
+
+	set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));	
 	crime = ioremap(CRIME_BASE, sizeof(struct sgi_crime));
 	mace = ioremap(MACE_BASE, sizeof(struct sgi_mace));
 

Index: include/asm-mips/ip32/crime.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/ip32/crime.h,v retrieving revision 1.6

asm-mips/ip32/crime.h +2 -0
diff -u -r1.6 crime.h
@@ -156,4 +156,6 @@
 
 extern struct sgi_crime *crime;
 
+#define CRIME_HI_MEM_BASE	0x40000000	/* this is where whole 1G of RAM is mapped */
+
 #endif /* __ASM_CRIME_H__ */

Index: include/asm-mips/mach-ip32/spaces.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips/mach-ip32/spaces.h,v retrieving revision 1.1

asm-mips/mach-ip32/spaces.h +5 -8
diff -u -r1.1 spaces.h
@@ -12,10 +12,6 @@
 
 #include <linux/config.h>
 
-/*
- * This handles the memory map.
- */
-#define PAGE_OFFSET		0xffffffff80000000
 
 /*
  * Memory above this physical address will be considered highmem.
@@ -26,11 +22,7 @@
 #define HIGHMEM_START		(1UL << 59UL)
 #endif
 
-#ifdef CONFIG_DMA_NONCOHERENT
 #define CAC_BASE		0x9800000000000000
-#else
-#define CAC_BASE		0xa800000000000000
-#endif
 #define IO_BASE			0x9000000000000000
 #define UNCAC_BASE		0x9000000000000000
 #define MAP_BASE		0xc000000000000000
@@ -39,4 +31,9 @@
 #define TO_CAC(x)		(CAC_BASE   | ((x) & TO_PHYS_MASK))
 #define TO_UNCAC(x)		(UNCAC_BASE | ((x) & TO_PHYS_MASK))
 
+/*
+ * This handles the memory map.
+ */
+#define PAGE_OFFSET		CAC_BASE
+
 #endif /* __ASM_MACH_IP32_SPACES_H */
asm-mips/mach-ip32/cpu-feature-overrides.h new file +22 -0
@@ -0,0 +1,22 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004 Ilya A. Volynets-Evenbakh
+ */
+#ifndef __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * R5000 has an interesting "restriction":  ll(d)/sc(d)
+ * instructions to XKPHYS region simply do uncached bus
+ * requests. This breaks all the atomic bitops functions.
+ * so, for 64bit IP32 kernel we just don't use ll/sc.
+ * This does not affect luserland.
+ */
+#if defined(CONFIG_CPU_R5000) && defined(CONFIG_MIPS64)
+#define cpu_has_llsc	0
+#endif
+
+#endif /* __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H */

Index: arch/mips/sgi-ip32/ip32-setup.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/sgi-ip32/ip32-setup.c,v retrieving revision 1.22

mips/sgi-ip32/ip32-setup.c +0 -4
diff -u -r1.22 ip32-setup.c
@@ -94,10 +94,6 @@
 
 static int __init ip32_setup(void)
 {
-	set_io_port_base((unsigned long) ioremap(MACEPCI_LOW_IO, 0x2000000));
-
-	crime_init();
-
 	board_be_init = ip32_be_init;
 
 	rtc_get_time = mc146818_get_cmos_time;
mips/mm/dma-ip32.c new file +367 -0

367 lines not on this page · raw message

mips/sgi-ip32/ip32-memory.c new file +53 -0

53 lines not on this page · raw message

asm-mips/mach-ip32/cpu-feature-overrides.h new file +22 -0
@@ -0,0 +1,22 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 2004 Ilya A. Volynets-Evenbakh
+ */
+#ifndef __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
+#define __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H
+
+/*
+ * R5000 has an interesting "restriction":  ll(d)/sc(d)
+ * instructions to XKPHYS region simply do uncached bus
+ * requests. This breaks all the atomic bitops functions.
+ * so, for 64bit IP32 kernel we just don't use ll/sc.
+ * This does not affect luserland.
+ */
+#if defined(CONFIG_CPU_R5000) && defined(CONFIG_MIPS64)
+#define cpu_has_llsc	0
+#endif
+
+#endif /* __ASM_MACH_IP32_CPU_FEATURE_OVERRIDES_H */