8xx: platform-specific mmu updates
PATCH 1/5 8xx: platform-specific mmu updates
In reply to a message not in the archiveThis is just a straight port of the same done in arch/ppc by Marcelo Tosatti. One used to be
[PATCH] ppc32 8xx: update_mmu_cache() needs unconditional tlbie, commit eb07d964b4491d1bb5864cd3d7e7633ccdda9a53
---
arch/powerpc/mm/mem.c | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-)
arch/powerpc/mm/mem.c +10 -10
@@ -490,19 +490,19 @@ #endif !cpu_has_feature(CPU_FTR_NOEXECUTE) && pfn_valid(pfn)) {struct page *page =pfn_to_page (pfn); +#ifdef CONFIG_8xx +/* On 8xx, cache control instructions (particularly +* "dcbst" from flush_dcache_icache) fault as write +* operation if there is an unpopulated TLB entry +* for the address in question. To workaround that, +* we invalidate the TLB here, thus avoiding dcbst +* misbehaviour. +*/ +_tlbie (address); +#endif if (!PageReserved (page) && !test_bit (PG_arch_1, &page->flags)) {if (vma->vm_mm == current->active_mm) { -#ifdef CONFIG_8xx -/* On 8xx, cache control instructions (particularly -* "dcbst" from flush_dcache_icache) fault as write -* operation if there is an unpopulated TLB entry -* for the address in question. To workaround that, -* we invalidate the TLB here, thus avoiding dcbst -* misbehaviour. -*/ -_tlbie (address); -#endif __flush_dcache_icache ((void *) address); }else flush_dcache_icache_page (page);
PATCH 3/5 8xx: platform-related changes to the fsl_soc.c
In reply to a message not in the archiveAdded 8xx SoC peripherials: fec for Ethernet and smc for UARTs. Ordinary routines to extract values from the device tree and insert respective platform devices
---
arch/powerpc/sysdev/fsl_soc.c | 270 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 269 insertions(+), 1 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +269 -1
@@ -39,6 +39,8 @@ #include <asm/cpm2.h>extern void init_fcc_ioports (struct fs_platform_info *);extern void init_scc_ioports (struct fs_uart_platform_info *); +extern void init_fec_ioports (struct fs_platform_info *); +extern void init_smc_ioports (struct fs_uart_platform_info *);static phys_addr_t immrbase =-1 ;phys_addr_t get_immrbase (void )
@@ -63,7 +65,7 @@ phys_addr_t get_immrbase(void)EXPORT_SYMBOL (get_immrbase); -#ifdef CONFIG_CPM2 +#if defined(CONFIG_CPM2 ) || defined(CONFIG_8xx)static u32 brgfreq =-1 ;
@@ -792,3 +794,269 @@ err:arch_initcall (cpm_uart_of_init);#endif /* CONFIG_CPM2 */ + +#ifdef CONFIG_8xx + +static int __init fs_enet_mdio_of_init (void ) +{ +struct device_node *np; +unsigned int i; +struct platform_device *mdio_dev; +struct resource res; +int ret; + +for (np =NULL , i =0 ; + (np =of_find_compatible_node (np,"mdio" ,"fs_enet" )) !=NULL ; + i++) { +struct fs_mii_fec_platform_info mdio_data; + +memset (&res,0 ,sizeof (res)); +memset (&mdio_data,0 ,sizeof (mdio_data)); + + ret =of_address_to_resource (np,0 , &res); +if (ret) + goto err; + + mdio_dev = +platform_device_register_simple ("fsl-cpm-fec-mdio" , + res.start, &res,1 ); +if (IS_ERR (mdio_dev)) { + ret =PTR_ERR (mdio_dev); + goto err; + } + + mdio_data.mii_speed = ((((ppc_proc_freq +4999999 ) /2500000 ) /2 ) &0x3F ) <<1 ; + + ret = +platform_device_add_data (mdio_dev, &mdio_data, +sizeof (struct fs_mii_fec_platform_info )); +if (ret) + goto unreg; + } +return 0 ; + +unreg: +platform_device_unregister (mdio_dev); +err: +return ret; +} + +arch_initcall (fs_enet_mdio_of_init); + +static const char *enet_regs ="regs" ; +static const char *enet_pram ="pram" ; +static const char *enet_irq ="interrupt" ; +static char bus_id[9 ][BUS_ID_SIZE ]; + +static int __init fs_enet_of_init (void ) +{ +struct device_node *np; +unsigned int i; +struct platform_device *fs_enet_dev =NULL ; +struct resource res; +int ret; + +for (np =NULL , i =0 ; + (np =of_find_compatible_node (np,"network" ,"fs_enet" )) !=NULL ; + i++) { +struct resource r[4 ]; +struct device_node *phy, *mdio; +struct fs_platform_info fs_enet_data; +unsigned int *id, *phy_addr; +void *mac_addr; +phandle *ph; +char *model; + +memset (r,0 ,sizeof (r)); +memset (&fs_enet_data,0 ,sizeof (fs_enet_data)); + + model = (char *)get_property (np,"model" ,NULL ); +if (model ==NULL ) { + ret = -ENODEV ; + goto unreg; + } + + id = (u32 *)get_property (np,"device-id" ,NULL ); + fs_enet_data.fs_no = *id; + +if (platform_device_skip (model, *id)) +continue ; + + ret =of_address_to_resource (np,0 , &r[0 ]); +if (ret) + goto err; + r[0 ].name = enet_regs; + + mac_addr = (void *)get_property (np,"mac-address" ,NULL ); +memcpy (fs_enet_data.macaddr, mac_addr,6 ); + + ph = (phandle *)get_property (np,"phy-handle" ,NULL ); + phy =of_find_node_by_phandle (*ph); + +if (phy !=NULL ) { + phy_addr = (u32 *)get_property (phy,"reg" ,NULL ); + fs_enet_data.phy_addr = *phy_addr; + fs_enet_data.has_phy =1 ; + } + + + model = (char *)get_property (np,"model" ,NULL ); +strcpy (fs_enet_data.fs_type, model); + + mdio =of_get_parent (phy); + ret =of_address_to_resource (mdio,0 , &res); +if (ret) { +of_node_put (phy); +of_node_put (mdio); + goto unreg; + } + +if (strstr (model,"FEC" )) { +// int fec_index = fs_get_fec_index(*id); + r[1 ].start = r[1 ].end =irq_of_parse_and_map (np,0 ); + r[1 ].flags =IORESOURCE_IRQ ; + r[1 ].name = enet_irq; + + fs_enet_dev = +platform_device_register_simple ("fsl-cpm-fec" , i, &r[0 ],2 ); + +if (IS_ERR (fs_enet_dev)) { + ret =PTR_ERR (fs_enet_dev); + goto err; + } + + fs_enet_data.rx_ring =128 ; + fs_enet_data.tx_ring =16 ; + fs_enet_data.rx_copybreak =240 ; + fs_enet_data.use_napi =1 ; + fs_enet_data.napi_weight =17 ; + +snprintf ((char *)&bus_id[(*id)],BUS_ID_SIZE ,"%x:%02x" , + (u32 )res.start, fs_enet_data.phy_addr); + fs_enet_data.bus_id = (char *)&bus_id[(*id)]; + fs_enet_data.init_ioports = init_fec_ioports; + } +if (strstr (model,"SCC" )) { + ret =of_address_to_resource (np,1 , &r[1 ]); +if (ret) + goto err; + r[1 ].name = enet_pram; + + r[2 ].start = r[2 ].end =irq_of_parse_and_map (np,0 ); + r[2 ].flags =IORESOURCE_IRQ ; + r[2 ].name = enet_irq; + + fs_enet_dev = +platform_device_register_simple ("fsl-cpm-scc" , i, &r[0 ],3 ); + +if (IS_ERR (fs_enet_dev)) { + ret =PTR_ERR (fs_enet_dev); + goto err; + } + + fs_enet_data.rx_ring =64 ; + fs_enet_data.tx_ring =8 ; + fs_enet_data.rx_copybreak =240 ; + fs_enet_data.use_napi =1 ; + fs_enet_data.napi_weight =17 ; + +snprintf ((char *)&bus_id[(*id)],BUS_ID_SIZE ,"%s" ,"fixed@10:1" ); + fs_enet_data.bus_id = (char *)&bus_id[(*id)]; + fs_enet_data.init_ioports = init_scc_ioports; + } + +of_node_put (phy); +of_node_put (mdio); + + ret =platform_device_add_data (fs_enet_dev, &fs_enet_data, +sizeof (struct +fs_platform_info )); +if (ret) { + goto unreg; + } + } +return 0 ; + +unreg: +platform_device_unregister (fs_enet_dev); +err: +return ret; +} + +arch_initcall (fs_enet_of_init); + + +static const char *smc_regs ="regs" ; +static const char *smc_pram ="pram" ; + +static int __init cpm_smc_uart_of_init (void ) +{ +struct device_node *np; +unsigned int i; +struct platform_device *cpm_uart_dev; +int ret; + +for (np =NULL , i =0 ; + (np =of_find_compatible_node (np,"serial" ,"cpm_uart" )) !=NULL ; + i++) { +struct resource r[3 ]; +struct fs_uart_platform_info cpm_uart_data; +int *id; +char *model; + +memset (r,0 ,sizeof (r)); +memset (&cpm_uart_data,0 ,sizeof (cpm_uart_data)); + + ret =of_address_to_resource (np,0 , &r[0 ]); +if (ret) + goto err; + + r[0 ].name = smc_regs; + + ret =of_address_to_resource (np,1 , &r[1 ]); +if (ret) + goto err; + r[1 ].name = smc_pram; + + r[2 ].start = r[2 ].end =irq_of_parse_and_map (np,0 ); + r[2 ].flags =IORESOURCE_IRQ ; + + cpm_uart_dev = +platform_device_register_simple ("fsl-cpm-smc:uart" , i, &r[0 ],3 ); + +if (IS_ERR (cpm_uart_dev)) { + ret =PTR_ERR (cpm_uart_dev); + goto err; + } + + model = (char *)get_property (np,"model" ,NULL ); +strcpy (cpm_uart_data.fs_type, model); + + id = (int *)get_property (np,"device-id" ,NULL ); + cpm_uart_data.fs_no = *id; + cpm_uart_data.uart_clk = ppc_proc_freq; + + cpm_uart_data.tx_num_fifo =4 ; + cpm_uart_data.tx_buf_size =32 ; + cpm_uart_data.rx_num_fifo =4 ; + cpm_uart_data.rx_buf_size =32 ; + + ret = +platform_device_add_data (cpm_uart_dev, &cpm_uart_data, +sizeof (struct +fs_uart_platform_info )); +if (ret) + goto unreg; + } + +return 0 ; + +unreg: +platform_device_unregister (cpm_uart_dev); +err: +return ret; +} + +arch_initcall (cpm_smc_uart_of_init); + +#endif /* CONFIG_8xx */
PATCH 2/5 8xx: generic 8xx code arch/powerpc port
In reply to a message not in the archiveIncluding support for non-coherent cache, some mm-related things + relevant field in Kconfig and Makefiles. Also included rheap.o compilaiton if 8xx is defined.
---
arch/powerpc/Kconfig | 11 + arch/powerpc/kernel/Makefile | 1 arch/powerpc/kernel/dma-mapping.c | 442 +++++++++++++++++++++++++++++++++++++ arch/powerpc/lib/Makefile | 1 arch/powerpc/mm/fault.c | 99 ++++++++ 5 files changed, 552 insertions(+), 2 deletions(-)
arch/powerpc/Kconfig +9 -2
@@ -158,6 +158,11 @@ config PPC_86xx help The Freescale E600 SoCs have 74xx cores. +config PPC_8xx + bool "Freescale 8xx" + select FSL_SOC + select 8xx + config 40x bool "AMCC 40x" select PPC_DCR_NATIVE
@@ -166,8 +171,6 @@ config 44x bool "AMCC 44x" select PPC_DCR_NATIVE -config 8xx - bool "Freescale 8xx" config E200 bool "Freescale e200"
@@ -196,6 +199,10 @@ config 6xx bool # this is temp to handle compat with arch=ppc +config 8xx + bool + +# this is temp to handle compat with arch=ppc config 83xx bool
arch/powerpc/kernel/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_PPC_UDBG_16550) += legacy_s module-$(CONFIG_PPC64) += module_64.o obj-$(CONFIG_MODULES) += $(module-y) +obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-mapping.o pci64-$(CONFIG_PPC64) += pci_64.o pci_dn.o pci32-$(CONFIG_PPC32) := pci_32.o
arch/powerpc/kernel/dma-mapping.c new file +442 -0
442 lines not on this page · raw message
arch/powerpc/lib/Makefile +1 -0
@@ -24,5 +24,6 @@ endif # Temporary hack until we have migrated to asm-powerpc ifeq ($(CONFIG_PPC_MERGE),y) +obj-$(CONFIG_8xx) += rheap.o obj-$(CONFIG_CPM2) += rheap.o endif
arch/powerpc/mm/fault.c +99 -0
102 lines not on this page · raw message
PATCH 4/5 8xx: powerpc port of core CPM, CPM PIC, etc.
In reply to a message not in the archiveThis covers common CPM access functions, CPM interrupt controller code, micropatch and a few compatibility things to kee the same driver base working with arch/ppc.
---
arch/powerpc/sysdev/Makefile | 3 arch/powerpc/sysdev/commproc.c | 426 ++++++++++++++++++++++ arch/powerpc/sysdev/micropatch.c | 743 ++++++++++++++++++++++++++++++++++++++ arch/powerpc/sysdev/mpc8xx_pic.c | 209 +++++++++++ arch/powerpc/sysdev/mpc8xx_pic.h | 12 + include/asm-powerpc/fs_pd.h | 44 ++ include/asm-powerpc/mpc8xx.h | 38 ++ 7 files changed, 1465 insertions(+), 10 deletions(-)
arch/powerpc/sysdev/Makefile +3 -0
@@ -22,3 +22,6 @@ # Temporary hack until we have migrated ifeq ($(ARCH),powerpc) obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o endif + +obj-$(CONFIG_8xx) += mpc8xx_pic.o commproc.o +obj-$(CONFIG_UCODE_PATCH) += micropatch.o
arch/powerpc/sysdev/commproc.c new file +426 -0
426 lines not on this page · raw message
arch/powerpc/sysdev/micropatch.c new file +743 -0
743 lines not on this page · raw message
arch/powerpc/sysdev/mpc8xx_pic.c new file +209 -0
209 lines not on this page · raw message
arch/powerpc/sysdev/mpc8xx_pic.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef _PPC_KERNEL_MPC8xx_H +#define _PPC_KERNEL_MPC8xx_H + +#include <linux/irq.h> +#include <linux/interrupt.h> + +extern struct hw_interrupt_type mpc8xx_pic; + +void mpc8xx_pic_init (struct device_node *node); +unsigned int mpc8xx_get_irq (void ); + +#endif /* _PPC_KERNEL_PPC8xx_H */
include/asm-powerpc/fs_pd.h +34 -10
58 lines not on this page · raw message
include/asm-powerpc/mpc8xx.h new file +38 -0
@@ -0,0 +1,38 @@ +/* This is the single file included by all MPC8xx build options. +* Since there are many different boards and no standard configuration, +* we have a unique include file for each. Rather than change every +* file that has to include MPC8xx configuration, they all include +* this one and the configuration switching is done here. +*/ +#ifdef __KERNEL__ +#ifndef __CONFIG_8xx_DEFS +#define __CONFIG_8xx_DEFS + + +#ifdef CONFIG_8xx + +#ifdef CONFIG_FADS +#include <platforms/fads.h> +#endif + +#if defined(CONFIG_MPC885ADS ) +#include <platforms/8xx/mpc885ads.h> +#endif + +/* Currently, all 8xx boards that support a processor to PCI/ISA bridge +* use the same memory map. +*/ +#if !defined(_IO_BASE)/* defined in board specific header */ +#define _IO_BASE 0 +#endif +#define _ISA_MEM_BASE 0 +#define PCI_DRAM_OFFSET 0 + +#ifndef __ASSEMBLY__ +//struct pt_regs; +//#define PPC_PIN_SIZE (24 * 1024 * 1024) /* 24Mbytes of data pinned */ +#endif /* !__ASSEMBLY__ */ + +#endif /* CONFIG_8xx */ +#endif /* __CONFIG_8xx_DEFS */ +#endif /* __KERNEL__ */
PATCH 5/5 8xx: Add mpc885ads support and common mpc8xx.
In reply to a message not in the archiveThis adds the core 8xx stuff and specifically mpc885ads board-specific bits to arch/powerpc. Respective Kconfig has been cleaned up from the stuff not yet ported over to avoid confusion.
---
arch/powerpc/boot/dts/mpc885ads.dts | 195 ++++++ arch/powerpc/configs/mpc885_ads_defconfig | 827 ++++++++++++++++++++++++++ arch/powerpc/platforms/8xx/Kconfig | 267 -------- arch/powerpc/platforms/8xx/Makefile | 5 arch/powerpc/platforms/8xx/m8xx_setup.c | 327 ++++++++++ arch/powerpc/platforms/8xx/mpc885ads.h | 95 +++ arch/powerpc/platforms/8xx/mpc885ads_setup.c | 365 +++++++++++ arch/powerpc/platforms/Makefile | 1 8 files changed, 1825 insertions(+), 257 deletions(-)
arch/powerpc/boot/dts/mpc885ads.dts new file +195 -0
@@ -0,0 +1,195 @@ +/* + * MPC885 ADS Device Tree Source + * + * Copyright 2006 MontaVista Software, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + + +{ + model = "MPC885ADS"; + compatible = "mpc8xx"; + #address-cells = <1>; + #size-cells = <1>; + linux,phandle = <100>; + + cpus { + #cpus = <1>; + #address-cells = <1>; + #size-cells = <0>; + linux,phandle = <200>; + + PowerPC,885@0 { + device_type = "cpu"; + reg = <0>; + d-cache-line-size = <20>; // 32 bytes + i-cache-line-size = <20>; // 32 bytes + d-cache-size = <2000>; // L1, 8K + i-cache-size = <2000>; // L1, 8K + timebase-frequency = <0>; + bus-frequency = <0>; + clock-frequency = <0>; + 32-bit; + interrupts = <f 2>; // decrementer interrupt + interrupt-parent = <ff000000>; + linux,phandle = <201>; + linux,boot-cpu; + }; + }; + + memory { + device_type = "memory"; + linux,phandle = <300>; + reg = <00000000 800000>; + }; + + flash@fe000000 { + device_type = "mtd"; + compatible = "physmap"; + reg = <fe000000 00800000>; + bank-width = <4>; + partitions = <00000000 00080001 + 00080000 00780000>; + partition-names = "firmware\0fs"; + }; + + soc885@ff000000 { + #address-cells = <1>; + #size-cells = <1>; + #interrupt-cells = <2>; + device_type = "soc"; + ranges = <0 ff000000 00100000>; + reg = <ff000000 00000200>; + bus-frequency = <0>; + mdio@e80 { + device_type = "mdio"; + compatible = "fs_enet"; + reg = <e80 8>; + linux,phandle = <e80>; + #address-cells = <1>; + #size-cells = <0>; + ethernet-phy@0 { + linux,phandle = <e8000>; + reg = <0>; + device_type = "ethernet-phy"; + }; + ethernet-phy@1 { + linux,phandle = <e8001>; + reg = <1>; + device_type = "ethernet-phy"; + }; + ethernet-phy@2 { + linux,phandle = <e8002>; + reg = <2>; + device_type = "ethernet-phy"; + }; + }; + + fec@e00 { + device_type = "network"; + compatible = "fs_enet"; + model = "FEC"; + device-id = <1>; + reg = <e00 188>; + mac-address = [ 00 00 0C 00 01 FD ]; + interrupts = <3 2>; + interrupt-parent = <ff000000>; + phy-handle = <e8000>; + }; + + fec@1e00 { + device_type = "network"; + compatible = "fs_enet"; + model = "FEC"; + device-id = <2>; + reg = <1e00 188>; + mac-address = [ 00 00 0C 00 02 FD ]; + interrupts = <7 2>; + interrupt-parent = <ff000000>; + phy-handle = <e8001>; + }; + + pic@ff000000 { + linux,phandle = <ff000000>; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <2>; + reg = <0 24>; + built-in; + device_type = "mpc8xx-pic"; + compatible = "CPM"; + }; + + cpm@ff000000 { + linux,phandle = <ff000000>; + #address-cells = <1>; + #size-cells = <1>; + #interrupt-cells = <2>; + device_type = "cpm"; + model = "CPM"; + ranges = <0 0 4000>; + reg = <860 f0>; + command-proc = <9c0>; + brg-frequency = <0>; + interrupts = <0 2>; // cpm error interrupt + interrupt-parent = <930>; + + pic@930 { + linux,phandle = <930>; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <2>; + interrupts = <5 2 0 2>; + interrupt-parent = <ff000000>; + reg = <930 20>; + built-in; + device_type = "cpm-pic"; + compatible = "CPM"; + }; + + smc@a80 { + device_type = "serial"; + compatible = "cpm_uart"; + model = "SMC"; + device-id = <1>; + reg = <a80 10 3e80 40>; + clock-setup = <00ffffff 0>; + rx-clock = <1>; + tx-clock = <1>; + current-speed = <0>; + interrupts = <4 3>; + interrupt-parent = <930>; + }; + + smc@a90 { + device_type = "serial"; + compatible = "cpm_uart"; + model = "SMC"; + device-id = <2>; + reg = <a90 20 3f80 40>; + clock-setup = <ff00ffff 90000>; + rx-clock = <2>; + tx-clock = <2>; + current-speed = <0>; + interrupts = <3 3>; + interrupt-parent = <930>; + }; + scc@a40 { + device_type = "network"; + compatible = "fs_enet"; + model = "SCC"; + device-id = <3>; + reg = <a40 18 3e00 80>; + mac-address = [ 00 00 0C 00 03 FD ]; + interrupts = <1c 3>; + interrupt-parent = <930>; + phy-handle = <e8002>; + }; + }; + + }; +};
arch/powerpc/configs/mpc885_ads_defconfig new file +827 -0
827 lines not on this page · raw message
arch/powerpc/platforms/8xx/Kconfig +10 -257
297 lines not on this page · raw message
arch/powerpc/platforms/8xx/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for the PowerPC 8xx linux kernel. +# +obj-$(CONFIG_PPC_8xx) += m8xx_setup.o +obj-$(CONFIG_MPC885ADS) += mpc885ads_setup.o
arch/powerpc/platforms/8xx/m8xx_setup.c new file +327 -0
327 lines not on this page · raw message
arch/powerpc/platforms/8xx/mpc885ads.h new file +95 -0
95 lines not on this page · raw message
arch/powerpc/platforms/8xx/mpc885ads_setup.c new file +365 -0
365 lines not on this page · raw message
arch/powerpc/platforms/Makefile +1 -0
@@ -8,6 +8,7 @@ endif obj-$(CONFIG_PPC_EFIKA) += efika/ obj-$(CONFIG_PPC_CHRP) += chrp/ obj-$(CONFIG_4xx) += 4xx/ +obj-$(CONFIG_PPC_8xx) += 8xx/ obj-$(CONFIG_PPC_83xx) += 83xx/ obj-$(CONFIG_PPC_85xx) += 85xx/ obj-$(CONFIG_PPC_86xx) += 86xx/
Re: [PATCH 3/5] [POWERPC] 8xx: platform-related changes to the fsl_soc.c
In reply to Vitaly BordugQuoted 3 lines · Vitaly Bordug
Added 8xx SoC peripherials: fec for Ethernet and smc for UARTs. Ordinary routines to extract values from the device tree and insert respective platform devices
Note that imho, that's at best a temporary thing. It would be much better to have these drivers register as of_platform_driver's and have the platform code publish of_platform_device's for all SoC nodes.
Ben.
Re: [PATCH 4/5] [POWERPC] 8xx: powerpc port of core CPM, CPM PIC, etc.
In reply to Vitaly BordugGreat !
Some comments ...
arch/powerpc/sysdev/commproc.c line 68
Quoted 13 lines
arch/powerpc/sysdev/commproc.c new file +13
-0+static void cpm_mask_irq (unsigned int irq) +{ +unsigned int cpm_vec = (unsigned int )irq_map[irq].hwirq; + +clrbits32 (&cpic_reg->cpic_cimr, (1 << cpm_vec)); +} + +static void cpm_unmask_irq (unsigned int irq) +{ +unsigned int cpm_vec = (unsigned int )irq_map[irq].hwirq; + +setbits32 (&cpic_reg->cpic_cimr, (1 << cpm_vec)); +}
Some space/tab mangling up there :-)
arch/powerpc/sysdev/commproc.c line 73
Quoted 4 lines
arch/powerpc/sysdev/commproc.c new file +4
-0+static void cpm_mask_and_ack (unsigned int irq) +{ +/* We do not need to do anything here. */ +}
Then you probably don't need the callback. What flow handler are you using ?
arch/powerpc/sysdev/commproc.c line 80
Quoted 6 lines
arch/powerpc/sysdev/commproc.c new file +6
-0+static void cpm_end_irq (unsigned int irq) +{ +unsigned int cpm_vec = (unsigned int )irq_map[irq].hwirq; + +out_be32 (&cpic_reg->cpic_cisr, (1 << cpm_vec)); +}
That looks like a fasteoi type handler to me...
arch/powerpc/sysdev/commproc.c line 89
Quoted 8 lines
arch/powerpc/sysdev/commproc.c new file +8
-0+static struct irq_chip cpm_pic = { + .typename =" CPM PIC " , + .enable = cpm_unmask_irq, + .disable = cpm_mask_irq, + .unmask = cpm_unmask_irq, + .mask_ack = cpm_mask_and_ack, + .end = cpm_end_irq, +};
Remove enable/disable, the common code will use mask/unmask to implement them. Also, remove mask_ack and use .eoi for your eoi handler and you should be able to use the handle_fasteoi_irq() flow handler for your PIC.
arch/powerpc/sysdev/commproc.c line 108
Quoted 4 lines
arch/powerpc/sysdev/commproc.c new file +4
-0+static int cpm_pic_host_match (struct irq_host *h,struct device_node *node) +{ +return cpm_pic_node ==NULL || cpm_pic_node == node; +}
Are you sure you want to match on a NULL node ?
arch/powerpc/sysdev/commproc.c line 118
Quoted 9 lines
arch/powerpc/sysdev/commproc.c new file +9
-0+static int cpm_pic_host_map (struct irq_host *h,unsigned int virq, +irq_hw_number_t hw) +{ +pr_debug ("cpm_pic_host_map(%d, 0x%lx)\n" , virq, hw); + +get_irq_desc (virq)->status |=IRQ_LEVEL ; +set_irq_chip_and_handler (virq, &cpm_pic, handle_level_irq); +return 0 ; +}
As I said above, use fasteoi, not level. Like mpic or xics
arch/powerpc/sysdev/commproc.c line 127
Quoted 8 lines
arch/powerpc/sysdev/commproc.c new file +8
-0+static void cpm_host_unmap (struct irq_host *h,unsigned int virq) +{ +/* Make sure irq is masked in hardware */ +cpm_mask_irq (virq); + +/* remove chip and handler */ +set_irq_chip_and_handler (virq,NULL ,NULL ); +}
The above is a duplicate of the common code, you can probably just not implement an unmap callback at all.
Quoted 9 lines
arch/powerpc/sysdev/commproc.c new file +9
-0+static int cpm_pic_host_xlate (struct irq_host *h,struct device_node *ct, +u32 *intspec,unsigned int intsize, +irq_hw_number_t *out_hwirq,unsigned int *out_flags) +{ +static unsigned char map_cpm_senses[4 ] = { +IRQ_TYPE_LEVEL_LOW , +IRQ_TYPE_LEVEL_HIGH , +IRQ_TYPE_EDGE_FALLING , +IRQ_TYPE_EDGE_RISING ,
arch/powerpc/sysdev/commproc.c line 147
Quoted 10 lines
arch/powerpc/sysdev/commproc.c new file +10
-0+ }; + + *out_hwirq = intspec[0 ]; +if (intsize >1 && intspec[1 ] <4 ) + *out_flags = map_cpm_senses[intspec[1 ]]; +else + *out_flags =IRQ_TYPE_NONE ; + +return 0 ; +}
Can the interrupts have a different sense/polarity ? Because you never configure that anywhere in the code, so that means you either expect them to be configured by the firmware, or they have a fixed sense/polarity in which case, since you can use a fasteoi handler, you don't even care wether they are level or edge. Thus, if all that is true, just use a #interrupt-cells of 1 and don't bother with putting sense/polarity info in the tree at all :-)
arch/powerpc/sysdev/commproc.c line 157
Quoted 9 lines
arch/powerpc/sysdev/commproc.c new file +9
-0+/* The CPM can generate the error interrupt when there is a race condition +* between generating and masking interrupts. All we have to do is ACK it +* and return. This is a no-op function so we don't need any special +* tests in the interrupt handler. +*/ +static irqreturn_t cpm_error_interrupt (int irq,void *dev) +{ +return IRQ_HANDLED ; +}
Can you tell me more about this error interrupt ?
arch/powerpc/sysdev/commproc.c line 192
Quoted 7 lines
arch/powerpc/sysdev/commproc.c new file +7
-0+ ret =of_address_to_resource (np,0 , &res); +if (ret) +return sirq; + + cpic_reg = (void *)ioremap (res.start, res.end - res.start +1 ); +if (cpic_reg ==NULL ) +return sirq;
Your error path probably need an of_node_put(np);
arch/powerpc/sysdev/commproc.c line 194
Quoted 1 line
arch/powerpc/sysdev/commproc.c new file +1
-0+ sirq =irq_of_parse_and_map (np,0 );
Check for NO_IRQ here in case the device-tree is broken.
arch/powerpc/sysdev/commproc.c line 200
Quoted 5 lines
arch/powerpc/sysdev/commproc.c new file +5
-0+/* Initialize the CPM interrupt controller. */ + hwirq = (unsigned int )irq_map[sirq].hwirq; +out_be32 (&cpic_reg->cpic_cicr, + (CICR_SCD_SCC4 |CICR_SCC_SCC3 |CICR_SCB_SCC2 |CICR_SCA_SCC1 ) | + ((hwirq/2 ) <<13 ) |CICR_HP_MASK );
Here you are configuring the HW irq going to the parent controller ?
arch/powerpc/sysdev/commproc.c line 206
Quoted 5 lines
arch/powerpc/sysdev/commproc.c new file +5
-0+out_be32 (&cpic_reg->cpic_cimr,0 ); + +/* create a legacy host */ +if (np) + cpm_pic_node =of_node_get (np);
The comment probably needs to change or go :-)
arch/powerpc/sysdev/commproc.c line 213
Quoted 6 lines
arch/powerpc/sysdev/commproc.c new file +6
-0+ cpm_pic_host =irq_alloc_host (IRQ_HOST_MAP_LINEAR ,64 , &cpm_pic_host_ops,64 ); +if (cpm_pic_host ==NULL ) { +printk (KERN_ERR "CPM2 PIC: failed to allocate irq host!\n" ); + sirq =NO_IRQ ; +return sirq; + }
More missing of_node_put() in error path.
arch/powerpc/sysdev/commproc.c line 219
Quoted 5 lines
arch/powerpc/sysdev/commproc.c new file +5
-0+/* Install our own error handler. */ + np =of_find_node_by_type (NULL ,"cpm" ); + eirq=irq_of_parse_and_map (np,0 ); +if (setup_irq (eirq, &cpm_error_irqaction)) +printk (KERN_ERR "Could not allocate CPM error IRQ!" );
Some error checking above might be useful on the result on of_find_node_by_type() and irq_of_parse_and_map().
[ skip ucode patches ]
Wouldn't it be better to have that in the device-tree ? Not sure here, just asking ...
Quoted 60 lines
arch/powerpc/sysdev/micropatch.c new file +60
-0+ +#ifdef CONFIG_USB_SOF_UCODE_PATCH + commproc->cp_rccr =0 ; + + dp = (uint *)(commproc->cp_dpmem); +for (i=0 ; i<(sizeof (patch_2000)/4 ); i++) + *dp++ = patch_2000[i]; + + dp = (uint *)&(commproc->cp_dpmem[0x0f00 ]); +for (i=0 ; i<(sizeof (patch_2f00)/4 ); i++) + *dp++ = patch_2f00[i]; + + commproc->cp_rccr =0x0009 ; + +printk ("USB SOF microcode patch installed\n" ); +#endif /* CONFIG_USB_SOF_UCODE_PATCH */ + +#if defined(CONFIG_I2C_SPI_UCODE_PATCH ) || \ + defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH ) + + commproc->cp_rccr =0 ; + + dp = (uint *)(commproc->cp_dpmem); +for (i=0 ; i<(sizeof (patch_2000)/4 ); i++) + *dp++ = patch_2000[i]; + + dp = (uint *)&(commproc->cp_dpmem[0x0f00 ]); +for (i=0 ; i<(sizeof (patch_2f00)/4 ); i++) + *dp++ = patch_2f00[i]; + + iip = (iic_t *)&commproc->cp_dparam[PROFF_IIC ]; +# define RPBASE 0x0500 + iip->iic_rpbase =RPBASE ; + +/* Put SPI above the IIC, also 32-byte aligned. +*/ + i = (RPBASE +sizeof (iic_t) +31 ) & ~31 ; + spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI ]; + spp->spi_rpbase = i; + +# if defined(CONFIG_I2C_SPI_UCODE_PATCH ) + commproc->cp_cpmcr1 =0x802a ; + commproc->cp_cpmcr2 =0x8028 ; + commproc->cp_cpmcr3 =0x802e ; + commproc->cp_cpmcr4 =0x802c ; + commproc->cp_rccr =1 ; + +printk ("I2C/SPI microcode patch installed.\n" ); +# endif /* CONFIG_I2C_SPI_UCODE_PATCH */ + +# if defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH ) + + dp = (uint *)&(commproc->cp_dpmem[0x0e00 ]); +for (i=0 ; i<(sizeof (patch_2e00)/4 ); i++) + *dp++ = patch_2e00[i]; + + commproc->cp_cpmcr1 =0x8080 ; + commproc->cp_cpmcr2 =0x808a ; + commproc->cp_cpmcr3 =0x8028 ; + commproc->cp_cpmcr4 =0x802a ;
arch/powerpc/sysdev/micropatch.c line 703
Quoted 10 lines
arch/powerpc/sysdev/micropatch.c new file +10
-0+ commproc->cp_rccr =3 ; + + smp = (smc_uart_t *)&commproc->cp_dparam[PROFF_SMC1 ]; + smp->smc_rpbase =0x1FC0 ; + +printk ("I2C/SPI/SMC1 microcode patch installed.\n" ); +# endif /* CONFIG_I2C_SPI_SMC1_UCODE_PATCH) */ + +#endif /* some variation of the I2C/SPI patch was selected */ +}
A lot of ifdefs in there ... I would prefer a few device-tree entries indicating what has to be done so that a given kernel image can be made to work on 2 or 3 revs of a board needing a different patch. That should be all small enough. You can still have CONFIG options to define which patches are supported (built in the kernel image) so that one can choose to only have one in to get the smallest possible image, but it would be nice to have the ability to select them as a set and have the platform define, via the tree, which patches to apply.
Quoted 4 lines
+/*
+ * Take this entire routine out, since no one calls it and its
+ * logic is suspect.
+ */
Well... just do it then :-)
Quoted 5 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +5
-0+static void mpc8xx_end_irq (unsigned int virq) +{ +unsigned int irq_nr = (unsigned int )irq_map[virq].hwirq; + + if (!(irq_desc[irq_nr].status & (IRQ_DISABLED|IRQ_INPROGRESS))
arch/powerpc/sysdev/mpc8xx_pic.c line 81
Quoted 10 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +10
-0+ && irq_desc[irq_nr].action) { +int bit, word; + + bit = irq_nr &0x1f ; + word = irq_nr >>5 ; + + ppc_cached_irq_mask[word] |= (1 << (31 -bit)); +out_be32 (&siu_reg->sc_simask, ppc_cached_irq_mask[word]); + } +}
You should never need a end() handler. You might want an eoi() if you have a smart controller and can use fasteoi(). For normal level or edge, the flow handler will implement the logic of unmasking when needed.
Quoted 11 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +11
-0+static int mpc8xx_set_irq_type (unsigned int virq,unsigned int flow_type) +{ +struct irq_desc *desc =get_irq_desc (virq); + + + desc->status &= ~(IRQ_TYPE_SENSE_MASK |IRQ_LEVEL ); + desc->status |= flow_type &IRQ_TYPE_SENSE_MASK ; +if (flow_type & (IRQ_TYPE_LEVEL_HIGH |IRQ_TYPE_LEVEL_LOW )) + desc->status |=IRQ_LEVEL ; + +if (flow_type &IRQ_TYPE_EDGE_FALLING ) {
arch/powerpc/sysdev/mpc8xx_pic.c line 103
Quoted 10 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +10
-0+irq_hw_number_t hw = (unsigned int )irq_map[virq].hwirq; +unsigned int siel =in_be32 (&siu_reg->sc_siel); +if ((hw &1 ) ==0 ) + siel |= (0x80000000 >> hw); +else + siel &= ~(0x80000000 >> (hw & ~1 )); +out_be32 (&siu_reg->sc_siel, siel); + } +return 0 ; +}
Don't you need to change the flow handler too between edge/level ?
Also, waht is this sc_siel register for ? I'm surprised you have to do something when swithing an irq to edge but not undo it when switching it to level...
arch/powerpc/sysdev/mpc8xx_pic.c line 113
Quoted 9 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +9
-0+static struct irq_chip mpc8xx_pic = { + .typename =" MPC8XX SIU " , + .enable = mpc8xx_unmask_irq, + .disable = mpc8xx_mask_irq, + .unmask = mpc8xx_unmask_irq, + .mask_ack = mpc8xx_mask_and_ack, + .end = mpc8xx_end_irq, + .set_type = mpc8xx_set_irq_type, +};
Remove enable/disable/end. Add ack() if you use the edge flow handler.
Quoted 12 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +12
-0+unsigned int mpc8xx_get_irq (void ) +{ +int irq; + +/* For MPC8xx, read the SIVEC register and shift the bits down +* to get the irq number. +*/ + irq =in_be32 (&siu_reg->sc_sivec) >>26 ; + +/* +* When we read the sivec without an interrupt to process, we will +* get back SIU_LEVEL7. In this case, return -1
arch/powerpc/sysdev/mpc8xx_pic.c line 136
Quoted 10 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +10
-0+*/ +// if (irq == CPM_INTERRUPT) +// irq = CPM_IRQ_OFFSET + cpm_get_irq(regs); +// else +if (irq ==PIC_VEC_SPURRIOUS ) + irq =NO_IRQ ; +return irq_linear_revmap (mpc8xx_pic_host, irq); + +// return irq; +}
Needs cleanups :-) Also is a bit buggy, you probably want
if (irq == PIC_VEC_SPURRIOUS) return NO_IRQ;
arch/powerpc/sysdev/mpc8xx_pic.c line 141
Quoted 4 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +4
-0+static int mpc8xx_pic_host_match (struct irq_host *h,struct device_node *node) +{ +return mpc8xx_pic_node ==NULL || mpc8xx_pic_node == node; +}
Why match when mpc8xx_pic_node is NULL ? This is something that 8259 does for weird reasons of being compatible with crappy device-trees on some machines. Not something you should bring in for new ports.
arch/powerpc/sysdev/mpc8xx_pic.c line 159
Quoted 8 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +8
-0+static void mpc8xx_pic_host_unmap (struct irq_host *h,unsigned int virq) +{ +/* Make sure irq is masked in hardware */ +mpc8xx_mask_irq (virq); + +/* remove chip and handler */ +set_irq_chip_and_handler (virq,NULL ,NULL ); +}
You probably don't need an unmap callback at all.
Quoted 6 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +6
-0+void mpc8xx_pic_init (struct device_node *np) +{ +struct resource res; +int ret; + +/* create a legacy host */
arch/powerpc/sysdev/mpc8xx_pic.c line 203
Quoted 10 lines
arch/powerpc/sysdev/mpc8xx_pic.c new file +10
-0+if (np) + mpc8xx_pic_node =of_node_get (np); + + ret =of_address_to_resource (np,0 , &res); +if (ret) +return ; + + siu_reg = (void *)ioremap (res.start, res.end - res.start +1 ); +if (siu_reg ==NULL ) +return ;
of_node_put(np);
Quoted 4 lines
include/asm-powerpc/mpc8xx.h new file +4
-0+ mpc8xx_pic_host =irq_alloc_host (IRQ_HOST_MAP_LINEAR ,64 , &mpc8xx_pic_host_ops,64 ); +if (mpc8xx_pic_host ==NULL ) { +printk (KERN_ERR "MPC8xx PIC: failed to allocate irq host!\n" ); + }
include/asm-powerpc/mpc8xx.h line 29
Quoted 10 lines
include/asm-powerpc/mpc8xx.h new file +9
-0+} +/* Currently, all 8xx boards that support a processor to PCI/ISA bridge +* use the same memory map. +*/ +#if !defined(_IO_BASE)/* defined in board specific header */ +#define _IO_BASE 0 +#endif +#define _ISA_MEM_BASE 0 +#define PCI_DRAM_OFFSET 0
The above should now be defined generically in asm-powerpc/io.h (at least with my latest patches).
include/asm-powerpc/mpc8xx.h line 34
Quoted 4 lines
include/asm-powerpc/mpc8xx.h new file +4
-0+#ifndef __ASSEMBLY__ +//struct pt_regs; +//#define PPC_PIN_SIZE (24 * 1024 * 1024) /* 24Mbytes of data pinned */ +#endif /* !__ASSEMBLY__ */
Some cleanup is overdue here :-)\
Cheers,
Ben.
Re: [PATCH 5/5] [POWERPC] 8xx: Add mpc885ads support and common mpc8xx.
In reply to Vitaly BordugFew comments..
arch/powerpc/platforms/8xx/m8xx_setup.c line 327
Quoted 12 lines
arch/powerpc/platforms/8xx/m8xx_setup.c new file +12
-0+/* +* Called very early, device-tree isn't unflattened +*/ +int __init mpc8xx_probe (void ) +{ +unsigned long root =of_get_flat_dt_root (); + +if (of_flat_dt_is_compatible (root,"mpc8xx" )) +return 1 ; + +return 0 ; +}
Why hooks on that ?
Normally, board support files test for their specific board. Thus they have their own probe() function, generally static just before the ppc_md definition. You probably want to remove the above,.
arch/powerpc/platforms/8xx/mpc885ads_setup.c line 356
Quoted 3 lines
arch/powerpc/platforms/8xx/mpc885ads_setup.c new file +3
-0+define_machine (mpc885_ads) { + .name = "MPC885 ADS", + .probe = mpc8xx_probe,
Do your own probe function that specifically checks for and MPC885 ADS board.
Re: [PATCH 3/5] [POWERPC] 8xx: platform-related changes to the fsl_soc.c
In reply to Benjamin HerrenschmidtQuoted 9 lines · On Tue, 14 Nov 2006 13:21:14 +1100 Benjamin Herrenschmidt…
Quoted 3 lines · Vitaly Bordug
Added 8xx SoC peripherials: fec for Ethernet and smc for UARTs. Ordinary routines to extract values from the device tree and insert respective platform devices
Note that imho, that's at best a temporary thing. It would be much better to have these drivers register as of_platform_driver's and have the platform code publish of_platform_device's for all SoC nodes.
The platform device way will persist until we haven't care about arch/ppc stuff anymore. As for now, I'm trying to keep both powerpc and ppc approaches sane.
Hence it is temporary, but it is the way of merge. of_platform_device rework is not a big deal - we'll do it later.
Signature · 2 lines
Sincerely, Vitaly
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
In reply to Vitaly Bordugarch/powerpc/kernel/dma-mapping.c
Quoted 2 lines · Vitaly Bordug
arch/powerpc/kernel/dma-mapping.c new file +0
-0
Can we please give this a more descriptive name? MIPS names the equivalent dma-noncoherent.c which makes a lot of sense to me.
Quoted 19 lines
arch/powerpc/kernel/dma-mapping.c new file +19
-0+#include <linux/module.h> +#include <linux/signal.h> +#include <linux/sched.h> +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/string.h> +#include <linux/types.h> +#include <linux/ptrace.h> +#include <linux/mman.h> +#include <linux/mm.h> +#include <linux/swap.h> +#include <linux/stddef.h> +#include <linux/vmalloc.h> +#include <linux/init.h> +#include <linux/delay.h> +#include <linux/bootmem.h> +#include <linux/highmem.h> +#include <linux/dma-mapping.h> +#include <linux/hardirq.h>
arch/powerpc/kernel/dma-mapping.c line 53
Quoted 10 lines
arch/powerpc/kernel/dma-mapping.c new file +10
-0+ +#include <asm/pgalloc.h> +#include <asm/prom.h> +#include <asm/io.h> +#include <asm/mmu_context.h> +#include <asm/pgtable.h> +#include <asm/mmu.h> +#include <asm/uaccess.h> +#include <asm/smp.h> +#include <asm/machdep.h>
Do you really need all these headers?
Quoted 1 line
+int
map_page(unsigned long va, phys_addr_t pa, int flags);
this one doesn't seem to be used ever. And even if it was a non-static forward-declaration in a .c is not something we'd want.
Quoted 14 lines
+/*
+ * VM region handling support.
+ *
+ * This should become something generic, handling VM region allocations for
+ * vmalloc and similar (ioremap, module space, etc).
+ *
+ * I envisage vmalloc()'s supportingvm_structbecoming:
+ *
+ * structvm_struct{+ * struct vm_region region; + * unsigned long flags; + * struct page **pages; + * unsigned int nr_pages; + * unsigned long phys_addr;
Quoted 14 lines
+ * };
+ *
+ *get_vm_area()would then callvm_region_allocwith an appropriate
+ * structvm_regionhead (eg):
+ *
+ * structvm_regionvmalloc_head= {
+ * .vm_list =LIST_HEAD_INIT(vmalloc_head.vm_list),
+ * .vm_start =VMALLOC_START,
+ * .vm_end =VMALLOC_END,
+ * };
+ *
+ * However, vmalloc_head.vm_start is variable (typically, it is dependent on
+ * the amount of RAM found at boot time.) I would imagine thatget_vm_area()
+ * would have to initialise this each time prior to calling vm_region_alloc(
Yeah, I suspect you should do that instead of adding another copy of a copy of core VM code..
Btw, is there anything ppc-specific in the noncoherent dma code? It might be a good idea to put it into lib/ otherwise, I'll contribute a dma-coherent.c for simple architectures for there aswell..
arch/powerpc/mm/fault.c void bad_page_fault(struct pt_regs *regs · line 452
Quoted 9 lines
arch/powerpc/mm/fault.c +3
-0@@ -447,3 +447,102 @@ void bad_page_fault(struct pt_regs *regsdie ("Kernel access of bad area" , regs, sig); } + +#ifdef CONFIG_8xx +
Can we put this functions into a separate file instea of an ifdefed section
Quoted 13 lines
arch/powerpc/mm/fault.c +13
-0+/* The pgtable.h claims some functions generically exist, but I +* can't find them...... +*/ +pte_t *va_to_pte (unsigned long address) +{ +pgd_t *dir; +pmd_t *pmd; +pte_t *pte; + +if (address <TASK_SIZE ) +return NULL ; + + dir =pgd_offset (&init_mm, address);
arch/powerpc/mm/fault.c void bad_page_fault(struct pt_regs *regs · line 475
Quoted 10 lines
arch/powerpc/mm/fault.c +10
-0+if (dir) { + pmd =pmd_offset (dir, address &PAGE_MASK ); +if (pmd &&pmd_present (*pmd)) { + pte =pte_offset_kernel (pmd, address &PAGE_MASK ); +if (pte &&pte_present (*pte)) +return (pte); + } + } +return NULL ; +}
But wha do you need this for anyway? It's not used anywhere currently, and it's not 8xx-specific at all?
arch/powerpc/mm/fault.c void bad_page_fault(struct pt_regs *regs · line 485
Quoted 9 lines
arch/powerpc/mm/fault.c +9
-0+unsigned long va_to_phys (unsigned long address) +{ +pte_t *pte; + + pte =va_to_pte (address); +if (pte) +return (((unsigned long )(pte_val (*pte)) &PAGE_MASK ) | (address & ~(PAGE_MASK ))); +return (0 ); +}
Shouldn't you use virt_to_phys instead?
Also for the last two I'd prefer if you'd find a way to avoid adding them.
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
Hi Christoph,
As a short disclaimer, the patch under consideration is a direct copy from arch/ppc (since the aim is to move the migration
forward). Apparently it looks like it's a good time to clean it up, and maybe move to /lib so that we have central stuff to deal with non-cache-coherent targets. But I have to say I don't know much about other arch's approaches to consider what we have below ppc-specific or not.
All your notes make sense so I'll clean up and will remove ifdeffed section.
But as for generic approach, my opinion is that it should be carefully considered, and I suggest to get back to it once the 8xx framework will get in.
Thanks for your time!
--
Sincerely, Vitaly
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
In reply to Christoph HellwigQuoted 16 lines
But wha do you need this for anyway? It's not used anywhere currently, and it's not 8xx-specific at all?
arch/powerpc/mm/fault.c void bad_page_fault(struct pt_regs *regs · line 485
Quoted 9 lines
arch/powerpc/mm/fault.c +9
-0+unsigned long va_to_phys (unsigned long address) +{ +pte_t *pte; + + pte =va_to_pte (address); +if (pte) +return (((unsigned long )(pte_val (*pte)) &PAGE_MASK ) | (address & ~(PAGE_MASK ))); +return (0 ); +}Shouldn't you use
virt_to_physinstead?
Quoted 2 lines
Also for the last two I'd prefer if you'd find a way to avoid adding them.
I think those 2 are used for cases where they either have a non-linear mapping a-la Amiga/APUS or in cases where they try to get addresses of things in the vmalloc area no ?.
Ben.
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
Quoted 3 lines · Benjamin Herrenschmidt
I think those 2 are used for cases where they either have a non-linear mapping a-la Amiga/APUS or in cases where they try to get addresses of things in the vmalloc area no ?.
For vmalloc we should be using vmalloc_to_page and then page_to_phys, but again, I'd prefer to see the actual user before making detailed suggestions.
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
In reply to Vitaly BordugI've done some grepping, so here are some more useful comments on the fault.c additions:
arch/powerpc/mm/fault.c void bad_page_fault(struct pt_regs *regs · line 455
Quoted 5 lines
arch/powerpc/mm/fault.c +5
-0+#ifdef CONFIG_8xx + +/* The pgtable.h claims some functions generically exist, but I +* can't find them...... +*/
This comment is copied from arch/ppc/ but utterly wrong - no one but 8xx implements any of these functions. I'd say just kill it.
Quoted 1 line
+pte_t *va_to_pte(unsigned long address)
this is used by arch/ppc/fec.c to set mapping uncachable, which seems rather odd to me. For now we'll have to keep it I think, but it might make sense to move the implementation to fec.c.
Quoted 1 line
+unsigned long
va_to_phys(unsigned long address)
this is completely unused. You should probably remove it from arch/ppc aswell.
arch/powerpc/mm/fault.c void bad_page_fault(struct pt_regs *regs · line 529
Quoted 5 lines
arch/powerpc/mm/fault.c +4
-0+void +print_8xx_pte(struct mm_struct *mm, unsigned long addr) +int +get_8xx_pte(struct mm_struct *mm, unsigned long addr)
These two are only used by arch/ppc/kernel/softemu8xx.c and should bew move to that file.
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
Quoted 2 lines · Christoph Hellwig
this is used by
arch/ppc/fec.cto set mapping uncachable, which seems rather odd to me.
I thought arch/ppc/fec.c is dead in favor of the "generic" version in the drivers/net directory?
We use the va_to_pte() functions to find
the mappings to create "coherent" cache areas by changing the cache attributes of the vmalloc() space. We can't use virt_to_phys() or similar associated functions because they simply do the kernel virtual arithmetic and don't return the proper PTEs for for changing these attributes.
I believe this is also used on the 4xx, but I could be mistaken.
Quoted 2 lines
..... For now we'll have to keep it I think, but it might make sense to move the implementation to
fec.c.
I don't know what version of fec.c you are looking at, but it should use the dma_alloc_coherent() functions and be stashing both the physical and virtual addresses. I made this change long ago and I hope it hasn't been lost.
The coherent dma functions will in turn use the va_to_pte() (or associated functions) mentioned above.
Thanks.
-- Dan
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
Quoted 7 lines · Dan Malek
Quoted 2 lines · Christoph Hellwig
this is used by
arch/ppc/fec.cto set mapping uncachable, which seems rather odd to me.I thought
arch/ppc/fec.cis dead in favor of the "generic" version in thedrivers/netdirectory?
Sorry, I actually meant drivers/net/fec.c.
Quoted 7 lines
We use the
va_to_pte()functions to find
the mappings to create "coherent" cache areas by changing the cache attributes of thevmalloc()space. We can't usevirt_to_phys()or similar associated functions because they simply do the kernel virtual arithmetic and don't return the proper PTEs for for changing these attributes.
Yes, I noticed that in the second round of actually looking at all the users.
Quoted 11 lines
Quoted 1 line
it might make sense to move the implementation to
fec.c.I don't know what version of
fec.cyou are looking at, but it should use thedma_alloc_coherent()functions and be stashing both the physical and virtual addresses. I made this change long ago and I hope it hasn't been lost.The coherent dma functions will in turn use the
va_to_pte()(or associated functions) mentioned above.
drivers/net/fec.c in current linus tree doesn't use the dma api at all, and there is no dma api implementation that uses va_to_pte(). The only users of va_to_pte() in current Linus tree are drivers/net/fec.c:fec_uncachable() in the #else block of a large #ifdef / #ifelse spagethhi sections and va_to_phys in arch/ppc/mm/fault.c under CONFIG_8xx, which is unused.
Re: [PATCH 2/5] [POWERPC] 8xx: generic 8xx code arch/powerpc port
Quoted 1 line · Christoph Hellwig
Sorry, I actually meant
drivers/net/fec.c.
That's the wrong one, too :-)
Since I was able to go on an adventure among the Ethernet drivers today, I noticed all of the PQs use the drivers/net/fs_enet directory. The MPC8xx will use some combination
of the SCC or FEC MAC driver functions in that directory. They all use the cache coherent DMA allocators properly.
Thanks.
-- Dan