a new UniCore32 arch-dependent patch for linux-2.6.37-rc1
Subsystems (3)
Please download second patches for review:
http://mprc.pku.edu.cn/~guanxuetao/linux/patch-2.6.37-rc2-uc32-gxt2-arch.bz2
(above patch for arch/unicore32 directory, 149KB)
http://mprc.pku.edu.cn/~guanxuetao/linux/patch-2.6.37-rc2-uc32-gxt2-drivers.
bz2
(above patch for drivers/staging/puv3 directory, which including some
necessary drivers, 31KB)
http://mprc.pku.edu.cn/~guanxuetao/linux/patch-2.6.37-rc2-uc32-gxt2-rest.bz2
(above patch for rest patch code, for modifying the file not inarch/unicore32 and drivers/staging/puv3, 2KB)
Replying Arnd's:
Quoted 4 lines
It would be good if you could make a tool chain available, ideally both a patch against gcc and pre-built binaries for an x86-unicore cross compiler. This is not strictly required, but it helps to get people to do build tests on your code.
[Guan] please download x86-unicore cross toolchain from:
http://mprc.pku.edu.cn/~guanxuetao/linux/uc4-1.0.5-hard.tgz (about 100MB) It should be un-tar to /usr/unicore/gnu-toolchain-unicore directory.
Quoted 3 lines
Further, you should find a way to publish git trees with your code, since a patch on a web site is less than ideal for transporting code changes, especially once the code gets merged into linux-next and mainline
afterwards.
Quoted 4 lines
If your university or company has problems setting up an official git server, you can ask for an account on kernel.org, see
http://www.kernel.org/faq/#account
[Guan] I have requested for kernel.org account, but no response now.
Quoted 5 lines
Detailed comments below.
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/boot/compressed/decompress.clinux-2.6.37.y/arch/unicore32/boot/compressed/decompress.c
Quoted 8 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/boot/compressed/misc.clinux-2.6.37.y/arch/unicore32/boot/compressed/misc.cThese two files look very generic. It may be a good time to now move them into the global
lib/directory and make them usable by all architectures that do not require special fixups in the decompress code.
[Guan] I have modified these files, and make it more generic.
Quoted 3 lines
Quoted 1 line
+MKIMAGE := $(srctree)/scripts/mkuboot.sh
Do you have u-boot support as well?
[Guan] Yes, we use u-boot as bootloader.
Quoted 10 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+CONFIG_CMDLINE_FROM_U_BOOT=y +CONFIG_CMDLINE="mem=512M ignore_loglevelvideo=unifb:1024x600-16@75 root=/dev/nfs rw nfsroot=/home/nfs/uc3,rsize=1024,wsize=1024 ip=192.168.10.83:192.168.10.82:192.168.10.1:255.255.255.0::eth0:off"
You should never need to pass the memory size in the command line. Please ensure that the boot loader always passes the memory size using your boot protocol (ideally in a device tree).
[Guan] CMDLINE will only be used when no bootloader params.
And u-boot params have another cmdline to replace this one.
Quoted 2 lines
Similarly, the frame buffer size should ideally be autodetected using hardware or the boot protocol, though that can be harder.
[Guan] I have to remain this method at present.
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/configs/nb0916_defconfig linux-2.6.37.y/arch/unicore32/configs/nb0916_defconfig
Quoted 1 line
--- linux-2.6.37-rc1/arch/unicore32/configs/nb0916_defconfig
1970-01-01
Quoted 7 lines
08:00:00.000000000 +0800
Quoted 1 line
+++ linux-2.6.37.y/arch/unicore32/configs/nb0916_defconfig 2010-11-08
10:14:07.110692045 +0800
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/configs/smw0919_defconfig linux-2.6.37.y/arch/unicore32/configs/smw0919_defconfig
Quoted 8 lines
Quoted 1 line
--- linux-2.6.37-rc1/arch/unicore32/configs/smw0919_defconfig
1970-01-01 08:00:00.000000000 +0800Quoted 1 line
+++ linux-2.6.37.y/arch/unicore32/configs/smw0919_defconfig
2010-11-08 10:14:07.110692045 +0800The files look mostly identical. If there is no fundamental difference between them, I would recommend providing only a single defconfig file that works on all the machines.
[Guan] nb0916 is for netbook and desktop, and CONFIG_MODULES must be enabled.
Smw0919 is for safety embedded devices, only necessary devices/drivers are
integrated.
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/dma.hlinux-2.6.37.y/arch/unicore32/include/asm/dma.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/dma.h1970-01-01
Quoted 8 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/dma.h2010-11-1109:55:29.517572760 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,34 @@ +/* + * linux/arch/unicore32/include/asm/dma.hJust use the asm-generic file.
[Guan] when I set MAX_DMA_ADDRESS to PAGE_OFFSET, some pci drivers have problem.
I will check it later.
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/fixmap.hlinux-2.6.37.y/arch/unicore32/include/asm/fixmap.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/fixmap.h1970-01-01
Quoted 8 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/fixmap.h2010-11-0815:36:42.574862020 +0800
Review line 4
Quoted 5 lines
(quoted diff) +4
-0@@ -0,0 +1,51 @@ +/* + * Nothing too fancy for now. + * + * On UniCore we already have well known fixed virtual addresses
imposed
Quoted 2 lines
by
Quoted 1 line
(quoted diff) +1
-0+ * the architecture such as the vector page which is located at
0xffff0000,
Quoted 3 lines
The comment is copied from ARM, but is it really true on unicore?
[Guan] Yes.
Quoted 7 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/highmem.hlinux-2.6.37.y/arch/unicore32/include/asm/highmem.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/highmem.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/highmem.h2010-11-0815:53:09.077836027 +0800
Quoted 8 lines
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,53 @@ +/* + * linux/arch/unicore32/include/asm/highmem.hWhat is the maximum amount of memory you support on the 32 bit machines? We're removing all the optimizations for highmem from the kernel now, so I would recommend not to support this in new architectures if you can avoid it.
[Guan] we need to support 2GB memory.
Quoted 6 lines
Quoted 2 lines
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/io.hlinux-2.6.37.y/arch/unicore32/include/asm/io.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/io.h1970-01-0108:00:00.000000000 +0800
Quoted 8 lines
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/io.h2010-11-1110:23:14.258566201 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,275 @@ +/* + * linux/arch/unicore32/include/asm/io.hThis also looks similar to the asm-generic version. Can you use that, or possibly change it enough so you can?
[Guan] I recommend splitting asm-generic/io.h into io.h and ioremap.h
Quoted 10 lines
Review line 9
Quoted 7 lines
(quoted diff) +7
-0+/* + * Use this value to indicate lack of interrupt + * capability + */ +#ifndef NO_IRQ +#define NO_IRQ ((unsigned int)(-1)) +#endifThis should not be required at all any more.
[Guan] amba bus driver need NO_IRQ
Quoted 2 lines
Review line 11
Quoted 2 lines
(quoted diff) +2
-0+##### +# Auto Generate the files that only include the corresponding
asm-generic
Quoted 2 lines
file
Quoted 1 line
(quoted diff) +1
-0+# 6 files in 27-uc: errno.h fcntl.h ioctl.h poll.h resource.h
siginfo.h
Quoted 9 lines
Review line 17
Quoted 5 lines
(quoted diff) +5
-0+ +define cmd_asmgeneric + (set -e; \ + echo '#include <asm-generic/$(notdir $@)>' ) > $@ +endefNice trick. I'd love to have something like this in the common code so we can do the same for all architectures.
Quoted 3 lines
Does this work with external object directories, i.e. building with make O=objdir, and with make
headers_install?
[Guan] For UniCore, more than forty headers are auto generated.
However, if all non-exist headers are auto-generated, it would make a
terrible mess.
So, it should depend on archprepare rule in arch/xxx/Makefile, but not inKbuild.
I think the arch maintainers should determine which files are needed. Also, make headers_install works well.
Quoted 36 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/pci.hlinux-2.6.37.y/arch/unicore32/include/asm/mach/pci.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/pci.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/mach/pci.h2010-11-0817:46:49.475569661 +0800
Quoted 29 lines
(quoted diff) +28
-0@@ -0,0 +1,65 @@ +/* + * linux/arch/unicore32/include/asm/mach/pci.h + +struct hw_pci { +#ifdef CONFIG_PCI_DOMAINS + int domain; +#endif + struct list_head buses; + int nr_controllers; + int (*setup)(int nr, struct pci_sys_data *); + struct pci_bus *(*scan)(int nr, struct pci_sys_data *); + void (*preinit)(void); + void (*postinit)(void); + u8 (*swizzle)(struct pci_dev *dev, u8 *pin); + int (*map_irq)(struct pci_dev *dev, u8 slot, u8 pin); +}; + +/* + * Per-controller structure + */ +struct pci_sys_data { +#ifdef CONFIG_PCI_DOMAINS + int domain; +#endif + struct list_head node; + int busnr; /* primary bus number */ + u64 mem_offset; /* bus->cpu memory mapping offset */ + unsigned long io_offset; /* bus->cpu IO mapping offset */
Quoted 8 lines
Review line 36
Quoted 8 lines
(quoted diff) +8
-0+ struct pci_bus *bus; /* PCI bus */ + struct resource *resource[3]; /* Primary PCI bus resources */ + /* Bridge swizzling */ + u8 (*swizzle)(struct pci_dev *, u8 *); + /* IRQ mapping */ + int (*map_irq)(struct pci_dev *, u8, u8); + struct hw_pci *hw; + void *private_data; /* platform controller private data
*/
Quoted 8 lines
Review line 37
Quoted 1 line
(quoted diff) +1
-0+};These are two separate abstractions for multiple PCI controllers, but your code does not even contain one implementation.
I can only assume that you actually have a PCI implementation, but if you do not have more than one, you are better off implementing just the one you have instead of extra wrappers.
[Guan] we do have pci bus and pci driver. I have to implement these interface for pci compatibility.
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/time.hlinux-2.6.37.y/arch/unicore32/include/asm/mach/time.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/time.h1970-01-01
Quoted 8 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/mach/time.h2010-11-0817:48:06.111456784 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,52 @@ +/* + * linux/arch/unicore32/include/asm/mach/time.hCan be removed when you get rid of the
machine_descabstraction.
[Guan] sys_timer can't be removed, which is used for device register.
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/memblock.hlinux-2.6.37.y/arch/unicore32/include/asm/memblock.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/memblock.h1970-01-01
Quoted 8 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/memblock.h2010-11-1018:59:14.326006751 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,22 @@ +/* + * linux/arch/unicore32/include/asm/memblock.hThis too.
[Guan] we use memblock as infrastructure, and perhaps it's not good.
Quoted 1 line
Also, do you actually support both MMU and NOMMU modes?
[Guan] Only support MMU mode.
Quoted 30 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/swab.hlinux-2.6.37.y/arch/unicore32/include/asm/swab.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/swab.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/swab.h2010-11-0909:28:21.005577540 +0800
Quoted 23 lines
(quoted diff) +22
-0@@ -0,0 +1,51 @@ +/* + * linux/arch/unicore32/include/asm/swab.h + * + * Code specific to PKUnity SoC and UniCore ISA + * + * Copyright (C) 2001-2008 GUAN Xue-tao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * In little endian mode, the data bus is connected such + * that byte accesses appear as: + * 0 = d0...d7, 1 = d8...d15, 2 = d16...d23, 3 = d24...d31 + * and word accesses (data or instruction) appear as: + * d0...d31 + */ +#ifndef __UNICORE_SWAB_H__ +#define __UNICORE_SWAB_H__ + +#include <linux/compiler.h> +#include <linux/types.h>
Quoted 8 lines
Review line 28
Quoted 6 lines
(quoted diff) +6
-0+ +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __SWAB_64_THRU_32__ +#endif + +static inline __attribute_const__ __u32 __arch_swab32(__u32 x)Can't you use the __builtin_bswap32/__builtin_bswap64 provided by gcc?
[Guan] __bswapsi2 is in libgcc, which is needed by __builtin_bswap32.
Quoted 5 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/uaccess.hlinux-2.6.37.y/arch/unicore32/include/asm/uaccess.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/uaccess.h1970-01-0108:00:00.000000000 +0800
Quoted 8 lines
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/uaccess.h2010-11-0911:33:30.209566466 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,408 @@ +/* + * linux/arch/unicore32/include/asm/uaccess.hPlease have another look at the asm-generic version of this file. With the current version it may be useful to base on that.
[Guan] __copy_from_user and __copy_to_user is too expensive for 1/2/4 words.
Quoted 10 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/unistd.hlinux-2.6.37.y/arch/unicore32/include/asm/unistd.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/unistd.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/unistd.h2010-11-1110:47:36.743710466 +0800
Please use the cleaned-up asm-generic version as
arch/tiledoes now. You add a lot of overhead otherwise.
[Guan] we use __NR_* as the immediate number in soft-interrupt instruction.
And if the syscall number changed, all software and toolchain need
re-compiled.
Quoted 2 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/Kconfig
linux-2.6.37.y/arch/unicore32/Kconfig
Quoted 1 line
Quoted 1 line
--- linux-2.6.37-rc1/arch/unicore32/Kconfig 1970-01-01
08:00:00.000000000
Quoted 2 lines
+0800
Quoted 1 line
+++ linux-2.6.37.y/arch/unicore32/Kconfig 2010-11-11
10:40:02.001225028
Quoted 16 lines
+0800
Review line 11
Quoted 12 lines
(quoted diff) +11
-0@@ -0,0 +1,337 @@ + config ARCH_PUV3 + bool "PKUnity v3 (SuperK)" + select CPU_UCV2 + select PKUNITY_AMBA + select ZONE_DMA + select EMBEDDED + select GENERIC_CLOCKEVENTS + select HAVE_CLK + select ARCH_USES_GETTIMEOFFSET + select ARCH_REQUIRE_GPIOLIB + select ARCH_HAS_CPUFREQYou might not want to select
ZONE_DMAandARCH_USES_GETTIMEOFFSET, since you are generally better off without them.
[Guan] We need ZONE_DMA for only 128M low memory could be used for DMA.
Quoted 2 lines
That's all for now, let's discuss my comments first and then I'll start commenting on the next parts.
[Guan] Thank you very much!
Guan Xuetao
Generic support for asm-generic headers [Was: a new UniCore32 arch-dependent patch for linux-2.6.37-rc1]
Quoted 15 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+##### +# Auto Generate the files that only include the correspondingasm-generic
Quoted 2 lines
file
Quoted 1 line
+# 6 files in 27-uc:
errno.hfcntl.hioctl.hpoll.hresource.h
siginfo.hQuoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ +define cmd_asmgeneric + (set -e; \ + echo '#include <asm-generic/$(notdir $@)>' ) > $@ +endefNice trick. I'd love to have something like this in the common code so we can do the same for all architectures.
Just a quick proof-of-concept hack.
Sam
Makefile +10 -2
@@ -344,7 +344,9 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage # Use LINUXINCLUDE when you must reference the include/ directory. # Needed to be compatible with the O= option -LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \ +LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \ + $(if $(KBUILD_SRC), -Iarch/$(hdr-arch)/include) \ + -Iinclude \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ -include include/generated/autoconf.h
@@ -950,7 +952,13 @@ prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \ archprepare: prepare1 scripts_basic -prepare0: archprepare FORCE +archheaders: $(addprefix arch/$(SRCARCH)/include/asm/, $(ARCH_GENERIC_HEADERS)) + +$(addprefix arch/$(SRCARCH)/include/asm/, $(ARCH_GENERIC_HEADERS)): arch/$(SRCARCH)/Makefile + $(Q)mkdir -p $(dir $@) + $(Q)echo '#include <asm-generic/$(notdir $@)>' > $@ + +prepare0: archprepare archheaders FORCE $(Q)$(MAKE) $(build)=. $(Q)$(MAKE) $(build)=. missing-syscalls
arch/x86/Makefile +2 -0
@@ -12,6 +12,8 @@ endif # e.g.: obj-y += foo_$(BITS).o export BITS +ARCH_GENERIC_HEADERS := termios.h + ifeq ($(CONFIG_X86_32),y) BITS := 32 UTS_MACHINE := i386
arch/x86/include/asm/termios.h deleted +0 -1
@@ -1 +0,0 @@ -#include <asm-generic/termios.h>
Arnd Bergmann
maintainerQuoted 11 lines · Guan
Please download second patches for review:
Replying Arnd's:
Quoted 4 lines
It would be good if you could make a tool chain available, ideally both a patch against gcc and pre-built binaries for an x86-unicore cross compiler. This is not strictly required, but it helps to get people to do build tests on your code.
[Guan] please download x86-unicore cross toolchain from:
http://mprc.pku.edu.cn/~guanxuetao/linux/uc4-1.0.5-hard.tgz (about 100MB) It should be un-tar to /usr/unicore/gnu-toolchain-unicore directory.
Ok, thanks for making this available.
Quoted 6 lines
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+CONFIG_CMDLINE_FROM_U_BOOT=y +CONFIG_CMDLINE="mem=512M ignore_loglevelvideo=unifb:1024x600-16@75 root=/dev/nfs rw nfsroot=/home/nfs/uc3,rsize=1024,wsize=1024 ip=192.168.10.83:192.168.10.82:192.168.10.1:255.255.255.0::eth0:off"
Quoted 6 lines
Quoted 4 lines
You should never need to pass the memory size in the command line. Please ensure that the boot loader always passes the memory size using your boot protocol (ideally in a device tree).
[Guan] CMDLINE will only be used when no bootloader params.
And u-boot params have another cmdline to replace this one.
Well, my point was more specifically that having to provide options on the command line that are hardware specific is wrong, independent of whether they come from the hardcoded command line or from u-boot.
The command line can of course be used for boot device configuration like the NFS root stuff (which I still would not put in the defconfig), but memory size and screen resolution are something that should always be detectable these days.
Quoted 7 lines
Quoted 3 lines
The files look mostly identical. If there is no fundamental difference between them, I would recommend providing only a single defconfig file that works on all the machines.
[Guan] nb0916 is for netbook and desktop, and
CONFIG_MODULESmust be enabled.
Smw0919 is for safety embedded devices, only necessary devices/drivers are
integrated.
The defconfig is not typically used without modifications on real systems, but serves as a starting point. If it's reasonable to build a configuration with all the smw0919 device drivers built-in and the additional nb0916 drivers as loadable modules, I guess that would make a reasonable defconfig. On smw0919 hardware, you can then just choose not to install the modules into the root file system.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/dma.hlinux-2.6.37.y/arch/unicore32/include/asm/dma.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/dma.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/dma.h2010-11-1109:55:29.517572760 +0800
Quoted 8 lines
Quoted 5 lines
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,34 @@ +/* + * linux/arch/unicore32/include/asm/dma.hJust use the asm-generic file.
[Guan] when I set
MAX_DMA_ADDRESStoPAGE_OFFSET, some pci drivers have problem.
I will check it later.
Interesting. You already allow to override MAX_DMA_ADDRESS to (PAGE_OFFSET + SZ_128M) when PCI is enabled. It would be good to find out (and document!) the signficance of the extra 128MB here.
If it turns out to be required, please make a patch to the asm-generic/dma.h file to allow overriding MAX_DMA_ADDRESS in the same way you do in your version.
Quoted 8 lines
Quoted 7 lines
Review line 6
Quoted 4 lines
(quoted diff) +4
-0+ * Nothing too fancy for now. + * + * On UniCore we already have well known fixed virtual addresses imposed by + * the architecture such as the vector page which is located at 0xffff0000,The comment is copied from ARM, but is it really true on unicore?
[Guan] Yes.
In what way does the architecture enforce this? What are the contents of this page? Can you make it an actual VDSO rather than a magic page that sits in the user address space?
Quoted 15 lines
Quoted 7 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/highmem.hlinux-2.6.37.y/arch/unicore32/include/asm/highmem.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/highmem.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/highmem.h2010-11-0815:53:09.077836027 +0800
Quoted 8 lines
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,53 @@ +/* + * linux/arch/unicore32/include/asm/highmem.hWhat is the maximum amount of memory you support on the 32 bit machines? We're removing all the optimizations for highmem from the kernel now, so I would recommend not to support this in new architectures if you can avoid it.
Quoted 1 line
[Guan] we need to support 2GB memory.
Would it be an option to have a fixed 2GB/2GB split between user and physical address space? That would limit the user addressable range to something just under 2GB (because of vmalloc/ioremap pages), but would significantly simplify and speed up user memory access from kernel space.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/io.hlinux-2.6.37.y/arch/unicore32/include/asm/io.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/io.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/io.h2010-11-1110:23:14.258566201 +0800
Quoted 7 lines
Quoted 6 lines
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,275 @@ +/* + * linux/arch/unicore32/include/asm/io.hThis also looks similar to the asm-generic version. Can you use that, or possibly change it enough so you can?
[Guan] I recommend splitting
asm-generic/io.hintoio.handioremap.h
Good idea. The ioremap parts of io.h are really specific to nommu architectures, while the other parts are specific to architectures that do not require specific ordering instructions.
Quoted 11 lines
Quoted 10 lines
Review line 9
Quoted 7 lines
(quoted diff) +7
-0+/* + * Use this value to indicate lack of interrupt + * capability + */ +#ifndef NO_IRQ +#define NO_IRQ ((unsigned int)(-1)) +#endifThis should not be required at all any more.
[Guan] amba bus driver need
NO_IRQ
That is a bug, as far as I can tell. I think it should be changed to a hardcoded (-1) in the amba drivers as we do elsewhere.
Until now, I was not even aware that we had an amba bus driver, and I'm not conviced that it's a good idea to use it either in its current form.
Most of the users of the amba bus currently declare static devices in the architecture tree, which is something that breaks a number of assumptions in the device model about the life time of device structures.
Quoted 11 lines
Quoted 11 lines
Review line 13
Quoted 4 lines
(quoted diff) +4
-0+define cmd_asmgeneric + (set -e; \ + echo '#include <asm-generic/$(notdir $@)>' ) > $@ +endefNice trick. I'd love to have something like this in the common code so we can do the same for all architectures.
Does this work with external object directories, i.e. building with make O=objdir, and with make
headers_install?
Quoted 6 lines
[Guan] For UniCore, more than forty headers are auto generated.
However, if all non-exist headers are auto-generated, it would make a
terrible mess.
So, it should depend on archprepare rule inarch/xxx/Makefile, but not inKbuild.
I think the arch maintainers should determine which files are needed.
Keeping the list in the architecture maintainer's hands sounds right. arch/xxx/Makefile however is really overloaded already, it contains all sorts of ad-hoc Makefile code, while a list of files to be generated would be more structured.
Quoted 1 line
Also, make
headers_installworks well.
Good.
Quoted 47 lines
Quoted 36 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/pci.hlinux-2.6.37.y/arch/unicore32/include/asm/mach/pci.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/pci.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/mach/pci.h2010-11-0817:46:49.475569661 +0800
Quoted 29 lines
(quoted diff) +28
-0@@ -0,0 +1,65 @@ +/* + * linux/arch/unicore32/include/asm/mach/pci.h + +struct hw_pci { +#ifdef CONFIG_PCI_DOMAINS + int domain; +#endif + struct list_head buses; + int nr_controllers; + int (*setup)(int nr, struct pci_sys_data *); + struct pci_bus *(*scan)(int nr, struct pci_sys_data *); + void (*preinit)(void); + void (*postinit)(void); + u8 (*swizzle)(struct pci_dev *dev, u8 *pin); + int (*map_irq)(struct pci_dev *dev, u8 slot, u8 pin); +}; + +/* + * Per-controller structure + */ +struct pci_sys_data { +#ifdef CONFIG_PCI_DOMAINS + int domain; +#endif + struct list_head node; + int busnr; /* primary bus number */ + u64 mem_offset; /* bus->cpu memory mapping offset */ + unsigned long io_offset; /* bus->cpu IO mapping offset */Quoted 8 lines
Review line 36
Quoted 8 lines
(quoted diff) +8
-0+ struct pci_bus *bus; /* PCI bus */ + struct resource *resource[3]; /* Primary PCI bus resources */ + /* Bridge swizzling */ + u8 (*swizzle)(struct pci_dev *, u8 *); + /* IRQ mapping */ + int (*map_irq)(struct pci_dev *, u8, u8); + struct hw_pci *hw; + void *private_data; /* platform controller private data*/
Quoted 2 lines
Quoted 1 line
(quoted diff) +1
-0+};
Quoted 8 lines
Quoted 6 lines
These are two separate abstractions for multiple PCI controllers, but your code does not even contain one implementation.
I can only assume that you actually have a PCI implementation, but if you do not have more than one, you are better off implementing just the one you have instead of extra wrappers.
[Guan] we do have pci bus and pci driver. I have to implement these interface for pci compatibility.
Ok. I would put the actual PCI implementation into the architecture patch series then, but get rid of the indirect function pointers.
Do you support multiple PCI domains (root bridges)?
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/time.hlinux-2.6.37.y/arch/unicore32/include/asm/mach/time.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/time.h1970-01-0108:00:00.000000000 +0800
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/mach/time.h2010-11-0817:48:06.111456784 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,52 @@ +/* + * linux/arch/unicore32/include/asm/mach/time.hCan be removed when you get rid of the
machine_descabstraction.[Guan]
sys_timercan't be removed, which is used for device register.
I don't understand. I can only see one sys_timer instance, the puv3_timer, so you can just as well hardcode access to that.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/memblock.hlinux-2.6.37.y/arch/unicore32/include/asm/memblock.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/memblock.h1970-01-0108:00:00.000000000 +0800
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/memblock.h2010-11-1018:59:14.326006751 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,22 @@ +/* + * linux/arch/unicore32/include/asm/memblock.hThis too.
[Guan] we use memblock as infrastructure, and perhaps it's not good.
No, there is nothing wrong with memblock.
My point was that the indirect function calls through machine_desc that you use here are not needed.
I would also recommend using only memblock and not also bootmem, by unconditionally setting CONFIG_NO_BOOTMEM.
Quoted 2 lines
Quoted 1 line
Also, do you actually support both MMU and NOMMU modes?
[Guan] Only support MMU mode.
ok
Quoted 16 lines
Quoted 16 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/swab.hlinux-2.6.37.y/arch/unicore32/include/asm/swab.hReview
Quoted 11 lines
(quoted diff) +11
-0+#ifndef __UNICORE_SWAB_H__ +#define __UNICORE_SWAB_H__ + +#include <linux/compiler.h> +#include <linux/types.h> + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __SWAB_64_THRU_32__ +#endif + +static inline __attribute_const__ __u32 __arch_swab32(__u32 x)Can't you use the __builtin_bswap32/__builtin_bswap64 provided by gcc?
Quoted 1 line
[Guan]
__bswapsi2is in libgcc, which is needed by__builtin_bswap32.
You could link against libgcc, see arch/tile/Makefile for an example how to do that.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/uaccess.hlinux-2.6.37.y/arch/unicore32/include/asm/uaccess.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/uaccess.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/uaccess.h2010-11-0911:33:30.209566466 +0800
Quoted 7 lines
Quoted 6 lines
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,408 @@ +/* + * linux/arch/unicore32/include/asm/uaccess.hPlease have another look at the asm-generic version of this file. With the current version it may be useful to base on that.
[Guan]
__copy_from_userand__copy_to_useris too expensive for 1/2/4 words.
The asm-generic version of __copy_from_user/__copy_to_user uses __builtin_constant_p() to optimize away all this overhead at build time, so even a copy_to_user(dst, src, 4) gets turned into a very small number of instructions.
This should work for both cases: when called with a constant size and when called from get_user/put_user.
I suppose you can do the same thing in your code.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/unistd.hlinux-2.6.37.y/arch/unicore32/include/asm/unistd.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/unistd.h1970-01-0108:00:00.000000000 +0800
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/unistd.h2010-11-1110:47:36.743710466 +0800
Please use the cleaned-up asm-generic version as
arch/tiledoes now. You add a lot of overhead otherwise.[Guan] we use __NR_* as the immediate number in soft-interrupt instruction.
And if the syscall number changed, all software and toolchain need
re-compiled.
Yes, I realize that. I think it would be very hard to integrate your architecture code without breaking compatibility, but breaking it once in order to fix all the problems arising from your backwards-compatibility code will make your life much easier in the long run.
One possible way to do the migration would be to do the upstream integration using only the new ABI, but keep a private patch that reverts to the existing ABI. At some point in the future, you can then declare the old ABI obsolete and drop the patch, supporting only the new ABI.
Quoted 24 lines
Quoted 2 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/Kconfig
linux-2.6.37.y/arch/unicore32/Kconfig
Quoted 1 line
Quoted 1 line
--- linux-2.6.37-rc1/arch/unicore32/Kconfig 1970-01-01
08:00:00.000000000
Quoted 2 lines
+0800
Quoted 1 line
+++ linux-2.6.37.y/arch/unicore32/Kconfig 2010-11-11
10:40:02.001225028
Quoted 16 lines
+0800
Review line 11
Quoted 12 lines
(quoted diff) +11
-0@@ -0,0 +1,337 @@ + config ARCH_PUV3 + bool "PKUnity v3 (SuperK)" + select CPU_UCV2 + select PKUNITY_AMBA + select ZONE_DMA + select EMBEDDED + select GENERIC_CLOCKEVENTS + select HAVE_CLK + select ARCH_USES_GETTIMEOFFSET + select ARCH_REQUIRE_GPIOLIB + select ARCH_HAS_CPUFREQYou might not want to select
ZONE_DMAandARCH_USES_GETTIMEOFFSET, since you are generally better off without them.
Quoted 1 line
[Guan] We need
ZONE_DMAfor only 128M low memory could be used for DMA.
Ok. Is this only for some device drivers, or is this a general limitation?
Arnd
Quoted 16 lines
Subject: Re: [PATCH] a new UniCore32 arch-dependent patch for linux- 2.6.37-rc1
Quoted 6 lines
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+CONFIG_CMDLINE_FROM_U_BOOT=y +CONFIG_CMDLINE="mem=512M ignore_loglevelvideo=unifb:1024x600-16@75 root=/dev/nfs rw nfsroot=/home/nfs/uc3,rsize=1024,wsize=1024 ip=192.168.10.83:192.168.10.82:192.168.10.1:255.255.255.0::eth0:off"
Quoted 6 lines
Quoted 4 lines
You should never need to pass the memory size in the command line. Please ensure that the boot loader always passes the memory size using your boot protocol (ideally in a device tree).
[Guan] CMDLINE will only be used when no bootloader params.
And u-boot params have another cmdline to replace this one.
Quoted 6 lines
Well, my point was more specifically that having to provide options on the command line that are hardware specific is wrong, independent of whether they come from the hardcoded command line or from u-boot.
The command line can of course be used for boot device configuration like the NFS root stuff (which I still would not put in the defconfig), but
memory
Quoted 2 lines
size and screen resolution are something that should always be detectable these days.
Ok, I will consider to remove memory size and screen resolution lator.
Quoted 10 lines
Quoted 4 lines
Quoted 3 lines
The files look mostly identical. If there is no fundamental difference between them, I would recommend providing only a single defconfig file that works on all the machines.
[Guan] nb0916 is for netbook and desktop, and
CONFIG_MODULESmustbe
Quoted 3 lines
enabled.
Smw0919 is for safety embedded devices, only necessary
devices/drivers are integrated.The defconfig is not typically used without modifications on real systems,
but
Quoted 1 line
serves as a starting point. If it's reasonable to build a configuration
with all the
Quoted 1 line
smw0919 device drivers built-in and the additional nb0916 drivers as
loadable
Quoted 3 lines
modules, I guess that would make a reasonable defconfig.
On smw0919 hardware, you can then just choose not to install the modules into the root file system.
Ok.
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/dma.hlinux-2.6.37.y/arch/unicore32/include/asm/dma.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/dma.h1970-01-0108:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/dma.h2010-11-1109:55:29.517572760 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,34 @@ +/* + * linux/arch/unicore32/include/asm/dma.hJust use the asm-generic file.
Quoted 8 lines
Quoted 3 lines
[Guan] when I set
MAX_DMA_ADDRESStoPAGE_OFFSET, some pci drivers have problem.
I will check it later.Interesting. You already allow to override
MAX_DMA_ADDRESSto (PAGE_OFFSET+SZ_128M) when PCI is enabled. It would be good to find out (and document!) the signficance of the extra 128MB here.
PCI controller in PKUnity-3 masks highest 5-bit for upstream channel, so we must
Limit the DMA allocation with 128M physical memory for supporting PCI devices.
Quoted 1 line
If it turns out to be required, please make a patch to the
asm-generic/dma.h
Quoted 2 lines
file to allow overriding
MAX_DMA_ADDRESSin the same way you do in your version.
I need to check it later.
I suppose MAX_DMA_ADDRESS is virtual address, so it should be larger than PAGE_OFFSET.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
(quoted diff) +6
-0+ * Nothing too fancy for now. + * + * On UniCore we already have well known fixed virtual addresses + imposed by + * the architecture such as the vector page which is located at + 0xffff0000,
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
The comment is copied from ARM, but is it really true on unicore?
[Guan] Yes.
In what way does the architecture enforce this? What are the contents of this page? Can you make it an actual VDSO rather than a magic page that
sits
Quoted 1 line
in the user address space?
Page table is created for vector page and exceptions entry stub. However, vector page is not in the user address space.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/highmem.hlinux-2.6.37.y/arch/unicore32/include/asm/highmem.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/highmem.h
1970-
Quoted 14 lines
01-01
Quoted 2 lines
Quoted 2 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/highmem.h2010-11-08
Quoted 6 lines
Quoted 6 lines
15:53:09.077836027 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,53 @@ +/* + * linux/arch/unicore32/include/asm/highmem.hWhat is the maximum amount of memory you support on the 32 bit
machines?
Quoted 3 lines
Quoted 3 lines
We're removing all the optimizations for highmem from the kernel now, so I would recommend not to support this in new architectures if you can avoid it.
Quoted 6 lines
Quoted 1 line
[Guan] we need to support 2GB memory.
Would it be an option to have a fixed 2GB/2GB split between user and physical address space? That would limit the user addressable range to something just under 2GB (because of vmalloc/ioremap pages), but would significantly simplify and speed up user memory access from kernel space.
Thanks. I consider not to support highmem in 32-bit address space.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Review line 9
Quoted 7 lines
(quoted diff) +7
-0+/* + * Use this value to indicate lack of interrupt + * capability + */ +#ifndef NO_IRQ +#define NO_IRQ ((unsigned int)(-1)) +#endifThis should not be required at all any more.
Quoted 3 lines
Quoted 1 line
[Guan] amba bus driver need
NO_IRQThat is a bug, as far as I can tell. I think it should be changed to a
hardcoded (-
Quoted 3 lines
1) in the amba drivers as we do elsewhere.
Until now, I was not even aware that we had an amba bus driver, and I'm
not
Quoted 4 lines
conviced that it's a good idea to use it either in its current form.
Most of the users of the amba bus currently declare static devices in the architecture tree, which is something that breaks a number of assumptions
in
Quoted 1 line
the device model about the life time of device structures.
Yes. Amba bus and NO_IRQ are removed.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/pci.hlinux-2.6.37.y/arch/unicore32/include/asm/mach/pci.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/pci.h
1970-
Quoted 3 lines
01-01
Quoted 2 lines
Quoted 2 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/mach/pci.h
2010-
Quoted 18 lines
11-08
Quoted 17 lines
Quoted 17 lines
17:46:49.475569661 +0800
Quoted 6 lines
(quoted diff) +5
-0@@ -0,0 +1,65 @@ +/* + * linux/arch/unicore32/include/asm/mach/pci.h + +struct hw_pci { +#ifdef CONFIG_PCI_DOMAINSReview line 15
Quoted 10 lines
(quoted diff) +10
-0+ int domain; +#endif + struct list_head buses; + int nr_controllers; + int (*setup)(int nr, struct pci_sys_data *); + struct pci_bus *(*scan)(int nr, struct pci_sys_data *); + void (*preinit)(void); + void (*postinit)(void); + u8 (*swizzle)(struct pci_dev *dev, u8 *pin); + int (*map_irq)(struct pci_dev *dev, u8 slot, u8
pin);
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Review line 26
Quoted 11 lines
(quoted diff) +11
-0+}; + +/* + * Per-controller structure + */ +struct pci_sys_data { +#ifdef CONFIG_PCI_DOMAINS + int domain; +#endif + struct list_head node; + int busnr; /* primary bus number
*/
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review line 27
Quoted 1 line
(quoted diff) +1
-0+ u64 mem_offset; /* bus->cpu memory mapping
offset
Quoted 2 lines
*/
Quoted 1 line
Quoted 1 line
Review line 28
Quoted 1 line
(quoted diff) +1
-0+ unsigned long io_offset; /* bus->cpu IO mapping
offset */
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review line 29
Quoted 1 line
(quoted diff) +1
-0+ struct pci_bus *bus; /* PCI bus
*/
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review line 30
Quoted 1 line
(quoted diff) +1
-0+ struct resource *resource[3]; /* Primary PCI bus resources
*/
Quoted 1 line
Quoted 1 line
Quoted 1 line
Review line 31
Quoted 1 line
(quoted diff) +1
-0+ /* Bridge swizzling
*/
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Review line 33
Quoted 2 lines
(quoted diff) +2
-0+ u8 (*swizzle)(struct pci_dev *, u8 *); + /* IRQ mapping*/Quoted 3 lines
Quoted 3 lines
Review line 36
Quoted 3 lines
(quoted diff) +3
-0+ int (*map_irq)(struct pci_dev *, u8, u8); + struct hw_pci *hw; + void *private_data; /* platform controller
private data
Quoted 9 lines
Quoted 9 lines
*/
Quoted 8 lines
Review line 37
Quoted 1 line
(quoted diff) +1
-0+};These are two separate abstractions for multiple PCI controllers, but your code does not even contain one implementation.
I can only assume that you actually have a PCI implementation, but if you do not have more than one, you are better off implementing just the one you have instead of extra wrappers.
Quoted 7 lines
Quoted 2 lines
[Guan] we do have pci bus and pci driver. I have to implement these interface for pci compatibility.
Ok. I would put the actual PCI implementation into the architecture patch series then, but get rid of the indirect function pointers.
Do you support multiple PCI domains (root bridges)?
No.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/time.hlinux-2.6.37.y/arch/unicore32/include/asm/mach/time.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/mach/time.h
1970-
Quoted 3 lines
01-01
Quoted 2 lines
Quoted 2 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/mach/time.h
2010-
Quoted 10 lines
11-08
Quoted 7 lines
Quoted 6 lines
17:48:06.111456784 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,52 @@ +/* + * linux/arch/unicore32/include/asm/mach/time.hCan be removed when you get rid of the
machine_descabstraction.[Guan]
sys_timercan't be removed, which is used for device register.I don't understand. I can only see one
sys_timerinstance, thepuv3_timer,
so
Quoted 1 line
you can just as well hardcode access to that.
Removed.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/memblock.hlinux-2.6.37.y/arch/unicore32/include/asm/memblock.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/memblock.h
1970-
Quoted 3 lines
01-01
Quoted 2 lines
Quoted 2 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/memblock.h
2010-
Quoted 7 lines
11-10
Quoted 6 lines
Quoted 6 lines
18:59:14.326006751 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,22 @@ +/* + * linux/arch/unicore32/include/asm/memblock.hThis too.
Quoted 5 lines
Quoted 1 line
[Guan] we use memblock as infrastructure, and perhaps it's not good.
No, there is nothing wrong with memblock.
My point was that the indirect function calls through
machine_descthat
you
Quoted 4 lines
use here are not needed.
I would also recommend using only memblock and not also bootmem, by unconditionally setting
CONFIG_NO_BOOTMEM.
I will consider it later.
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 2 lines
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/swab.hlinux-2.6.37.y/arch/unicore32/include/asm/swab.hReview
Quoted 10 lines
(quoted diff) +10
-0+#ifndef __UNICORE_SWAB_H__ +#define __UNICORE_SWAB_H__ + +#include <linux/compiler.h> +#include <linux/types.h> + +#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) # define +__SWAB_64_THRU_32__ #endif + +static inline __attribute_const__ __u32 __arch_swab32(__u32 x)Can't you use the __builtin_bswap32/__builtin_bswap64 provided by gcc?
Quoted 3 lines
Quoted 1 line
[Guan]
__bswapsi2is in libgcc, which is needed by__builtin_bswap32.You could link against libgcc, see
arch/tile/Makefilefor an example how
to do
Quoted 1 line
that.
Yes, it works. I think it's not a good idea. Kernel should be independent on libgcc.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/uaccess.hlinux-2.6.37.y/arch/unicore32/include/asm/uaccess.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/uaccess.h
1970-
Quoted 11 lines
01-01
Quoted 2 lines
Quoted 2 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/uaccess.h2010-11-09
Quoted 7 lines
Quoted 7 lines
11:33:30.209566466 +0800
Review line 2
Quoted 3 lines
(quoted diff) +2
-0@@ -0,0 +1,408 @@ +/* + * linux/arch/unicore32/include/asm/uaccess.hPlease have another look at the asm-generic version of this file. With the current version it may be useful to base on that.
Quoted 5 lines
Quoted 1 line
[Guan]
__copy_from_userand__copy_to_useris too expensive for 1/2/4words.
The asm-generic version of __copy_from_user/__copy_to_user uses
__builtin_constant_p()to optimize away all this overhead at build time,
so
Quoted 7 lines
even a
copy_to_user(dst, src, 4)gets turned into a very small number of instructions.This should work for both cases: when called with a constant size and when called from get_user/put_user.
I suppose you can do the same thing in your code.
Ok, I will do this work later.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/include/asm/unistd.hlinux-2.6.37.y/arch/unicore32/include/asm/unistd.hQuoted 1 line
---
linux-2.6.37-rc1/arch/unicore32/include/asm/unistd.h
1970-01-01
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
08:00:00.000000000 +0800
Quoted 1 line
+++
linux-2.6.37.y/arch/unicore32/include/asm/unistd.h2010-11-1110:47:36.743710466 +0800
Quoted 8 lines
Quoted 3 lines
Quoted 2 lines
Please use the cleaned-up asm-generic version as
arch/tiledoes now. You add a lot of overhead otherwise.[Guan] we use __NR_* as the immediate number in soft-interrupt
instruction.
Quoted 2 lines
And if the syscall number changed, all software and toolchain
need re-compiled.Yes, I realize that. I think it would be very hard to integrate your
architecture
Quoted 1 line
code without breaking compatibility, but breaking it once in order to fix
all
Quoted 5 lines
the problems arising from your backwards-compatibility code will make your life much easier in the long run.
One possible way to do the migration would be to do the upstream integration using only the new ABI, but keep a private patch that reverts
to
Quoted 1 line
the existing ABI. At some point in the future, you can then declare the
old
Quoted 1 line
ABI obsolete and drop the patch, supporting only the new ABI.
Good. We will just do the new ABI work recently, and it's a great idea.
Quoted 24 lines
Quoted 24 lines
Quoted 3 lines
Quoted 2 lines
diff -uprN -X linux-2.6.37-rc1/Documentation/dontdiff
linux-2.6.37-rc1/arch/unicore32/Kconfig
linux-2.6.37.y/arch/unicore32/Kconfig
Quoted 1 line
Quoted 1 line
--- linux-2.6.37-rc1/arch/unicore32/Kconfig 1970-01-01
08:00:00.000000000
Quoted 2 lines
+0800
Quoted 1 line
+++ linux-2.6.37.y/arch/unicore32/Kconfig 2010-11-11
10:40:02.001225028
Quoted 15 lines
+0800
Review line 11
Quoted 12 lines
(quoted diff) +11
-0@@ -0,0 +1,337 @@ + config ARCH_PUV3 + bool "PKUnity v3 (SuperK)" + select CPU_UCV2 + select PKUNITY_AMBA + select ZONE_DMA + select EMBEDDED + select GENERIC_CLOCKEVENTS + select HAVE_CLK + select ARCH_USES_GETTIMEOFFSET + select ARCH_REQUIRE_GPIOLIB + select ARCH_HAS_CPUFREQYou might not want to select
ZONE_DMAand
Quoted 6 lines
ARCH_USES_GETTIMEOFFSET,Quoted 2 lines
Quoted 1 line
since you are generally better off without them.
[Guan] We need
ZONE_DMAfor only 128M low memory could be used forDMA.
Ok. Is this only for some device drivers, or is this a general limitation?
The ZONE_DMA only limits pci devices, not a general limitation. However, many chips could be connected to different bus, so this limit influences global in our architecture.
Guan Xuetao
Arnd Bergmann
maintainerQuoted 12 lines · Guan Xuetao
Quoted 8 lines
Quoted 3 lines
[Guan] when I set
MAX_DMA_ADDRESStoPAGE_OFFSET, some pci drivers have problem.
I will check it later.Interesting. You already allow to override
MAX_DMA_ADDRESSto (PAGE_OFFSET+SZ_128M) when PCI is enabled. It would be good to find out (and document!) the signficance of the extra 128MB here.PCI controller in PKUnity-3 masks highest 5-bit for upstream channel, so we must Limit the DMA allocation with 128M physical memory for supporting PCI devices.
Quoted 6 lines
Quoted 3 lines
If it turns out to be required, please make a patch to the
asm-generic/dma.hfile to allow overridingMAX_DMA_ADDRESSin the same way you do in your version.I need to check it later.
I supposeMAX_DMA_ADDRESSis virtual address, so it should be larger thanPAGE_OFFSET.
I had a closer look again at this. MAX_DMA_ADDRESS is meant to reflect the size of ZONE_DMA, which it does in your patch.
However, something else is really wrong, in that ZONE_DMA (i.e. GFP_DMA) should only be used for legacy ISA devices like floppy or parallel port, not for PCI devices.
If your PCI bus can only do DMA to a limited memory range, you can not in general use MAX_DMA_ADDRESS/ZONE_DMA for this, but instead need to use the swiotlb code or a hardware IOMMU in place of your asm/dma-mapping.h file.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
+ * Nothing too fancy for now.
+ *
+ * On UniCore we already have well known fixed virtual addresses
+ imposed by
+ * the architecture such as the vector page which is located at
+0xffff0000,The comment is copied from ARM, but is it really true on unicore?
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
[Guan] Yes.
In what way does the architecture enforce this? What are the contents of this page? Can you make it an actual VDSO rather than a magic page that sits in the user address space?
Page table is created for vector page and exceptions entry stub. However, vector page is not in the user address space.
Interesting. So if it's not mapped into user space, why do you even need to have the vectors at a specific page? I think ARM only maps it to the high page because that page is shared to user space, while most architectures just have their interrupt vectors in the linar mapping, since the hardware typically uses the physical address to find it.
Quoted 3 lines
Quoted 2 lines
I would also recommend using only memblock and not also bootmem, by unconditionally setting
CONFIG_NO_BOOTMEM.I will consider it later.
ok.
Quoted 5 lines
Quoted 1 line
You could link against libgcc, see
arch/tile/Makefilefor an example howto do
Quoted 1 line
that.
Yes, it works. I think it's not a good idea. Kernel should be independent on libgcc.
I've seen both libgcc based and standalone library approaches in architectures, but I could never see a strong reaons for one way or another. Why do you think it should be independent? Licensing technical problems?
Quoted 10 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
You might not want to select
ZONE_DMAand
ARCH_USES_GETTIMEOFFSET,Quoted 2 lines
Quoted 1 line
since you are generally better off without them.
[Guan] We need
ZONE_DMAfor only 128M low memory could be used forDMA.
Ok. Is this only for some device drivers, or is this a general limitation?
The
ZONE_DMAonly limits pci devices, not a general limitation. However, many chips could be connected to different bus, so this limit influences global in our architecture.
As mentioned above, the drivers behind the PCI (except PCI-ISA bridges) should be using dma_map_single/dma_alloc_coherent instead of GFP_DMA to get DMA capable memory, so what you need instead is swiotlb.
Arnd
Quoted 34 lines
-----Original Message-----
From: [email protected] [mailto:linux-arch- [email protected]] On Behalf Of Arnd Bergmann
Sent: Tuesday, November 30, 2010 12:35 AM
To: Guan Xuetao
Cc: 'Greg KH'; 'Andrew Morton'; 'Linus Torvalds'; linux- [email protected]; [email protected]
Subject: Re: [PATCH] a new UniCore32 arch-dependent patch for linux- 2.6.37-rc1Quoted 1 line · Guan Xuetao
Quoted 1 line
Quoted 1 line
[Guan] when I set
MAX_DMA_ADDRESStoPAGE_OFFSET, some pcidrivers
Quoted 11 lines
Quoted 7 lines
Quoted 2 lines
have problem.
I will check it later.Interesting. You already allow to override
MAX_DMA_ADDRESSto (PAGE_OFFSET+SZ_128M) when PCI is enabled. It would be good to find out (and document!) the signficance of the extra 128MB here.PCI controller in PKUnity-3 masks highest 5-bit for upstream channel, so we must Limit the DMA allocation with 128M physical memory for supporting PCI devices.
Quoted 6 lines
Quoted 3 lines
If it turns out to be required, please make a patch to the
asm-generic/dma.hfile to allow overridingMAX_DMA_ADDRESSin the same way you do in your version.I need to check it later.
I supposeMAX_DMA_ADDRESSis virtual address, so it should be larger thanPAGE_OFFSET.
Quoted 5 lines
I had a closer look again at this.
MAX_DMA_ADDRESSis meant to reflect the size ofZONE_DMA, which it does in your patch.However, something else is really wrong, in that
ZONE_DMA(i.e.GFP_DMA) should only be used for legacy ISA devices like floppy or parallel port,
not for
Quoted 6 lines
PCI devices.
If your PCI bus can only do DMA to a limited memory range, you can not in general use MAX_DMA_ADDRESS/ZONE_DMA for this, but instead need to use the swiotlb code or a hardware IOMMU in place of your asm/dma-
mapping.hfile.
Ok. Since we have no pci peripherals in our products, I removed these codes.
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
Quoted 10 lines
Quoted 7 lines
+ * Nothing too fancy for now.
+ *
+ * On UniCore we already have well known fixed virtual
+ addresses imposed by
+ * the architecture such as the vector page which is located
+ at0xffff0000,The comment is copied from ARM, but is it really true on unicore?
[Guan] Yes.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
In what way does the architecture enforce this? What are the contents of this page? Can you make it an actual VDSO rather than a magic page that sits in the user address space?
Page table is created for vector page and exceptions entry stub. However, vector page is not in the user address space.
Interesting. So if it's not mapped into user space, why do you even need
to
Quoted 1 line
have the vectors at a specific page? I think ARM only maps it to the high
page
Quoted 1 line
because that page is shared to user space, while most architectures just
have
Quoted 1 line
their interrupt vectors in the linar mapping, since the hardware typically
uses
Quoted 1 line
the physical address to find it.
In UniCore-32, when MMU enabled, vector page address is virtual address.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
You could link against libgcc, see
arch/tile/Makefilefor an example howto do
Quoted 1 line
that.
Yes, it works. I think it's not a good idea. Kernel should be independent on libgcc.
I've seen both libgcc based and standalone library approaches in architectures, but I could never see a strong reaons for one way or
another.
Quoted 1 line
Why do you think it should be independent? Licensing technical problems?
No license problem, just my understanding. Thanks.
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
You might not want to select
ZONE_DMAand
ARCH_USES_GETTIMEOFFSET,Quoted 2 lines
Quoted 1 line
since you are generally better off without them.
[Guan] We need
ZONE_DMAfor only 128M low memory could be usedfor
Quoted 3 lines
Quoted 3 lines
DMA.
Ok. Is this only for some device drivers, or is this a general
limitation?
Quoted 7 lines
Quoted 3 lines
The
ZONE_DMAonly limits pci devices, not a general limitation. However, many chips could be connected to different bus, so this limit influences global in our architecture.As mentioned above, the drivers behind the PCI (except PCI-ISA bridges) should be using dma_map_single/dma_alloc_coherent instead of
GFP_DMAto get DMA capable memory, so what you need instead is swiotlb.
Ok, thanks.
Guan Xuetao
Arnd Bergmann
maintainerQuoted 8 lines · Guan Xuetao
Quoted 8 lines · Guan Xuetao
Quoted 6 lines
Quoted 4 lines
In what way does the architecture enforce this? What are the contents of this page? Can you make it an actual VDSO rather than a magic page that sits in the user address space?
Page table is created for vector page and exceptions entry stub. However, vector page is not in the user address space.
Quoted 7 lines
Quoted 5 lines
Interesting. So if it's not mapped into user space, why do you even need to have the vectors at a specific page? I think ARM only maps it to the high page because that page is shared to user space, while most architectures just have their interrupt vectors in the linar mapping, since the hardware typically uses the physical address to find it.
In UniCore-32, when MMU enabled, vector page address is virtual address.
Ok. I see.
The arch_exit_mmap() and arch_setup_additional_pages() functions seems to refer to how ARM maps this page into user space as well, you should probably change that.
I've finished the second half of the code review now, I'll follow up with an email but drop the personal Cc to everyone besides us, in case people are getting bored from the discussion by now ;-)
Arnd
Quoted 11 lines
-----Original Message-----
From: Arnd Bergmann [mailto:[email protected]]
Sent: Tuesday, November 30, 2010 11:27 PM
To: Guan Xuetao
Cc: 'Greg KH'; 'Andrew Morton'; 'Linus Torvalds'; linux- [email protected]; [email protected]
Subject: Re: [PATCH] a new UniCore32 arch-dependent patch for linux- 2.6.37-rc1
Quoted 14 lines
Quoted 13 lines · Guan Xuetao
Quoted 13 lines · Guan Xuetao
Quoted 6 lines
Quoted 4 lines
In what way does the architecture enforce this? What are the contents of this page? Can you make it an actual VDSO rather than a magic page that sits in the user address space?
Page table is created for vector page and exceptions entry stub. However, vector page is not in the user address space.
Interesting. So if it's not mapped into user space, why do you even need to have the vectors at a specific page? I think ARM only maps it to the high page because that page is shared to user space, while most architectures just have their interrupt vectors in the linar mapping, since the hardware typically uses the physical address to
find it.
Quoted 8 lines
Quoted 2 lines
In UniCore-32, when MMU enabled, vector page address is virtual address.
Ok. I see.
The
arch_exit_mmap()andarch_setup_additional_pages()functions seems to refer to how ARM maps this page into user space as well, you should probably change that.
Vector page is also used as kuser page, so arch_setup_additional_pages need to
Map it into user space.
Quoted 2 lines
I've finished the second half of the code review now, I'll follow up with
an
Quoted 2 lines
email but drop the personal Cc to everyone besides us, in case people are getting bored from the discussion by now ;-)
Thanks again.
Guan Xuetao