* [PATCH 0/5] SWIOTLB for ppc/mpc86xx @ 2009-04-20 16:26 Becky Bruce 2009-04-20 16:26 ` [PATCH 0/5] enable swiotlb on ppc/86xx Becky Bruce 0 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori This patch series allows the use of swiotlb on mpc86xx, with 85xx support soon to follow. The most notable change here is the addition of addr_needs_map to dma_ops. This is used to tell if a device can reach an address without bounce buffering. I believe that patches will be coming out soon to make dma_ops non-arch-specific, and I expect to see something similar there as well. I've also changed sg_dma_len to be the same on both 32 and 64-bit. We now look at sg->dma_length in both cases (see patch log). The dma_window* elements in the pci_controller struct are hoisted out of an #ifdef CONFIG_PPC64 so we can use them to store off information about how much memory is mapped via the inbound pci windows. A dma-swiotlb.c is created in arch/powerpc/kernel to contain all the platform-specific iotlb code. Finally, hooks are provided to allow enabling of this feature on 86xx via Kconfig, and a 36-bit device tree for 8641hpcn is provided. Ye Olde Diffstat: arch/powerpc/Kconfig | 2 +- arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 ++++++++++++++++++++++++++++ arch/powerpc/include/asm/dma-mapping.h | 11 + arch/powerpc/include/asm/pci-bridge.h | 6 +- arch/powerpc/include/asm/scatterlist.h | 6 +- arch/powerpc/include/asm/swiotlb.h | 24 ++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/dma-swiotlb.c | 161 ++++++++ arch/powerpc/kernel/dma.c | 2 +- arch/powerpc/kernel/setup_32.c | 4 + arch/powerpc/sysdev/fsl_pci.c | 4 + 11 files changed, 809 insertions(+), 9 deletions(-) Cheers, Becky ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 0/5] enable swiotlb on ppc/86xx 2009-04-20 16:26 [PATCH 0/5] SWIOTLB for ppc/mpc86xx Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 16:26 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce 0 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori GIT: Please enter your email below. GIT: Lines beginning in "GIT: " will be removed. GIT: Consider including an overall diffstat or table of contents GIT: for the patch you are writing. ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx 2009-04-20 16:26 ` [PATCH 0/5] enable swiotlb on ppc/86xx Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 16:26 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Becky Bruce 2009-04-20 16:29 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce 0 siblings, 2 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori GIT: Please enter your email below. GIT: Lines beginning in "GIT: " will be removed. GIT: Consider including an overall diffstat or table of contents GIT: for the patch you are writing. ^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit 2009-04-20 16:26 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 16:26 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn Becky Bruce 2009-04-20 20:06 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Kumar Gala 2009-04-20 16:29 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce 1 sibling, 2 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh to report sg_dma_len. However, since the default dma code for 32-bit (the dma_direct case) sets dma_length and length to the same thing, we should be able to use dma_length there as well. This gets rid of some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which actually distinguishes between dma_length and length. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> --- arch/powerpc/include/asm/scatterlist.h | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/include/asm/scatterlist.h index fcf7d55..912bf59 100644 --- a/arch/powerpc/include/asm/scatterlist.h +++ b/arch/powerpc/include/asm/scatterlist.h @@ -21,7 +21,7 @@ struct scatterlist { unsigned int offset; unsigned int length; - /* For TCE support */ + /* For TCE or SWIOTLB support */ dma_addr_t dma_address; u32 dma_length; }; @@ -34,11 +34,7 @@ struct scatterlist { * is 0. */ #define sg_dma_address(sg) ((sg)->dma_address) -#ifdef __powerpc64__ #define sg_dma_len(sg) ((sg)->dma_length) -#else -#define sg_dma_len(sg) ((sg)->length) -#endif #ifdef __powerpc64__ #define ISA_DMA_THRESHOLD (~0UL) -- 1.6.0.6 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn 2009-04-20 16:26 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 16:26 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Becky Bruce ` (2 more replies) 2009-04-20 20:06 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Kumar Gala 1 sibling, 3 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori The new dts places most of the devices in physical address space above 32-bits, which allows us to have more than 4GB of RAM present. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> --- arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 ++++++++++++++++++++++++++++ 1 files changed, 597 insertions(+), 0 deletions(-) create mode 100644 arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts b/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts new file mode 100644 index 0000000..baa3dba --- /dev/null +++ b/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts @@ -0,0 +1,597 @@ +/* + * MPC8641 HPCN Device Tree Source + * + * Copyright 2006 Freescale Semiconductor 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. + */ + +/dts-v1/; + +/ { + model = "MPC8641HPCN"; + compatible = "fsl,mpc8641hpcn"; + #address-cells = <2>; + #size-cells = <2>; + + aliases { + ethernet0 = &enet0; + ethernet1 = &enet1; + ethernet2 = &enet2; + ethernet3 = &enet3; + serial0 = &serial0; + serial1 = &serial1; + pci0 = &pci0; + pci1 = &pci1; + }; + + cpus { + #address-cells = <1>; + #size-cells = <0>; + + PowerPC,8641@0 { + device_type = "cpu"; + reg = <0>; + d-cache-line-size = <32>; // 32 bytes + i-cache-line-size = <32>; // 32 bytes + d-cache-size = <32768>; // L1, 32K + i-cache-size = <32768>; // L1, 32K + timebase-frequency = <0>; // 33 MHz, from uboot + bus-frequency = <0>; // From uboot + clock-frequency = <0>; // From uboot + }; + PowerPC,8641@1 { + device_type = "cpu"; + reg = <1>; + d-cache-line-size = <32>; // 32 bytes + i-cache-line-size = <32>; // 32 bytes + d-cache-size = <32768>; // L1, 32K + i-cache-size = <32768>; // L1, 32K + timebase-frequency = <0>; // 33 MHz, from uboot + bus-frequency = <0>; // From uboot + clock-frequency = <0>; // From uboot + }; + }; + + memory { + device_type = "memory"; + reg = <0x0 0x00000000 0x0 0x40000000>; // 1G at 0x0 + }; + + localbus@fffe05000 { + #address-cells = <2>; + #size-cells = <1>; + compatible = "fsl,mpc8641-localbus", "simple-bus"; + reg = <0x0f 0xffe05000 0x0 0x1000>; + interrupts = <19 2>; + interrupt-parent = <&mpic>; + + ranges = <0 0 0xf 0xef800000 0x00800000 + 2 0 0xf 0xffdf8000 0x00008000 + 3 0 0xf 0xffdf0000 0x00008000>; + + flash@0,0 { + compatible = "cfi-flash"; + reg = <0 0 0x00800000>; + bank-width = <2>; + device-width = <2>; + #address-cells = <1>; + #size-cells = <1>; + partition@0 { + label = "kernel"; + reg = <0x00000000 0x00300000>; + }; + partition@300000 { + label = "firmware b"; + reg = <0x00300000 0x00100000>; + read-only; + }; + partition@400000 { + label = "fs"; + reg = <0x00400000 0x00300000>; + }; + partition@700000 { + label = "firmware a"; + reg = <0x00700000 0x00100000>; + read-only; + }; + }; + }; + + soc8641@fffe00000 { + #address-cells = <1>; + #size-cells = <1>; + device_type = "soc"; + compatible = "simple-bus"; + ranges = <0x00000000 0x0f 0xffe00000 0x00100000>; + reg = <0x0f 0xffe00000 0x0 0x00001000>; // CCSRBAR + bus-frequency = <0>; + + i2c@3000 { + #address-cells = <1>; + #size-cells = <0>; + cell-index = <0>; + compatible = "fsl-i2c"; + reg = <0x3000 0x100>; + interrupts = <43 2>; + interrupt-parent = <&mpic>; + dfsrr; + }; + + i2c@3100 { + #address-cells = <1>; + #size-cells = <0>; + cell-index = <1>; + compatible = "fsl-i2c"; + reg = <0x3100 0x100>; + interrupts = <43 2>; + interrupt-parent = <&mpic>; + dfsrr; + }; + + dma@21300 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "fsl,mpc8641-dma", "fsl,eloplus-dma"; + reg = <0x21300 0x4>; + ranges = <0x0 0x21100 0x200>; + cell-index = <0>; + dma-channel@0 { + compatible = "fsl,mpc8641-dma-channel", + "fsl,eloplus-dma-channel"; + reg = <0x0 0x80>; + cell-index = <0>; + interrupt-parent = <&mpic>; + interrupts = <20 2>; + }; + dma-channel@80 { + compatible = "fsl,mpc8641-dma-channel", + "fsl,eloplus-dma-channel"; + reg = <0x80 0x80>; + cell-index = <1>; + interrupt-parent = <&mpic>; + interrupts = <21 2>; + }; + dma-channel@100 { + compatible = "fsl,mpc8641-dma-channel", + "fsl,eloplus-dma-channel"; + reg = <0x100 0x80>; + cell-index = <2>; + interrupt-parent = <&mpic>; + interrupts = <22 2>; + }; + dma-channel@180 { + compatible = "fsl,mpc8641-dma-channel", + "fsl,eloplus-dma-channel"; + reg = <0x180 0x80>; + cell-index = <3>; + interrupt-parent = <&mpic>; + interrupts = <23 2>; + }; + }; + + enet0: ethernet@24000 { + #address-cells = <1>; + #size-cells = <1>; + cell-index = <0>; + device_type = "network"; + model = "TSEC"; + compatible = "gianfar"; + reg = <0x24000 0x1000>; + ranges = <0x0 0x24000 0x1000>; + local-mac-address = [ 00 00 00 00 00 00 ]; + interrupts = <29 2 30 2 34 2>; + interrupt-parent = <&mpic>; + tbi-handle = <&tbi0>; + phy-handle = <&phy0>; + phy-connection-type = "rgmii-id"; + + mdio@520 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,gianfar-mdio"; + reg = <0x520 0x20>; + + phy0: ethernet-phy@0 { + interrupt-parent = <&mpic>; + interrupts = <10 1>; + reg = <0>; + device_type = "ethernet-phy"; + }; + phy1: ethernet-phy@1 { + interrupt-parent = <&mpic>; + interrupts = <10 1>; + reg = <1>; + device_type = "ethernet-phy"; + }; + phy2: ethernet-phy@2 { + interrupt-parent = <&mpic>; + interrupts = <10 1>; + reg = <2>; + device_type = "ethernet-phy"; + }; + phy3: ethernet-phy@3 { + interrupt-parent = <&mpic>; + interrupts = <10 1>; + reg = <3>; + device_type = "ethernet-phy"; + }; + tbi0: tbi-phy@11 { + reg = <0x11>; + device_type = "tbi-phy"; + }; + }; + }; + + enet1: ethernet@25000 { + #address-cells = <1>; + #size-cells = <1>; + cell-index = <1>; + device_type = "network"; + model = "TSEC"; + compatible = "gianfar"; + reg = <0x25000 0x1000>; + ranges = <0x0 0x25000 0x1000>; + local-mac-address = [ 00 00 00 00 00 00 ]; + interrupts = <35 2 36 2 40 2>; + interrupt-parent = <&mpic>; + tbi-handle = <&tbi1>; + phy-handle = <&phy1>; + phy-connection-type = "rgmii-id"; + + mdio@520 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,gianfar-tbi"; + reg = <0x520 0x20>; + + tbi1: tbi-phy@11 { + reg = <0x11>; + device_type = "tbi-phy"; + }; + }; + }; + + enet2: ethernet@26000 { + #address-cells = <1>; + #size-cells = <1>; + cell-index = <2>; + device_type = "network"; + model = "TSEC"; + compatible = "gianfar"; + reg = <0x26000 0x1000>; + ranges = <0x0 0x26000 0x1000>; + local-mac-address = [ 00 00 00 00 00 00 ]; + interrupts = <31 2 32 2 33 2>; + interrupt-parent = <&mpic>; + tbi-handle = <&tbi2>; + phy-handle = <&phy2>; + phy-connection-type = "rgmii-id"; + + mdio@520 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,gianfar-tbi"; + reg = <0x520 0x20>; + + tbi2: tbi-phy@11 { + reg = <0x11>; + device_type = "tbi-phy"; + }; + }; + }; + + enet3: ethernet@27000 { + #address-cells = <1>; + #size-cells = <1>; + cell-index = <3>; + device_type = "network"; + model = "TSEC"; + compatible = "gianfar"; + reg = <0x27000 0x1000>; + ranges = <0x0 0x27000 0x1000>; + local-mac-address = [ 00 00 00 00 00 00 ]; + interrupts = <37 2 38 2 39 2>; + interrupt-parent = <&mpic>; + tbi-handle = <&tbi3>; + phy-handle = <&phy3>; + phy-connection-type = "rgmii-id"; + + mdio@520 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "fsl,gianfar-tbi"; + reg = <0x520 0x20>; + + tbi3: tbi-phy@11 { + reg = <0x11>; + device_type = "tbi-phy"; + }; + }; + }; + + serial0: serial@4500 { + cell-index = <0>; + device_type = "serial"; + compatible = "ns16550"; + reg = <0x4500 0x100>; + clock-frequency = <0>; + interrupts = <42 2>; + interrupt-parent = <&mpic>; + }; + + serial1: serial@4600 { + cell-index = <1>; + device_type = "serial"; + compatible = "ns16550"; + reg = <0x4600 0x100>; + clock-frequency = <0>; + interrupts = <28 2>; + interrupt-parent = <&mpic>; + }; + + mpic: pic@40000 { + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <2>; + reg = <0x40000 0x40000>; + compatible = "chrp,open-pic"; + device_type = "open-pic"; + }; + + global-utilities@e0000 { + compatible = "fsl,mpc8641-guts"; + reg = <0xe0000 0x1000>; + fsl,has-rstcr; + }; + }; + + pci0: pcie@fffe08000 { + cell-index = <0>; + compatible = "fsl,mpc8641-pcie"; + device_type = "pci"; + #interrupt-cells = <1>; + #size-cells = <2>; + #address-cells = <3>; + reg = <0x0f 0xffe08000 0x0 0x1000>; + bus-range = <0x0 0xff>; + ranges = <0x02000000 0x0 0xc0000000 0x0c 0x00000000 0x0 0x20000000 + 0x01000000 0x0 0x00000000 0x0f 0xffc00000 0x0 0x00010000>; + clock-frequency = <33333333>; + interrupt-parent = <&mpic>; + interrupts = <24 2>; + interrupt-map-mask = <0xff00 0 0 7>; + interrupt-map = < + /* IDSEL 0x11 func 0 - PCI slot 1 */ + 0x8800 0 0 1 &mpic 2 1 + 0x8800 0 0 2 &mpic 3 1 + 0x8800 0 0 3 &mpic 4 1 + 0x8800 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 1 - PCI slot 1 */ + 0x8900 0 0 1 &mpic 2 1 + 0x8900 0 0 2 &mpic 3 1 + 0x8900 0 0 3 &mpic 4 1 + 0x8900 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 2 - PCI slot 1 */ + 0x8a00 0 0 1 &mpic 2 1 + 0x8a00 0 0 2 &mpic 3 1 + 0x8a00 0 0 3 &mpic 4 1 + 0x8a00 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 3 - PCI slot 1 */ + 0x8b00 0 0 1 &mpic 2 1 + 0x8b00 0 0 2 &mpic 3 1 + 0x8b00 0 0 3 &mpic 4 1 + 0x8b00 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 4 - PCI slot 1 */ + 0x8c00 0 0 1 &mpic 2 1 + 0x8c00 0 0 2 &mpic 3 1 + 0x8c00 0 0 3 &mpic 4 1 + 0x8c00 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 5 - PCI slot 1 */ + 0x8d00 0 0 1 &mpic 2 1 + 0x8d00 0 0 2 &mpic 3 1 + 0x8d00 0 0 3 &mpic 4 1 + 0x8d00 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 6 - PCI slot 1 */ + 0x8e00 0 0 1 &mpic 2 1 + 0x8e00 0 0 2 &mpic 3 1 + 0x8e00 0 0 3 &mpic 4 1 + 0x8e00 0 0 4 &mpic 1 1 + + /* IDSEL 0x11 func 7 - PCI slot 1 */ + 0x8f00 0 0 1 &mpic 2 1 + 0x8f00 0 0 2 &mpic 3 1 + 0x8f00 0 0 3 &mpic 4 1 + 0x8f00 0 0 4 &mpic 1 1 + + /* IDSEL 0x12 func 0 - PCI slot 2 */ + 0x9000 0 0 1 &mpic 3 1 + 0x9000 0 0 2 &mpic 4 1 + 0x9000 0 0 3 &mpic 1 1 + 0x9000 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 1 - PCI slot 2 */ + 0x9100 0 0 1 &mpic 3 1 + 0x9100 0 0 2 &mpic 4 1 + 0x9100 0 0 3 &mpic 1 1 + 0x9100 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 2 - PCI slot 2 */ + 0x9200 0 0 1 &mpic 3 1 + 0x9200 0 0 2 &mpic 4 1 + 0x9200 0 0 3 &mpic 1 1 + 0x9200 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 3 - PCI slot 2 */ + 0x9300 0 0 1 &mpic 3 1 + 0x9300 0 0 2 &mpic 4 1 + 0x9300 0 0 3 &mpic 1 1 + 0x9300 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 4 - PCI slot 2 */ + 0x9400 0 0 1 &mpic 3 1 + 0x9400 0 0 2 &mpic 4 1 + 0x9400 0 0 3 &mpic 1 1 + 0x9400 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 5 - PCI slot 2 */ + 0x9500 0 0 1 &mpic 3 1 + 0x9500 0 0 2 &mpic 4 1 + 0x9500 0 0 3 &mpic 1 1 + 0x9500 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 6 - PCI slot 2 */ + 0x9600 0 0 1 &mpic 3 1 + 0x9600 0 0 2 &mpic 4 1 + 0x9600 0 0 3 &mpic 1 1 + 0x9600 0 0 4 &mpic 2 1 + + /* IDSEL 0x12 func 7 - PCI slot 2 */ + 0x9700 0 0 1 &mpic 3 1 + 0x9700 0 0 2 &mpic 4 1 + 0x9700 0 0 3 &mpic 1 1 + 0x9700 0 0 4 &mpic 2 1 + + // IDSEL 0x1c USB + 0xe000 0 0 1 &i8259 12 2 + 0xe100 0 0 2 &i8259 9 2 + 0xe200 0 0 3 &i8259 10 2 + 0xe300 0 0 4 &i8259 11 2 + + // IDSEL 0x1d Audio + 0xe800 0 0 1 &i8259 6 2 + + // IDSEL 0x1e Legacy + 0xf000 0 0 1 &i8259 7 2 + 0xf100 0 0 1 &i8259 7 2 + + // IDSEL 0x1f IDE/SATA + 0xf800 0 0 1 &i8259 14 2 + 0xf900 0 0 1 &i8259 5 2 + >; + + pcie@0 { + reg = <0 0 0 0 0>; + #size-cells = <2>; + #address-cells = <3>; + device_type = "pci"; + ranges = <0x02000000 0x0 0xc0000000 + 0x02000000 0x0 0xc0000000 + 0x0 0x20000000 + + 0x01000000 0x0 0x00000000 + 0x01000000 0x0 0x00000000 + 0x0 0x00010000>; + uli1575@0 { + reg = <0 0 0 0 0>; + #size-cells = <2>; + #address-cells = <3>; + ranges = <0x02000000 0x0 0xc0000000 + 0x02000000 0x0 0xc0000000 + 0x0 0x20000000 + 0x01000000 0x0 0x00000000 + 0x01000000 0x0 0x00000000 + 0x0 0x00010000>; + isa@1e { + device_type = "isa"; + #interrupt-cells = <2>; + #size-cells = <1>; + #address-cells = <2>; + reg = <0xf000 0 0 0 0>; + ranges = <1 0 0x01000000 0 0 + 0x00001000>; + interrupt-parent = <&i8259>; + + i8259: interrupt-controller@20 { + reg = <1 0x20 2 + 1 0xa0 2 + 1 0x4d0 2>; + interrupt-controller; + device_type = "interrupt-controller"; + #address-cells = <0>; + #interrupt-cells = <2>; + compatible = "chrp,iic"; + interrupts = <9 2>; + interrupt-parent = <&mpic>; + }; + + i8042@60 { + #size-cells = <0>; + #address-cells = <1>; + reg = <1 0x60 1 1 0x64 1>; + interrupts = <1 3 12 3>; + interrupt-parent = + <&i8259>; + + keyboard@0 { + reg = <0>; + compatible = "pnpPNP,303"; + }; + + mouse@1 { + reg = <1>; + compatible = "pnpPNP,f03"; + }; + }; + + rtc@70 { + compatible = + "pnpPNP,b00"; + reg = <1 0x70 2>; + }; + + gpio@400 { + reg = <1 0x400 0x80>; + }; + }; + }; + }; + + }; + + pci1: pcie@fffe09000 { + cell-index = <1>; + compatible = "fsl,mpc8641-pcie"; + device_type = "pci"; + #interrupt-cells = <1>; + #size-cells = <2>; + #address-cells = <3>; + reg = <0x0f 0xffe09000 0x0 0x1000>; + bus-range = <0x0 0xff>; + ranges = <0x02000000 0x0 0xc0000000 0x0c 0x20000000 0x0 0x20000000 + 0x01000000 0x0 0x00000000 0x0f 0xffc10000 0x0 0x00010000>; + clock-frequency = <33333333>; + interrupt-parent = <&mpic>; + interrupts = <25 2>; + interrupt-map-mask = <0xf800 0 0 7>; + interrupt-map = < + /* IDSEL 0x0 */ + 0x0000 0 0 1 &mpic 4 1 + 0x0000 0 0 2 &mpic 5 1 + 0x0000 0 0 3 &mpic 6 1 + 0x0000 0 0 4 &mpic 7 1 + >; + pcie@0 { + reg = <0 0 0 0 0>; + #size-cells = <2>; + #address-cells = <3>; + device_type = "pci"; + ranges = <0x02000000 0x0 0xc0000000 + 0x02000000 0x0 0xc0000000 + 0x0 0x20000000 + + 0x01000000 0x0 0x00000000 + 0x01000000 0x0 0x00000000 + 0x0 0x00010000>; + }; + }; +}; -- 1.6.0.6 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b 2009-04-20 16:26 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 16:26 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Becky Bruce 2009-04-20 16:58 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Kumar Gala 2009-04-21 1:10 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn David Gibson 2009-04-21 21:11 ` Kumar Gala 2 siblings, 2 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori Also, convert them to resource_size_t (which is unsigned long on 64-bit, so it's not a change there). We will be using these on fsl 32b to indicate the start and size address of memory that the pci controller can actually reach - this is needed to determine if an address requires bounce buffering. For now, initialize them to a standard value; in the near future, the value will be calculated based on how the inbound windows are programmed. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> --- arch/powerpc/include/asm/pci-bridge.h | 6 ++++-- arch/powerpc/sysdev/fsl_pci.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h index 84007af..9861258 100644 --- a/arch/powerpc/include/asm/pci-bridge.h +++ b/arch/powerpc/include/asm/pci-bridge.h @@ -140,10 +140,12 @@ struct pci_controller { struct resource io_resource; struct resource mem_resources[3]; int global_number; /* PCI domain number */ + + resource_size_t dma_window_base_cur; + resource_size_t dma_window_size; + #ifdef CONFIG_PPC64 unsigned long buid; - unsigned long dma_window_base_cur; - unsigned long dma_window_size; void *private_data; #endif /* CONFIG_PPC64 */ diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index 78021d8..376603d 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -152,6 +152,10 @@ static void __init setup_pci_atmu(struct pci_controller *hose, out_be32(&pci->piw[2].piwbar,0x00000000); out_be32(&pci->piw[2].piwar, PIWAR_2G); + /* Save the base address and size covered by inbound window mappings */ + hose->dma_window_base_cur = 0x00000000; + hose->dma_window_size = 0x80000000; + iounmap(pci); } -- 1.6.0.6 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 16:26 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 16:26 ` [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB Becky Bruce ` (2 more replies) 2009-04-20 16:58 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Kumar Gala 1 sibling, 3 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori This patch includes the basic infrastructure to use swiotlb bounce buffering on 32-bit powerpc. It is not yet enabled on any platforms. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> --- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/dma-mapping.h | 11 ++ arch/powerpc/include/asm/swiotlb.h | 24 +++++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/dma-swiotlb.c | 161 ++++++++++++++++++++++++++++++++ arch/powerpc/kernel/dma.c | 2 +- arch/powerpc/kernel/setup_32.c | 4 + 7 files changed, 203 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/include/asm/swiotlb.h create mode 100644 arch/powerpc/kernel/dma-swiotlb.c diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 5b50e1a..197f6a3 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -294,7 +294,7 @@ config IOMMU_HELPER config PPC_NEED_DMA_SYNC_OPS def_bool y - depends on NOT_COHERENT_CACHE + depends on (NOT_COHERENT_CACHE || SWIOTLB) config HOTPLUG_CPU bool "Support for enabling/disabling CPUs" diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h index c69f2b5..71bbc17 100644 --- a/arch/powerpc/include/asm/dma-mapping.h +++ b/arch/powerpc/include/asm/dma-mapping.h @@ -15,9 +15,18 @@ #include <linux/scatterlist.h> #include <linux/dma-attrs.h> #include <asm/io.h> +#include <asm/swiotlb.h> #define DMA_ERROR_CODE (~(dma_addr_t)0x0) +/* Some dma direct funcs must be visible for use in other dma_ops */ +extern void *dma_direct_alloc_coherent(struct device *dev, size_t size, + dma_addr_t *dma_handle, gfp_t flag); +extern void dma_direct_free_coherent(struct device *dev, size_t size, + void *vaddr, dma_addr_t dma_handle); + +extern unsigned long get_dma_direct_offset(struct device *dev); + #ifdef CONFIG_NOT_COHERENT_CACHE /* * DMA-consistent mapping functions for PowerPCs that don't support @@ -76,6 +85,8 @@ struct dma_mapping_ops { dma_addr_t dma_address, size_t size, enum dma_data_direction direction, struct dma_attrs *attrs); + int (*addr_needs_map)(struct device *dev, dma_addr_t addr, + size_t size); #ifdef CONFIG_PPC_NEED_DMA_SYNC_OPS void (*sync_single_range_for_cpu)(struct device *hwdev, dma_addr_t dma_handle, unsigned long offset, diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h new file mode 100644 index 0000000..6440fdf --- /dev/null +++ b/arch/powerpc/include/asm/swiotlb.h @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2009 Becky Bruce, Freescale Semiconductor + * + * 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. + * + */ + +#ifndef __ASM_SWIOTLB_H +#define __ASM_SWIOTLB_H + +#include <linux/swiotlb.h> + +extern struct dma_mapping_ops swiotlb_dma_ops; +extern struct dma_mapping_ops swiotlb_pci_dma_ops; + +int swiotlb_arch_address_needs_mapping(struct device *, dma_addr_t, + size_t size); + +static inline void dma_mark_clean(void *addr, size_t size) {} + +#endif /* __ASM_SWIOTLB_H */ diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile index 71901fb..34c0a95 100644 --- a/arch/powerpc/kernel/Makefile +++ b/arch/powerpc/kernel/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_PPC_UDBG_16550) += legacy_serial.o udbg_16550.o obj-$(CONFIG_STACKTRACE) += stacktrace.o +obj-$(CONFIG_SWIOTLB) += dma-swiotlb.o pci64-$(CONFIG_PPC64) += pci_dn.o isa-bridge.o obj-$(CONFIG_PCI) += pci_$(CONFIG_WORD_SIZE).o $(pci64-y) \ diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c new file mode 100644 index 0000000..29a68e6 --- /dev/null +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -0,0 +1,161 @@ +/* + * Contains routines needed to support swiotlb for ppc. + * + * Copyright (C) 2009 Becky Bruce, Freescale Semiconductor + * + * 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. + * + */ + +#include <linux/dma-mapping.h> +#include <linux/pfn.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> +#include <linux/pci.h> + +#include <asm/machdep.h> +#include <asm/swiotlb.h> +#include <asm/dma.h> +#include <asm/abs_addr.h> + +int swiotlb __read_mostly; + +void *swiotlb_bus_to_virt(struct device *hwdev, dma_addr_t addr) +{ + unsigned long pfn = PFN_DOWN(swiotlb_bus_to_phys(hwdev, addr)); + void *pageaddr = page_address(pfn_to_page(pfn)); + + if (pageaddr != NULL) + return pageaddr + (addr % PAGE_SIZE); + return NULL; +} + +dma_addr_t swiotlb_phys_to_bus(struct device *hwdev, phys_addr_t paddr) +{ + return paddr + get_dma_direct_offset(hwdev); +} + +phys_addr_t swiotlb_bus_to_phys(struct device *hwdev, dma_addr_t baddr) + +{ + return baddr - get_dma_direct_offset(hwdev); +} + +/* + * Determine if an address needs bounce buffering via swiotlb. + * Going forward I expect the swiotlb code to generalize on using + * a dma_ops->addr_needs_map, and this function will move from here to the + * generic swiotlb code. + */ +int +swiotlb_arch_address_needs_mapping(struct device *hwdev, dma_addr_t addr, + size_t size) +{ + struct dma_mapping_ops *dma_ops = get_dma_ops(hwdev); + + BUG_ON(!dma_ops); + return dma_ops->addr_needs_map(hwdev, addr, size); +} + +/* + * Determine if an address is reachable by a pci device, or if we must bounce. + */ +static int +swiotlb_pci_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) +{ + u64 mask = dma_get_mask(hwdev); + dma_addr_t max; + struct pci_controller *hose; + struct pci_dev *pdev = to_pci_dev(hwdev); + + hose = pci_bus_to_host(pdev->bus); + max = hose->dma_window_base_cur + hose->dma_window_size; + + /* check that we're within mapped pci window space */ + if ((addr + size > max) | (addr < hose->dma_window_base_cur)) + return 1; + + return !is_buffer_dma_capable(mask, addr, size); +} + +static int +swiotlb_addr_needs_map(struct device *hwdev, dma_addr_t addr, size_t size) +{ + return !is_buffer_dma_capable(dma_get_mask(hwdev), addr, size); +} + + +/* + * At the moment, all platforms that use this code only require + * swiotlb to be used if we're operating on HIGHMEM. Since + * we don't ever call anything other than map_sg, unmap_sg, + * map_page, and unmap_page on highmem, use normal dma_ops + * for everything else. + */ +struct dma_mapping_ops swiotlb_dma_ops = { + .alloc_coherent = dma_direct_alloc_coherent, + .free_coherent = dma_direct_free_coherent, + .map_sg = swiotlb_map_sg_attrs, + .unmap_sg = swiotlb_unmap_sg_attrs, + .dma_supported = swiotlb_dma_supported, + .map_page = swiotlb_map_page, + .unmap_page = swiotlb_unmap_page, + .addr_needs_map = swiotlb_addr_needs_map, + .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, + .sync_single_range_for_device = swiotlb_sync_single_range_for_device, + .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, + .sync_sg_for_device = swiotlb_sync_sg_for_device +}; + +struct dma_mapping_ops swiotlb_pci_dma_ops = { + .alloc_coherent = dma_direct_alloc_coherent, + .free_coherent = dma_direct_free_coherent, + .map_sg = swiotlb_map_sg_attrs, + .unmap_sg = swiotlb_unmap_sg_attrs, + .dma_supported = swiotlb_dma_supported, + .map_page = swiotlb_map_page, + .unmap_page = swiotlb_unmap_page, + .addr_needs_map = swiotlb_pci_addr_needs_map, + .sync_single_range_for_cpu = swiotlb_sync_single_range_for_cpu, + .sync_single_range_for_device = swiotlb_sync_single_range_for_device, + .sync_sg_for_cpu = swiotlb_sync_sg_for_cpu, + .sync_sg_for_device = swiotlb_sync_sg_for_device +}; + +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct device *dev = data; + + /* We are only intereted in device addition */ + if (action != BUS_NOTIFY_ADD_DEVICE) + return 0; + + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) + set_dma_ops(dev, &swiotlb_dma_ops); + + return NOTIFY_DONE; +} + +static struct notifier_block ppc_swiotlb_plat_bus_notifier = { + .notifier_call = ppc_swiotlb_bus_notify, + .priority = 0, +}; + +static struct notifier_block ppc_swiotlb_of_bus_notifier = { + .notifier_call = ppc_swiotlb_bus_notify, + .priority = 0, +}; + +static int __init setup_bus_notifier(void) +{ + bus_register_notifier(&platform_bus_type, + &ppc_swiotlb_plat_bus_notifier); + bus_register_notifier(&of_platform_bus_type, + &ppc_swiotlb_of_bus_notifier); + + return 0; +} diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c index 53c7788..62d80c4 100644 --- a/arch/powerpc/kernel/dma.c +++ b/arch/powerpc/kernel/dma.c @@ -19,7 +19,7 @@ * default the offset is PCI_DRAM_OFFSET. */ -static unsigned long get_dma_direct_offset(struct device *dev) +unsigned long get_dma_direct_offset(struct device *dev) { if (dev) return (unsigned long)dev->archdata.dma_data; diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c index 9e1ca74..f038b13 100644 --- a/arch/powerpc/kernel/setup_32.c +++ b/arch/powerpc/kernel/setup_32.c @@ -332,6 +332,10 @@ void __init setup_arch(char **cmdline_p) ppc_md.setup_arch(); if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab); + /* Allow iotlb to do it's setup */ +#ifdef CONFIG_SWIOTLB + swiotlb_init(); +#endif paging_init(); /* Initialize the MMU context management stuff */ -- 1.6.0.6 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB 2009-04-20 16:26 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Becky Bruce @ 2009-04-20 16:26 ` Becky Bruce 2009-04-20 17:00 ` Kumar Gala 2009-04-20 16:57 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Kumar Gala 2009-04-20 18:31 ` Kumar Gala 2 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:26 UTC (permalink / raw) To: linuxppc-dev, fujita.tomonori Minor code to allow enabling swiotlb on mpc86xx, including Kconfig addition for SWIOTLB. Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> --- arch/powerpc/Kconfig | 10 ++++++++++ arch/powerpc/kernel/dma-swiotlb.c | 2 ++ arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 3 +++ 3 files changed, 15 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 197f6a3..e47c81d 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -292,6 +292,16 @@ config IOMMU_VMERGE config IOMMU_HELPER def_bool PPC64 +config SWIOTLB + bool "SWIOTLB support" + depends on PPC_86xx + select IOMMU_HELPER + ---help--- + Support for IO bounce buffering for systems without an IOMMU. + This allows us to DMA to the full physical address space on + platforms where the size of a physical address is larger + than the bus address. + config PPC_NEED_DMA_SYNC_OPS def_bool y depends on (NOT_COHERENT_CACHE || SWIOTLB) diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c index 29a68e6..3065d03 100644 --- a/arch/powerpc/kernel/dma-swiotlb.c +++ b/arch/powerpc/kernel/dma-swiotlb.c @@ -159,3 +159,5 @@ static int __init setup_bus_notifier(void) return 0; } + +machine_arch_initcall(mpc86xx_hpcn, setup_bus_notifier); diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c index c4ec49b..f7b88b9 100644 --- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c +++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c @@ -88,6 +88,9 @@ mpc86xx_hpcn_setup_arch(void) ppc_md.pci_exclude_device = mpc86xx_exclude_device; +#ifdef CONFIG_SWIOTLB + set_pci_dma_ops(&swiotlb_pci_dma_ops); +#endif #endif printk("MPC86xx HPCN board from Freescale Semiconductor\n"); -- 1.6.0.6 ^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB 2009-04-20 16:26 ` [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB Becky Bruce @ 2009-04-20 17:00 ` Kumar Gala 2009-04-20 17:58 ` Becky Bruce 0 siblings, 1 reply; 27+ messages in thread From: Kumar Gala @ 2009-04-20 17:00 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > Minor code to allow enabling swiotlb on mpc86xx, including > Kconfig addition for SWIOTLB. > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > --- > arch/powerpc/Kconfig | 10 ++++++++++ > arch/powerpc/kernel/dma-swiotlb.c | 2 ++ > arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 3 +++ > 3 files changed, 15 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index 197f6a3..e47c81d 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -292,6 +292,16 @@ config IOMMU_VMERGE > config IOMMU_HELPER > def_bool PPC64 > > +config SWIOTLB > + bool "SWIOTLB support" > + depends on PPC_86xx > + select IOMMU_HELPER > + ---help--- > + Support for IO bounce buffering for systems without an IOMMU. > + This allows us to DMA to the full physical address space on > + platforms where the size of a physical address is larger > + than the bus address. > + As stated on previous patch, move the bulk of this into 4/5. > > config PPC_NEED_DMA_SYNC_OPS > def_bool y > depends on (NOT_COHERENT_CACHE || SWIOTLB) > diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/ > dma-swiotlb.c > index 29a68e6..3065d03 100644 > --- a/arch/powerpc/kernel/dma-swiotlb.c > +++ b/arch/powerpc/kernel/dma-swiotlb.c > @@ -159,3 +159,5 @@ static int __init setup_bus_notifier(void) > > return 0; > } > + > +machine_arch_initcall(mpc86xx_hpcn, setup_bus_notifier); Hmm, not sure what we chatted about here, but I don't want to have to add every board into this file to register the bus notifiers. > > diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/ > powerpc/platforms/86xx/mpc86xx_hpcn.c > index c4ec49b..f7b88b9 100644 > --- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c > +++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c > @@ -88,6 +88,9 @@ mpc86xx_hpcn_setup_arch(void) > > ppc_md.pci_exclude_device = mpc86xx_exclude_device; > > +#ifdef CONFIG_SWIOTLB > + set_pci_dma_ops(&swiotlb_pci_dma_ops); > +#endif > #endif > > printk("MPC86xx HPCN board from Freescale Semiconductor\n"); > -- > 1.6.0.6 > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB 2009-04-20 17:00 ` Kumar Gala @ 2009-04-20 17:58 ` Becky Bruce 2009-04-21 2:14 ` Michael Ellerman 0 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-20 17:58 UTC (permalink / raw) To: Kumar Gala; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 12:00 PM, Kumar Gala wrote: > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > >> Minor code to allow enabling swiotlb on mpc86xx, including >> Kconfig addition for SWIOTLB. >> >> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> >> --- >> arch/powerpc/Kconfig | 10 ++++++++++ >> arch/powerpc/kernel/dma-swiotlb.c | 2 ++ >> arch/powerpc/platforms/86xx/mpc86xx_hpcn.c | 3 +++ >> 3 files changed, 15 insertions(+), 0 deletions(-) >> >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig >> index 197f6a3..e47c81d 100644 >> --- a/arch/powerpc/Kconfig >> +++ b/arch/powerpc/Kconfig >> @@ -292,6 +292,16 @@ config IOMMU_VMERGE >> config IOMMU_HELPER >> def_bool PPC64 >> >> +config SWIOTLB >> + bool "SWIOTLB support" >> + depends on PPC_86xx >> + select IOMMU_HELPER >> + ---help--- >> + Support for IO bounce buffering for systems without an IOMMU. >> + This allows us to DMA to the full physical address space on >> + platforms where the size of a physical address is larger >> + than the bus address. >> + > > As stated on previous patch, move the bulk of this into 4/5. Yep. > > >> >> config PPC_NEED_DMA_SYNC_OPS >> def_bool y >> depends on (NOT_COHERENT_CACHE || SWIOTLB) >> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/ >> kernel/dma-swiotlb.c >> index 29a68e6..3065d03 100644 >> --- a/arch/powerpc/kernel/dma-swiotlb.c >> +++ b/arch/powerpc/kernel/dma-swiotlb.c >> @@ -159,3 +159,5 @@ static int __init setup_bus_notifier(void) >> >> return 0; >> } >> + >> +machine_arch_initcall(mpc86xx_hpcn, setup_bus_notifier); > > Hmm, not sure what we chatted about here, but I don't want to have > to add every board into this file to register the bus notifiers. We talked about this, and this was what we decided on - I don't really like the idea, either, but there's a lot of precedent for it. I'd like to do this differently, but I"m not sure what the solution is - we'd need to look into that more (or perhaps someone here will have some sage advice). Cheers, B ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB 2009-04-20 17:58 ` Becky Bruce @ 2009-04-21 2:14 ` Michael Ellerman 0 siblings, 0 replies; 27+ messages in thread From: Michael Ellerman @ 2009-04-21 2:14 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev [-- Attachment #1: Type: text/plain, Size: 1480 bytes --] On Mon, 2009-04-20 at 12:58 -0500, Becky Bruce wrote: > On Apr 20, 2009, at 12:00 PM, Kumar Gala wrote: > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > >> > >> config PPC_NEED_DMA_SYNC_OPS > >> def_bool y > >> depends on (NOT_COHERENT_CACHE || SWIOTLB) > >> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/ > >> kernel/dma-swiotlb.c > >> index 29a68e6..3065d03 100644 > >> --- a/arch/powerpc/kernel/dma-swiotlb.c > >> +++ b/arch/powerpc/kernel/dma-swiotlb.c > >> @@ -159,3 +159,5 @@ static int __init setup_bus_notifier(void) > >> > >> return 0; > >> } > >> + > >> +machine_arch_initcall(mpc86xx_hpcn, setup_bus_notifier); > > > > Hmm, not sure what we chatted about here, but I don't want to have > > to add every board into this file to register the bus notifiers. > > We talked about this, and this was what we decided on - I don't really > like the idea, either, but there's a lot of precedent for it. I'd > like to do this differently, but I"m not sure what the solution is - > we'd need to look into that more (or perhaps someone here will have > some sage advice). Give it a better name, export it, and call it from the board setup file? Actually what depends on the board anyway? It's just the dma window config in the pci_controller isn't it? So maybe you can always call the notifier, and if the dma mask isn't 36 bits, and the controller has the window configured then you use swiotlb? cheers [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 16:26 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Becky Bruce 2009-04-20 16:26 ` [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB Becky Bruce @ 2009-04-20 16:57 ` Kumar Gala 2009-04-20 18:03 ` Becky Bruce 2009-04-20 18:31 ` Kumar Gala 2 siblings, 1 reply; 27+ messages in thread From: Kumar Gala @ 2009-04-20 16:57 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > This patch includes the basic infrastructure to use swiotlb > bounce buffering on 32-bit powerpc. It is not yet enabled on > any platforms. > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > --- > arch/powerpc/Kconfig | 2 +- > arch/powerpc/include/asm/dma-mapping.h | 11 ++ > arch/powerpc/include/asm/swiotlb.h | 24 +++++ > arch/powerpc/kernel/Makefile | 1 + > arch/powerpc/kernel/dma-swiotlb.c | 161 +++++++++++++++++++++++ > +++++++++ > arch/powerpc/kernel/dma.c | 2 +- > arch/powerpc/kernel/setup_32.c | 4 + > 7 files changed, 203 insertions(+), 2 deletions(-) > create mode 100644 arch/powerpc/include/asm/swiotlb.h > create mode 100644 arch/powerpc/kernel/dma-swiotlb.c > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index 5b50e1a..197f6a3 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -294,7 +294,7 @@ config IOMMU_HELPER > > config PPC_NEED_DMA_SYNC_OPS > def_bool y > - depends on NOT_COHERENT_CACHE > + depends on (NOT_COHERENT_CACHE || SWIOTLB) This isn't right, since you haven't introduced the SWIOTLB Kconfig. Why don't we just put the SWIOTLB Kconfig option in here and default it no (and remove the dep on 86xx). > config HOTPLUG_CPU > bool "Support for enabling/disabling CPUs" > diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/ > dma-swiotlb.c > new file mode 100644 > index 0000000..29a68e6 > --- /dev/null > +++ b/arch/powerpc/kernel/dma-swiotlb.c > @@ -0,0 +1,161 @@ > +/* > + * Contains routines needed to support swiotlb for ppc. > + * > + * Copyright (C) 2009 Becky Bruce, Freescale Semiconductor > + * > + * 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. > + * > + */ [snip] > > + > +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, > + unsigned long action, void *data) > +{ > + struct device *dev = data; > + > + /* We are only intereted in device addition */ > + if (action != BUS_NOTIFY_ADD_DEVICE) > + return 0; > + > + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) > + set_dma_ops(dev, &swiotlb_dma_ops); > + this isn't right. Isn't possible for a PCI dev to have a DMA_BIT_MASK(64) but us still not be able to dma to it? Also, I dont like the assumption of 36-bit physical here. > > + return NOTIFY_DONE; > +} > + > +static struct notifier_block ppc_swiotlb_plat_bus_notifier = { > + .notifier_call = ppc_swiotlb_bus_notify, > + .priority = 0, > +}; > + > +static struct notifier_block ppc_swiotlb_of_bus_notifier = { > + .notifier_call = ppc_swiotlb_bus_notify, > + .priority = 0, > +}; > + > +static int __init setup_bus_notifier(void) > +{ > + bus_register_notifier(&platform_bus_type, > + &ppc_swiotlb_plat_bus_notifier); > + bus_register_notifier(&of_platform_bus_type, > + &ppc_swiotlb_of_bus_notifier); > + > + return 0; > +} ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 16:57 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Kumar Gala @ 2009-04-20 18:03 ` Becky Bruce 2009-04-21 2:39 ` FUJITA Tomonori 0 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-20 18:03 UTC (permalink / raw) To: Kumar Gala; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 11:57 AM, Kumar Gala wrote: > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > >> This patch includes the basic infrastructure to use swiotlb >> bounce buffering on 32-bit powerpc. It is not yet enabled on >> any platforms. >> >> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> >> --- >> arch/powerpc/Kconfig | 2 +- >> arch/powerpc/include/asm/dma-mapping.h | 11 ++ >> arch/powerpc/include/asm/swiotlb.h | 24 +++++ >> arch/powerpc/kernel/Makefile | 1 + >> arch/powerpc/kernel/dma-swiotlb.c | 161 ++++++++++++++++++++++ >> ++++++++++ >> arch/powerpc/kernel/dma.c | 2 +- >> arch/powerpc/kernel/setup_32.c | 4 + >> 7 files changed, 203 insertions(+), 2 deletions(-) >> create mode 100644 arch/powerpc/include/asm/swiotlb.h >> create mode 100644 arch/powerpc/kernel/dma-swiotlb.c >> >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig >> index 5b50e1a..197f6a3 100644 >> --- a/arch/powerpc/Kconfig >> +++ b/arch/powerpc/Kconfig >> @@ -294,7 +294,7 @@ config IOMMU_HELPER >> >> config PPC_NEED_DMA_SYNC_OPS >> def_bool y >> - depends on NOT_COHERENT_CACHE >> + depends on (NOT_COHERENT_CACHE || SWIOTLB) > > This isn't right, since you haven't introduced the SWIOTLB Kconfig. > > > Why don't we just put the SWIOTLB Kconfig option in here and default > it no (and remove the dep on 86xx). Sure. I'll probably add a comment or something though so people don't think they can just enable it on anything and expect it to work. Too many people seem to read the config files and decide things are possible that actually aren't :) > > >> config HOTPLUG_CPU >> bool "Support for enabling/disabling CPUs" > > >> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/ >> kernel/dma-swiotlb.c >> new file mode 100644 >> index 0000000..29a68e6 >> --- /dev/null >> +++ b/arch/powerpc/kernel/dma-swiotlb.c >> @@ -0,0 +1,161 @@ >> +/* >> + * Contains routines needed to support swiotlb for ppc. >> + * >> + * Copyright (C) 2009 Becky Bruce, Freescale Semiconductor >> + * >> + * 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. >> + * >> + */ > > [snip] > >> >> + >> +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, >> + unsigned long action, void *data) >> +{ >> + struct device *dev = data; >> + >> + /* We are only intereted in device addition */ >> + if (action != BUS_NOTIFY_ADD_DEVICE) >> + return 0; >> + >> + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) >> + set_dma_ops(dev, &swiotlb_dma_ops); >> + > > this isn't right. Isn't possible for a PCI dev to have a > DMA_BIT_MASK(64) but us still not be able to dma to it? Also, I > dont like the assumption of 36-bit physical here. You're right - this is just handling the basic case and for now I'm assuming that we don't bounce 64-bit devices (or any device that can handle 36 bits). We'll need to talk in more detail about a solution to that problem, because knowing if a 64b dev *might* need to bounce (which is all this is really saying) requires more information. We also don't really have infrastructure to deal with holes in the visible dev memory, and I don't know if we want to handle that as well. I don't want to set the dma_ops to swiotlb unless we have to because there's a slight perf hit in running all the checks to see if an address needs to be bounced. Thanks, B ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 18:03 ` Becky Bruce @ 2009-04-21 2:39 ` FUJITA Tomonori 0 siblings, 0 replies; 27+ messages in thread From: FUJITA Tomonori @ 2009-04-21 2:39 UTC (permalink / raw) To: beckyb; +Cc: fujita.tomonori, linuxppc-dev On Mon, 20 Apr 2009 13:03:20 -0500 Becky Bruce <beckyb@kernel.crashing.org> wrote: > > On Apr 20, 2009, at 11:57 AM, Kumar Gala wrote: > > > > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > > > >> This patch includes the basic infrastructure to use swiotlb > >> bounce buffering on 32-bit powerpc. It is not yet enabled on > >> any platforms. > >> > >> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > >> --- > >> arch/powerpc/Kconfig | 2 +- > >> arch/powerpc/include/asm/dma-mapping.h | 11 ++ > >> arch/powerpc/include/asm/swiotlb.h | 24 +++++ > >> arch/powerpc/kernel/Makefile | 1 + > >> arch/powerpc/kernel/dma-swiotlb.c | 161 ++++++++++++++++++++++ > >> ++++++++++ > >> arch/powerpc/kernel/dma.c | 2 +- > >> arch/powerpc/kernel/setup_32.c | 4 + > >> 7 files changed, 203 insertions(+), 2 deletions(-) > >> create mode 100644 arch/powerpc/include/asm/swiotlb.h > >> create mode 100644 arch/powerpc/kernel/dma-swiotlb.c > >> > >> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > >> index 5b50e1a..197f6a3 100644 > >> --- a/arch/powerpc/Kconfig > >> +++ b/arch/powerpc/Kconfig > >> @@ -294,7 +294,7 @@ config IOMMU_HELPER > >> > >> config PPC_NEED_DMA_SYNC_OPS > >> def_bool y > >> - depends on NOT_COHERENT_CACHE > >> + depends on (NOT_COHERENT_CACHE || SWIOTLB) > > > > This isn't right, since you haven't introduced the SWIOTLB Kconfig. > > > > > > Why don't we just put the SWIOTLB Kconfig option in here and default > > it no (and remove the dep on 86xx). > > Sure. I'll probably add a comment or something though so people don't > think they can just enable it on anything and expect it to work. Too > many people seem to read the config files and decide things are > possible that actually aren't :) > > > > > > >> config HOTPLUG_CPU > >> bool "Support for enabling/disabling CPUs" > > > > > >> diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/ > >> kernel/dma-swiotlb.c > >> new file mode 100644 > >> index 0000000..29a68e6 > >> --- /dev/null > >> +++ b/arch/powerpc/kernel/dma-swiotlb.c > >> @@ -0,0 +1,161 @@ > >> +/* > >> + * Contains routines needed to support swiotlb for ppc. > >> + * > >> + * Copyright (C) 2009 Becky Bruce, Freescale Semiconductor > >> + * > >> + * 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. > >> + * > >> + */ > > > > [snip] > > > >> > >> + > >> +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, > >> + unsigned long action, void *data) > >> +{ > >> + struct device *dev = data; > >> + > >> + /* We are only intereted in device addition */ > >> + if (action != BUS_NOTIFY_ADD_DEVICE) > >> + return 0; > >> + > >> + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) > >> + set_dma_ops(dev, &swiotlb_dma_ops); > >> + > > > > this isn't right. Isn't possible for a PCI dev to have a > > DMA_BIT_MASK(64) but us still not be able to dma to it? Also, I > > dont like the assumption of 36-bit physical here. > > You're right - this is just handling the basic case and for now I'm > assuming that we don't bounce 64-bit devices (or any device that can > handle 36 bits). We'll need to talk in more detail about a solution > to that problem, because knowing if a 64b dev *might* need to bounce > (which is all this is really saying) requires more information. We > also don't really have infrastructure to deal with holes in the > visible dev memory, and I don't know if we want to handle that as > well. I don't want to set the dma_ops to swiotlb unless we have to > because there's a slight perf hit in running all the checks to see if > an address needs to be bounced. I think that you always just set the dma_ops to swiotlb. It's the cleanest solution. Do you really see the performance drop due to the checking? ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 16:26 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Becky Bruce 2009-04-20 16:26 ` [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB Becky Bruce 2009-04-20 16:57 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Kumar Gala @ 2009-04-20 18:31 ` Kumar Gala 2009-04-20 19:06 ` Becky Bruce 2 siblings, 1 reply; 27+ messages in thread From: Kumar Gala @ 2009-04-20 18:31 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, > + unsigned long action, void *data) > +{ > + struct device *dev = data; > + > + /* We are only intereted in device addition */ > + if (action != BUS_NOTIFY_ADD_DEVICE) > + return 0; > + > + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) > + set_dma_ops(dev, &swiotlb_dma_ops); > + > + return NOTIFY_DONE; > +} > + > +static struct notifier_block ppc_swiotlb_plat_bus_notifier = { > + .notifier_call = ppc_swiotlb_bus_notify, > + .priority = 0, > +}; > + > +static struct notifier_block ppc_swiotlb_of_bus_notifier = { > + .notifier_call = ppc_swiotlb_bus_notify, > + .priority = 0, > +}; > + > +static int __init setup_bus_notifier(void) > +{ > + bus_register_notifier(&platform_bus_type, > + &ppc_swiotlb_plat_bus_notifier); > + bus_register_notifier(&of_platform_bus_type, > + &ppc_swiotlb_of_bus_notifier); > + > + return 0; > +} I think we should move all this into the platform code for now. I don't like having to duplicate it but that gives us the proper flexibility for now. - k ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 18:31 ` Kumar Gala @ 2009-04-20 19:06 ` Becky Bruce 2009-04-20 20:04 ` Kumar Gala 0 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-20 19:06 UTC (permalink / raw) To: Kumar Gala; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 1:31 PM, Kumar Gala wrote: > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > >> +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, >> + unsigned long action, void *data) >> +{ >> + struct device *dev = data; >> + >> + /* We are only intereted in device addition */ >> + if (action != BUS_NOTIFY_ADD_DEVICE) >> + return 0; >> + >> + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) >> + set_dma_ops(dev, &swiotlb_dma_ops); >> + >> + return NOTIFY_DONE; >> +} >> + >> +static struct notifier_block ppc_swiotlb_plat_bus_notifier = { >> + .notifier_call = ppc_swiotlb_bus_notify, >> + .priority = 0, >> +}; >> + >> +static struct notifier_block ppc_swiotlb_of_bus_notifier = { >> + .notifier_call = ppc_swiotlb_bus_notify, >> + .priority = 0, >> +}; >> + >> +static int __init setup_bus_notifier(void) >> +{ >> + bus_register_notifier(&platform_bus_type, >> + &ppc_swiotlb_plat_bus_notifier); >> + bus_register_notifier(&of_platform_bus_type, >> + &ppc_swiotlb_of_bus_notifier); >> + >> + return 0; >> +} > > I think we should move all this into the platform code for now. I > don't like having to duplicate it but that gives us the proper > flexibility for now. Ugh, gross. I'd like to think about this some more. -B ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 19:06 ` Becky Bruce @ 2009-04-20 20:04 ` Kumar Gala 2009-04-20 20:16 ` Scott Wood 0 siblings, 1 reply; 27+ messages in thread From: Kumar Gala @ 2009-04-20 20:04 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 2:06 PM, Becky Bruce wrote: > > On Apr 20, 2009, at 1:31 PM, Kumar Gala wrote: > >> >> On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: >> >>> +static int ppc_swiotlb_bus_notify(struct notifier_block *nb, >>> + unsigned long action, void *data) >>> +{ >>> + struct device *dev = data; >>> + >>> + /* We are only intereted in device addition */ >>> + if (action != BUS_NOTIFY_ADD_DEVICE) >>> + return 0; >>> + >>> + if (dma_get_mask(dev) < DMA_BIT_MASK(36)) >>> + set_dma_ops(dev, &swiotlb_dma_ops); >>> + >>> + return NOTIFY_DONE; >>> +} >>> + >>> +static struct notifier_block ppc_swiotlb_plat_bus_notifier = { >>> + .notifier_call = ppc_swiotlb_bus_notify, >>> + .priority = 0, >>> +}; >>> + >>> +static struct notifier_block ppc_swiotlb_of_bus_notifier = { >>> + .notifier_call = ppc_swiotlb_bus_notify, >>> + .priority = 0, >>> +}; >>> + >>> +static int __init setup_bus_notifier(void) >>> +{ >>> + bus_register_notifier(&platform_bus_type, >>> + &ppc_swiotlb_plat_bus_notifier); >>> + bus_register_notifier(&of_platform_bus_type, >>> + &ppc_swiotlb_of_bus_notifier); >>> + >>> + return 0; >>> +} >> >> I think we should move all this into the platform code for now. I >> don't like having to duplicate it but that gives us the proper >> flexibility for now. > > Ugh, gross. I'd like to think about this some more. I'm suggesting we do it one for FSL in fsl_soc.c, the 4xx guys can do it once, etc. Since the behavior desired is going to be a bit unique to SoCs/chipsets. - k ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit 2009-04-20 20:04 ` Kumar Gala @ 2009-04-20 20:16 ` Scott Wood 0 siblings, 0 replies; 27+ messages in thread From: Scott Wood @ 2009-04-20 20:16 UTC (permalink / raw) To: Kumar Gala; +Cc: fujita.tomonori, linuxppc-dev Kumar Gala wrote: > I'm suggesting we do it one for FSL in fsl_soc.c, the 4xx guys can do it > once, etc. Since the behavior desired is going to be a bit unique to > SoCs/chipsets. Perhaps we should have a dma_mask in platform/of_platform device structs? The driver knows best how many bits it can shove into a DMA address register, and it would let us avoid hardcoding 36 bits into this code. What other platform-specific behavior do you have in mind? Could we supply a default implementation that platforms can override if they need something weird, rather than duplicating it per soc family? -Scott ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b 2009-04-20 16:26 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Becky Bruce 2009-04-20 16:26 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Becky Bruce @ 2009-04-20 16:58 ` Kumar Gala 1 sibling, 0 replies; 27+ messages in thread From: Kumar Gala @ 2009-04-20 16:58 UTC (permalink / raw) To: Benjamin Herrenschmidt; +Cc: FUJITA Tomonori, Linuxppc-dev Development On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > Also, convert them to resource_size_t (which is unsigned long > on 64-bit, so it's not a change there). > > We will be using these on fsl 32b to indicate the start and size > address of memory that the pci controller can actually reach - this > is needed to determine if an address requires bounce buffering. For > now, initialize them to a standard value; in the near future, the > value will be calculated based on how the inbound windows are > programmed. > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > --- > arch/powerpc/include/asm/pci-bridge.h | 6 ++++-- > arch/powerpc/sysdev/fsl_pci.c | 4 ++++ > 2 files changed, 8 insertions(+), 2 deletions(-) Ben, your ack on this patch would be appreciated as I've got some other FSL PCI patches that I want to fold this into my tree for. - k ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn 2009-04-20 16:26 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn Becky Bruce 2009-04-20 16:26 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Becky Bruce @ 2009-04-21 1:10 ` David Gibson 2009-04-21 15:33 ` Becky Bruce 2009-04-21 21:11 ` Kumar Gala 2 siblings, 1 reply; 27+ messages in thread From: David Gibson @ 2009-04-21 1:10 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Mon, Apr 20, 2009 at 11:26:47AM -0500, Becky Bruce wrote: > The new dts places most of the devices in physical address space > above 32-bits, which allows us to have more than 4GB of RAM present. > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > --- > arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 ++++++++++++++++++++++++++++ > 1 files changed, 597 insertions(+), 0 deletions(-) > create mode 100644 arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts > > diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts b/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts > new file mode 100644 > index 0000000..baa3dba > --- /dev/null > +++ b/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts > @@ -0,0 +1,597 @@ > +/* > + * MPC8641 HPCN Device Tree Source > + * > + * Copyright 2006 Freescale Semiconductor 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. > + */ [snip] > + soc8641@fffe00000 { > + #address-cells = <1>; > + #size-cells = <1>; > + device_type = "soc"; > + compatible = "simple-bus"; Uh, you definitely need something more specific in the compatible property before "simple-bus". -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn 2009-04-21 1:10 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn David Gibson @ 2009-04-21 15:33 ` Becky Bruce 2009-04-22 1:26 ` David Gibson 0 siblings, 1 reply; 27+ messages in thread From: Becky Bruce @ 2009-04-21 15:33 UTC (permalink / raw) To: David Gibson; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 8:10 PM, David Gibson wrote: > On Mon, Apr 20, 2009 at 11:26:47AM -0500, Becky Bruce wrote: >> The new dts places most of the devices in physical address space >> above 32-bits, which allows us to have more than 4GB of RAM present. >> >> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> >> --- >> arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 ++++++++++++++++++ >> ++++++++++ >> 1 files changed, 597 insertions(+), 0 deletions(-) >> create mode 100644 arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts >> >> diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts b/arch/ >> powerpc/boot/dts/mpc8641_hpcn_36b.dts >> new file mode 100644 >> index 0000000..baa3dba >> --- /dev/null >> +++ b/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts >> @@ -0,0 +1,597 @@ >> +/* >> + * MPC8641 HPCN Device Tree Source >> + * >> + * Copyright 2006 Freescale Semiconductor 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. >> + */ > > [snip] >> + soc8641@fffe00000 { >> + #address-cells = <1>; >> + #size-cells = <1>; >> + device_type = "soc"; >> + compatible = "simple-bus"; > > Uh, you definitely need something more specific in the compatible > property before "simple-bus". This is a copy of the existing mpc8641hpcn dts file, with just physical address changes, so if there's a problem here it definitely exists in the current 8641hpcn dts, and possibly other dts files as well. I think the correct solution is for me to go look at that .dts (and any others that may be similar), and put out a followup to fix them all. Thanks, Becky ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn 2009-04-21 15:33 ` Becky Bruce @ 2009-04-22 1:26 ` David Gibson 0 siblings, 0 replies; 27+ messages in thread From: David Gibson @ 2009-04-22 1:26 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Tue, Apr 21, 2009 at 10:33:34AM -0500, Becky Bruce wrote: > > On Apr 20, 2009, at 8:10 PM, David Gibson wrote: > >> On Mon, Apr 20, 2009 at 11:26:47AM -0500, Becky Bruce wrote: >>> The new dts places most of the devices in physical address space >>> above 32-bits, which allows us to have more than 4GB of RAM present. >>> >>> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> >>> --- >>> arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 ++++++++++++++++++ >>> ++++++++++ >>> 1 files changed, 597 insertions(+), 0 deletions(-) >>> create mode 100644 arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts >>> >>> diff --git a/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts b/arch/ >>> powerpc/boot/dts/mpc8641_hpcn_36b.dts >>> new file mode 100644 >>> index 0000000..baa3dba >>> --- /dev/null >>> +++ b/arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts >>> @@ -0,0 +1,597 @@ >>> +/* >>> + * MPC8641 HPCN Device Tree Source >>> + * >>> + * Copyright 2006 Freescale Semiconductor 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. >>> + */ >> >> [snip] >>> + soc8641@fffe00000 { >>> + #address-cells = <1>; >>> + #size-cells = <1>; >>> + device_type = "soc"; >>> + compatible = "simple-bus"; >> >> Uh, you definitely need something more specific in the compatible >> property before "simple-bus". > > This is a copy of the existing mpc8641hpcn dts file, with just physical > address changes, so if there's a problem here it definitely exists in the > current 8641hpcn dts, and possibly other dts files as well. I think the > correct solution is for me to go look at that .dts (and any others that > may be similar), and put out a followup to fix them all. Ok, fair enough. -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn 2009-04-20 16:26 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn Becky Bruce 2009-04-20 16:26 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Becky Bruce 2009-04-21 1:10 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn David Gibson @ 2009-04-21 21:11 ` Kumar Gala 2 siblings, 0 replies; 27+ messages in thread From: Kumar Gala @ 2009-04-21 21:11 UTC (permalink / raw) To: Becky Bruce; +Cc: Linuxppc-dev Development On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > The new dts places most of the devices in physical address space > above 32-bits, which allows us to have more than 4GB of RAM present. > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > --- > arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 +++++++++++++++++++ > +++++++++ > 1 files changed, 597 insertions(+), 0 deletions(-) > create mode 100644 arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts applied to next. We can deal with any simple-bus issues in a follow up patch. - k ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit 2009-04-20 16:26 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Becky Bruce 2009-04-20 16:26 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn Becky Bruce @ 2009-04-20 20:06 ` Kumar Gala 2009-04-21 2:27 ` FUJITA Tomonori 2009-04-21 15:23 ` Becky Bruce 1 sibling, 2 replies; 27+ messages in thread From: Kumar Gala @ 2009-04-20 20:06 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh > to report sg_dma_len. However, since the default dma code for 32-bit > (the dma_direct case) sets dma_length and length to the same thing, > we should be able to use dma_length there as well. This gets rid of > some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which > actually distinguishes between dma_length and length. > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > --- > arch/powerpc/include/asm/scatterlist.h | 6 +----- > 1 files changed, 1 insertions(+), 5 deletions(-) > > diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/ > include/asm/scatterlist.h > index fcf7d55..912bf59 100644 > --- a/arch/powerpc/include/asm/scatterlist.h > +++ b/arch/powerpc/include/asm/scatterlist.h > @@ -21,7 +21,7 @@ struct scatterlist { > unsigned int offset; > unsigned int length; can we get rid of length? > > > - /* For TCE support */ > + /* For TCE or SWIOTLB support */ > dma_addr_t dma_address; > u32 dma_length; > }; > @@ -34,11 +34,7 @@ struct scatterlist { > * is 0. > */ > #define sg_dma_address(sg) ((sg)->dma_address) > -#ifdef __powerpc64__ > #define sg_dma_len(sg) ((sg)->dma_length) > -#else > -#define sg_dma_len(sg) ((sg)->length) > -#endif > > #ifdef __powerpc64__ > #define ISA_DMA_THRESHOLD (~0UL) > -- > 1.6.0.6 - k ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit 2009-04-20 20:06 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Kumar Gala @ 2009-04-21 2:27 ` FUJITA Tomonori 2009-04-21 15:23 ` Becky Bruce 1 sibling, 0 replies; 27+ messages in thread From: FUJITA Tomonori @ 2009-04-21 2:27 UTC (permalink / raw) To: galak; +Cc: fujita.tomonori, linuxppc-dev On Mon, 20 Apr 2009 15:06:16 -0500 Kumar Gala <galak@kernel.crashing.org> wrote: > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > > > Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh > > to report sg_dma_len. However, since the default dma code for 32-bit > > (the dma_direct case) sets dma_length and length to the same thing, > > we should be able to use dma_length there as well. This gets rid of > > some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which > > actually distinguishes between dma_length and length. > > > > Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> > > --- > > arch/powerpc/include/asm/scatterlist.h | 6 +----- > > 1 files changed, 1 insertions(+), 5 deletions(-) > > > > diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/ > > include/asm/scatterlist.h > > index fcf7d55..912bf59 100644 > > --- a/arch/powerpc/include/asm/scatterlist.h > > +++ b/arch/powerpc/include/asm/scatterlist.h > > @@ -21,7 +21,7 @@ struct scatterlist { > > unsigned int offset; > > unsigned int length; > > can we get rid of length? You can't. > > > > > > - /* For TCE support */ > > + /* For TCE or SWIOTLB support */ > > dma_addr_t dma_address; > > u32 dma_length; > > }; > > @@ -34,11 +34,7 @@ struct scatterlist { > > * is 0. > > */ > > #define sg_dma_address(sg) ((sg)->dma_address) > > -#ifdef __powerpc64__ > > #define sg_dma_len(sg) ((sg)->dma_length) > > -#else > > -#define sg_dma_len(sg) ((sg)->length) > > -#endif > > > > #ifdef __powerpc64__ > > #define ISA_DMA_THRESHOLD (~0UL) > > -- > > 1.6.0.6 > > - k > > ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit 2009-04-20 20:06 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Kumar Gala 2009-04-21 2:27 ` FUJITA Tomonori @ 2009-04-21 15:23 ` Becky Bruce 1 sibling, 0 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-21 15:23 UTC (permalink / raw) To: Kumar Gala; +Cc: fujita.tomonori, linuxppc-dev On Apr 20, 2009, at 3:06 PM, Kumar Gala wrote: > > On Apr 20, 2009, at 11:26 AM, Becky Bruce wrote: > >> Currently, the 32-bit code uses sg->length instead of sg->dma_lentgh >> to report sg_dma_len. However, since the default dma code for 32-bit >> (the dma_direct case) sets dma_length and length to the same thing, >> we should be able to use dma_length there as well. This gets rid of >> some 32-vs-64-bit ifdefs, and is needed by the swiotlb code which >> actually distinguishes between dma_length and length. >> >> Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org> >> --- >> arch/powerpc/include/asm/scatterlist.h | 6 +----- >> 1 files changed, 1 insertions(+), 5 deletions(-) >> >> diff --git a/arch/powerpc/include/asm/scatterlist.h b/arch/powerpc/ >> include/asm/scatterlist.h >> index fcf7d55..912bf59 100644 >> --- a/arch/powerpc/include/asm/scatterlist.h >> +++ b/arch/powerpc/include/asm/scatterlist.h >> @@ -21,7 +21,7 @@ struct scatterlist { >> unsigned int offset; >> unsigned int length; > > can we get rid of length? No - they're both used by the iotlb code and are conceptually different. "dma_length" can get set to less than "length" to indicate that something went wrong with a dma request - the iotlb code sets it to 0 if we can't allocate a bounce buffer, for example. It probably has other uses as well - this is just the one I'm familiar with. In most cases they are equal. Cheers, B ^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx 2009-04-20 16:26 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce 2009-04-20 16:26 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Becky Bruce @ 2009-04-20 16:29 ` Becky Bruce 1 sibling, 0 replies; 27+ messages in thread From: Becky Bruce @ 2009-04-20 16:29 UTC (permalink / raw) To: Becky Bruce; +Cc: fujita.tomonori, linuxppc-dev FAIL. Here's the text that should have been there :) -B This patch series allows the use of swiotlb on mpc86xx, with 85xx upport soon to follow. The most notable change here is the addition of addr_needs_map to dma_ops. This is used to tell if a device can reach an address without bounce buffering. I believe that patches will be coming out soon to make dma_ops non-arch-specific, and I expect to see something similar there as well. I've also changed sg_dma_len to be the same on both 32 and 64-bit. We now look at sg->dma_length in both cases (see patch log). The dma_window* elements in the pci_controller struct are hoisted out of an #ifdef CONFIG_PPC64 so we can use them to store off information about how much memory is mapped via the inbound pci windows. A dma-swiotlb.c is created in arch/powerpc/kernel to contain all the platform-specific iotlb code. Finally, hooks are provided to allow enabling of this feature on 86xx via Kconfig, and a 36-bit device tree for 8641hpcn is provided. Ye Olde Diffstat: arch/powerpc/Kconfig | 2 +- arch/powerpc/boot/dts/mpc8641_hpcn_36b.dts | 597 +++++++++++++++++++ +++++++++ arch/powerpc/include/asm/dma-mapping.h | 11 + arch/powerpc/include/asm/pci-bridge.h | 6 +- arch/powerpc/include/asm/scatterlist.h | 6 +- arch/powerpc/include/asm/swiotlb.h | 24 ++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/dma-swiotlb.c | 161 ++++++++ arch/powerpc/kernel/dma.c | 2 +- arch/powerpc/kernel/setup_32.c | 4 + arch/powerpc/sysdev/fsl_pci.c | 4 + 11 files changed, 809 insertions(+), 9 deletions(-) Cheers, Becky ^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2009-04-22 1:45 UTC | newest] Thread overview: 27+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-04-20 16:26 [PATCH 0/5] SWIOTLB for ppc/mpc86xx Becky Bruce 2009-04-20 16:26 ` [PATCH 0/5] enable swiotlb on ppc/86xx Becky Bruce 2009-04-20 16:26 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce 2009-04-20 16:26 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Becky Bruce 2009-04-20 16:26 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn Becky Bruce 2009-04-20 16:26 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Becky Bruce 2009-04-20 16:26 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Becky Bruce 2009-04-20 16:26 ` [PATCH 5/5] powerpc: Add 86xx support for SWIOTLB Becky Bruce 2009-04-20 17:00 ` Kumar Gala 2009-04-20 17:58 ` Becky Bruce 2009-04-21 2:14 ` Michael Ellerman 2009-04-20 16:57 ` [PATCH 4/5] powerpc: Add support for swiotlb on 32-bit Kumar Gala 2009-04-20 18:03 ` Becky Bruce 2009-04-21 2:39 ` FUJITA Tomonori 2009-04-20 18:31 ` Kumar Gala 2009-04-20 19:06 ` Becky Bruce 2009-04-20 20:04 ` Kumar Gala 2009-04-20 20:16 ` Scott Wood 2009-04-20 16:58 ` [PATCH 3/5] powerpc: make dma_window_* in pci_controller struct avail on 32b Kumar Gala 2009-04-21 1:10 ` [PATCH 2/5] powerpc: Add 36-bit device tree for mpc8641hpcn David Gibson 2009-04-21 15:33 ` Becky Bruce 2009-04-22 1:26 ` David Gibson 2009-04-21 21:11 ` Kumar Gala 2009-04-20 20:06 ` [PATCH 1/5] powerpc: Use sg->dma_length in sg_dma_len() macro on 32-bit Kumar Gala 2009-04-21 2:27 ` FUJITA Tomonori 2009-04-21 15:23 ` Becky Bruce 2009-04-20 16:29 ` [PATCH 0/5] Allow swiotlb use on ppc/mpc86xx Becky Bruce
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).