MIPS: Add Loongson-3 based machines support.
Subsystems (8)
PATCH v2 12/16 drm/radeon: Make radeon card usable for Loongson.
In reply to Huacai Chen1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset
occurs at resume from suspend).
--- drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/radeon/radeon_bios.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_device.c | 5 +++++ drivers/gpu/drm/radeon/radeon_ttm.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +- include/drm/drm_sarea.h | 2 ++ 6 files changed, 44 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_vm.c +1 -1
@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp =pgprot_writecombine (tmp); else tmp =pgprot_noncached (tmp); -#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__) tmp =pgprot_noncached (tmp);#endif return tmp;
drivers/gpu/drm/radeon/radeon_bios.c +32 -0
@@ -29,6 +29,7 @@#include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h>
@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)return true; } +#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr; +static bool loongson3_read_bios (struct radeon_device *rdev) +{ +u8 *bios; +resource_size_t size =512 *1024 ;/* ??? */ + + rdev->bios =NULL ; + + bios = (u8 *)vgabios_addr; +if (!bios) { +return false; + } + +if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { +return false; + } + rdev->bios =kmalloc (size,GFP_KERNEL ); +if (rdev->bios ==NULL ) { +return false; + } +memcpy (rdev->bios, bios, size); +return true; +} +#endif +static bool radeon_read_bios (struct radeon_device *rdev) {uint8_t __iomem *bios;
@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev)if (r == false) { r =radeon_read_disabled_bios (rdev); } +#ifdef CONFIG_CPU_LOONGSON3 +if (r == false) { + r =loongson3_read_bios (rdev); + } +#endif if (r == false || rdev->bios ==NULL ) {DRM_ERROR ("Unable to locate a BIOS ROM\n" ); rdev->bios =NULL ;
drivers/gpu/drm/radeon/radeon_device.c +5 -0
@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ?32 :40 ; r =pci_set_dma_mask (rdev->pdev,DMA_BIT_MASK (dma_bits));if (r) {
drivers/gpu/drm/radeon/radeon_ttm.c +3 -3
@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {return ttm_dma_populate (>t->ttm, rdev->dev); }
@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {ttm_dma_unpopulate (>t->ttm, rdev->dev);return ;
@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features =0 ; radeon_mem_types_list[i++].data =NULL ; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {sprintf (radeon_mem_types_names[i],"ttm_dma_page_pool" ); radeon_mem_types_list[i].name = radeon_mem_types_names[i];
drivers/gpu/drm/ttm/ttm_bo_util.c +1 -1
@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp) else tmp =pgprot_noncached (tmp);#endif -#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &TTM_PL_FLAG_CACHED )) tmp =pgprot_noncached (tmp);#endif
include/drm/drm_sarea.h +2 -0
@@ -37,6 +37,8 @@/* SAREA area needs to be at least a page */ #if defined(__alpha__)#define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U#elif defined(__ia64__)#define SAREA_MAX 0x10000U/* 64kB */ #else
Signature · 1 line
1.7.7.3
v2 cover MIPS: Add Loongson-3 based machines support.
This patchset is for git repository git://git.linux-mips.org/pub/scm/
ralf/linux. Loongson-3 is a multi-core MIPS family CPU, it is MIPS64R2 compatible and has the same IMP field (0x6300) as Loongson-2. These patches make Linux kernel support Loongson-3 CPU and Loongson-3 based computers (including Laptop, Mini-ITX, All-In-One PC, etc.)
V1 -> V2:
1, Split the first patch to two patches, one is constant definition and
the other is CPU probing, cache initializing, etc.
2, Remove Kconfig options in the first 9 patches and put all of them in
the 10th patch.
3, Use "make savedefconfig" to generate the new default config file. 4, Rework serial port support to use PORT and PORT_M macros. 5, Fix some compile warnings.
Huacai Chen(16):
MIPS: Loongson: Add basic Loongson-3 definition.
MIPS: Loongson: Add basic Loongson-3 CPU support.
MIPS: Loongson 3: Add Lemote-3A machtypes definition.
MIPS: Loongson: Make Loongson-3 to use BCD format for RTC.
MIPS: Loongson: Add UEFI-like firmware interface support.
MIPS: Loongson 3: Add HT-linked PCI support.
MIPS: Loongson 3: Add IRQ init and dispatch support.
MIPS: Loongson 3: Add serial port support.
MIPS: Loongson: Add swiotlb to support big memory (>4GB).
MIPS: Loongson: Add Loongson-3 Kconfig options.
ata: Use 32bit DMA in AHCI for Loongson 3. drm/radeon: Make radeon card usable for Loongson.
ALSA: HDA: Make hda sound card usable for Loongson.
MIPS: Loongson 3: Add Loongson-3 SMP support.
MIPS: Loongson 3: Add CPU Hotplug support.
MIPS: Loongson: Add a Loongson-3 default config file.
--- arch/mips/Kconfig | 23 + arch/mips/configs/loongson3_defconfig | 279 ++++++++++++ arch/mips/include/asm/addrspace.h | 6 + arch/mips/include/asm/bootinfo.h | 23 +- arch/mips/include/asm/cpu.h | 6 +- arch/mips/include/asm/mach-loongson/boot_param.h | 150 +++++++ .../mips/include/asm/mach-loongson/dma-coherence.h | 25 +- arch/mips/include/asm/mach-loongson/irq.h | 24 + arch/mips/include/asm/mach-loongson/loongson.h | 26 +- arch/mips/include/asm/mach-loongson/machine.h | 6 + arch/mips/include/asm/mach-loongson/mc146818rtc.h | 4 + arch/mips/include/asm/mach-loongson/pci.h | 5 + arch/mips/include/asm/mach-loongson/spaces.h | 15 + arch/mips/include/asm/module.h | 2 + arch/mips/include/asm/pgtable-bits.h | 7 + arch/mips/include/asm/smp.h | 1 + arch/mips/kernel/Makefile | 1 + arch/mips/kernel/cpu-probe.c | 12 +- arch/mips/kernel/process.c | 4 +- arch/mips/lib/Makefile | 1 + arch/mips/loongson/Kconfig | 52 +++ arch/mips/loongson/Makefile | 6 + arch/mips/loongson/Platform | 1 + arch/mips/loongson/common/Makefile | 5 + arch/mips/loongson/common/dma-swiotlb.c | 147 +++++++ arch/mips/loongson/common/env.c | 67 +++- arch/mips/loongson/common/init.c | 14 +- arch/mips/loongson/common/machtype.c | 5 +- arch/mips/loongson/common/mem.c | 42 ++ arch/mips/loongson/common/pci.c | 6 +- arch/mips/loongson/common/reset.c | 14 + arch/mips/loongson/common/serial.c | 25 +- arch/mips/loongson/common/setup.c | 6 +- arch/mips/loongson/common/uart_base.c | 8 +- arch/mips/loongson/loongson-3/Makefile | 6 + arch/mips/loongson/loongson-3/irq.c | 97 +++++ arch/mips/loongson/loongson-3/smp.c | 453 ++++++++++++++++++++ arch/mips/loongson/loongson-3/smp.h | 24 + arch/mips/mm/Makefile | 1 + arch/mips/mm/c-r4k.c | 84 ++++ arch/mips/mm/dma-default.c | 13 +- arch/mips/mm/tlb-r4k.c | 2 +- arch/mips/mm/tlbex.c | 1 + arch/mips/pci/Makefile | 1 + arch/mips/pci/fixup-loongson3.c | 50 +++ arch/mips/pci/ops-loongson3.c | 104 +++++ drivers/ata/ahci.c | 5 + drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/radeon/radeon_bios.c | 32 ++ drivers/gpu/drm/radeon/radeon_device.c | 5 + drivers/gpu/drm/radeon/radeon_ttm.c | 6 +- drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +- include/drm/drm_sarea.h | 2 + include/linux/pci_ids.h | 2 + sound/pci/hda/hda_intel.c | 5 + sound/pci/hda/patch_conexant.c | 52 +++- 56 files changed, 1898 insertions(+), 69 deletions(-) create mode 100644 arch/mips/configs/loongson3_defconfig create mode 100644 arch/mips/include/asm/mach-loongson/boot_param.h create mode 100644 arch/mips/include/asm/mach-loongson/irq.h create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h create mode 100644 arch/mips/loongson/common/dma-swiotlb.c create mode 100644 arch/mips/loongson/loongson-3/Makefile create mode 100644 arch/mips/loongson/loongson-3/irq.c create mode 100644 arch/mips/loongson/loongson-3/smp.c create mode 100644 arch/mips/loongson/loongson-3/smp.h create mode 100644 arch/mips/pci/fixup-loongson3.c create mode 100644 arch/mips/pci/ops-loongson3.c
Signature · 1 line
1.7.7.3
PATCH v2 1/16 MIPS: Loongson: Add basic Loongson-3 definition.
Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2 fully. Loongson-3 has the same IMP field (0x6300) as Loongson-2.
Loongson-3 has a hardware-maintained cache, system software doesn't need to maintain coherency.
Loongson-3A is the first revision of Loongson-3, and it is the quad- core version of Loongson-2G. Loongson-3A has a simplified version named Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two HyperTransport controller but 2Gq has only one. HT0 is used for cross- chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq cannot support NUMA but 3A can.
Exsisting Loongson family CPUs:
Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson-
2Gq), they are 64-bit MIPS CPUs.
Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.
--- arch/mips/include/asm/addrspace.h | 6 ++++++ arch/mips/include/asm/cpu.h | 6 ++++-- arch/mips/include/asm/mach-loongson/spaces.h | 15 +++++++++++++++ arch/mips/include/asm/module.h | 2 ++ arch/mips/include/asm/pgtable-bits.h | 7 +++++++ arch/mips/loongson/Platform | 1 + 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h
arch/mips/include/asm/addrspace.h +6 -0
@@ -116,7 +116,13 @@#define K_CALG_UNCACHED 2#define K_CALG_NONCOHERENT 3#define K_CALG_COH_EXCL 4 + +#ifdef CONFIG_CPU_LOONGSON3 +#define K_CALG_COH_SHAREABLE 3 +#else #define K_CALG_COH_SHAREABLE 5 +#endif +#define K_CALG_NOTUSED 6#define K_CALG_UNCACHED_ACCEL 7
arch/mips/include/asm/cpu.h +4 -2
@@ -72,6 +72,7 @@#define PRID_IMP_R5432 0x5400#define PRID_IMP_R5500 0x5500#define PRID_IMP_LOONGSON2 0x6300 +#define PRID_IMP_LOONGSON3 0x6300#define PRID_IMP_UNKNOWN 0xff00
@@ -199,6 +200,7 @@#define PRID_REV_34K_V1_0_2 0x0022#define PRID_REV_LOONGSON2E 0x0002#define PRID_REV_LOONGSON2F 0x0003 +#define PRID_REV_LOONGSON3A 0x0005/* * Older processors used to encode processor version and revision in two
@@ -267,8 +269,8 @@ enum cpu_type_enum {* MIPS64 class processors */ CPU_5KC ,CPU_5KE ,CPU_20KC ,CPU_25KF ,CPU_SB1 ,CPU_SB1A ,CPU_LOONGSON2 , -CPU_CAVIUM_OCTEON ,CPU_CAVIUM_OCTEON_PLUS ,CPU_CAVIUM_OCTEON2 , -CPU_XLR ,CPU_XLP , +CPU_LOONGSON3 ,CPU_CAVIUM_OCTEON ,CPU_CAVIUM_OCTEON_PLUS , +CPU_CAVIUM_OCTEON2 ,CPU_XLR ,CPU_XLP ,CPU_LAST };
arch/mips/include/asm/mach-loongson/spaces.h new file +15 -0
@@ -0,0 +1,15 @@ +#ifndef __ASM_MACH_LOONGSON_SPACES_H_ +#define __ASM_MACH_LOONGSON_SPACES_H_ + +#ifndef CAC_BASE +#if defined(CONFIG_64BIT ) +#if defined(CONFIG_DMA_NONCOHERENT ) || defined(CONFIG_CPU_LOONGSON3 ) +#define CAC_BASE _AC(0x9800000000000000, UL) +#else +#define CAC_BASE _AC(0xa800000000000000, UL) +#endif /* CONFIG_DMA_NONCOHERENT || CONFIG_CPU_LOONGSON3 */ +#endif /* CONFIG_64BIT */ +#endif /* CONFIG_CAC_BASE */ + +#include <asm/mach-generic/spaces.h> +#endif
arch/mips/include/asm/module.h +2 -0
@@ -119,6 +119,8 @@ search_module_dbetables(unsigned long addr)#define MODULE_PROC_FAMILY "SB1 "#elif definedCONFIG_CPU_LOONGSON2 #define MODULE_PROC_FAMILY "LOONGSON2 " +#elif definedCONFIG_CPU_LOONGSON3 +#define MODULE_PROC_FAMILY "LOONGSON3 "#elif definedCONFIG_CPU_CAVIUM_OCTEON #define MODULE_PROC_FAMILY "OCTEON "#elif definedCONFIG_CPU_XLR
arch/mips/include/asm/pgtable-bits.h +7 -0
@@ -206,6 +206,13 @@ static inline uint64_t pte_to_entrylo(unsigned long pte_val)#define _CACHE_UNCACHED _CACHE_UC_B#define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB +#elif defined(CONFIG_CPU_LOONGSON3 ) + +#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)/* LOONGSON */ +#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT)/* LOONGSON */ +#define _CACHE_CACHABLE_COHERENT (3<<_CACHE_SHIFT)/* LOONGSON-3 */ +#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)/* LOONGSON */ +#else #define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT)/* R4600 only */
arch/mips/loongson/Platform +1 -0
@@ -30,3 +30,4 @@ platform-$(CONFIG_MACH_LOONGSON) += loongson/ cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-loongson -mno-branch-likely load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000 +load-$(CONFIG_CPU_LOONGSON3) += 0xffffffff80200000
Signature · 1 line
1.7.7.3
PATCH v2 2/16 MIPS: Loongson: Add basic Loongson-3 CPU support.
In reply to Huacai ChenBasic Loongson-3 CPU support include: CPU probing, TLB and cache initializing, cache flushing method, etc.
--- arch/mips/kernel/Makefile | 1 + arch/mips/kernel/cpu-probe.c | 12 ++++- arch/mips/lib/Makefile | 1 + arch/mips/loongson/common/setup.c | 6 +- arch/mips/mm/Makefile | 1 + arch/mips/mm/c-r4k.c | 84 +++++++++++++++++++++++++++++++++++++ arch/mips/mm/tlb-r4k.c | 2 +- arch/mips/mm/tlbex.c | 1 + 8 files changed, 101 insertions(+), 7 deletions(-)
arch/mips/kernel/Makefile +1 -0
@@ -35,6 +35,7 @@ obj-$(CONFIG_MODULES) += mips_ksyms.o module.o obj-$(CONFIG_FUNCTION_TRACER) += mcount.o ftrace.o obj-$(CONFIG_CPU_LOONGSON2) += r4k_fpu.o r4k_switch.o +obj-$(CONFIG_CPU_LOONGSON3) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_MIPS32) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_MIPS64) += r4k_fpu.o r4k_switch.o obj-$(CONFIG_CPU_R3000) += r2300_fpu.o r2300_switch.o
arch/mips/kernel/cpu-probe.c +9 -3
@@ -619,16 +619,22 @@ static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu) c->tlbsize =64 ;break ;case PRID_IMP_LOONGSON2 : - c->cputype =CPU_LOONGSON2 ; - __cpu_name[cpu] ="ICT Loongson-2" ; -switch (c->processor_id &PRID_REV_MASK ) {case PRID_REV_LOONGSON2E : + c->cputype =CPU_LOONGSON2 ; + __cpu_name[cpu] ="ICT Loongson-2" ;set_elf_platform (cpu,"loongson2e" );break ;case PRID_REV_LOONGSON2F : + c->cputype =CPU_LOONGSON2 ; + __cpu_name[cpu] ="ICT Loongson-2" ;set_elf_platform (cpu,"loongson2f" );break ; +case PRID_REV_LOONGSON3A : + c->cputype =CPU_LOONGSON3 ; + __cpu_name[cpu] ="ICT Loongson-3" ; +set_elf_platform (cpu,"loongson3a" ); +break ; } c->isa_level =MIPS_CPU_ISA_III ;
arch/mips/lib/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-y += iomap.o obj-$(CONFIG_PCI) += iomap-pci.o obj-$(CONFIG_CPU_LOONGSON2) += dump_tlb.o +obj-$(CONFIG_CPU_LOONGSON3) += dump_tlb.o obj-$(CONFIG_CPU_MIPS32) += dump_tlb.o obj-$(CONFIG_CPU_MIPS64) += dump_tlb.o obj-$(CONFIG_CPU_NEVADA) += dump_tlb.o
arch/mips/loongson/common/setup.c +3 -3
@@ -18,9 +18,6 @@#include <linux/screen_info.h> #endif -void (*__wbflush)(void ); -EXPORT_SYMBOL (__wbflush); -static void wbflush_loongson (void ) { asm(".set\tpush\n\t"
@@ -32,6 +29,9 @@ static void wbflush_loongson(void) ".set mips0\n\t"); } +void (*__wbflush)(void ) = wbflush_loongson; +EXPORT_SYMBOL (__wbflush); +void __init plat_mem_setup (void ) { __wbflush = wbflush_loongson;
arch/mips/mm/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o tlb-r4k.o +obj-$(CONFIG_CPU_LOONGSON3) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_MIPS64) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_NEVADA) += c-r4k.o cex-gen.o tlb-r4k.o
arch/mips/mm/c-r4k.c +84 -0
149 lines not on this page · raw message
arch/mips/mm/tlb-r4k.c +1 -1
@@ -50,7 +50,7 @@ extern void build_tlb_refill_handler(void);#endif /* CONFIG_MIPS_MT_SMTC */ -#if defined(CONFIG_CPU_LOONGSON2 ) +#if defined(CONFIG_CPU_LOONGSON2 ) || defined(CONFIG_CPU_LOONGSON3 )/* * LOONGSON2 has a 4 entry itlb which is a subset of dtlb, * unfortrunately, itlb is not totally transparent to software.
arch/mips/mm/tlbex.c +1 -0
@@ -507,6 +507,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,case CPU_BMIPS4380 :case CPU_BMIPS5000 :case CPU_LOONGSON2 : +case CPU_LOONGSON3 :case CPU_R5500 :if (m4kc_tlbp_war ())uasm_i_nop (p);
Signature · 1 line
1.7.7.3
PATCH v2 3/16 MIPS: Loongson 3: Add Lemote-3A machtypes definition.
In reply to Huacai ChenAdd three Loongson 3 based machine types:MACH_LEMOTE_A1004 is laptop;MACH_LEMOTE_A1101 is mini-itx;MACH_LEMOTE_A1205 is all-in-one machine.
The most significant differrent between A1004 and A1101/A1205 is the laptop has EC but others don't.
--- arch/mips/include/asm/bootinfo.h | 23 ++++++++++++++--------- arch/mips/include/asm/mach-loongson/machine.h | 6 ++++++ arch/mips/loongson/common/machtype.c | 5 ++++- 3 files changed, 24 insertions(+), 10 deletions(-)
arch/mips/include/asm/bootinfo.h +14 -9
@@ -61,15 +61,20 @@/* * Valid machtype for Loongson family */ -#define MACH_LOONGSON_UNKNOWN 0 -#define MACH_LEMOTE_FL2E 1 -#define MACH_LEMOTE_FL2F 2 -#define MACH_LEMOTE_ML2F7 3 -#define MACH_LEMOTE_YL2F89 4 -#define MACH_DEXXON_GDIUM2F10 5 -#define MACH_LEMOTE_NAS 6 -#define MACH_LEMOTE_LL2F 7 -#define MACH_LOONGSON_END 8 +enum loongson_machine_type { +MACH_LOONGSON_UNKNOWN , +MACH_LEMOTE_FL2E , +MACH_LEMOTE_FL2F , +MACH_LEMOTE_ML2F7 , +MACH_LEMOTE_YL2F89 , +MACH_DEXXON_GDIUM2F10 , +MACH_LEMOTE_NAS , +MACH_LEMOTE_LL2F , +MACH_LEMOTE_A1004 , +MACH_LEMOTE_A1101 , +MACH_LEMOTE_A1205 , +MACH_LOONGSON_END +};/* * Valid machtype for group INGENIC
arch/mips/include/asm/mach-loongson/machine.h +6 -0
@@ -24,4 +24,10 @@#endif +#ifdef CONFIG_LEMOTE_MACH3A + +#define LOONGSON_MACHTYPE MACH_LEMOTE_A1004 + +#endif /* CONFIG_LEMOTE_MACH3A */ +#endif /* __ASM_MACH_LOONGSON_MACHINE_H */
arch/mips/loongson/common/machtype.c +4 -1
@@ -25,8 +25,11 @@ static const char *system_types[] = { [MACH_LEMOTE_ML2F7] "lemote-mengloong-2f-7inches", [MACH_LEMOTE_YL2F89] "lemote-yeeloong-2f-8.9inches", [MACH_DEXXON_GDIUM2F10] "dexxon-gdium-2f", - [MACH_LEMOTE_NAS] "lemote-nas-2f", + [MACH_LEMOTE_NAS] "lemote-nas-2f", [MACH_LEMOTE_LL2F] "lemote-lynloong-2f", + [MACH_LEMOTE_A1004] "lemote-3a-notebook-a1004", + [MACH_LEMOTE_A1101] "lemote-3a-itx-a1101", + [MACH_LEMOTE_A1205] "lemote-2gq-aio-a1205", [MACH_LOONGSON_END] NULL, };
Signature · 1 line
1.7.7.3
PATCH v2 4/16 MIPS: Loongson: Make Loongson-3 to use BCD format for RTC.
In reply to Huacai Chen--- arch/mips/include/asm/mach-loongson/mc146818rtc.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/mips/include/asm/mach-loongson/mc146818rtc.h +4 -0
@@ -27,7 +27,11 @@ static inline void CMOS_WRITE(unsigned char data, unsigned long addr)outb_p (data,RTC_PORT (1 )); } +#ifdef CONFIG_CPU_LOONGSON3 +#define RTC_ALWAYS_BCD 1 +#else #define RTC_ALWAYS_BCD 0 +#endif #ifndef mc146818_decode_year#define mc146818_decode_year (year) ((year) < 70 ? (year) + 2000 : (year) + 1970)
Signature · 1 line
1.7.7.3
PATCH v2 5/16 MIPS: Loongson: Add UEFI-like firmware interface support.
In reply to Huacai ChenThe new UEFI-like firmware interface has 3 advantages:
1, Firmware export a physical memory map which is similar to X86's
E820 map, so prom_init_memory() will be more elegant that #ifdef clauses can be removed.
2, Firmware export a pci irq routing table, we no longer need pci
irq routing fixup in kernel's code.
3, Firmware has a built-in vga bios, and its address is exported,
the linux kernel no longer need an embedded blob.
With the new interface, Loongson-3A/2G and all their successors can use a unified kernel. All Loongson-based machines support this new interface except 2E/2F series.
--- arch/mips/include/asm/mach-loongson/boot_param.h | 150 ++++++++++++++++++++++ arch/mips/include/asm/mach-loongson/loongson.h | 4 +- arch/mips/loongson/common/env.c | 67 ++++++++-- arch/mips/loongson/common/init.c | 9 +- arch/mips/loongson/common/mem.c | 42 ++++++ arch/mips/loongson/common/pci.c | 6 +- arch/mips/loongson/common/reset.c | 14 ++ 7 files changed, 272 insertions(+), 20 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/boot_param.h
arch/mips/include/asm/mach-loongson/boot_param.h new file +150 -0
@@ -0,0 +1,150 @@ +#ifndef __ASM_MACH_LOONGSON_BOOT_PARAM_H_ +#define __ASM_MACH_LOONGSON_BOOT_PARAM_H_ + +#define SYSTEM_RAM_LOW 1 +#define SYSTEM_RAM_HIGH 2 +#define MEM_RESERVED 3 +#define PCI_IO 4 +#define PCI_MEM 5 +#define LOONGSON_CFG_REG 6 +#define VIDEO_ROM 7 +#define ADAPTER_ROM 8 +#define ACPI_TABLE 9 +#define MAX_MEMORY_TYPE 10 + +#define LOONGSON3_BOOT_MEM_MAP_MAX 128 +struct efi_memory_map_loongson { +u16 vers;/* version of efi_memory_map */ +u32 nr_map;/* number of memory_maps */ +u32 mem_freq;/* memory frequence */ +struct mem_map { +u32 node_id;/* node_id which memory attached to */ +u32 mem_type;/* system memory, pci memory, pci io, etc. */ +u64 mem_start;/* memory map start address */ +u32 mem_size;/* each memory_map size, not the total size */ + }map[LOONGSON3_BOOT_MEM_MAP_MAX ]; +}__attribute__((packed)); + +enum loongson_cpu_type +{ + Loongson_2E, + Loongson_2F, + Loongson_3A, + Loongson_3B, + Loongson_1A, + Loongson_1B +}; + +/* +* Capability and feature descriptor structure for MIPS CPU +*/ +struct efi_cpuinfo_loongson { +u16 vers;/* version of efi_cpuinfo_loongson */ +u32 processor_id;/* PRID, e.g. 6305, 6306 */ +enum loongson_cpu_type cputype;/* 3A, 3B, etc. */ +u32 total_node;/* num of total numa nodes */ +u32 cpu_startup_core_id;/* Core id: */ +u32 cpu_clock_freq;/* cpu_clock */ +u32 nr_cpus; +}__attribute__((packed)); + +struct system_loongson { +u16 vers;/* version of system_loongson */ +u32 ccnuma_smp;/* 0:no numa; 1: has numa */ +u32 sing_double_channel;/* 1:single; 2:double */ +}__attribute__((packed)); + +struct irq_source_routing_table { +u16 vers; +u16 size; +u16 rtr_bus; +u16 rtr_devfn; +u32 vendor; +u32 device; +u32 PIC_type;/* conform use HT or PCI to route to CPU-PIC */ +u64 ht_int_bit;/* 3A: 1<<24; 3B:1<<16 */ +u64 ht_enable;/* irqs used in this PIC.eg:3a-0x0000d17a */ +u32 node_id;/* node id, 0x0—0, 0x1—1; 0x10—2;0x11—3;0x100—4 */ +u64 pci_mem_start_addr; +u64 pci_mem_end_addr; +u64 pci_io_start_addr; +u64 pci_io_end_addr; +u64 pci_config_addr; +}__attribute__((packed)); + +struct interface_info { +u16 vers;/* version of the specificition */ +u16 size; +u8 flag; +char description[64 ]; +}__attribute__((packed)); + +#define MAX_RESOURCE_NUMBER 128 +struct resource_loongson { +u64 start;/* resource start address */ +u64 end;/* resource end address */ +char name[64 ]; +u32 flags; +}; + +struct archdev_data {};/* arch specific additions */ + +struct board_devices { +char name[64 ];/* hold the device name */ +u32 num_resources;/* number of device_resource */ +struct resource_loongson resource[MAX_RESOURCE_NUMBER ];/* for each device's resource */ +/* arch specific additions */ +struct archdev_data archdata; +}; + +struct loongson_special_attribute { +u16 vers;/* version of this special */ +char special_name[64 ];/* special_atribute_name */ +u32 loongson_special_type;/* type of special device */ +struct resource_loongson resource[MAX_RESOURCE_NUMBER ];/* for each device's resource */ +}; + +struct loongson_params { +u64 memory_offset;/* efi_memory_map_loongson struct offset */ +u64 cpu_offset;/* efi_cpuinfo_loongson struct offset */ +u64 system_offset;/* system_loongson struct offset */ +u64 irq_offset;/* irq_source_routing_table struct offset */ +u64 interface_offset;/* interface_info struct offset */ +u64 special_offset;/* loongson_special_attribute struct offset */ +u64 boarddev_table_offset;/* board_devices offset */ +}; + +struct smbios_tables { +u16 vers;/* version of smbios */ +u64 vga_bios;/* vga_bios address */ +struct loongson_params lp; +}; + +struct efi_reset_system_t { +u64 ResetCold; +u64 ResetWarm; +u64 ResetType; +u64 Shutdown; +}; + +struct efi_loongson { +u64 mps;/* MPS table */ +u64 acpi;/* ACPI table (IA64 ext 0.71) */ +u64 acpi20;/* ACPI table (ACPI 2.0) */ +struct smbios_tables smbios;/* SM BIOS table */ +u64 sal_systab;/* SAL system table */ +u64 boot_info;/* boot info table */ +}; + +struct boot_params { +struct efi_loongson efi; +struct efi_reset_system_t reset_system; +}; + +extern u32 nr_cpus_loongson; +extern enum loongson_cpu_type cputype; +extern struct efi_memory_map_loongson *emap; +extern u64 ht_control_base; +extern u64 pci_mem_start_addr,pci_mem_end_addr; +extern u64 loongson_pciio_base; +#endif
arch/mips/include/asm/mach-loongson/loongson.h +2 -2
@@ -23,8 +23,8 @@ extern void mach_prepare_reboot(void);extern void mach_prepare_shutdown (void );/* environment arguments from bootloader */ -extern unsigned long cpu_clock_freq; -extern unsigned long memsize, highmemsize; +extern u32 cpu_clock_freq; +extern u32 memsize, highmemsize;/* loongson-specific command line, env and memory initialization */ extern void __init prom_init_memory (void );
arch/mips/loongson/common/env.c +54 -13
111 lines not on this page · raw message
arch/mips/loongson/common/init.c +5 -4
@@ -17,10 +17,6 @@ unsigned long __maybe_unused _loongson_addrwincfg_base;void __init prom_init (void ) { -/* init base address of io space */ -set_io_port_base ((unsigned long ) -ioremap (LOONGSON_PCIIO_BASE ,LOONGSON_PCIIO_SIZE )); -#ifdef CONFIG_CPU_SUPPORTS_ADDRWINCFG _loongson_addrwincfg_base = (unsigned long )ioremap (LOONGSON_ADDRWINCFG_BASE ,LOONGSON_ADDRWINCFG_SIZE );
@@ -28,6 +24,11 @@ void __init prom_init(void)prom_init_cmdline ();prom_init_env (); + +/* init base address of io space */ +set_io_port_base ((unsigned long ) +ioremap (LOONGSON_PCIIO_BASE ,LOONGSON_PCIIO_SIZE )); +prom_init_memory ();/*init the uart base address */
arch/mips/loongson/common/mem.c +42 -0
57 lines not on this page · raw message
arch/mips/loongson/common/pci.c +5 -1
@@ -11,6 +11,7 @@#include <pci.h> #include <loongson.h> +#include <boot_param.h> static struct resource loongson_pci_mem_resource = { .name ="pci memory space" ,
@@ -82,7 +83,10 @@ static int __init pcibios_init(void)setup_pcimap (); loongson_pci_controller.io_map_base = mips_io_port_base; - +#ifdef CONFIG_UEFI_FIRMWARE_INTERFACE + loongson_pci_mem_resource.start = pci_mem_start_addr; + loongson_pci_mem_resource.end = pci_mem_end_addr; +#endif register_pci_controller (&loongson_pci_controller);return 0 ;
arch/mips/loongson/common/reset.c +14 -0
@@ -36,17 +36,31 @@ static inline void loongson_reboot(void)static void loongson_restart (char *command) { +#ifndef CONFIG_UEFI_FIRMWARE_INTERFACE /* do preparation for reboot */ mach_prepare_reboot ();/* reboot via jumping to boot base address */ loongson_reboot (); +#else +extern u64 restart_addr; +void (*fw_restart)(void ) = (void *)restart_addr; + +fw_restart (); +#endif }static void loongson_poweroff (void ) { +#ifndef CONFIG_UEFI_FIRMWARE_INTERFACE mach_prepare_shutdown ();unreachable (); +#else +extern u64 poweroff_addr; +void (*fw_poweroff)(void ) = (void *)poweroff_addr; + +fw_poweroff (); +#endif }static void loongson_halt (void )
Signature · 1 line
1.7.7.3
PATCH v2 6/16 MIPS: Loongson 3: Add HT-linked PCI support.
In reply to Huacai ChenLoongson family machines use Hyper-Transport bus for inter-core connection and device connection. The PCI bus is a subordinate linked at HT1.
With UEFI-like firmware interface, We don't need PCI irq routing fixup.
--- arch/mips/include/asm/mach-loongson/loongson.h | 7 ++ arch/mips/include/asm/mach-loongson/pci.h | 5 + arch/mips/pci/Makefile | 1 + arch/mips/pci/fixup-loongson3.c | 50 +++++++++++ arch/mips/pci/ops-loongson3.c | 104 ++++++++++++++++++++++++ 5 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 arch/mips/pci/fixup-loongson3.c create mode 100644 arch/mips/pci/ops-loongson3.c
arch/mips/include/asm/mach-loongson/loongson.h +7 -0
@@ -14,6 +14,7 @@#include <linux/io.h> #include <linux/init.h> #include <linux/irq.h> +#include <boot_param.h> /* loongson internal northbridge initialization */ extern void bonito_irq_init (void );
@@ -100,7 +101,13 @@ static inline void do_perfcnt_IRQ(void)#define LOONGSON_PCICFG_BASE 0x1fe80000#define LOONGSON_PCICFG_SIZE 0x00000800/* 2K */ #define LOONGSON_PCICFG_TOP (LOONGSON_PCICFG_BASE+LOONGSON_PCICFG_SIZE-1) + +#if defined(CONFIG_HT_PCI ) +#define LOONGSON_PCIIO_BASE loongson_pciio_base +#else #define LOONGSON_PCIIO_BASE 0x1fd00000 +#endif +#define LOONGSON_PCIIO_SIZE 0x00100000/* 1M */ #define LOONGSON_PCIIO_TOP (LOONGSON_PCIIO_BASE+LOONGSON_PCIIO_SIZE-1)
arch/mips/include/asm/mach-loongson/pci.h +5 -0
@@ -40,8 +40,13 @@ extern struct pci_ops loongson_pci_ops;#else /* loongson2f/32bit & loongson2e */ /* this pci memory space is mapped by pcimap in pci.c */ +#ifdef CONFIG_CPU_LOONGSON3 +#define LOONGSON_PCI_MEM_START 0x40000000UL +#define LOONGSON_PCI_MEM_END 0x7effffffUL +#else #define LOONGSON_PCI_MEM_START LOONGSON_PCILO1_BASE#define LOONGSON_PCI_MEM_END (LOONGSON_PCILO1_BASE + 0x04000000 * 2) +#endif /* this is an offset from mips_io_port_base */ #define LOONGSON_PCI_IO_START 0x00004000UL
arch/mips/pci/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_MIPS_COBALT) += fixup-cobalt.o obj-$(CONFIG_SOC_PNX8550) += fixup-pnx8550.o ops-pnx8550.o obj-$(CONFIG_LEMOTE_FULOONG2E) += fixup-fuloong2e.o ops-loongson2.o obj-$(CONFIG_LEMOTE_MACH2F) += fixup-lemote2f.o ops-loongson2.o +obj-$(CONFIG_LEMOTE_MACH3A) += fixup-loongson3.o ops-loongson3.o obj-$(CONFIG_MIPS_MALTA) += fixup-malta.o obj-$(CONFIG_PMC_MSP7120_GW) += fixup-pmcmsp.o ops-pmcmsp.o obj-$(CONFIG_PMC_MSP7120_EVAL) += fixup-pmcmsp.o ops-pmcmsp.o
arch/mips/pci/fixup-loongson3.c new file +50 -0
50 lines not on this page · raw message
arch/mips/pci/ops-loongson3.c new file +104 -0
104 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 7/16 MIPS: Loongson 3: Add IRQ init and dispatch support.
In reply to Huacai ChenIRQ routing path of Loongson-3:
Devices(most) --> I8259 --> HT Controller --> IRQ Routing Table --> CPU
^
|Device(legacy devices such as UART) --> Bonito ---|
IRQ Routing Table route 32 INTs to CPU's INT0~INT3(IP2~IP5 of CP0), 32 INTs include 16 HT INTs(mostly), 4 PCI INTs, 1 LPC INT, etc. IP6 is used for IPI and IP7 is used for internal MIPS timer. LOONGSON_INT_ROUTER_* are IRQ Routing Table registers.
I8259 IRQs are 1:1 mapped to HT1 INTs. LOONGSON_HT1_* are configuration registers of HT1 controller.
--- arch/mips/include/asm/mach-loongson/irq.h | 24 +++++++ arch/mips/include/asm/mach-loongson/loongson.h | 9 +++ arch/mips/loongson/Makefile | 6 ++ arch/mips/loongson/loongson-3/Makefile | 4 + arch/mips/loongson/loongson-3/irq.c | 87 ++++++++++++++++++++++++ 5 files changed, 130 insertions(+), 0 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/irq.h create mode 100644 arch/mips/loongson/loongson-3/Makefile create mode 100644 arch/mips/loongson/loongson-3/irq.c
arch/mips/include/asm/mach-loongson/irq.h new file +24 -0
@@ -0,0 +1,24 @@ +#ifndef __ASM_MACH_LOONGSON_IRQ_H_ +#define __ASM_MACH_LOONGSON_IRQ_H_ + +#include <boot_param.h> + +/* cpu core interrupt numbers */ +#define MIPS_CPU_IRQ_BASE 56 + +#ifdef CONFIG_CPU_LOONGSON3 + +#define LOONGSON_UART_IRQ (MIPS_CPU_IRQ_BASE + 2)/* uart */ +#define LOONGSON_I8259_IRQ (MIPS_CPU_IRQ_BASE + 3)/* i8259 */ +#define LOONGSON_TIMER_IRQ (MIPS_CPU_IRQ_BASE + 7)/* cpu timer */ + +#define LOONGSON_HT1_CFG_BASE ht_control_base +#define LOONGSON_HT1_INT_VECTOR_BASE LOONGSON_HT1_CFG_BASE + 0x80 +#define LOONGSON_HT1_INT_EN_BASE LOONGSON_HT1_CFG_BASE + 0xa0 +#define LOONGSON_HT1_INT_VECTOR (n) LOONGSON3_REG32(LOONGSON_HT1_INT_VECTOR_BASE, 4 * n) +#define LOONGSON_HT1_INTN_EN (n) LOONGSON3_REG32(LOONGSON_HT1_INT_EN_BASE, 4 * n) + +#endif + +#include_next <irq.h> +#endif /* __ASM_MACH_LOONGSON_IRQ_H_ */
arch/mips/include/asm/mach-loongson/loongson.h +9 -0
@@ -61,6 +61,12 @@ extern int mach_i8259_irq(void);#define LOONGSON_REG (x) \ (*(volatile u32 *)((char *)CKSEG1ADDR(LOONGSON_REG_BASE) + (x))) +#define LOONGSON3_REG8 (base, x) \ + (*(volatile u8 *)((char *)TO_UNCAC(base) + (x))) + +#define LOONGSON3_REG32 (base, x) \ + (*(volatile u32 *)((char *)TO_UNCAC(base) + (x))) +#define LOONGSON_IRQ_BASE 32#define LOONGSON2_PERFCNT_IRQ (MIPS_CPU_IRQ_BASE + 6)/* cpu perf counter */
@@ -86,6 +92,9 @@ static inline void do_perfcnt_IRQ(void)#define LOONGSON_REG_BASE 0x1fe00000#define LOONGSON_REG_SIZE 0x00100000/* 256Bytes + 256Bytes + ??? */ #define LOONGSON_REG_TOP (LOONGSON_REG_BASE+LOONGSON_REG_SIZE-1) +#define LOONGSON3_REG_BASE 0x3ff00000 +#define LOONGSON3_REG_SIZE 0x00100000/* 256Bytes + 256Bytes + ??? */ +#define LOONGSON3_REG_TOP (LOONGSON3_REG_BASE+LOONGSON3_REG_SIZE-1)#define LOONGSON_LIO1_BASE 0x1ff00000#define LOONGSON_LIO1_SIZE 0x00100000/* 1M */
arch/mips/loongson/Makefile +6 -0
@@ -15,3 +15,9 @@ obj-$(CONFIG_LEMOTE_FULOONG2E) += fuloong-2e/ # obj-$(CONFIG_LEMOTE_MACH2F) += lemote-2f/ + +# +# All Loongson-3 family machines +# + +obj-$(CONFIG_CPU_LOONGSON3) += loongson-3/
arch/mips/loongson/loongson-3/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for Loongson-3 family machines +# +obj-y += irq.o
arch/mips/loongson/loongson-3/irq.c new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 8/16 MIPS: Loongson 3: Add serial port support.
In reply to Huacai ChenLoongson family machines has three types of serial port: PCI UART, LPC UART and CPU internal UART. Loongson-2E and parts of Loongson-2F based machines use PCI UART; most Loongson-2F based machines use LPC UART; Loongson-2G/3A has both LPC and CPU UART but usually use CPU UART.
Port address of UARTs:
CPU UART: REG_BASE + OFFSET;
LPC UART: LIO1_BASE + OFFSET;
PCI UART: PCIIO_BASE + OFFSET.
Since LPC UART are linked in "Local Bus", both CPU UART and LPC UART are called "CPU provided serial port".
--- arch/mips/loongson/common/serial.c | 25 ++++++++++++++----------- arch/mips/loongson/common/uart_base.c | 8 +++++++- 2 files changed, 21 insertions(+), 12 deletions(-)
arch/mips/loongson/common/serial.c +14 -11
@@ -19,19 +19,19 @@#include <loongson.h> #include <machine.h> -#define PORT (int) \ +#define PORT (int, clk) \ { \ .irq = int, \ - .uartclk = 1843200, \ + .uartclk = clk, \ .iotype = UPIO_PORT, \ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \ .regshift = 0, \ } -#define PORT_M (int) \ +#define PORT_M (int, clk) \ { \ .irq = MIPS_CPU_IRQ_BASE + (int), \ - .uartclk = 3686400, \ + .uartclk = clk, \ .iotype = UPIO_MEM, \ .membase = (void __iomem *)NULL, \ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, \
@@ -40,13 +40,16 @@static struct plat_serial8250_port uart8250_data[][2 ] = { [MACH_LOONGSON_UNKNOWN] {}, - [MACH_LEMOTE_FL2E] {PORT(4), {} }, - [MACH_LEMOTE_FL2F] {PORT(3), {} }, - [MACH_LEMOTE_ML2F7] {PORT_M(3), {} }, - [MACH_LEMOTE_YL2F89] {PORT_M(3), {} }, - [MACH_DEXXON_GDIUM2F10] {PORT_M(3), {} }, - [MACH_LEMOTE_NAS] {PORT_M(3), {} }, - [MACH_LEMOTE_LL2F] {PORT(3), {} }, + [MACH_LEMOTE_FL2E] {PORT(4, 1843200), {} }, + [MACH_LEMOTE_FL2F] {PORT(3, 1843200), {} }, + [MACH_LEMOTE_ML2F7] {PORT_M(3, 3686400), {} }, + [MACH_LEMOTE_YL2F89] {PORT_M(3, 3686400), {} }, + [MACH_DEXXON_GDIUM2F10] {PORT_M(3, 3686400), {} }, + [MACH_LEMOTE_NAS] {PORT_M(3, 3686400), {} }, + [MACH_LEMOTE_LL2F] {PORT(3, 1843200), {} }, + [MACH_LEMOTE_A1004] {PORT_M(2, 33177600), {} }, + [MACH_LEMOTE_A1101] {PORT_M(2, 25000000), {} }, + [MACH_LEMOTE_A1205] {PORT_M(2, 25000000), {} }, [MACH_LOONGSON_END] {}, };
arch/mips/loongson/common/uart_base.c +7 -1
@@ -35,9 +35,15 @@ void prom_init_loongson_uart_base(void)case MACH_DEXXON_GDIUM2F10 :case MACH_LEMOTE_NAS :default : -/* The CPU provided serial port */ +/* The CPU provided serial port (LPC) */ loongson_uart_base =LOONGSON_LIO1_BASE +0x3f8 ;break ; +case MACH_LEMOTE_A1004 : +case MACH_LEMOTE_A1101 : +case MACH_LEMOTE_A1205 : +/* The CPU provided serial port (CPU) */ + loongson_uart_base =LOONGSON_REG_BASE +0x1e0 ; +break ; } _loongson_uart_base =
Signature · 1 line
1.7.7.3
PATCH v2 9/16 MIPS: Loongson: Add swiotlb to support big memory (>4GB).
In reply to Huacai ChenThis is probably a workaround because Loongson doesn't support DMA address above 4GB. If memory is more than 4GB, CONFIG_SWIOTLB and ZONE_DMA32 should be selected. In this way, DMA pages are allocated below 4GB.
However, CONFIG_SWIOTLB+ZONE_DMA32 is not enough, so, in the following patches, drivers of block device, graphics card, sound card, etc. will all be set a DMA32 flags explitly.
--- .../mips/include/asm/mach-loongson/dma-coherence.h | 25 +++- arch/mips/loongson/common/Makefile | 5 + arch/mips/loongson/common/dma-swiotlb.c | 147 ++++++++++++++++++++ arch/mips/mm/dma-default.c | 13 ++- 4 files changed, 185 insertions(+), 5 deletions(-) create mode 100644 arch/mips/loongson/common/dma-swiotlb.c
arch/mips/include/asm/mach-loongson/dma-coherence.h +23 -2
@@ -13,26 +13,43 @@struct device ; +extern dma_addr_t phys_to_dma (struct device *dev,phys_addr_t paddr); +extern phys_addr_t dma_to_phys (struct device *dev,dma_addr_t daddr);static inline dma_addr_t plat_map_dma_mem (struct device *dev,void *addr,size_t size) { +#ifdef CONFIG_CPU_LOONGSON3 +return virt_to_phys (addr) <0x10000000 ? + (virt_to_phys (addr) |0x0000000080000000 ) :virt_to_phys (addr); +#else return virt_to_phys (addr) |0x80000000 ; +#endif }static inline dma_addr_t plat_map_dma_mem_page (struct device *dev,struct page *page) { +#ifdef CONFIG_CPU_LOONGSON3 +return page_to_phys (page) <0x10000000 ? + (page_to_phys (page) |0x0000000080000000 ) :page_to_phys (page); +#else return page_to_phys (page) |0x80000000 ; +#endif }static inline unsigned long plat_dma_addr_to_phys (struct device *dev,dma_addr_t dma_addr) { -#if defined(CONFIG_CPU_LOONGSON2F ) && defined(CONFIG_64BIT ) +#if defined(CONFIG_64BIT ) +#if defined(CONFIG_CPU_LOONGSON3 ) +return (dma_addr <0x90000000 && dma_addr >=0x80000000 ) ? + (dma_addr &0x0fffffff ) : dma_addr; +#elif defined(CONFIG_CPU_LOONGSON2F )return (dma_addr >0x8fffffff ) ? dma_addr : (dma_addr &0x0fffffff ); +#endif /* CONFIG_CPU_LOONGSON3 */ #else return dma_addr &0x7fffffff ; -#endif +#endif /* CONFIG_64BIT */ } static inline void plat_unmap_dma_mem(struct device *dev, dma_addr_t dma_addr,
@@ -65,7 +82,11 @@ static inline int plat_dma_mapping_error(struct device *dev,static inline int plat_device_is_coherent (struct device *dev) { +#ifdef CONFIG_DMA_NONCOHERENT return 0 ; +#else +return 1 ; +#endif /* CONFIG_DMA_NONCOHERENT */ }#endif /* __ASM_MACH_LOONGSON_DMA_COHERENCE_H */
arch/mips/loongson/common/Makefile +5 -0
@@ -25,3 +25,8 @@ obj-$(CONFIG_CS5536) += cs5536/ # obj-$(CONFIG_LOONGSON_SUSPEND) += pm.o + +# +# Big Memory Support +# +obj-$(CONFIG_LOONGSON_BIGMEM) += dma-swiotlb.o
arch/mips/loongson/common/dma-swiotlb.c new file +147 -0
147 lines not on this page · raw message
arch/mips/mm/dma-default.c +10 -3
@@ -42,6 +42,13 @@ static inline int cpu_is_noncoherent_r10000(struct device *dev) current_cpu_type() == CPU_R12000); } +static inline int cpu_is_noncoherent_loongson (struct device *dev) +{ +return !plat_device_is_coherent (dev) && + (current_cpu_type () ==CPU_LOONGSON2 || +current_cpu_type () ==CPU_LOONGSON3 ); +} +static gfp_t massage_gfp_flags (const struct device *dev,gfp_t gfp) {gfp_t dma_flag;
@@ -209,7 +216,7 @@ static inline void __dma_sync(struct page *page,static void mips_dma_unmap_page (struct device *dev,dma_addr_t dma_addr,size_t size,enum dma_data_direction direction,struct dma_attrs *attrs) { -if (cpu_is_noncoherent_r10000 (dev)) +if (cpu_is_noncoherent_r10000 (dev) ||cpu_is_noncoherent_loongson (dev))__dma_sync (dma_addr_to_page (dev, dma_addr), dma_addr & ~PAGE_MASK , size, direction);
@@ -260,7 +267,7 @@ static void mips_dma_unmap_sg(struct device *dev, struct scatterlist *sg,static void mips_dma_sync_single_for_cpu (struct device *dev,dma_addr_t dma_handle,size_t size,enum dma_data_direction direction) { -if (cpu_is_noncoherent_r10000 (dev)) +if (cpu_is_noncoherent_r10000 (dev) ||cpu_is_noncoherent_loongson (dev))__dma_sync (dma_addr_to_page (dev, dma_handle), dma_handle & ~PAGE_MASK , size, direction); }
@@ -281,7 +288,7 @@ static void mips_dma_sync_sg_for_cpu(struct device *dev,/* Make sure that gcc doesn't leave the empty loop body. */ for (i =0 ; i < nelems; i++, sg++) { -if (cpu_is_noncoherent_r10000 (dev)) +if (cpu_is_noncoherent_r10000 (dev) ||cpu_is_noncoherent_loongson (dev))__dma_sync (sg_page (sg), sg->offset, sg->length, direction); }
Signature · 1 line
1.7.7.3
PATCH v2 10/16 MIPS: Loongson: Add Loongson-3 Kconfig options.
In reply to Huacai ChenAdded Kconfig options include: Loongson-3 CPU and machine definition, UEFI-like firmware interface, HT-linked PCI, and big memory support.
--- arch/mips/Kconfig | 22 ++++++++++++++++++ arch/mips/loongson/Kconfig | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 0 deletions(-)
arch/mips/Kconfig +22 -0
@@ -1544,6 +1544,16 @@ config CPU_LOONGSON2 select CPU_SUPPORTS_64BIT_KERNEL select CPU_SUPPORTS_HIGHMEM +config CPU_LOONGSON3 + bool "Loongson 3 CPU" + depends on SYS_HAS_CPU_LOONGSON3 + select CPU_SUPPORTS_32BIT_KERNEL + select CPU_SUPPORTS_64BIT_KERNEL + select CPU_SUPPORTS_HIGHMEM + help + The Loongson 3 processor implements the MIPS III instruction set + with many extensions. + config CPU_BMIPS bool select CPU_MIPS32
@@ -1562,6 +1572,9 @@ config SYS_HAS_CPU_LOONGSON2F select CPU_SUPPORTS_ADDRWINCFG if 64BIT select CPU_SUPPORTS_UNCACHED_ACCELERATED +config SYS_HAS_CPU_LOONGSON3 + bool + config SYS_HAS_CPU_MIPS32_R1 bool
@@ -2361,6 +2374,15 @@ config PCI your box. Other bus systems are ISA, EISA, or VESA. If you have PCI, say Y, otherwise N. +config HT_PCI + bool "Support for HT-linked PCI" + select PCI_DOMAINS + help + Loongson family machines use Hyper-Transport bus for inter-core + connection and device connection. The PCI bus is a subordinate + linked at HT. Choose Y unless you are using Loongson 2E/2F based + machines. + config PCI_DOMAINS bool
arch/mips/loongson/Kconfig +52 -0
66 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 11/16 ata: Use 32-bit DMA in AHCI for Loongson-3.
In reply to Huacai ChenThis is a workaround because Loongson-3 has a hardware bug that it doesn't support DMA address above 4GB.
--- drivers/ata/ahci.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/ata/ahci.c +5 -0
@@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] = { }, [board_ahci_sb700] = /* for SB700 and SB800 */ { +#ifndef CONFIG_CPU_LOONGSON3 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL), +#else + AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | + AHCI_HFLAG_32BIT_ONLY), +#endif .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6,
Signature · 1 line
1.7.7.3
PATCH v2 13/16 ALSA: HDA: Make hda sound card usable for Loongson.
In reply to Huacai ChenLemote A1004(Laptop) and A1205(All-In-One) use Conexant's hda codec, this patch make it usable:
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
2, Modify patch_conexant.c to add Lemote specific code.
--- include/linux/pci_ids.h | 2 + sound/pci/hda/hda_intel.c | 5 ++++ sound/pci/hda/patch_conexant.c | 52 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-)
include/linux/pci_ids.h +2 -0
@@ -2906,3 +2906,5 @@#define PCI_DEVICE_ID_XEN_PLATFORM 0x0001#define PCI_VENDOR_ID_OCZ 0x1b85 + +#define PCI_VENDOR_ID_LEMOTE 0x1c06
sound/pci/hda/hda_intel.c +5 -0
@@ -3013,6 +3013,11 @@ static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) gcap &= ~ICH6_GCAP_64OK ; } +#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 64-bit DMA */ + gcap &= ~ICH6_GCAP_64OK ; +#endif +/* disable buffer size rounding to 128-byte multiples if supported */ if (align_buffer_size >=0 ) chip->align_buffer_size = !!align_buffer_size;
sound/pci/hda/patch_conexant.c +50 -2
94 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 14/16 MIPS: Loongson 3: Add Loongson-3 SMP support.
In reply to Huacai ChenIPI registers of Loongson-3 include IPI_SET, IPI_CLEAR, IPI_STATUS, IPI_EN and IPI_MAILBOX_BUF. Each bit of IPI_STATUS indicate a type of IPI and IPI_EN indicate whether the IPI is enabled. The sender write 1 to IPI_SET bits generate IPIs in IPI_STATUS, and receiver write 1 to bits of IPI_CLEAR to clear IPIs. IPI_MAILBOX_BUF are used to deliver more information about IPIs.
--- arch/mips/loongson/common/init.c | 5 + arch/mips/loongson/loongson-3/Makefile | 2 + arch/mips/loongson/loongson-3/smp.c | 278 ++++++++++++++++++++++++++++++++ arch/mips/loongson/loongson-3/smp.h | 24 +++ 4 files changed, 309 insertions(+), 0 deletions(-) create mode 100644 arch/mips/loongson/loongson-3/smp.c create mode 100644 arch/mips/loongson/loongson-3/smp.h
arch/mips/loongson/common/init.c +5 -0
@@ -12,6 +12,8 @@#include <loongson.h> +extern struct plat_smp_ops loongson3_smp_ops; +/* Loongson CPU address windows config space base address */ unsigned long __maybe_unused _loongson_addrwincfg_base;
@@ -33,6 +35,9 @@ void __init prom_init(void)/*init the uart base address */ prom_init_uart_base (); +#if defined(CONFIG_SMP ) +register_smp_ops (&loongson3_smp_ops); +#endif }void __init prom_free_prom_memory (void )
arch/mips/loongson/loongson-3/Makefile +2 -0
@@ -2,3 +2,5 @@ # Makefile for Loongson-3 family machines # obj-y += irq.o + +obj-$(CONFIG_SMP) += smp.o
arch/mips/loongson/loongson-3/smp.c new file +278 -0
278 lines not on this page · raw message
arch/mips/loongson/loongson-3/smp.h new file +24 -0
@@ -0,0 +1,24 @@ +/* for Loongson-3A smp support */ + +/* 4 groups(nodes) in maximum in numa case */ +#define smp_core_group0_base 0x900000003ff01000 +#define smp_core_group1_base 0x900010003ff01000 +#define smp_core_group2_base 0x900020003ff01000 +#define smp_core_group3_base 0x900030003ff01000 + +/* 4 cores in each group(node) */ +#define smp_core0_offset 0x000 +#define smp_core1_offset 0x100 +#define smp_core2_offset 0x200 +#define smp_core3_offset 0x300 + +/* ipi registers offsets */ +#define STATUS0 0x00 +#define EN0 0x04 +#define SET0 0x08 +#define CLEAR0 0x0c +#define STATUS1 0x10 +#define MASK1 0x14 +#define SET1 0x18 +#define CLEAR1 0x1c +#define BUF 0x20
Signature · 1 line
1.7.7.3
PATCH v2 15/16 MIPS: Loongson 3: Add CPU Hotplug support.
In reply to Huacai ChenTips of Loongson's CPU Hotplug:
1, To fully shutdown a core in Loongson 3, the target core should go to
CKSEG1 and flush all L2 cache entries at first. Then, another core (usually Core 0) can safely disable the clock of the target core. So play_dead() call loongson3_play_dead() via CKSEG1 (both uncached and unmmaped).
2, The default clocksource of Loongson is MIPS. Since clock source is a
global device, timekeeping need the CP0' Count registers of each core be synchronous. Thus, when a core is up, we use a SMP_ASK_C0COUNT IPI to ask Core-0's Count.
--- arch/mips/Kconfig | 1 + arch/mips/include/asm/mach-loongson/loongson.h | 6 +- arch/mips/include/asm/smp.h | 1 + arch/mips/kernel/process.c | 4 +- arch/mips/loongson/loongson-3/irq.c | 10 ++ arch/mips/loongson/loongson-3/smp.c | 181 +++++++++++++++++++++++- 6 files changed, 194 insertions(+), 9 deletions(-)
arch/mips/Kconfig +1 -0
@@ -256,6 +256,7 @@ config LASAT config MACH_LOONGSON bool "Loongson family of machines" select SYS_SUPPORTS_ZBOOT + select SYS_SUPPORTS_HOTPLUG_CPU help This enables the support of Loongson family of machines.
arch/mips/include/asm/mach-loongson/loongson.h +3 -3
@@ -246,6 +246,9 @@ static inline void do_perfcnt_IRQ(void)#define LOONGSON_PXARB_CFG LOONGSON_REG(LOONGSON_REGBASE + 0x68)#define LOONGSON_PXARB_STATUS LOONGSON_REG(LOONGSON_REGBASE + 0x6c) +/* Chip Config */ +#define LOONGSON_CHIPCFG0 LOONGSON_REG(LOONGSON_REGBASE + 0x80) +/* pcimap */ #define LOONGSON_PCIMAP_PCIMAP_LO0 0x0000003f
@@ -262,9 +265,6 @@ static inline void do_perfcnt_IRQ(void)#include <linux/cpufreq.h> extern void loongson2_cpu_wait (void );extern struct cpufreq_frequency_table loongson2_clockmod_table[]; - -/* Chip Config */ -#define LOONGSON_CHIPCFG0 LOONGSON_REG(LOONGSON_REGBASE + 0x80)#endif /*
arch/mips/include/asm/smp.h +1 -0
@@ -40,6 +40,7 @@ extern int __cpu_logical_map[NR_CPUS];#define SMP_CALL_FUNCTION 0x2/* Octeon - Tell another core to flush its icache */ #define SMP_ICACHE_FLUSH 0x4 +#define SMP_ASK_C0COUNT 0x8extern volatile cpumask_t cpu_callin_map;
arch/mips/kernel/process.c +1 -3
@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void) } }#ifdef CONFIG_HOTPLUG_CPU -if (!cpu_online (cpu) && !cpu_isset (cpu, cpu_callin_map) && - (system_state ==SYSTEM_RUNNING || - system_state ==SYSTEM_BOOTING )) +if (!cpu_online (cpu) && !cpu_isset (cpu, cpu_callin_map))play_dead ();#endif rcu_idle_exit ();
arch/mips/loongson/loongson-3/irq.c +10 -0
@@ -85,3 +85,13 @@ void __init mach_init_irq(void)set_c0_status (STATUSF_IP2 |STATUSF_IP6 ); } + +#ifdef CONFIG_HOTPLUG_CPU + +void fixup_irqs (void ) +{ +irq_cpu_offline (); +clear_c0_status (ST0_IM ); +} + +#endif
arch/mips/loongson/loongson-3/smp.c +178 -3
233 lines not on this page · raw message
Signature · 1 line
1.7.7.3
PATCH v2 16/16 MIPS: Loongson: Add a Loongson-3 default config file.
In reply to Huacai Chen--- arch/mips/configs/loongson3_defconfig | 279 +++++++++++++++++++++++++++++++++ 1 files changed, 279 insertions(+), 0 deletions(-) create mode 100644 arch/mips/configs/loongson3_defconfig
arch/mips/configs/loongson3_defconfig new file +279 -0
@@ -0,0 +1,279 @@ +CONFIG_MACH_LOONGSON=y +CONFIG_LEMOTE_MACH3A=y +CONFIG_LOONGSON_BIGMEM=y +CONFIG_CPU_LOONGSON3=y +CONFIG_64BIT=y +CONFIG_PAGE_SIZE_16KB=y +CONFIG_SPARSEMEM_MANUAL=y +CONFIG_KSM=y +CONFIG_SMP=y +CONFIG_NR_CPUS=4 +CONFIG_HZ_256=y +CONFIG_PREEMPT=y +CONFIG_KEXEC=y +CONFIG_EXPERIMENTAL=y +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y +CONFIG_POSIX_MQUEUE=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_BSD_PROCESS_ACCT_V3=y +CONFIG_AUDIT=y +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_CPUSETS=y +CONFIG_RESOURCE_COUNTERS=y +CONFIG_CGROUP_MEM_RES_CTLR=y +CONFIG_CGROUP_MEM_RES_CTLR_SWAP=y +CONFIG_BLK_CGROUP=y +CONFIG_SCHED_AUTOGROUP=y +CONFIG_SYSFS_DEPRECATED=y +CONFIG_RELAY=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +CONFIG_SYSCTL_SYSCALL=y +CONFIG_EMBEDDED=y +CONFIG_MODULES=y +CONFIG_MODULE_UNLOAD=y +CONFIG_MODULE_FORCE_UNLOAD=y +CONFIG_PARTITION_ADVANCED=y +CONFIG_CFQ_GROUP_IOSCHED=y +CONFIG_PCI=y +CONFIG_HT_PCI=y +CONFIG_HOTPLUG_PCI=y +CONFIG_HOTPLUG_PCI_SHPC=m +CONFIG_MIPS32_COMPAT=y +CONFIG_MIPS32_O32=y +CONFIG_MIPS32_N32=y +CONFIG_PM_RUNTIME=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_MULTICAST=y +CONFIG_IP_ADVANCED_ROUTER=y +CONFIG_IP_MULTIPLE_TABLES=y +CONFIG_IP_ROUTE_MULTIPATH=y +CONFIG_IP_ROUTE_VERBOSE=y +CONFIG_NETFILTER=y +CONFIG_NETFILTER_NETLINK_LOG=m +CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m +CONFIG_NETFILTER_XT_TARGET_MARK=m +CONFIG_NETFILTER_XT_TARGET_NFQUEUE=m +CONFIG_NETFILTER_XT_MATCH_COMMENT=m +CONFIG_NETFILTER_XT_MATCH_DCCP=m +CONFIG_NETFILTER_XT_MATCH_ESP=m +CONFIG_NETFILTER_XT_MATCH_LENGTH=m +CONFIG_NETFILTER_XT_MATCH_LIMIT=m +CONFIG_NETFILTER_XT_MATCH_MAC=m +CONFIG_NETFILTER_XT_MATCH_MARK=m +CONFIG_NETFILTER_XT_MATCH_MULTIPORT=m +CONFIG_NETFILTER_XT_MATCH_PKTTYPE=m +CONFIG_NETFILTER_XT_MATCH_QUOTA=m +CONFIG_NETFILTER_XT_MATCH_REALM=m +CONFIG_NETFILTER_XT_MATCH_SCTP=m +CONFIG_NETFILTER_XT_MATCH_STATISTIC=m +CONFIG_NETFILTER_XT_MATCH_STRING=m +CONFIG_NETFILTER_XT_MATCH_TCPMSS=m +CONFIG_IP_NF_QUEUE=m +CONFIG_IP_NF_IPTABLES=m +CONFIG_IP_NF_MATCH_AH=m +CONFIG_IP_NF_MATCH_ECN=m +CONFIG_IP_NF_MATCH_TTL=m +CONFIG_IP_NF_FILTER=m +CONFIG_IP_NF_TARGET_REJECT=m +CONFIG_IP_NF_TARGET_ULOG=m +CONFIG_IP_NF_MANGLE=m +CONFIG_IP_NF_TARGET_ECN=m +CONFIG_IP_NF_TARGET_TTL=m +CONFIG_IP_NF_RAW=m +CONFIG_IP_NF_ARPTABLES=m +CONFIG_IP_NF_ARPFILTER=m +CONFIG_IP_NF_ARP_MANGLE=m +CONFIG_CFG80211=y +CONFIG_LIB80211=y +CONFIG_MAC80211=y +CONFIG_RFKILL=y +CONFIG_RFKILL_INPUT=y +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_MTD=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_CRYPTOLOOP=y +CONFIG_BLK_DEV_RAM=y +CONFIG_BLK_DEV_RAM_SIZE=8192 +CONFIG_RAID_ATTRS=m +CONFIG_SCSI_TGT=y +CONFIG_BLK_DEV_SD=y +CONFIG_CHR_DEV_SG=y +CONFIG_CHR_DEV_SCH=m +CONFIG_SCSI_MULTI_LUN=y +CONFIG_SCSI_CONSTANTS=y +CONFIG_SCSI_LOGGING=y +CONFIG_SCSI_SPI_ATTRS=m +CONFIG_SCSI_FC_ATTRS=m +CONFIG_SCSI_ISCSI_ATTRS=m +CONFIG_ATA=y +CONFIG_SATA_AHCI=y +CONFIG_MD=y +CONFIG_BLK_DEV_DM=y +CONFIG_DM_CRYPT=y +CONFIG_DM_SNAPSHOT=y +CONFIG_DM_MIRROR=y +CONFIG_DM_ZERO=y +CONFIG_NETDEVICES=y +CONFIG_R8169=y +CONFIG_ATH_COMMON=y +CONFIG_ATH9K=y +CONFIG_INPUT_POLLDEV=m +CONFIG_INPUT_SPARSEKMAP=y +CONFIG_INPUT_EVDEV=y +CONFIG_KEYBOARD_XTKBD=m +CONFIG_MOUSE_PS2_SENTELIC=y +CONFIG_MOUSE_SERIAL=m +CONFIG_INPUT_MISC=y +CONFIG_INPUT_UINPUT=m +CONFIG_SERIO_SERPORT=m +CONFIG_SERIO_RAW=m +CONFIG_LEGACY_PTY_COUNT=16 +CONFIG_SERIAL_NONSTANDARD=y +CONFIG_N_HDLC=m +CONFIG_STALDRV=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +CONFIG_SERIAL_8250_NR_UARTS=16 +CONFIG_SERIAL_8250_EXTENDED=y +CONFIG_SERIAL_8250_MANY_PORTS=y +CONFIG_SERIAL_8250_SHARE_IRQ=y +CONFIG_SERIAL_8250_RSA=y +CONFIG_IPMI_HANDLER=m +CONFIG_IPMI_DEVICE_INTERFACE=m +CONFIG_IPMI_SI=m +CONFIG_IPMI_WATCHDOG=m +CONFIG_IPMI_POWEROFF=m +CONFIG_HW_RANDOM=y +CONFIG_R3964=m +CONFIG_RAW_DRIVER=m +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_PIIX4=y +CONFIG_SPI=y +CONFIG_SPI_BITBANG=m +CONFIG_SENSORS_ADM1021=m +CONFIG_SENSORS_ADM1025=m +CONFIG_SENSORS_ADM1026=m +CONFIG_SENSORS_ADM1031=m +CONFIG_SENSORS_ADM9240=m +CONFIG_SENSORS_ATXP1=m +CONFIG_SENSORS_DS1621=m +CONFIG_SENSORS_GL518SM=m +CONFIG_SENSORS_GL520SM=m +CONFIG_SENSORS_IT87=m +CONFIG_SENSORS_LM63=m +CONFIG_SENSORS_LM70=m +CONFIG_SENSORS_LM75=m +CONFIG_SENSORS_LM77=m +CONFIG_SENSORS_LM78=m +CONFIG_SENSORS_LM80=m +CONFIG_SENSORS_LM83=m +CONFIG_SENSORS_LM85=m +CONFIG_SENSORS_LM87=m +CONFIG_SENSORS_LM90=m +CONFIG_SENSORS_LM92=m +CONFIG_SENSORS_MAX1619=m +CONFIG_SENSORS_PC87360=m +CONFIG_SENSORS_SMSC47M1=m +CONFIG_SENSORS_SMSC47M192=m +CONFIG_SENSORS_SMSC47B397=m +CONFIG_SENSORS_W83781D=m +CONFIG_SENSORS_W83791D=m +CONFIG_SENSORS_W83792D=m +CONFIG_SENSORS_W83793=m +CONFIG_SENSORS_W83L785TS=m +CONFIG_SENSORS_W83627HF=m +CONFIG_SENSORS_W83627EHF=m +CONFIG_DRM=y +CONFIG_DRM_RADEON=y +CONFIG_DRM_RADEON_KMS=y +CONFIG_VIDEO_OUTPUT_CONTROL=y +CONFIG_FB_RADEON=y +CONFIG_FB_ATY128=y +CONFIG_FB_ATY=y +CONFIG_FB_ATY_CT=y +CONFIG_FB_ATY_GENERIC_LCD=y +CONFIG_FB_ATY_GX=y +CONFIG_LCD_CLASS_DEVICE=y +# CONFIG_VGA_CONSOLE is not set +CONFIG_FRAMEBUFFER_CONSOLE=y +CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +CONFIG_LOGO=y +CONFIG_SOUND=y +CONFIG_SND=y +CONFIG_SND_SEQUENCER=m +CONFIG_SND_SEQ_DUMMY=m +CONFIG_SND_DUMMY=y +CONFIG_SND_ALOOP=y +CONFIG_SND_HDA_INTEL=y +CONFIG_SND_HDA_PATCH_LOADER=y +CONFIG_HID_A4TECH=m +CONFIG_USB=y +CONFIG_USB_MON=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_ROOT_HUB_TT=y +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_UHCI_HCD=m +CONFIG_USB_STORAGE=m +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_CMOS=y +CONFIG_DMADEVICES=y +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +CONFIG_EXT3_FS=y +CONFIG_EXT3_FS_POSIX_ACL=y +CONFIG_EXT3_FS_SECURITY=y +CONFIG_EXT4_FS=y +CONFIG_EXT4_FS_POSIX_ACL=y +CONFIG_EXT4_FS_SECURITY=y +CONFIG_QUOTA=y +CONFIG_AUTOFS4_FS=y +CONFIG_FUSE_FS=m +CONFIG_ISO9660_FS=m +CONFIG_JOLIET=y +CONFIG_PROC_KCORE=y +CONFIG_TMPFS=y +CONFIG_NFS_FS=m +CONFIG_NFS_V3_ACL=y +CONFIG_NFS_V4=y +CONFIG_NFSD=m +CONFIG_NFSD_V3_ACL=y +CONFIG_NFSD_V4=y +CONFIG_CIFS=m +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_CODEPAGE_936=y +CONFIG_NLS_UTF8=y +CONFIG_PRINTK_TIME=y +CONFIG_FRAME_WARN=1024 +CONFIG_MAGIC_SYSRQ=y +CONFIG_STRIP_ASM_SYMS=y +CONFIG_DEBUG_SECTION_MISMATCH=y +CONFIG_CRYPTO_AUTHENC=m +CONFIG_CRYPTO_HMAC=y +CONFIG_CRYPTO_MD5=y +CONFIG_CRYPTO_MICHAEL_MIC=m +CONFIG_CRYPTO_SHA1=m +CONFIG_CRYPTO_SHA256=m +CONFIG_CRYPTO_SHA512=m +CONFIG_CRYPTO_TGR192=m +CONFIG_CRYPTO_WP512=m +CONFIG_CRYPTO_ANUBIS=m +CONFIG_CRYPTO_BLOWFISH=m +CONFIG_CRYPTO_CAST5=m +CONFIG_CRYPTO_CAST6=m +CONFIG_CRYPTO_KHAZAD=m +CONFIG_CRYPTO_SERPENT=m +CONFIG_CRYPTO_TEA=m +CONFIG_CRYPTO_TWOFISH=m +CONFIG_CRYPTO_DEFLATE=m +CONFIG_CRC_T10DIF=m +CONFIG_LIBCRC32C=m
Signature · 1 line
1.7.7.3
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Huacai ChenHello Huacai,
Am Dienstag, den 19.06.2012, 14:50 +0800 schrieb Huacai Chen:
Quoted 2 lines
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
This is a bug of your platform/CPU and should be fixed at a lower level, not in every driver. While radeon might be the only device using 40bit DMA right know, it is very well possible that other devices pop up in the future. So please fix your platform code to disallow >32bit DMA.
Quoted 2 lines
2, Read vga bios offered by system firmware. 3, Handle io prot correctly for MIPS.
This seems good to me, but you should really split this out in a separate TTM patch.
Quoted 3 lines
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset
occurs at resume from suspend).
While SWIOTLB might not be a common setup, simply ignoring it because it doesn't work on your platform is the wrong thing to do. Could you please try to root-cause the issue?
Thanks,
Lucas
Quoted 156 lines
Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>--- drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/radeon/radeon_bios.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_device.c | 5 +++++ drivers/gpu/drm/radeon/radeon_ttm.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +- include/drm/drm_sarea.h | 2 ++ 6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +1
-1@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp =pgprot_writecombine (tmp); else tmp =pgprot_noncached (tmp); -#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__) tmp =pgprot_noncached (tmp);#endif return tmp;drivers/gpu/drm/radeon/radeon_bios.c +32
-0@@ -29,6 +29,7 @@#include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h> @@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)return true; } +#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr; +static bool loongson3_read_bios (struct radeon_device *rdev) +{ +u8 *bios; +resource_size_t size =512 *1024 ;/* ??? */ + + rdev->bios =NULL ; + + bios = (u8 *)vgabios_addr; +if (!bios) { +return false; + } + +if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { +return false; + } + rdev->bios =kmalloc (size,GFP_KERNEL ); +if (rdev->bios ==NULL ) { +return false; + } +memcpy (rdev->bios, bios, size); +return true; +} +#endif +static bool radeon_read_bios (struct radeon_device *rdev) {uint8_t __iomem *bios;@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev)if (r == false) { r =radeon_read_disabled_bios (rdev); } +#ifdef CONFIG_CPU_LOONGSON3 +if (r == false) { + r =loongson3_read_bios (rdev); + } +#endif if (r == false || rdev->bios ==NULL ) {DRM_ERROR ("Unable to locate a BIOS ROM\n" ); rdev->bios =NULL ;drivers/gpu/drm/radeon/radeon_device.c +5
-0@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ?32 :40 ; r =pci_set_dma_mask (rdev->pdev,DMA_BIT_MASK (dma_bits));if (r) {drivers/gpu/drm/radeon/radeon_ttm.c +3
-3@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {return ttm_dma_populate (>t->ttm, rdev->dev); }@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {ttm_dma_unpopulate (>t->ttm, rdev->dev);return ;@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features =0 ; radeon_mem_types_list[i++].data =NULL ; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {sprintf (radeon_mem_types_names[i],"ttm_dma_page_pool" ); radeon_mem_types_list[i].name = radeon_mem_types_names[i];drivers/gpu/drm/ttm/ttm_bo_util.c +1
-1@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp) else tmp =pgprot_noncached (tmp);#endif -#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &TTM_PL_FLAG_CACHED )) tmp =pgprot_noncached (tmp);#endif include/drm/drm_sarea.h +2
-0@@ -37,6 +37,8 @@/* SAREA area needs to be at least a page */ #if defined(__alpha__)#define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U#elif defined(__ia64__)#define SAREA_MAX 0x10000U/* 64kB */ #else
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Huacai ChenQuoted 6 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset
occurs at resume from suspend).
Sounds like this should be split up into smaller patches.
include/drm/drm_sarea.h line 44
Quoted 13 lines
include/drm/drm_sarea.h +2
-0@@ -37,6 +37,8 @@/* SAREA area needs to be at least a page */ #if defined(__alpha__)#define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U#elif defined(__ia64__)#define SAREA_MAX 0x10000U/* 64kB */ #else
Also, this change doesn't seem to be accounted for in the commit log.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Debian, X and DRI developer _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH V2 13/16] ALSA: HDA: Make hda sound card usable for Loongson.
In reply to Huacai ChenQuoted 3 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
2, Modifypatch_conexant.cto add Lemote specific code.
Please create separate patches for these two changes.
include/linux/pci_ids.h line 2910
Quoted 7 lines
+++
b/include/linux/pci_ids.hinclude/linux/pci_ids.h +2
-0@@ -2906,3 +2906,5 @@#define PCI_DEVICE_ID_XEN_PLATFORM 0x0001#define PCI_VENDOR_ID_OCZ 0x1b85 + +#define PCI_VENDOR_ID_LEMOTE 0x1c06
AFAICS this symbol is not used in this patch.
sound/pci/hda/hda_intel.c static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) · line 3019
Quoted 4 lines
sound/pci/hda/hda_intel.c +4
-0+#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 64-bit DMA */ + gcap &= ~ICH6_GCAP_64OK ; +#endif
/* Workaround: Loongson 3 doesn't actually support 64-bit DMA */
Regards,
Clemens
Re: [alsa-devel] [PATCH V2 13/16] ALSA: HDA: Make hda sound card usable for Loongson.
In reply to Huacai ChenAt Tue, 19 Jun 2012 14:50:21 +0800,
Quoted 22 lines · Huacai Chen
Lemote A1004(Laptop) and A1205(All-In-One) use Conexant's hda codec, this patch make it usable:
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
2, Modifypatch_conexant.cto add Lemote specific code.Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>--- include/linux/pci_ids.h | 2 + sound/pci/hda/hda_intel.c | 5 ++++ sound/pci/hda/patch_conexant.c | 52 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-)include/linux/pci_ids.h +0
-0
include/linux/pci_ids.h line 2910
Quoted 5 lines
include/linux/pci_ids.h +2
-0@@ -2906,3 +2906,5 @@#define PCI_DEVICE_ID_XEN_PLATFORM 0x0001#define PCI_VENDOR_ID_OCZ 0x1b85 + +#define PCI_VENDOR_ID_LEMOTE 0x1c06
As Clemens already suggested, please split your patch. The addition of PCI ID, addition of the workaround in HD-audio controller code, and the modification to Conexant codec code are all different things.
sound/pci/hda/hda_intel.c static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) · line 3019
Quoted 12 lines
sound/pci/hda/hda_intel.c +4
-0@@ -3013,6 +3013,11 @@ static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) gcap &= ~ICH6_GCAP_64OK ; } +#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 64-bit DMA */ + gcap &= ~ICH6_GCAP_64OK ; +#endif
Where is CONFIG_CPU_LOONGSON3 defined at all? This isn't found in the upstream Linus or linux-next tree.
sound/pci/hda/patch_conexant.c struct conexant_spec { · line 145
Quoted 9 lines
sound/pci/hda/patch_conexant.c +1
-0@@ -142,6 +142,7 @@ struct conexant_spec { unsigned int thinkpad:1; unsigned int hp_laptop:1; unsigned int asus:1; + unsigned int lemote:1;
In general, we don't accept such a static quirk any longer unless a special reason is given. Doesn't the auto-parser work for you?
thanks,
Takashi
Re: [PATCH V2 15/16] MIPS: Loongson 3: Add CPU Hotplug support.
In reply to Huacai Chenarch/mips/kernel/process.c void __noreturn cpu_idle(void) · line 76
Quoted 13 lines · Huacai Chen
arch/mips/kernel/process.c +1
-3@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void) } }#ifdef CONFIG_HOTPLUG_CPU -if (!cpu_online (cpu) && !cpu_isset (cpu, cpu_callin_map) && - (system_state ==SYSTEM_RUNNING || - system_state ==SYSTEM_BOOTING )) +if (!cpu_online (cpu) && !cpu_isset (cpu, cpu_callin_map))play_dead ();
I think patch like this should be separated from BSP code.
BTW, what's the story behind this change?
Thanks,
Yong
Re: [PATCH V2 15/16] MIPS: Loongson 3: Add CPU Hotplug support.
In reply to Huacai Chenarch/mips/loongson/loongson-3/smp.c void __init loongson3_cpus_done(void) · line 299
Quoted 3 lines · Huacai Chen
arch/mips/loongson/loongson-3/smp.c +3
-0+#ifdef CONFIG_HOTPLUG_CPU + +static DEFINE_SPINLOCK (smp_reserve_lock);
Do you really need this lock?
Thanks,
Yong
Re: [PATCH V2 01/16] MIPS: Loongson: Add basic Loongson-3 definition.
In reply to Huacai ChenHi,
Quoted 2 lines · On Tuesday 19 June 2012 14:50:09 Huacai Chen wrote:
Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2 fully. Loongson-3 has the same IMP field (
0x6300) as Loongson-2.
Then what is the purpose of having a PrID if you don't increment it when you make a new CPU? Especially in this case where there are major architectural changes. Anyway, you seem to have a dedicated revision number which is good enough.
Quoted 30 lines
Loongson-3 has a hardware-maintained cache, system software doesn't need to maintain coherency.
Loongson-3A is the first revision of Loongson-3, and it is the quad- core version of Loongson-2G. Loongson-3A has a simplified version named Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two HyperTransport controller but 2Gq has only one. HT0 is used for cross- chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq cannot support NUMA but 3A can.
Exsisting Loongson family CPUs:
Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson-
2Gq), they are 64-bit MIPS CPUs.
Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>--- arch/mips/include/asm/addrspace.h | 6 ++++++ arch/mips/include/asm/cpu.h | 6 ++++-- arch/mips/include/asm/mach-loongson/spaces.h | 15 +++++++++++++++ arch/mips/include/asm/module.h | 2 ++ arch/mips/include/asm/pgtable-bits.h | 7 +++++++ arch/mips/loongson/Platform | 1 + 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson/spaces.h
Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/mips/include/asm/addrspace.h
Review
Quoted 49 lines
index 569f80a..cf62bfb 100644
arch/mips/include/asm/addrspace.h +6
-0@@ -116,7 +116,13 @@#define K_CALG_UNCACHED 2#define K_CALG_NONCOHERENT 3#define K_CALG_COH_EXCL 4 + +#ifdef CONFIG_CPU_LOONGSON3 +#define K_CALG_COH_SHAREABLE 3 +#else #define K_CALG_COH_SHAREABLE 5 +#endif +#define K_CALG_NOTUSED 6#define K_CALG_UNCACHED_ACCEL 7arch/mips/include/asm/cpu.h +4
-2@@ -72,6 +72,7 @@#define PRID_IMP_R5432 0x5400#define PRID_IMP_R5500 0x5500#define PRID_IMP_LOONGSON2 0x6300 +#define PRID_IMP_LOONGSON3 0x6300#define PRID_IMP_UNKNOWN 0xff00@@ -199,6 +200,7 @@#define PRID_REV_34K_V1_0_2 0x0022#define PRID_REV_LOONGSON2E 0x0002#define PRID_REV_LOONGSON2F 0x0003 +#define PRID_REV_LOONGSON3A 0x0005/* * Older processors used to encode processor version and revision in two @@ -267,8 +269,8 @@ enum cpu_type_enum {* MIPS64 class processors */ CPU_5KC ,CPU_5KE ,CPU_20KC ,CPU_25KF ,CPU_SB1 ,CPU_SB1A ,CPU_LOONGSON2 , -CPU_CAVIUM_OCTEON ,CPU_CAVIUM_OCTEON_PLUS ,CPU_CAVIUM_OCTEON2 , -CPU_XLR ,CPU_XLP , +CPU_LOONGSON3 ,CPU_CAVIUM_OCTEON ,CPU_CAVIUM_OCTEON_PLUS , +CPU_CAVIUM_OCTEON2 ,CPU_XLR ,CPU_XLP ,CPU_LAST };(quoted diff) +0
-0
b/arch/mips/include/asm/mach-loongson/spaces.h
Review
Quoted 34 lines
new file mode 100644
index 0000000..1e82804arch/mips/include/asm/mach-loongson/spaces.h new file +15
-0@@ -0,0 +1,15 @@ +#ifndef __ASM_MACH_LOONGSON_SPACES_H_ +#define __ASM_MACH_LOONGSON_SPACES_H_ + +#ifndef CAC_BASE +#if defined(CONFIG_64BIT ) +#if defined(CONFIG_DMA_NONCOHERENT ) || defined(CONFIG_CPU_LOONGSON3 ) +#define CAC_BASE _AC(0x9800000000000000, UL) +#else +#define CAC_BASE _AC(0xa800000000000000, UL) +#endif /* CONFIG_DMA_NONCOHERENT || CONFIG_CPU_LOONGSON3 */ +#endif /* CONFIG_64BIT */ +#endif /* CONFIG_CAC_BASE */ + +#include <asm/mach-generic/spaces.h> +#endif arch/mips/include/asm/module.h +2
-0@@ -119,6 +119,8 @@ search_module_dbetables(unsigned long addr)#define MODULE_PROC_FAMILY "SB1 "#elif definedCONFIG_CPU_LOONGSON2 #define MODULE_PROC_FAMILY "LOONGSON2 " +#elif definedCONFIG_CPU_LOONGSON3 +#define MODULE_PROC_FAMILY "LOONGSON3 "#elif definedCONFIG_CPU_CAVIUM_OCTEON #define MODULE_PROC_FAMILY "OCTEON "#elif definedCONFIG_CPU_XLR (quoted diff) +0
-0
b/arch/mips/include/asm/pgtable-bits.h
arch/mips/include/asm/pgtable-bits.h static inline uint64_t pte_to_entrylo(unsigned long
Quoted 4 lines
index e9fe7e9..1afd39a 100644
arch/mips/include/asm/pgtable-bits.h +0
-0@@ -206,6 +206,13 @@ static inline uint64_t pte_to_entrylo(unsigned long
pte_val)
Quoted 18 lines
arch/mips/include/asm/pgtable-bits.h +7
-0#define _CACHE_UNCACHED _CACHE_UC_B#define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB +#elif defined(CONFIG_CPU_LOONGSON3 ) + +#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)/* LOONGSON */ +#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT)/* LOONGSON */ +#define _CACHE_CACHABLE_COHERENT (3<<_CACHE_SHIFT)/* LOONGSON-3 */ +#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)/* LOONGSON */ +#else #define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT)/* R4600 only */ arch/mips/loongson/Platform +0
-0
arch/mips/loongson/Platform platform-$(CONFIG_MACH_LOONGSON) += loongson/ · line 30
Quoted 1 line
arch/mips/loongson/Platform +0
-0@@ -30,3 +30,4 @@ platform-$(CONFIG_MACH_LOONGSON) += loongson/ cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-
loongson -mno-branch-likely
Quoted 7 lines
arch/mips/loongson/Platform +1
-0load-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000 load-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000 +load-$(CONFIG_CPU_LOONGSON3) += 0xffffffff80200000Signature · 1 line
1.7.7.3
Re: [PATCH V2 02/16] MIPS: Loongson: Add basic Loongson-3 CPU support.
In reply to Huacai ChenHi,
Comments inline, especially about your c-r4k.c changes. You don't seem to have updated arch/mips/include/asm/mach-loongson/cpu-feature-overrides.h for LOONGSON3 is that inentional?
Quoted 7 lines · On Tuesday 19 June 2012 14:50:10 Huacai Chen wrote:
Basic Loongson-3 CPU support include: CPU probing, TLB and cache initializing, cache flushing method, etc.
Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
[snip]
Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/mips/loongson/common/setup.c
Quoted 14 lines
index 27d826b..ebb17ef 100644
arch/mips/loongson/common/setup.c +0
-3@@ -18,9 +18,6 @@#include <linux/screen_info.h> #endif -void (*__wbflush)(void ); -EXPORT_SYMBOL (__wbflush); -static void wbflush_loongson (void ) { asm(".set\tpush\n\t"
arch/mips/loongson/common/setup.c static void wbflush_loongson(void) · line 34
Quoted 6 lines
arch/mips/loongson/common/setup.c +3
-0@@ -32,6 +29,9 @@ static void wbflush_loongson(void) ".set mips0\n\t"); } +void (*__wbflush)(void ) = wbflush_loongson; +EXPORT_SYMBOL (__wbflush); +
Can you explain why you need to move this symbol? It also looks like this could be a separate patch.
arch/mips/mm/c-r4k.c static inline void local_r4k___flush_cache_all(void *
Quoted 20 lines
arch/mips/loongson/common/setup.c +0
-0void __init plat_mem_setup (void ) { __wbflush = wbflush_loongson;arch/mips/mm/Makefile +1
-0@@ -12,6 +12,7 @@ obj-$(CONFIG_HIGHMEM) += highmem.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o tlb-r4k.o +obj-$(CONFIG_CPU_LOONGSON3) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_MIPS64) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_NEVADA) += c-r4k.o cex-gen.o tlb-r4k.oarch/mips/mm/c-r4k.c +0
-0@@ -362,6 +362,9 @@ static inline void local_r4k___flush_cache_all(void *
args)
arch/mips/mm/c-r4k.c static inline void local_r4k___flush_cache_all(void * args) · line 369
Quoted 8 lines
arch/mips/mm/c-r4k.c +3
-0static void r4k___flush_cache_all (void ) { +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif r4k_on_each_cpu (local_r4k___flush_cache_all,NULL ); }
This looks wrong, there is already a check for LOONGSON2 in local_r4k___flush_cache_all() and yet you are adding this special case in r4k___flush_cache_all(), so just move it to local_r4k___flush_cache_all() instead.
arch/mips/mm/c-r4k.c static inline int has_valid_asid(const struct
Quoted 2 lines
arch/mips/mm/c-r4k.c +0
-0@@ -382,11 +385,17 @@ static inline int has_valid_asid(const struct
mm_struct *mm)
Quoted 6 lines
arch/mips/mm/c-r4k.c +3
-0static void r4k__flush_cache_vmap (void ) { +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif
arch/mips/mm/c-r4k.c static inline int has_valid_asid(const struct mm_struct *mm) · line 400
Quoted 10 lines
arch/mips/mm/c-r4k.c +3
-0r4k_blast_dcache (); }static void r4k__flush_cache_vunmap (void ) { +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif r4k_blast_dcache (); }
We might want to introduce a new cpu_has_foo() inline for this, such as cpu_has_blast_dache() or something like that.
arch/mips/mm/c-r4k.c static void r4k_flush_cache_range(struct vm_area_struct
Quoted 2 lines
arch/mips/mm/c-r4k.c +0
-0@@ -408,6 +417,9 @@ static void r4k_flush_cache_range(struct vm_area_struct
*vma,
arch/mips/mm/c-r4k.c static void r4k_flush_cache_range(struct vm_area_struct *vma, · line 422
Quoted 6 lines
arch/mips/mm/c-r4k.c +3
-0{int exec = vma->vm_flags &VM_EXEC ; +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif
We end up having an unused but set variable here in case of LOONGSOON3, so please mark this variable as __maybe_unused.
arch/mips/mm/c-r4k.c static inline void local_r4k_flush_cache_mm(void * args) · line 457
Quoted 12 lines
arch/mips/mm/c-r4k.c +3
-0if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc))r4k_on_each_cpu (local_r4k_flush_cache_range, vma); }@@ -438,6 +450,9 @@ static inline void local_r4k_flush_cache_mm(void * args)static void r4k_flush_cache_mm (struct mm_struct *mm) { +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif if (!cpu_has_dc_aliases)return ;
This makes me think that maybe your cpu does not have data cache aliases? If such this should be noted as such in cpu-features-override.h and this ifdef can go away.
arch/mips/mm/c-r4k.c static void r4k_flush_cache_page(struct vm_area_struct
Quoted 2 lines
arch/mips/mm/c-r4k.c +0
-0@@ -528,6 +543,9 @@ static void r4k_flush_cache_page(struct vm_area_struct
*vma,
arch/mips/mm/c-r4k.c static void r4k_flush_cache_page(struct vm_area_struct *vma, · line 548
Quoted 6 lines
arch/mips/mm/c-r4k.c +3
-0unsigned long addr, unsigned long pfn) {struct flush_cache_page_args args; +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif
args becomes an unused variable.
arch/mips/mm/c-r4k.c static inline void local_r4k_flush_data_cache_page(void *
Quoted 4 lines
arch/mips/mm/c-r4k.c +0
-0args.vma = vma; args.addr = addr;@@ -543,6 +561,9 @@ static inline void local_r4k_flush_data_cache_page(void *
addr)
arch/mips/mm/tlbex.c static void __cpuinit build_tlb_write_entry(u32 **p,
Quoted 118 lines
arch/mips/mm/c-r4k.c +66
-0static void r4k_flush_data_cache_page (unsigned long addr) { +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif if (in_atomic ())local_r4k_flush_data_cache_page ((void *)addr);else @@ -701,6 +722,9 @@ static void local_r4k_flush_cache_sigtramp(void * arg)static void r4k_flush_cache_sigtramp (unsigned long addr) { +#if defined(CONFIG_CPU_LOONGSON3 ) +return ; +#endif r4k_on_each_cpu (local_r4k_flush_cache_sigtramp, (void *) addr); }@@ -952,6 +976,31 @@ static void __cpuinit probe_pcache(void) c->dcache.waybit =0 ;break ; +case CPU_LOONGSON3 : + config1 =read_c0_config1 (); +if ((lsize = ((config1 >>19 ) &7 ))) + c->icache.linesz =2 << lsize; +else + c->icache.linesz = lsize; + c->icache.sets =64 << ((config1 >>22 ) &7 ); + c->icache.ways =1 + ((config1 >>16 ) &7 ); + icache_size = c->icache.sets * + c->icache.ways * + c->icache.linesz; + c->icache.waybit =0 ; + +if ((lsize = ((config1 >>10 ) &7 ))) + c->dcache.linesz =2 << lsize; +else + c->dcache.linesz = lsize; + c->dcache.sets =64 << ((config1 >>13 ) &7 ); + c->dcache.ways =1 + ((config1 >>7 ) &7 ); + dcache_size = c->dcache.sets * + c->dcache.ways * + c->dcache.linesz; + c->dcache.waybit =0 ; +break ; +default :if (!(config &MIPS_CONF_M ))panic ("Don't know how to probe P-caches on this cpu." );@@ -1170,6 +1219,34 @@ static void __init loongson2_sc_init(void) }#endif +#if defined(CONFIG_CPU_LOONGSON3 ) +static void __init loongson3_sc_init (void ) +{ +struct cpuinfo_mips *c = ¤t_cpu_data; +unsigned int config2, lsize; + + config2 =read_c0_config2 (); +if ((lsize = ((config2 >>4 ) &15 ))) + c->scache.linesz =2 << lsize; +else + c->scache.linesz = lsize; + c->scache.sets =64 << ((config2 >>8 ) &15 ); + c->scache.ways =1 + (config2 &15 ); + + scache_size = c->scache.sets * + c->scache.ways * + c->scache.linesz; +/* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */ + scache_size *=4 ; + c->scache.waybit =0 ; +pr_info ("Unified secondary cache %ldkB %s, linesize %d bytes.\n" , + scache_size >>10 , way_string[c->scache.ways], c->scache.linesz); +if (scache_size) + c->options |=MIPS_CPU_INCLUSIVE_CACHES ; +return ; +} +#endif +extern int r5k_sc_init (void );extern int rm7k_sc_init (void );extern int mips_sc_init (void );@@ -1224,6 +1301,13 @@ static void __cpuinit setup_scache(void)loongson2_sc_init ();return ;#endif + +#if defined(CONFIG_CPU_LOONGSON3 ) +case CPU_LOONGSON3 : +loongson3_sc_init (); +return ; +#endif +case CPU_XLP :/* don't need to worry about L2, fully coherent */ return ;arch/mips/mm/tlb-r4k.c +1
-1@@ -50,7 +50,7 @@ extern void build_tlb_refill_handler(void);#endif /* CONFIG_MIPS_MT_SMTC */ -#if defined(CONFIG_CPU_LOONGSON2 ) +#if defined(CONFIG_CPU_LOONGSON2 ) || defined(CONFIG_CPU_LOONGSON3 )/* * LOONGSON2 has a 4 entry itlb which is a subset of dtlb, * unfortrunately, itlb is not totally transparent to software. arch/mips/mm/tlbex.c +0
-0@@ -507,6 +507,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p,
struct uasm_label **l,
Quoted 11 lines
arch/mips/mm/tlbex.c +1
-0case CPU_BMIPS4380 :case CPU_BMIPS5000 :case CPU_LOONGSON2 : +case CPU_LOONGSON3 :case CPU_R5500 :if (m4kc_tlbp_war ())uasm_i_nop (p);Signature · 1 line
1.7.7.3
Re: [PATCH V2 01/16] MIPS: Loongson: Add basic Loongson-3 definition.
In reply to Florian FainelliWhen designing CPU, Loongson-2 is single-core and Loongson-3 is multi-core, but their core is the same. So, there IMP field is also the same.
Quoted 160 lines · Florian Fainelli
Hi,
Quoted 2 lines · On Tuesday 19 June 2012 14:50:09 Huacai Chen wrote:
Loongson-3 is a multi-core MIPS family CPU, it support MIPS64R2 fully. Loongson-3 has the same IMP field (
0x6300) as Loongson-2.Then what is the purpose of having a PrID if you don't increment it when you make a new CPU? Especially in this case where there are major architectural changes. Anyway, you seem to have a dedicated revision number which is good enough.
Quoted 27 lines
Loongson-3 has a hardware-maintained cache, system software doesn't need to maintain coherency.
Loongson-3A is the first revision of Loongson-3, and it is the quad- core version of Loongson-2G. Loongson-3A has a simplified version named Loongson-2Gq, the main difference between Loongson-3A/2Gq is 3A has two HyperTransport controller but 2Gq has only one. HT0 is used for cross- chip interconnection and HT1 is used to link PCI bus. Therefore, 2Gq cannot support NUMA but 3A can.
Exsisting Loongson family CPUs:
Loongson-1: Loongson-1A, Loongson-1B, they are 32-bit MIPS CPUs.
Loongson-2: Loongson-2E, Loongson-2F, Loongson-2G(including Loongson- 2Gq), they are 64-bit MIPS CPUs.
Loongson-3: Loongson-3A, it is a 64-bit MIPS CPU.Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
arch/mips/include/asm/addrspace.h | 6 ++++++arch/mips/include/asm/cpu.h| 6 ++++--arch/mips/include/asm/mach-loongson/spaces.h| 15 +++++++++++++++arch/mips/include/asm/module.h| 2 ++arch/mips/include/asm/pgtable-bits.h| 7 +++++++arch/mips/loongson/Platform| 1 +Review
Quoted 4 lines
6 files changed, 35 insertions(+), 2 deletions(-)create mode 100644
arch/mips/include/asm/mach-loongson/spaces.h(quoted diff) +0
-0
b/arch/mips/include/asm/addrspace.hQuoted 48 lines
index 569f80a..cf62bfb 100644
arch/mips/include/asm/addrspace.h +6
-0@@ -116,7 +116,13 @@ #define K_CALG_UNCACHED 2 #define K_CALG_NONCOHERENT 3 #define K_CALG_COH_EXCL 4 + +#ifdef CONFIG_CPU_LOONGSON3 +#define K_CALG_COH_SHAREABLE 3 +#else #define K_CALG_COH_SHAREABLE 5 +#endif + #define K_CALG_NOTUSED 6 #define K_CALG_UNCACHED_ACCEL 7arch/mips/include/asm/cpu.h +4
-2@@ -72,6 +72,7 @@ #define PRID_IMP_R5432 0x5400 #define PRID_IMP_R5500 0x5500 #define PRID_IMP_LOONGSON2 0x6300 +#define PRID_IMP_LOONGSON3 0x6300 #define PRID_IMP_UNKNOWN 0xff00@@ -199,6 +200,7 @@ #define PRID_REV_34K_V1_0_2 0x0022 #define PRID_REV_LOONGSON2E 0x0002 #define PRID_REV_LOONGSON2F 0x0003 +#define PRID_REV_LOONGSON3A 0x0005 /** Older processors used to encode processor version and revision in two @@ -267,8 +269,8 @@ enum cpu_type_enum {* MIPS64 class processors */ CPU_5KC, CPU_5KE, CPU_20KC, CPU_25KF, CPU_SB1, CPU_SB1A, CPU_LOONGSON2, - CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, CPU_CAVIUM_OCTEON2, - CPU_XLR, CPU_XLP, + CPU_LOONGSON3, CPU_CAVIUM_OCTEON, CPU_CAVIUM_OCTEON_PLUS, + CPU_CAVIUM_OCTEON2, CPU_XLR, CPU_XLP,
CPU_LAST
};Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/mips/include/asm/mach-loongson/spaces.hReview
Quoted 34 lines
new file mode 100644
index 0000000..1e82804arch/mips/include/asm/mach-loongson/spaces.h new file +15
-0@@ -0,0 +1,15 @@ +#ifndef __ASM_MACH_LOONGSON_SPACES_H_ +#define __ASM_MACH_LOONGSON_SPACES_H_ + +#ifndef CAC_BASE +#if defined(CONFIG_64BIT ) +#if defined(CONFIG_DMA_NONCOHERENT ) || defined(CONFIG_CPU_LOONGSON3 ) +#define CAC_BASE _AC(0x9800000000000000, UL) +#else +#define CAC_BASE _AC(0xa800000000000000, UL) +#endif /* CONFIG_DMA_NONCOHERENT || CONFIG_CPU_LOONGSON3 */ +#endif /* CONFIG_64BIT */ +#endif /* CONFIG_CAC_BASE */ + +#include <asm/mach-generic/spaces.h> +#endif arch/mips/include/asm/module.h +2
-0@@ -119,6 +119,8 @@ search_module_dbetables(unsigned long addr) #define MODULE_PROC_FAMILY "SB1 " #elif defined CONFIG_CPU_LOONGSON2 #define MODULE_PROC_FAMILY "LOONGSON2 " +#elif definedCONFIG_CPU_LOONGSON3 +#define MODULE_PROC_FAMILY "LOONGSON3 " #elif defined CONFIG_CPU_CAVIUM_OCTEON #define MODULE_PROC_FAMILY "OCTEON " #elif defined CONFIG_CPU_XLR(quoted diff) +0
-0
b/arch/mips/include/asm/pgtable-bits.harch/mips/include/asm/pgtable-bits.h static inline uint64_t pte_to_entrylo(unsigned long
Quoted 4 lines
index e9fe7e9..1afd39a 100644
arch/mips/include/asm/pgtable-bits.h +0
-0@@ -206,6 +206,13 @@ static inline uint64_t pte_to_entrylo(unsigned long
pte_val)Quoted 18 lines
arch/mips/include/asm/pgtable-bits.h +7
-0#define _CACHE_UNCACHED _CACHE_UC_B #define _CACHE_CACHABLE_NONCOHERENT _CACHE_WB +#elif defined(CONFIG_CPU_LOONGSON3 ) + +#define _CACHE_UNCACHED (2<<_CACHE_SHIFT)/* LOONGSON */ +#define _CACHE_CACHABLE_NONCOHERENT (3<<_CACHE_SHIFT)/* LOONGSON */ +#define _CACHE_CACHABLE_COHERENT (3<<_CACHE_SHIFT)/* LOONGSON-3 */ +#define _CACHE_UNCACHED_ACCELERATED (7<<_CACHE_SHIFT)/* LOONGSON */ + #else #define _CACHE_CACHABLE_NO_WA (0<<_CACHE_SHIFT) /* R4600 only */arch/mips/loongson/Platform +0
-0@@ -30,3 +30,4 @@ platform-$(CONFIG_MACH_LOONGSON) += loongson/Quoted 1 line
cflags-$(CONFIG_MACH_LOONGSON) += -I$(srctree)/arch/mips/include/asm/mach-
loongson -mno-branch-likely
Quoted 7 lines
load-$(CONFIG_LEMOTE_FULOONG2E) +=
0xffffffff80100000load-$(CONFIG_LEMOTE_MACH2F) +=0xffffffff80200000+load-$(CONFIG_CPU_LOONGSON3) +=0xffffffff80200000--
1.7.7.3
Re: [PATCH V2 02/16] MIPS: Loongson: Add basic Loongson-3 CPU support.
In reply to Florian FainelliThanks, I'll improve the code.
Quoted 276 lines · Florian Fainelli
Hi,
Comments inline, especially about your
c-r4k.cchanges. You don't seem to have updatedarch/mips/include/asm/mach-loongson/cpu-feature-overrides.hfor LOONGSON3 is that inentional?Quoted 7 lines · On Tuesday 19 June 2012 14:50:10 Huacai Chen wrote:
Basic Loongson-3 CPU support include: CPU probing, TLB and cache initializing, cache flushing method, etc.
Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
[snip]
Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/mips/loongson/common/setup.cQuoted 14 lines
index 27d826b..ebb17ef 100644
arch/mips/loongson/common/setup.c +0
-3@@ -18,9 +18,6 @@ #include <linux/screen_info.h> #endif -void (*__wbflush)(void ); -EXPORT_SYMBOL (__wbflush); - static void wbflush_loongson(void) {asm(".set\tpush\n\t"
arch/mips/loongson/common/setup.c static void wbflush_loongson(void) · line 34
Quoted 6 lines
arch/mips/loongson/common/setup.c +3
-0@@ -32,6 +29,9 @@ static void wbflush_loongson(void) ".set mips0\n\t"); } +void (*__wbflush)(void ) = wbflush_loongson; +EXPORT_SYMBOL (__wbflush); +Can you explain why you need to move this symbol? It also looks like this could be a separate patch.
arch/mips/mm/c-r4k.c static inline void local_r4k___flush_cache_all(void *
Quoted 20 lines
arch/mips/loongson/common/setup.c +0
-0void __init plat_mem_setup(void) { __wbflush = wbflush_loongson;arch/mips/mm/Makefile +0
-0@@ -12,6 +12,7 @@ obj-$(CONFIG_HIGHMEM) += highmem.oobj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
obj-$(CONFIG_CPU_LOONGSON2) += c-r4k.o cex-gen.o tlb-r4k.o +obj-$(CONFIG_CPU_LOONGSON3) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_MIPS32) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_MIPS64) += c-r4k.o cex-gen.o tlb-r4k.o obj-$(CONFIG_CPU_NEVADA) += c-r4k.o cex-gen.o tlb-r4k.o
arch/mips/mm/c-r4k.c +0
-0@@ -362,6 +362,9 @@ static inline void local_r4k___flush_cache_all(void *args)
arch/mips/mm/c-r4k.c static inline void local_r4k___flush_cache_all(void * args) · line 369
Quoted 8 lines
arch/mips/mm/c-r4k.c +3
-0static void r4k___flush_cache_all(void) { +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif r4k_on_each_cpu(local_r4k___flush_cache_all, NULL); }This looks wrong, there is already a check for LOONGSON2 in
local_r4k___flush_cache_all()and yet you are adding this special case inr4k___flush_cache_all(), so just move it tolocal_r4k___flush_cache_all()instead.arch/mips/mm/c-r4k.c static inline int has_valid_asid(const struct
Quoted 2 lines
arch/mips/mm/c-r4k.c +0
-0@@ -382,11 +385,17 @@ static inline int has_valid_asid(const struct
mm_struct*mm)Quoted 6 lines
arch/mips/mm/c-r4k.c +3
-0static void r4k__flush_cache_vmap(void) { +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif arch/mips/mm/c-r4k.c static inline int has_valid_asid(const struct mm_struct *mm) · line 400
Quoted 10 lines
arch/mips/mm/c-r4k.c +3
-0r4k_blast_dcache(); } static void r4k__flush_cache_vunmap(void) { +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif r4k_blast_dcache(); }We might want to introduce a new
cpu_has_foo()inline for this, such ascpu_has_blast_dache()or something like that.arch/mips/mm/c-r4k.c static void r4k_flush_cache_range(struct vm_area_struct
Quoted 2 lines
arch/mips/mm/c-r4k.c +0
-0@@ -408,6 +417,9 @@ static void r4k_flush_cache_range(struct vm_area_struct*vma,
arch/mips/mm/c-r4k.c static void r4k_flush_cache_range(struct vm_area_struct *vma, · line 422
Quoted 6 lines
arch/mips/mm/c-r4k.c +3
-0{ int exec = vma->vm_flags & VM_EXEC; +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif We end up having an unused but set variable here in case of LOONGSOON3, so please mark this variable as
__maybe_unused.arch/mips/mm/c-r4k.c static inline void local_r4k_flush_cache_mm(void * args) · line 457
Quoted 12 lines
arch/mips/mm/c-r4k.c +3
-0if (cpu_has_dc_aliases || (exec && !cpu_has_ic_fills_f_dc)) r4k_on_each_cpu(local_r4k_flush_cache_range, vma); }@@ -438,6 +450,9 @@ static inline void local_r4k_flush_cache_mm(void * args) static void r4k_flush_cache_mm(struct mm_struct *mm) { +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif if (!cpu_has_dc_aliases) return;This makes me think that maybe your cpu does not have data cache aliases? If such this should be noted as such in
cpu-features-override.hand this ifdef can go away.arch/mips/mm/c-r4k.c static void r4k_flush_cache_page(struct vm_area_struct
Quoted 2 lines
arch/mips/mm/c-r4k.c +0
-0@@ -528,6 +543,9 @@ static void r4k_flush_cache_page(struct vm_area_struct*vma,
arch/mips/mm/c-r4k.c static void r4k_flush_cache_page(struct vm_area_struct *vma, · line 548
Quoted 6 lines
arch/mips/mm/c-r4k.c +3
-0unsigned long addr, unsigned long pfn) { struct flush_cache_page_args args; +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif args becomes an unused variable.
arch/mips/mm/c-r4k.c static inline void local_r4k_flush_data_cache_page(void *
Quoted 4 lines
arch/mips/mm/c-r4k.c +0
-0args.vma = vma; args.addr = addr;@@ -543,6 +561,9 @@ static inline void local_r4k_flush_data_cache_page(void *addr)
arch/mips/mm/tlbex.c static void __cpuinit build_tlb_write_entry(u32 **p,
Quoted 118 lines
arch/mips/mm/c-r4k.c +3
-0static void r4k_flush_data_cache_page(unsigned long addr) { +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif if (in_atomic()) local_r4k_flush_data_cache_page((void *)addr);else
arch/mips/mm/c-r4k.c +28
-0@@ -701,6 +722,9 @@ static void local_r4k_flush_cache_sigtramp(void * arg) static void r4k_flush_cache_sigtramp(unsigned long addr) { +#if defined(CONFIG_CPU_LOONGSON3 ) + return; +#endif r4k_on_each_cpu(local_r4k_flush_cache_sigtramp, (void *) addr); }@@ -952,6 +976,31 @@ static void __cpuinit probe_pcache(void) c->dcache.waybit = 0; break; + case CPU_LOONGSON3: + config1 = read_c0_config1(); + if ((lsize = ((config1 >> 19) & 7))) + c->icache.linesz = 2 << lsize; + else + c->icache.linesz = lsize; + c->icache.sets = 64 << ((config1 >> 22) & 7); + c->icache.ways = 1 + ((config1 >> 16) & 7); + icache_size = c->icache.sets * + c->icache.ways * + c->icache.linesz; + c->icache.waybit = 0; + + if ((lsize = ((config1 >> 10) & 7))) + c->dcache.linesz = 2 << lsize; + else + c->dcache.linesz = lsize; + c->dcache.sets = 64 << ((config1 >> 13) & 7); + c->dcache.ways = 1 + ((config1 >> 7) & 7); + dcache_size = c->dcache.sets * + c->dcache.ways * + c->dcache.linesz; + c->dcache.waybit = 0; + break; +default:
if (!(config &MIPS_CONF_M))
panic("Don't know how to probe P-caches on this cpu.");arch/mips/mm/c-r4k.c +35
-0@@ -1170,6 +1219,34 @@ static void __init loongson2_sc_init(void) } #endif +#if defined(CONFIG_CPU_LOONGSON3 ) +static void __init loongson3_sc_init (void ) +{ + struct cpuinfo_mips *c = ¤t_cpu_data; + unsigned int config2, lsize; + + config2 = read_c0_config2(); + if ((lsize = ((config2 >> 4) & 15))) + c->scache.linesz = 2 << lsize; + else + c->scache.linesz = lsize; + c->scache.sets = 64 << ((config2 >> 8) & 15); + c->scache.ways = 1 + (config2 & 15); + + scache_size = c->scache.sets * + c->scache.ways * + c->scache.linesz; + /* Loongson-3 has 4 cores, 1MB scache for each. scaches are shared */ + scache_size *= 4; + c->scache.waybit = 0; + pr_info("Unified secondary cache %ldkB %s, linesize %d bytes.\n", + scache_size >> 10, way_string[c->scache.ways], c->scache.linesz); + if (scache_size) + c->options |= MIPS_CPU_INCLUSIVE_CACHES; + return; +} +#endif + extern int r5k_sc_init(void); extern int rm7k_sc_init(void); extern int mips_sc_init(void);@@ -1224,6 +1301,13 @@ static void __cpuinit setup_scache(void) loongson2_sc_init(); return; #endif + +#if defined(CONFIG_CPU_LOONGSON3 ) + case CPU_LOONGSON3: + loongson3_sc_init(); + return; +#endif +case
CPU_XLP:
/* don't need to worry about L2, fully coherent */ return;arch/mips/mm/tlb-r4k.c +1
-1@@ -50,7 +50,7 @@ extern void build_tlb_refill_handler(void); #endif /* CONFIG_MIPS_MT_SMTC */ -#if defined(CONFIG_CPU_LOONGSON2 ) +#if defined(CONFIG_CPU_LOONGSON2 ) || defined(CONFIG_CPU_LOONGSON3 ) /** LOONGSON2 has a 4 entry itlb which is a subset of dtlb, * unfortrunately, itlb is not totally transparent to software. arch/mips/mm/tlbex.c +0
-0@@ -507,6 +507,7 @@ static void __cpuinit build_tlb_write_entry(u32 **p,struct
uasm_label**l,Quoted 11 lines
case
CPU_BMIPS4380:
caseCPU_BMIPS5000:
caseCPU_LOONGSON2:
+ caseCPU_LOONGSON3:
caseCPU_R5500:
if (m4kc_tlbp_war())
uasm_i_nop(p);
--
1.7.7.3
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Michel DänzerThanks, I'll follow your suggestions.
Quoted 31 lines · Michel Dänzer
Quoted 6 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset occurs at resume from suspend).Sounds like this should be split up into smaller patches.
include/drm/drm_sarea.h line 44
Quoted 13 lines
include/drm/drm_sarea.h +2
-0@@ -37,6 +37,8 @@ /* SAREA area needs to be at least a page */ #if defined(__alpha__) #define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U #elif defined(__ia64__) #define SAREA_MAX 0x10000U /* 64kB */ #elseAlso, this change doesn't seem to be accounted for in the commit log.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Debian, X and DRI developer
Re: [PATCH V2 13/16] ALSA: HDA: Make hda sound card usable for Loongson.
In reply to Takashi IwaiThanks, I'll improve the patch.
Quoted 69 lines · Takashi Iwai
At Tue, 19 Jun 2012 14:50:21 +0800,
Quoted 22 lines · Huacai Chen
Lemote A1004(Laptop) and A1205(All-In-One) use Conexant's hda codec, this patch make it usable:
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
2, Modifypatch_conexant.cto add Lemote specific code.Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
include/linux/pci_ids.h | 2 +sound/pci/hda/hda_intel.c| 5 ++++sound/pci/hda/patch_conexant.c| 52 ++++++++++++++++++++++++++++++++++++++-3 files changed, 57 insertions(+), 2 deletions(-)include/linux/pci_ids.h +0
-0include/linux/pci_ids.h line 2910
Quoted 5 lines
include/linux/pci_ids.h +2
-0@@ -2906,3 +2906,5 @@ #define PCI_DEVICE_ID_XEN_PLATFORM 0x0001 #define PCI_VENDOR_ID_OCZ 0x1b85 + +#define PCI_VENDOR_ID_LEMOTE 0x1c06As Clemens already suggested, please split your patch. The addition of PCI ID, addition of the workaround in HD-audio controller code, and the modification to Conexant codec code are all different things.
sound/pci/hda/hda_intel.c static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) · line 3019
Quoted 12 lines
sound/pci/hda/hda_intel.c +4
-0@@ -3013,6 +3013,11 @@ static int DELAYED_INIT_MARK azx_first_init(struct azx *chip) gcap &= ~ICH6_GCAP_64OK; } +#ifdef CONFIG_CPU_LOONGSON3 + /* Workaround: Loongson 3 doesn't support 64-bit DMA */ + gcap &= ~ICH6_GCAP_64OK; +#endif Where is
CONFIG_CPU_LOONGSON3defined at all? This isn't found in the upstream Linus or linux-next tree.sound/pci/hda/patch_conexant.c struct conexant_spec { · line 145
Quoted 9 lines
sound/pci/hda/patch_conexant.c +1
-0@@ -142,6 +142,7 @@ struct conexant_spec { unsigned int thinkpad:1; unsigned int hp_laptop:1; unsigned int asus:1; + unsigned int lemote:1;In general, we don't accept such a static quirk any longer unless a special reason is given. Doesn't the auto-parser work for you?
thanks,
Takashi
Re: [PATCH V2 15/16] MIPS: Loongson 3: Add CPU Hotplug support.
In reply to Yong ZhangQuoted 17 lines · Yong Zhang
arch/mips/kernel/process.c void __noreturn cpu_idle(void) · line 76
Quoted 13 lines · Huacai Chen
arch/mips/kernel/process.c +1
-3@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void) } } #ifdef CONFIG_HOTPLUG_CPU - if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map) && - (system_state == SYSTEM_RUNNING || - system_state == SYSTEM_BOOTING)) + if (!cpu_online(cpu) && !cpu_isset(cpu, cpu_callin_map)) play_dead();I think patch like this should be separated from BSP code.
Quoted 1 line
BTW, what's the story behind this change?
When poweroff, disable_nonboot_cpus() is called, and if HOTPLUG_CPU is configured, disable_nonboot_cpus() is not an empty function but try to offline nonboot cores. If without this change, poweroff fails.
Quoted 3 lines
Thanks,
Yong
Re: [PATCH V2 03/16] MIPS: Loongson 3: Add Lemote-3A machtypes definition.
In reply to Huacai ChenHello.
Quoted 11 lines · Huacai Chen
Add three Loongson 3 based machine types:
MACH_LEMOTE_A1004is laptop;MACH_LEMOTE_A1101is mini-itx;MACH_LEMOTE_A1205is all-in-one machine.The most significant differrent between A1004 and A1101/A1205 is the laptop has EC but others don't.
Signed-off-by Huacai Chen<[email protected]>Signed-off-by Hongliang Tao<[email protected]>Signed-off-by Hua Yan<[email protected]>
[...]
Quoted 5 lines
arch/mips/loongson/common/machtype.c +0
-0
arch/mips/loongson/common/machtype.c static const char *system_types[] = { · line 33
Quoted 10 lines
arch/mips/loongson/common/machtype.c +4
-1@@ -25,8 +25,11 @@ static const char *system_types[] = { [MACH_LEMOTE_ML2F7] "lemote-mengloong-2f-7inches", [MACH_LEMOTE_YL2F89] "lemote-yeeloong-2f-8.9inches", [MACH_DEXXON_GDIUM2F10] "dexxon-gdium-2f", - [MACH_LEMOTE_NAS] "lemote-nas-2f", + [MACH_LEMOTE_NAS] "lemote-nas-2f", [MACH_LEMOTE_LL2F] "lemote-lynloong-2f", + [MACH_LEMOTE_A1004] "lemote-3a-notebook-a1004", + [MACH_LEMOTE_A1101] "lemote-3a-itx-a1101", + [MACH_LEMOTE_A1205] "lemote-2gq-aio-a1205", [MACH_LOONGSON_END] NULL,
It's preferred that indentation is done with tabs, not spaces.
WBR, Sergei
Re: [PATCH V2 03/16] MIPS: Loongson 3: Add Lemote-3A machtypes definition.
OK, I will do this later.
Thanks.
Quoted 43 lines · Sergei Shtylyov
Hello.
Quoted 13 lines · Huacai Chen
Add three Loongson 3 based machine types:
MACH_LEMOTE_A1004is laptop;MACH_LEMOTE_A1101is mini-itx;MACH_LEMOTE_A1205is all-in-one machine.The most significant differrent between A1004 and A1101/A1205 is the laptop has EC but others don't.
Signed-off-by Huacai Chen<[email protected]>Signed-off-by Hongliang Tao<[email protected]>Signed-off-by Hua Yan<[email protected]>[...]
Quoted 6 lines
arch/mips/loongson/common/machtype.c +0
-0arch/mips/loongson/common/machtype.c static const char *system_types[] = { · line 33
Quoted 10 lines
arch/mips/loongson/common/machtype.c +4
-1@@ -25,8 +25,11 @@ static const char *system_types[] = { [MACH_LEMOTE_ML2F7] "lemote-mengloong-2f-7inches", [MACH_LEMOTE_YL2F89] "lemote-yeeloong-2f-8.9inches", [MACH_DEXXON_GDIUM2F10] "dexxon-gdium-2f", - [MACH_LEMOTE_NAS] "lemote-nas-2f", + [MACH_LEMOTE_NAS] "lemote-nas-2f", [MACH_LEMOTE_LL2F] "lemote-lynloong-2f", + [MACH_LEMOTE_A1004] "lemote-3a-notebook-a1004", + [MACH_LEMOTE_A1101] "lemote-3a-itx-a1101", + [MACH_LEMOTE_A1205] "lemote-2gq-aio-a1205", [MACH_LOONGSON_END] NULL,It's preferred that indentation is done with tabs, not spaces.
WBR, Sergei
Jeff Garzik
NAKRe: [PATCH V2 11/16] ata: Use 32-bit DMA in AHCI for Loongson-3.
In reply to Huacai ChenQuoted 5 lines · Huacai Chen
drivers/ata/ahci.c +0
-0
drivers/ata/ahci.c static const struct ata_port_info ahci_port_info[] = { · line 192
Quoted 10 lines
drivers/ata/ahci.c +5
-0@@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] = { }, [board_ahci_sb700] = /* for SB700 and SB800 */ { +#ifndef CONFIG_CPU_LOONGSON3 AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL), +#else + AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | + AHCI_HFLAG_32BIT_ONLY), +#endif .flags = AHCI_FLAG_COMMON,
NAK -- the place to fix this up is ahci_init_one()
Re: [PATCH V2 11/16] ata: Use 32-bit DMA in AHCI for Loongson-3.
OK, thanks.
Quoted 23 lines · Jeff Garzik
Quoted 16 lines · Huacai Chen
drivers/ata/ahci.c +0
-0@@ -183,7 +183,12 @@ static const struct ata_port_info ahci_port_info[] = { },[board_ahci_sb700] = /* for SB700 and SB800 */ {
+#ifndefCONFIG_CPU_LOONGSON3
AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL),drivers/ata/ahci.c +4
-0+#else + AHCI_HFLAGS (AHCI_HFLAG_IGN_SERR_INTERNAL | + AHCI_HFLAG_32BIT_ONLY), +#endif Quoted 1 line
.flags =
AHCI_FLAG_COMMON,NAK -- the place to fix this up is
ahci_init_one()
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Huacai ChenQuoted 46 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset
occurs at resume from suspend).Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>--- drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/radeon/radeon_bios.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_device.c | 5 +++++ drivers/gpu/drm/radeon/radeon_ttm.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +- include/drm/drm_sarea.h | 2 ++ 6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +1
-1@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp =pgprot_writecombine (tmp); else tmp =pgprot_noncached (tmp); -#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__) tmp =pgprot_noncached (tmp);#endif return tmp;drivers/gpu/drm/radeon/radeon_bios.c +1
-0@@ -29,6 +29,7 @@#include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h>
drivers/gpu/drm/radeon/radeon_bios.c static bool igp_read_bios_from_vram(struct radeon_device *rdev) · line 78
Quoted 5 lines
drivers/gpu/drm/radeon/radeon_bios.c +2
-0@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)return true; } +#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr;
Ugly, is this how platform specific stuff are handled usualy ? I hope not, i would rather see a platform specific function such as loongson3_get_vga_bios.
Cheers,
Jerome
Quoted 119 lines
drivers/gpu/drm/radeon/radeon_bios.c +29
-0+static bool loongson3_read_bios (struct radeon_device *rdev) +{ +u8 *bios; +resource_size_t size =512 *1024 ;/* ??? */ + + rdev->bios =NULL ; + + bios = (u8 *)vgabios_addr; +if (!bios) { +return false; + } + +if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { +return false; + } + rdev->bios =kmalloc (size,GFP_KERNEL ); +if (rdev->bios ==NULL ) { +return false; + } +memcpy (rdev->bios, bios, size); +return true; +} +#endif +static bool radeon_read_bios (struct radeon_device *rdev) {uint8_t __iomem *bios;@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev)if (r == false) { r =radeon_read_disabled_bios (rdev); } +#ifdef CONFIG_CPU_LOONGSON3 +if (r == false) { + r =loongson3_read_bios (rdev); + } +#endif if (r == false || rdev->bios ==NULL ) {DRM_ERROR ("Unable to locate a BIOS ROM\n" ); rdev->bios =NULL ;drivers/gpu/drm/radeon/radeon_device.c +5
-0@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ?32 :40 ; r =pci_set_dma_mask (rdev->pdev,DMA_BIT_MASK (dma_bits));if (r) {drivers/gpu/drm/radeon/radeon_ttm.c +3
-3@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {return ttm_dma_populate (>t->ttm, rdev->dev); }@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {ttm_dma_unpopulate (>t->ttm, rdev->dev);return ;@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features =0 ; radeon_mem_types_list[i++].data =NULL ; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {sprintf (radeon_mem_types_names[i],"ttm_dma_page_pool" ); radeon_mem_types_list[i].name = radeon_mem_types_names[i];drivers/gpu/drm/ttm/ttm_bo_util.c +1
-1@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp) else tmp =pgprot_noncached (tmp);#endif -#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &TTM_PL_FLAG_CACHED )) tmp =pgprot_noncached (tmp);#endif include/drm/drm_sarea.h +2
-0@@ -37,6 +37,8 @@/* SAREA area needs to be at least a page */ #if defined(__alpha__)#define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U#elif defined(__ia64__)#define SAREA_MAX 0x10000U/* 64kB */ #else Signature · 6 lines
1.7.7.3 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Lucas StachQuoted 20 lines · Lucas Stach
Hello Huacai,
Am Dienstag, den 19.06.2012, 14:50 +0800 schrieb Huacai Chen:
Quoted 2 lines
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).This is a bug of your platform/CPU and should be fixed at a lower level, not in every driver. While radeon might be the only device using 40bit DMA right know, it is very well possible that other devices pop up in the future. So please fix your platform code to disallow >32bit DMA.
Quoted 2 lines
2, Read vga bios offered by system firmware. 3, Handle io prot correctly for MIPS.
This seems good to me, but you should really split this out in a separate TTM patch.
Quoted 3 lines
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset
occurs at resume from suspend).
Quoted 6 lines
While SWIOTLB might not be a common setup, simply ignoring it because it doesn't work on your platform is the wrong thing to do. Could you please try to root-cause the issue?
Thanks,
Lucas
It's most likely because somehow with loongson and swiotlb you get bounce page, radeon won't work with bounce pages.
Cheers,
Jerome
Quoted 163 lines
Quoted 149 lines
Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>--- drivers/gpu/drm/drm_vm.c | 2 +- drivers/gpu/drm/radeon/radeon_bios.c | 32 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/radeon/radeon_device.c | 5 +++++ drivers/gpu/drm/radeon/radeon_ttm.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +- include/drm/drm_sarea.h | 2 ++ 6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +1
-1@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp =pgprot_writecombine (tmp); else tmp =pgprot_noncached (tmp); -#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__) tmp =pgprot_noncached (tmp);#endif return tmp;drivers/gpu/drm/radeon/radeon_bios.c +32
-0@@ -29,6 +29,7 @@#include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h> @@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev)return true; } +#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr; +static bool loongson3_read_bios (struct radeon_device *rdev) +{ +u8 *bios; +resource_size_t size =512 *1024 ;/* ??? */ + + rdev->bios =NULL ; + + bios = (u8 *)vgabios_addr; +if (!bios) { +return false; + } + +if (size ==0 || bios[0 ] !=0x55 || bios[1 ] !=0xaa ) { +return false; + } + rdev->bios =kmalloc (size,GFP_KERNEL ); +if (rdev->bios ==NULL ) { +return false; + } +memcpy (rdev->bios, bios, size); +return true; +} +#endif +static bool radeon_read_bios (struct radeon_device *rdev) {uint8_t __iomem *bios;@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev)if (r == false) { r =radeon_read_disabled_bios (rdev); } +#ifdef CONFIG_CPU_LOONGSON3 +if (r == false) { + r =loongson3_read_bios (rdev); + } +#endif if (r == false || rdev->bios ==NULL ) {DRM_ERROR ("Unable to locate a BIOS ROM\n" ); rdev->bios =NULL ;drivers/gpu/drm/radeon/radeon_device.c +5
-0@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 +/* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ?32 :40 ; r =pci_set_dma_mask (rdev->pdev,DMA_BIT_MASK (dma_bits));if (r) {drivers/gpu/drm/radeon/radeon_ttm.c +3
-3@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {return ttm_dma_populate (>t->ttm, rdev->dev); }@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) }#endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {ttm_dma_unpopulate (>t->ttm, rdev->dev);return ;@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features =0 ; radeon_mem_types_list[i++].data =NULL ; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 )if (swiotlb_nr_tbl ()) {sprintf (radeon_mem_types_names[i],"ttm_dma_page_pool" ); radeon_mem_types_list[i].name = radeon_mem_types_names[i];drivers/gpu/drm/ttm/ttm_bo_util.c +1
-1@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp) else tmp =pgprot_noncached (tmp);#endif -#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &TTM_PL_FLAG_CACHED )) tmp =pgprot_noncached (tmp);#endif include/drm/drm_sarea.h +0
-0include/drm/drm_sarea.h line 44
Quoted 8 lines
include/drm/drm_sarea.h +2
-0@@ -37,6 +37,8 @@/* SAREA area needs to be at least a page */ #if defined(__alpha__)#define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U#elif defined(__ia64__)#define SAREA_MAX 0x10000U/* 64kB */ #else _______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to j.glisseQuoted 50 lines · j.glisse
Quoted 49 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset occurs at resume from suspend).Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
drivers/gpu/drm/drm_vm.c | 2 +-drivers/gpu/drm/radeon/radeon_bios.c| 32 ++++++++++++++++++++++++++++++++drivers/gpu/drm/radeon/radeon_device.c| 5 +++++drivers/gpu/drm/radeon/radeon_ttm.c| 6 +++---drivers/gpu/drm/ttm/ttm_bo_util.c| 2 +-include/drm/drm_sarea.h| 2 ++6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +0
-0@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp = pgprot_writecombine(tmp);else
tmp =pgprot_noncached(tmp);drivers/gpu/drm/drm_vm.c +1
-1-#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__)tmp =
pgprot_noncached(tmp);
#endif
return tmp;drivers/gpu/drm/radeon/radeon_bios.c +1
-0@@ -29,6 +29,7 @@ #include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h>@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) return true; }
Quoted 5 lines
drivers/gpu/drm/radeon/radeon_bios.c static bool igp_read_bios_from_vram(struct radeon_device *rdev) · line 78
Quoted 2 lines
drivers/gpu/drm/radeon/radeon_bios.c +2
-0+#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr;Ugly, is this how platform specific stuff are handled usualy ? I hope not, i would rather see a platform specific function such as
loongson3_get_vga_bios.
It could be hooked in as a pci quirk similar to how we read the vbios from the legacy vga location on x86.
Alex
Quoted 127 lines
Cheers,
JeromeQuoted 115 lines
drivers/gpu/drm/radeon/radeon_bios.c +29
-0+static bool loongson3_read_bios (struct radeon_device *rdev) +{ + u8 *bios; + resource_size_t size = 512 * 1024; /* ??? */ + + rdev->bios = NULL; + + bios = (u8 *)vgabios_addr; + if (!bios) { + return false; + } + + if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { + return false; + } + rdev->bios = kmalloc(size, GFP_KERNEL); + if (rdev->bios == NULL) { + return false; + } + memcpy(rdev->bios, bios, size); + return true; +} +#endif + static bool radeon_read_bios(struct radeon_device *rdev) { uint8_t __iomem *bios;@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev) if (r == false) { r = radeon_read_disabled_bios(rdev); } +#ifdef CONFIG_CPU_LOONGSON3 + if (r == false) { + r = loongson3_read_bios(rdev); + } +#endif if (r == false || rdev->bios == NULL) { DRM_ERROR("Unable to locate a BIOS ROM\n"); rdev->bios = NULL;drivers/gpu/drm/radeon/radeon_device.c +5
-0@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 + /* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ? 32 : 40; r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits)); if (r) {drivers/gpu/drm/radeon/radeon_ttm.c +3
-3@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) } #endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { return ttm_dma_populate(>t->ttm, rdev->dev); }@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) } #endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { ttm_dma_unpopulate(>t->ttm, rdev->dev); return;@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features = 0; radeon_mem_types_list[i++].data = NULL; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool"); radeon_mem_types_list[i].name = radeon_mem_types_names[i];drivers/gpu/drm/ttm/ttm_bo_util.c +0
-0@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp)else
tmp =pgprot_noncached(tmp); #endifdrivers/gpu/drm/ttm/ttm_bo_util.c +1
-1-#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &
TTM_PL_FLAG_CACHED)) tmp =pgprot_noncached(tmp); #endifinclude/drm/drm_sarea.h +2
-1@@ -37,6 +37,8 @@ /* SAREA area needs to be at least a page */ #if defined(__alpha__) #define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U #elif defined(__ia64__) #define SAREA_MAX 0x10000U /* 64kB */ #else --1.7.7.3
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Lucas StachQuoted 10 lines · Lucas Stach
Hello Huacai,
Am Dienstag, den 19.06.2012, 14:50 +0800 schrieb Huacai Chen:
Quoted 2 lines
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
This is a bug of your platform/CPU and should be fixed at a lower level, not in every driver. While radeon might be the only device using 40bit DMA right know, it is very well possible that other devices pop up in the future. So please fix your platform code to disallow >32bit DMA.
Hi, Lucas
I have fixed my platform code to disallow >32bit DMA. This method fix the DMA problems in SATA and sound card, but fails on radeon (display is OK, but accerlaration is unusable), because need_dma32 not only affect dma_mask/coherent_dma_mask, but also affect th gfp_flags of ttm_get_pages(). Platform code fixes cannot solve the problem of ttm_get_pages(), could you please give me some suggestions? Thank you.
Quoted 175 lines
Quoted 3 lines
2, Read vga bios offered by system firmware. 3, Handle io prot correctly for MIPS.
This seems good to me, but you should really split this out in a separate TTM patch.
Quoted 3 lines
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset occurs at resume from suspend).
While SWIOTLB might not be a common setup, simply ignoring it because it doesn't work on your platform is the wrong thing to do. Could you please try to root-cause the issue?
Thanks,
LucasQuoted 156 lines
Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
drivers/gpu/drm/drm_vm.c | 2 +-drivers/gpu/drm/radeon/radeon_bios.c| 32 ++++++++++++++++++++++++++++++++drivers/gpu/drm/radeon/radeon_device.c| 5 +++++drivers/gpu/drm/radeon/radeon_ttm.c| 6 +++---drivers/gpu/drm/ttm/ttm_bo_util.c| 2 +-include/drm/drm_sarea.h| 2 ++6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +0
-0@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp = pgprot_writecombine(tmp);else
tmp =pgprot_noncached(tmp);drivers/gpu/drm/drm_vm.c +1
-1-#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__)tmp =
pgprot_noncached(tmp);
#endif
return tmp;drivers/gpu/drm/radeon/radeon_bios.c +32
-0@@ -29,6 +29,7 @@ #include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h>@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) return true; } +#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr; +static bool loongson3_read_bios (struct radeon_device *rdev) +{ + u8 *bios; + resource_size_t size = 512 * 1024; /* ??? */ + + rdev->bios = NULL; + + bios = (u8 *)vgabios_addr; + if (!bios) { + return false; + } + + if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { + return false; + } + rdev->bios = kmalloc(size, GFP_KERNEL); + if (rdev->bios == NULL) { + return false; + } + memcpy(rdev->bios, bios, size); + return true; +} +#endif + static bool radeon_read_bios(struct radeon_device *rdev) { uint8_t __iomem *bios;@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev) if (r == false) { r = radeon_read_disabled_bios(rdev); } +#ifdef CONFIG_CPU_LOONGSON3 + if (r == false) { + r = loongson3_read_bios(rdev); + } +#endif if (r == false || rdev->bios == NULL) { DRM_ERROR("Unable to locate a BIOS ROM\n"); rdev->bios = NULL;drivers/gpu/drm/radeon/radeon_device.c +5
-0@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 + /* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ? 32 : 40; r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits)); if (r) {drivers/gpu/drm/radeon/radeon_ttm.c +3
-3@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) } #endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { return ttm_dma_populate(>t->ttm, rdev->dev); }@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) } #endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { ttm_dma_unpopulate(>t->ttm, rdev->dev); return;@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features = 0; radeon_mem_types_list[i++].data = NULL; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool"); radeon_mem_types_list[i].name = radeon_mem_types_names[i];drivers/gpu/drm/ttm/ttm_bo_util.c +0
-0@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp)else
tmp =pgprot_noncached(tmp); #endifdrivers/gpu/drm/ttm/ttm_bo_util.c +1
-1-#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &
TTM_PL_FLAG_CACHED)) tmp =pgprot_noncached(tmp); #endifinclude/drm/drm_sarea.h +2
-0@@ -37,6 +37,8 @@ /* SAREA area needs to be at least a page */ #if defined(__alpha__) #define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U #elif defined(__ia64__) #define SAREA_MAX 0x10000U /* 64kB */ #else
Re: [PATCH V2 15/16] MIPS: Loongson 3: Add CPU Hotplug support.
In reply to Huacai ChenQuoted 18 lines · Huacai Chen
Quoted 17 lines · Yong Zhang
Quoted 7 lines · Huacai Chen
arch/mips/kernel/process.c +0
-0@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void) ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? }Quoted 6 lines
?#ifdef
CONFIG_HOTPLUG_CPU
- ? ? ? ? ? ? if (!cpu_online(cpu) && !cpu_isset(cpu,cpu_callin_map) &&
- ? ? ? ? ? ? ? ? (system_state==SYSTEM_RUNNING||
- ? ? ? ? ? ? ? ? ?system_state ==SYSTEM_BOOTING))
+ ? ? ? ? ? ? if (!cpu_online(cpu) && !cpu_isset(cpu,cpu_callin_map)) ? ? ? ? ? ? ? ? ? ? ?play_dead();I think patch like this should be separated from BSP code.
Quoted 4 lines
Quoted 1 line
BTW, what's the story behind this change?
When poweroff,
disable_nonboot_cpus()is called, and ifHOTPLUG_CPUis configured,disable_nonboot_cpus()is not an empty function but try to offline nonboot cores. If without this change, poweroff fails.
Yeah. It's an issue. I think Cavium is also affected (Cc'ing David).
So mind making this a single patch? We should also send it to -stable IMHO.
Thanks,
Yong
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Huacai ChenAm Mittwoch, den 20.06.2012, 14:12 +0800 schrieb Huacai Chen:
Quoted 12 lines · Lucas Stach
Quoted 10 lines
Hello Huacai,
Am Dienstag, den 19.06.2012, 14:50 +0800 schrieb Huacai Chen:
Quoted 2 lines
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it
doesn't support DMA address above 4GB).This is a bug of your platform/CPU and should be fixed at a lower level, not in every driver. While radeon might be the only device using 40bit DMA right know, it is very well possible that other devices pop up in the future. So please fix your platform code to disallow >32bit DMA.
Quoted 7 lines
Hi, Lucas
I have fixed my platform code to disallow >32bit DMA. This method fix the DMA problems in SATA and sound card, but fails on radeon (display is OK, but accerlaration is unusable), becauseneed_dma32not only affect dma_mask/coherent_dma_mask, but also affect thgfp_flagsofttm_get_pages(). Platform code fixes cannot solve the problem ofttm_get_pages(), could you please give me some suggestions? Thank you.
If your platform does disallow >32bit DMA masks, radeon should already do the right thing and set need_dma32 to true. Have a look at radeon_device.c:783
Make sure you really disallow >32bit DMA masks, not just prefer <=32bit masks.
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.This seems good to me, but you should really split this out in a separate TTM patch.
Quoted 3 lines
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset
occurs at resume from suspend).While SWIOTLB might not be a common setup, simply ignoring it because it doesn't work on your platform is the wrong thing to do. Could you please try to root-cause the issue?
[snip]
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
Quoted 21 lines · Lucas Stach
Am Mittwoch, den 20.06.2012, 14:12 +0800 schrieb Huacai Chen:
Quoted 12 lines · Lucas Stach
Quoted 10 lines
Hello Huacai,
Am Dienstag, den 19.06.2012, 14:50 +0800 schrieb Huacai Chen:
Quoted 2 lines
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
This is a bug of your platform/CPU and should be fixed at a lower level, not in every driver. While radeon might be the only device using 40bit DMA right know, it is very well possible that other devices pop up in the future. So please fix your platform code to disallow >32bit DMA.
Quoted 7 lines
Hi, Lucas
I have fixed my platform code to disallow >32bit DMA. This method fix the DMA problems in SATA and sound card, but fails on radeon (display is OK, but accerlaration is unusable), becauseneed_dma32not only affect dma_mask/coherent_dma_mask, but also affect thgfp_flagsofttm_get_pages(). Platform code fixes cannot solve the problem ofttm_get_pages(), could you please give me some suggestions? Thank you.
Quoted 6 lines
If your platform does disallow >32bit DMA masks, radeon should already do the right thing and set
need_dma32to true. Have a look at radeon_device.c:783Make sure you really disallow >32bit DMA masks, not just prefer <=32bit masks.
I know, my previous code change is provide an arch-specific dma_map_ops::set_dma_mask() and dma_set_coherent_mask() to force the dma_mask/coherent_dma_mask <=bit, but always return success. In fact the right way is return an error code when driver try to set the dma_mask >32bit. Thank you very much!
Quoted 18 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.This seems good to me, but you should really split this out in a separate TTM patch.
Quoted 3 lines
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset occurs at resume from suspend).
While SWIOTLB might not be a common setup, simply ignoring it because it doesn't work on your platform is the wrong thing to do. Could you please try to root-cause the issue?
[snip]
Re: [PATCH V2 15/16] MIPS: Loongson 3: Add CPU Hotplug support.
In reply to Yong ZhangQuoted 24 lines · Yong Zhang
Quoted 18 lines · Huacai Chen
Quoted 17 lines · Yong Zhang
Quoted 7 lines · Huacai Chen
arch/mips/kernel/process.c +0
-0@@ -72,9 +72,7 @@ void __noreturn cpu_idle(void) ? ? ? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? ? }Quoted 6 lines
?#ifdef
CONFIG_HOTPLUG_CPU
- ? ? ? ? ? ? if (!cpu_online(cpu) && !cpu_isset(cpu,cpu_callin_map) &&
- ? ? ? ? ? ? ? ? (system_state==SYSTEM_RUNNING||
- ? ? ? ? ? ? ? ? ?system_state ==SYSTEM_BOOTING))
+ ? ? ? ? ? ? if (!cpu_online(cpu) && !cpu_isset(cpu,cpu_callin_map)) ? ? ? ? ? ? ? ? ? ? ?play_dead();I think patch like this should be separated from BSP code.
Quoted 4 lines
Quoted 1 line
BTW, what's the story behind this change?
When poweroff,
disable_nonboot_cpus()is called, and ifHOTPLUG_CPUis configured,disable_nonboot_cpus()is not an empty function but try to offline nonboot cores. If without this change, poweroff fails.
Quoted 6 lines
Yeah. It's an issue. I think Cavium is also affected (Cc'ing David).
So mind making this a single patch? We should also send it to -stable IMHO.
Thanks,
Yong
Ok, wait some time, please.
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
In reply to Alex DeucherQuoted 51 lines · Alex Deucher
Quoted 50 lines · j.glisse
Quoted 49 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset occurs at resume from suspend).Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
drivers/gpu/drm/drm_vm.c | 2 +-drivers/gpu/drm/radeon/radeon_bios.c| 32 ++++++++++++++++++++++++++++++++drivers/gpu/drm/radeon/radeon_device.c| 5 +++++drivers/gpu/drm/radeon/radeon_ttm.c| 6 +++---drivers/gpu/drm/ttm/ttm_bo_util.c| 2 +-include/drm/drm_sarea.h| 2 ++6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +0
-0@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp = pgprot_writecombine(tmp);else
tmp =pgprot_noncached(tmp);drivers/gpu/drm/drm_vm.c +1
-1-#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__)tmp =
pgprot_noncached(tmp);
#endif
return tmp;drivers/gpu/drm/radeon/radeon_bios.c +1
-0@@ -29,6 +29,7 @@ #include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h>@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) return true; }
Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/radeon/radeon_bios.c static bool igp_read_bios_from_vram(struct radeon_device *rdev) · line 78
Quoted 2 lines
drivers/gpu/drm/radeon/radeon_bios.c +2
-0+#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr;Ugly, is this how platform specific stuff are handled usualy ? I hope not, i would rather see a platform specific function such as
loongson3_get_vga_bios.It could be hooked in as a pci quirk similar to how we read the vbios from the legacy vga location on x86.
Hi, Alex, the method you said is pci_fixup_video() in arch/x86/pci/fixup.c?
Quoted 130 lines
Alex
Quoted 127 lines
Cheers,
JeromeQuoted 115 lines
drivers/gpu/drm/radeon/radeon_bios.c +29
-0+static bool loongson3_read_bios (struct radeon_device *rdev) +{ + u8 *bios; + resource_size_t size = 512 * 1024; /* ??? */ + + rdev->bios = NULL; + + bios = (u8 *)vgabios_addr; + if (!bios) { + return false; + } + + if (size == 0 || bios[0] != 0x55 || bios[1] != 0xaa) { + return false; + } + rdev->bios = kmalloc(size, GFP_KERNEL); + if (rdev->bios == NULL) { + return false; + } + memcpy(rdev->bios, bios, size); + return true; +} +#endif + static bool radeon_read_bios(struct radeon_device *rdev) { uint8_t __iomem *bios;@@ -490,6 +517,11 @@ bool radeon_get_bios(struct radeon_device *rdev) if (r == false) { r = radeon_read_disabled_bios(rdev); } +#ifdef CONFIG_CPU_LOONGSON3 + if (r == false) { + r = loongson3_read_bios(rdev); + } +#endif if (r == false || rdev->bios == NULL) { DRM_ERROR("Unable to locate a BIOS ROM\n"); rdev->bios = NULL;drivers/gpu/drm/radeon/radeon_device.c +5
-0@@ -777,6 +777,11 @@ int radeon_device_init(struct radeon_device *rdev, (rdev->family < CHIP_RS400)) rdev->need_dma32 = true; +#ifdef CONFIG_CPU_LOONGSON3 + /* Workaround: Loongson 3 doesn't support 40-bits DMA */ + rdev->need_dma32 = true; +#endif + dma_bits = rdev->need_dma32 ? 32 : 40; r = pci_set_dma_mask(rdev->pdev, DMA_BIT_MASK(dma_bits)); if (r) {drivers/gpu/drm/radeon/radeon_ttm.c +3
-3@@ -630,7 +630,7 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm) } #endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { return ttm_dma_populate(>t->ttm, rdev->dev); }@@ -676,7 +676,7 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) } #endif -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { ttm_dma_unpopulate(>t->ttm, rdev->dev); return;@@ -906,7 +906,7 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs; radeon_mem_types_list[i].driver_features = 0; radeon_mem_types_list[i++].data = NULL; -#ifdef CONFIG_SWIOTLB +#if defined(CONFIG_SWIOTLB ) && !defined(CONFIG_CPU_LOONGSON3 ) if (swiotlb_nr_tbl()) { sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool"); radeon_mem_types_list[i].name = radeon_mem_types_names[i];drivers/gpu/drm/ttm/ttm_bo_util.c +0
-0@@ -472,7 +472,7 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp)else
tmp =pgprot_noncached(tmp); #endifdrivers/gpu/drm/ttm/ttm_bo_util.c +1
-1-#if defined(__sparc__) +#if defined(__sparc__) || defined(__mips__)if (!(caching_flags &
TTM_PL_FLAG_CACHED)) tmp =pgprot_noncached(tmp); #endifinclude/drm/drm_sarea.h +2
-1@@ -37,6 +37,8 @@ /* SAREA area needs to be at least a page */ #if defined(__alpha__) #define SAREA_MAX 0x2000U +#elif defined(__mips__) +#define SAREA_MAX 0x4000U #elif defined(__ia64__) #define SAREA_MAX 0x10000U /* 64kB */ #else --1.7.7.3
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH V2 12/16] drm/radeon: Make radeon card usable for Loongson.
Quoted 58 lines · Huacai Chen
Quoted 57 lines · Alex Deucher
Quoted 55 lines · j.glisse
Quoted 46 lines · Huacai Chen
1, Use 32-bit DMA as a workaround (Loongson has a hardware bug that it doesn't support DMA address above 4GB).
2, Read vga bios offered by system firmware.
3, Handle io prot correctly for MIPS.
4, Don't use swiotlb on Loongson machines (when use swiotlb, GPU reset occurs at resume from suspend).Signed-off-by Huacai Chen <[email protected]>Signed-off-by Hongliang Tao <[email protected]>Signed-off-by Hua Yan <[email protected]>---
drivers/gpu/drm/drm_vm.c | 2 +-drivers/gpu/drm/radeon/radeon_bios.c| 32 ++++++++++++++++++++++++++++++++drivers/gpu/drm/radeon/radeon_device.c| 5 +++++drivers/gpu/drm/radeon/radeon_ttm.c| 6 +++---drivers/gpu/drm/ttm/ttm_bo_util.c| 2 +-include/drm/drm_sarea.h| 2 ++6 files changed, 44 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_vm.c +0
-0@@ -62,7 +62,7 @@ static pgprot_t drm_io_prot(uint32_t map_type, struct vm_area_struct *vma) tmp = pgprot_writecombine(tmp);else
tmp =pgprot_noncached(tmp);drivers/gpu/drm/drm_vm.c +1
-1-#elif defined(__sparc__) || defined(__arm__) +#elif defined(__sparc__) || defined(__arm__) || defined(__mips__)tmp =
pgprot_noncached(tmp);
#endif
return tmp;drivers/gpu/drm/radeon/radeon_bios.c +1
-0@@ -29,6 +29,7 @@ #include "radeon_reg.h" #include "radeon.h" #include "atom.h" +#include <asm/bootinfo.h> #include <linux/vga_switcheroo.h> #include <linux/slab.h>drivers/gpu/drm/radeon/radeon_bios.c static bool igp_read_bios_from_vram(struct radeon_device *rdev) · line 78
Quoted 5 lines
drivers/gpu/drm/radeon/radeon_bios.c +2
-0@@ -73,6 +74,32 @@ static bool igp_read_bios_from_vram(struct radeon_device *rdev) return true; } +#ifdef CONFIG_CPU_LOONGSON3 +extern u64 vgabios_addr;Ugly, is this how platform specific stuff are handled usualy ? I hope not, i would rather see a platform specific function such as
loongson3_get_vga_bios.
Quoted 3 lines
Quoted 2 lines
It could be hooked in as a pci quirk similar to how we read the vbios from the legacy vga location on x86.
Hi, Alex, the method you said is
pci_fixup_video()inarch/x86/pci/fixup.c?
Correct, although you will probably need it in arch/mips/pci for your platform. You may want to make your quirk specific to this pci device unless you need it for all vga chips on your platform.
Alex