ARM: S3C24XX: add dmaengine based dma-driver
Subsystems (4)
cover ARM: S3C24XX: add dmaengine based dma-driver
This series tries to provide a basic dmaengine driver for the s3c24xx SoCs.
The driver currently has some limitations, in that it does not support the earlier s3c24xx socs, that cannot use every channel, but have special channel requirements for specific slave-targets.
Another limitation is, that it currently does not support scatter-gather lists with more than element, due to me not understanding sg at first. While it does not hinder the usability, as all applicable Samsung drivers currently use only 1-element-lists, I plan to fix this in the next revision.
In any case, I would be thankful for pointers to the obvious mistakes I'll probably have made, due to this being my first travel into dmaengine-land.
Heiko Stuebner (4):
ARM: S3C24XX: number the dma clocks
dma: add dmaengine driver for Samsung s3c24xx SoCs
ARM: S3C24XX: add platform-devices for new dma driver for s3c2412 and s3c2443
ARM: SAMSUNG: set s3c24xx_dma_filter for s3c64xx-spi0 device
arch/arm/mach-s3c24xx/clock-s3c2412.c | 8 +- arch/arm/mach-s3c24xx/common-s3c2443.c | 12 +- arch/arm/mach-s3c24xx/common.c | 103 +++ arch/arm/mach-s3c24xx/common.h | 3 + arch/arm/plat-samsung/devs.c | 5 +- drivers/dma/Kconfig | 12 +- drivers/dma/Makefile | 1 + drivers/dma/s3c24xx-dma.c | 1129 +++++++++++++++++++++++++++++ include/linux/platform_data/dma-s3c24xx.h | 54 ++ 9 files changed, 1315 insertions(+), 12 deletions(-) create mode 100644 drivers/dma/s3c24xx-dma.c create mode 100644 include/linux/platform_data/dma-s3c24xx.h
Signature · 1 line
1.7.2.3
RFC 1/4 ARM: S3C24XX: number the dma clocks
Each dma channel has its own clock. The upcoming dma driver wants to handle these itself and therefore needs to be able to get the correct clock for a channel.
Therefore rename the dma clocks to "dma.X" for s3c2412, s3c2416 and s3c2443. This does not change the behaviour for the old dma driver at all, as all dma clocks are still always on and not handled by the old dma driver at all.
are always enabled in the original code.
--- arch/arm/mach-s3c24xx/clock-s3c2412.c | 8 ++++---- arch/arm/mach-s3c24xx/common-s3c2443.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-)
arch/arm/mach-s3c24xx/clock-s3c2412.c +4 -4
@@ -484,22 +484,22 @@ static struct clk init_clocks_disable[] = {static struct clk init_clocks[] = { { - .name ="dma" , + .name ="dma.0" , .parent = &clk_h, .enable = s3c2412_clkcon_enable, .ctrlbit =S3C2412_CLKCON_DMA0 , }, { - .name ="dma" , + .name ="dma.1" , .parent = &clk_h, .enable = s3c2412_clkcon_enable, .ctrlbit =S3C2412_CLKCON_DMA1 , }, { - .name ="dma" , + .name ="dma.2" , .parent = &clk_h, .enable = s3c2412_clkcon_enable, .ctrlbit =S3C2412_CLKCON_DMA2 , }, { - .name ="dma" , + .name ="dma.3" , .parent = &clk_h, .enable = s3c2412_clkcon_enable, .ctrlbit =S3C2412_CLKCON_DMA3 ,
arch/arm/mach-s3c24xx/common-s3c2443.c +6 -6
@@ -500,32 +500,32 @@ static struct clk init_clocks_off[] = {static struct clk init_clocks[] = { { - .name ="dma" , + .name ="dma.0" , .parent = &clk_h, .enable = s3c2443_clkcon_enable_h, .ctrlbit =S3C2443_HCLKCON_DMA0 , }, { - .name ="dma" , + .name ="dma.1" , .parent = &clk_h, .enable = s3c2443_clkcon_enable_h, .ctrlbit =S3C2443_HCLKCON_DMA1 , }, { - .name ="dma" , + .name ="dma.2" , .parent = &clk_h, .enable = s3c2443_clkcon_enable_h, .ctrlbit =S3C2443_HCLKCON_DMA2 , }, { - .name ="dma" , + .name ="dma.3" , .parent = &clk_h, .enable = s3c2443_clkcon_enable_h, .ctrlbit =S3C2443_HCLKCON_DMA3 , }, { - .name ="dma" , + .name ="dma.4" , .parent = &clk_h, .enable = s3c2443_clkcon_enable_h, .ctrlbit =S3C2443_HCLKCON_DMA4 , }, { - .name ="dma" , + .name ="dma.5" , .parent = &clk_h, .enable = s3c2443_clkcon_enable_h, .ctrlbit =S3C2443_HCLKCON_DMA5 ,
Signature · 1 line
1.7.2.3
RFC 2/4 dma: add dmaengine driver for Samsung s3c24xx SoCs
In reply to Heiko StübnerThis adds a new driver to support the s3c24xx dma using the dmaengine and make the old one in mach-s3c24xx obsolete in the long run.
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the slave_sg one.
The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Tested on a s3c2416-based board, memcpy using the dmatest module and slave_sg partially using the spi-s3c64xx driver.
--- drivers/dma/Kconfig | 12 +- drivers/dma/Makefile | 1 + drivers/dma/s3c24xx-dma.c | 1129 +++++++++++++++++++++++++++++ include/linux/platform_data/dma-s3c24xx.h | 54 ++ 4 files changed, 1195 insertions(+), 1 deletions(-) create mode 100644 drivers/dma/s3c24xx-dma.c create mode 100644 include/linux/platform_data/dma-s3c24xx.h
drivers/dma/Kconfig +11 -1
@@ -174,7 +174,17 @@ config TEGRA20_APB_DMA This DMA controller transfers data from memory to peripheral fifo or vice versa. It does not support memory to memory data transfer. - +config S3C24XX_DMAC + tristate "Samsung S3C24XX DMA support" + depends on ARCH_S3C24XX && !S3C24XX_DMA + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help + Support for the Samsung S3C24XX DMA controller driver. The + DMA controller is having multiple DMA channels which can be + configured for different peripherals like audio, UART, SPI. + The DMA controller can transfer data from memory to peripheral, + periphal to memory, periphal to periphal and memory to memory. config SH_DMAE tristate "Renesas SuperH DMAC support"
drivers/dma/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_SIRF_DMA) += sirf-dma.o obj-$(CONFIG_TI_EDMA) += edma.o obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o +obj-$(CONFIG_S3C24XX_DMAC) += s3c24xx-dma.o obj-$(CONFIG_PL330_DMA) += pl330.o obj-$(CONFIG_PCH_DMA) += pch_dma.o obj-$(CONFIG_AMBA_PL08X) += amba-pl08x.o
drivers/dma/s3c24xx-dma.c new file +1129 -0
1,129 lines not on this page · raw message
include/linux/platform_data/dma-s3c24xx.h new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
1.7.2.3
RFC 3/4 ARM: S3C24XX: add platform-devices for new dma driver for s3c2412 and s3c2443
In reply to Heiko StübnerThis includes defining the mapping for the request sources.
--- arch/arm/mach-s3c24xx/common.c | 103 ++++++++++++++++++++++++++++++++++++++++ arch/arm/mach-s3c24xx/common.h | 3 + 2 files changed, 106 insertions(+), 0 deletions(-)
arch/arm/mach-s3c24xx/common.c +103 -0
@@ -30,6 +30,7 @@#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/io.h> +#include <linux/platform_data/dma-s3c24xx.h> #include <mach/hardware.h> #include <mach/regs-clock.h>
@@ -302,3 +303,105 @@ void __init_or_cpufreq s3c24xx_setup_clocks(unsigned long fclk, clk_p.rate = pclk; clk_f.rate = fclk; } + +#if defined(CONFIG_CPU_S3C2410 ) || defined(CONFIG_CPU_S3C2412 ) || \ + defined(CONFIG_CPUS_3C2440 ) || defined(CONFIG_CPUS_3C2442 ) +static struct resource s3c2410_dma_resource[] = { + [0 ] =DEFINE_RES_MEM (S3C24XX_PA_DMA ,S3C24XX_SZ_DMA ), + [1 ] =DEFINE_RES_IRQ (IRQ_DMA0 ), + [2 ] =DEFINE_RES_IRQ (IRQ_DMA1 ), + [3 ] =DEFINE_RES_IRQ (IRQ_DMA2 ), + [4 ] =DEFINE_RES_IRQ (IRQ_DMA3 ), +}; +#endif + +#ifdef CONFIG_CPU_S3C2412 +static int s3c2412_dma_reqsel[S3C24XX_DMACH_MAX ] = { + [S3C24XX_DMACH_XD0 ] =17 , + [S3C24XX_DMACH_XD1 ] =18 , + [S3C24XX_DMACH_SDI ] =10 , + [S3C24XX_DMACH_SPI0_RX ] =1 , + [S3C24XX_DMACH_SPI0_TX ] =0 , + [S3C24XX_DMACH_SPI1_RX ] =3 , + [S3C24XX_DMACH_SPI1_TX ] =2 , + [S3C24XX_DMACH_UART0 ] =19 , + [S3C24XX_DMACH_UART1 ] =21 , + [S3C24XX_DMACH_UART2 ] =23 , + [S3C24XX_DMACH_UART0_SRC2 ] =20 , + [S3C24XX_DMACH_UART1_SRC2 ] =22 , + [S3C24XX_DMACH_UART2_SRC2 ] =24 , + [S3C24XX_DMACH_TIMER ] =9 , + [S3C24XX_DMACH_I2S_RX ] =5 , + [S3C24XX_DMACH_I2S_TX ] =4 , + [S3C24XX_DMACH_USB_EP1 ] =13 , + [S3C24XX_DMACH_USB_EP2 ] =14 , + [S3C24XX_DMACH_USB_EP3 ] =15 , + [S3C24XX_DMACH_USB_EP4 ] =16 , +}; + +static struct s3c24xx_dma_platdata s3c2412_dma_platdata = { + .num_phy_channels =4 , + .reqsel_map = s3c2412_dma_reqsel, +}; + +struct platform_device s3c2412_device_dma = { + .name ="s3c2412-dma" , + .id =0 , + .num_resources =ARRAY_SIZE (s3c2410_dma_resource), + .resource = s3c2410_dma_resource, + .dev = { + .platform_data = &s3c2412_dma_platdata, + }, +}; +#endif + +#if defined(CONFIG_CPUS_3C2443 ) || defined(CONFIG_CPU_S3C2416 ) +static struct resource s3c2443_dma_resource[] = { + [0 ] =DEFINE_RES_MEM (S3C24XX_PA_DMA ,S3C24XX_SZ_DMA ), + [1 ] =DEFINE_RES_IRQ (IRQ_S3C2443_DMA0 ), + [2 ] =DEFINE_RES_IRQ (IRQ_S3C2443_DMA1 ), + [3 ] =DEFINE_RES_IRQ (IRQ_S3C2443_DMA2 ), + [4 ] =DEFINE_RES_IRQ (IRQ_S3C2443_DMA3 ), + [5 ] =DEFINE_RES_IRQ (IRQ_S3C2443_DMA4 ), + [6 ] =DEFINE_RES_IRQ (IRQ_S3C2443_DMA5 ), +}; + +static int s3c2443_dma_reqsel[S3C24XX_DMACH_MAX ] = { + [S3C24XX_DMACH_XD0 ] =17 , + [S3C24XX_DMACH_XD1 ] =18 , + [S3C24XX_DMACH_SDI ] =10 , + [S3C24XX_DMACH_SPI0_RX ] =1 , + [S3C24XX_DMACH_SPI0_TX ] =0 , + [S3C24XX_DMACH_SPI1_RX ] =3 , + [S3C24XX_DMACH_SPI1_TX ] =2 , + [S3C24XX_DMACH_UART0 ] =19 , + [S3C24XX_DMACH_UART1 ] =21 , + [S3C24XX_DMACH_UART2 ] =23 , + [S3C24XX_DMACH_UART3 ] =25 , + [S3C24XX_DMACH_UART0_SRC2 ] =20 , + [S3C24XX_DMACH_UART1_SRC2 ] =22 , + [S3C24XX_DMACH_UART2_SRC2 ] =24 , + [S3C24XX_DMACH_UART3_SRC2 ] =26 , + [S3C24XX_DMACH_TIMER ] =9 , + [S3C24XX_DMACH_I2S_RX ] =5 , + [S3C24XX_DMACH_I2S_TX ] =4 , + [S3C24XX_DMACH_PCM_IN ] =28 , + [S3C24XX_DMACH_PCM_OUT ] =27 , + [S3C24XX_DMACH_MIC_IN ] =29 , +}; + +static struct s3c24xx_dma_platdata s3c2443_dma_platdata = { + .num_phy_channels =6 , + .reqsel_map = s3c2443_dma_reqsel, +}; + +struct platform_device s3c2443_device_dma = { + .name ="s3c2443-dma" , + .id =0 , + .num_resources =ARRAY_SIZE (s3c2443_dma_resource), + .resource = s3c2443_dma_resource, + .dev = { + .platform_data = &s3c2443_dma_platdata, + }, +}; +#endif
arch/arm/mach-s3c24xx/common.h +3 -0
@@ -107,4 +107,7 @@ extern void s3c2443_init_irq(void);extern struct syscore_ops s3c24xx_irq_syscore_ops; +extern struct platform_device s3c2412_device_dma; +extern struct platform_device s3c2443_device_dma; +#endif /* __ARCH_ARM_MACH_S3C24XX_COMMON_H */
Signature · 1 line
1.7.2.3
RFC 4/4 ARM: SAMSUNG: set s3c24xx_dma_filter for s3c64xx-spi0 device
In reply to Heiko StübnerThe spi-s3c64xx device is also used on the s3c2416 and s3c2443 SoCs. The driver also already uses only generic dma-engine operations.
Therefore add another elif to set the s3c24xx filter.
--- arch/arm/plat-samsung/devs.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/plat-samsung/devs.c +4 -1
@@ -32,6 +32,7 @@#include <linux/ioport.h> #include <linux/platform_data/s3c-hsudc.h> #include <linux/platform_data/s3c-hsotg.h> +#include <linux/platform_data/dma-s3c24xx.h> #include <media/s5p_hdmi.h>
@@ -1513,8 +1514,10 @@ void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, pd.num_cs = num_cs; pd.src_clk_nr = src_clk_nr; pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; -#ifdef CONFIG_PL330_DMA +#if defined(CONFIG_PL330_DMA ) pd.filter = pl330_filter; +#elif defined(CONFIG_S3C24XX_DMAC ) + pd.filter = s3c24xx_dma_filter;#endif s3c_set_platdata (&pd,sizeof (pd), &s3c64xx_device_spi0);
Signature · 1 line
1.7.2.3
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
In reply to Heiko StübnerQuoted 11 lines · Heiko St?bner
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the
slave_sgone.The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Quoted 4 lines
Tested on a s3c2416-based board, memcpy using the dmatest module and
slave_sgpartially using the spi-s3c64xx driver.Signed-off-by Heiko Stuebner <[email protected]>
So have I understood correctly if I assume that *some* S3C variants, i.e. this: arch/arm/mach-s3c64xx/dma.c have a vanilla, unmodified, or just slightly modified PL08x block, while this DMAC is something probably based on the PL08x where some ASIC engineer has had a good time hacking around in the VHDL code to meet some feature requirements. Correct? Or plausible guess?
Exactly *how* far away from the pl08x hardware is it?
I guess you have already come to the conclusion that the amba-pl08x.c driver cannot be augmented to handle this hardware after some educated reading of that code?
But are really no parts reusable?
For example, if the LLIs have the same layout, could we split out the LLI handling from amba-pl08x into a separate file and reuse that?
The more you share with amba-pl08x the better for everyone, I am positively sure. And please include Russell on the review chain, he wrote the virtual channel abstraction.
If I was given the option amongst S3C work I would definatley have augmented the amba-pl08x.c to handle the stuff in arch/arm/mach-s3c64xx/dma.c *first* then started to work on this driver, but I guess you might not be working on s3c64xx?
Yours,
Linus Walleij
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Am Dienstag, 14. Mai 2013, 14:47:19 schrieb Linus Walleij:
Quoted 17 lines · Heiko St?bner
Quoted 11 lines
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the
slave_sgone.The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Quoted 4 lines
Tested on a s3c2416-based board, memcpy using the dmatest module and
slave_sgpartially using the spi-s3c64xx driver.Signed-off-by Heiko Stuebner <[email protected]>
Quoted 7 lines
So have I understood correctly if I assume that *some* S3C variants, i.e. this:
arch/arm/mach-s3c64xx/dma.chave a vanilla, unmodified, or just slightly modified PL08x block, while this DMAC is something probably based on the PL08x where some ASIC engineer has had a good time hacking around in the VHDL code to meet some feature requirements. Correct? Or plausible guess?
You're guess is at good as mine :-) . The public s3c64xx (ARM11 based) documentation says that it is using s PL080 as dma controller while the s3c24xx (ARM9 based) SoCs have this one, which doesn't come with any label in the manuals.
Similar to the s3c64xx using a vic, while the s3c24xx uses something homegrown.
The relationship description was more based on the concepts used, i.e. the virtual channel concept and general handling of dma transfers feel somehow similar - as I said these are my first steps into this, so I still need to understand a lot.
Quoted 11 lines
Exactly *how* far away from the pl08x hardware is it?
I guess you have already come to the conclusion that the
amba-pl08x.cdriver cannot be augmented to handle this hardware after some educated reading of that code?But are really no parts reusable?
For example, if the LLIs have the same layout, could we split out the LLI handling from amba-pl08x into a separate file and reuse that?
The s3c24xx-dma doesn't have these. You simply put source and destination addresses on the bus, tell it the number of transfers and start it, while the pl080 seems to split these then into the LLIs, which seems to be some kind of hardware feature.
For the rest, the register-layout of the controller is completely different (I checked the PL080 manual), each channel has its own interrupt and the above mentioned missing LLIs.
Both drivers share somehow how they handle end of transfers, i.e. how they reuse the physical channel for a possible waiting virtual channel. But it didn't look like anything worth factoring out.
Quoted 3 lines
The more you share with amba-pl08x the better for everyone, I am positively sure. And please include Russell on the review chain, he wrote the virtual channel abstraction.
I think the best feature is already factored out - the virtual channel handling, which was very nice to have.
I used the list from get_maintainer.pl, so sorry for forgetting Russel.
Quoted 4 lines
If I was given the option amongst S3C work I would definatley have augmented the
amba-pl08x.cto handle the stuff inarch/arm/mach-s3c64xx/dma.c*first* then started to work on this driver, but I guess you might not be working on s3c64xx?
correct, my pet-project is s3c2416-based [0], so I haven't seen any other Samsung stuff at all.
Heiko
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
In reply to Linus WalleijHi Linus, Heiko,
Quoted 25 lines · On Tuesday 14 of May 2013 14:47:19 Linus Walleij wrote:
Quoted 11 lines · Heiko St?bner
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the
slave_sgone.The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Quoted 4 lines
Tested on a s3c2416-based board, memcpy using the dmatest module and
slave_sgpartially using the spi-s3c64xx driver.Signed-off-by Heiko Stuebner <[email protected]>So have I understood correctly if I assume that *some* S3C variants, i.e. this:
arch/arm/mach-s3c64xx/dma.chave a vanilla, unmodified, or just slightly modified PL08x block, while this DMAC is something probably based on the PL08x where some ASIC engineer has had a good time hacking around in the VHDL code to meet some feature requirements. Correct? Or plausible guess?
Quoted 1 line
Exactly *how* far away from the pl08x hardware is it?
AFAIK the DMAC of S3C24xx is completely different from PL08x. I think Heiko just meant that it uses similar concepts, like virtual channels.
Quoted 10 lines
I guess you have already come to the conclusion that the
amba-pl08x.cdriver cannot be augmented to handle this hardware after some educated reading of that code?But are really no parts reusable?
For example, if the LLIs have the same layout, could we split out the LLI handling from amba-pl08x into a separate file and reuse that?
Quoted 8 lines
The more you share with amba-pl08x the better for everyone, I am positively sure. And please include Russell on the review chain, he wrote the virtual channel abstraction.
If I was given the option amongst S3C work I would definatley have augmented the
amba-pl08x.cto handle the stuff inarch/arm/mach-s3c64xx/dma.c*first* then started to work on this driver, but I guess you might not be working on s3c64xx?
Well, I still hope that someone will pick up the work on adapting PL08x driver to support PL080s of S3C64xx as well, but most likely it will end up with me doing it, as a part of DT support for S3C64xx.
Best regards,
Signature · 3 lines
Tomasz Figa Samsung Poland R&D Center SW Solution Development, Kernel and System Framework
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
In reply to Heiko StübnerQuoted 33 lines · Heiko St?bner
Am Dienstag, 14. Mai 2013, 14:47:19 schrieb Linus Walleij:
Quoted 17 lines · Heiko St?bner
Quoted 11 lines
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the
slave_sgone.The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Quoted 4 lines
Tested on a s3c2416-based board, memcpy using the dmatest module and
slave_sgpartially using the spi-s3c64xx driver.Signed-off-by Heiko Stuebner <[email protected]>Quoted 7 lines
So have I understood correctly if I assume that *some* S3C variants, i.e. this:
arch/arm/mach-s3c64xx/dma.chave a vanilla, unmodified, or just slightly modified PL08x block, while this DMAC is something probably based on the PL08x where some ASIC engineer has had a good time hacking around in the VHDL code to meet some feature requirements. Correct? Or plausible guess?You're guess is at good as mine :-) . The public s3c64xx (ARM11 based) documentation says that it is using s PL080 as dma controller while the s3c24xx (ARM9 based) SoCs have this one, which doesn't come with any label in the manuals.
Similar to the s3c64xx using a vic, while the s3c24xx uses something homegrown.
Quoted 4 lines
The relationship description was more based on the concepts used, i.e. the virtual channel concept and general handling of dma transfers feel somehow similar - as I said these are my first steps into this, so I still need to understand a lot.
OK then, a separate driver seems required, will look a bit closer at the patch as such.
Yours,
Linus Walleij
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
In reply to Heiko StübnerQuoted 18 lines · Heiko St?bner
This adds a new driver to support the s3c24xx dma using the dmaengine and make the old one in mach-s3c24xx obsolete in the long run.
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the
slave_sgone.The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Tested on a s3c2416-based board, memcpy using the dmatest module and
slave_sgpartially using the spi-s3c64xx driver.Signed-off-by Heiko Stuebner <[email protected]>
(...)
Quoted 8 lines
drivers/dma/s3c24xx-dma.c new file +8
-0+static u32 s3c24xx_dma_getbytes_chan (struct s3c24xx_dma_chan *s3cchan) +{ +struct s3c24xx_dma_phy *phy = s3cchan->phy; +struct s3c24xx_txd *txd = s3cchan->at; +u32 tc =readl (phy->base +DSTAT ) &DSTAT_CURRTC_MASK ; + +switch (txd->dcon &DCON_DSZ_MASK ) { +case DCON_DSZ_BYTE :
drivers/dma/s3c24xx-dma.c line 326
Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10
-0+return tc; +case DCON_DSZ_HALFWORD : +return tc *2 ; +case DCON_DSZ_WORD : +return tc *4 ; +default : +break ; + } + +BUG ();
Isn't that a bit nasty. This macro should be used with care and we should recover if possible. dev_err()?
Quoted 62 lines
drivers/dma/s3c24xx-dma.c new file +62
-0+/* +* Set the initial DMA register values. +* Put them into the hardware and start the transfer. +*/ +static void s3c24xx_dma_start_next_txd (struct s3c24xx_dma_chan *s3cchan) +{ +struct s3c24xx_dma_engine *s3cdma = s3cchan->host; +struct s3c24xx_dma_phy *phy = s3cchan->phy; +struct virt_dma_desc *vd =vchan_next_desc (&s3cchan->vc); +struct s3c24xx_txd *txd =to_s3c24xx_txd (&vd->tx); +u32 dcon = txd->dcon; +u32 val; + +list_del (&txd->vd.node); + + s3cchan->at = txd; + +/* Wait for channel inactive */ +while (s3c24xx_dma_phy_busy (phy)) +cpu_relax (); + +/* transfer-size and -count from len and width */ +switch (txd->width) { +case 1 : + dcon |=DCON_DSZ_BYTE | txd->len; +break ; +case 2 : + dcon |=DCON_DSZ_HALFWORD | (txd->len /2 ); +break ; +case 4 : + dcon |=DCON_DSZ_WORD | (txd->len /4 ); +break ; + } + +if (s3cchan->slave) { +if (s3cdma->sdata->has_reqsel) { +int reqsel = s3cdma->pdata->reqsel_map[s3cchan->id]; +writel ((reqsel <<1 ) |DMAREQSEL_HW , + phy->base +DMAREQSEL ); + }else { +dev_err (&s3cdma->pdev->dev,"non-reqsel unsupported\n" ); +return ; + dcon |=DCON_HWTRIG ; + } + }else { +if (s3cdma->sdata->has_reqsel) { +writel (0 , phy->base +DMAREQSEL ); + }else { +dev_err (&s3cdma->pdev->dev,"non-reqsel unsupported\n" ); +return ; + } + } + +writel (txd->src_addr, phy->base +DISRC ); +writel (txd->disrcc, phy->base +DISRCC ); +writel (txd->dst_addr, phy->base +DIDST ); +writel (txd->didstc, phy->base +DIDSTC ); + +writel (dcon, phy->base +DCON ); + + val =readl (phy->base +DMASKTRIG ); + val &= ~DMASKTRIG_STOP ;
drivers/dma/s3c24xx-dma.c line 427
Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10
-0+ val |=DMASKTRIG_ON ; +writel (val, phy->base +DMASKTRIG ); + +/* trigger the dma operation for memcpy transfers */ +if (!s3cchan->slave) { + val =readl (phy->base +DMASKTRIG ); + val |=DMASKTRIG_SWTRIG ; +writel (val, phy->base +DMASKTRIG ); + } +}
Since you have a few readl() and writel() in potentially time-critical code, consider using readl_relaxed() and writel_relaxed().
Quoted 23 lines
drivers/dma/s3c24xx-dma.c new file +23
-0+static irqreturn_t s3c24xx_dma_irq (int irq,void *data) +{ +struct s3c24xx_dma_phy *phy = data; +struct s3c24xx_dma_chan *s3cchan = phy->serving; +struct s3c24xx_txd *txd; + +dev_dbg (&phy->host->pdev->dev,"interrupt on channel %d\n" , phy->id); + +if (!s3cchan) { +dev_err (&phy->host->pdev->dev,"interrupt on unused channel %d\n" , + phy->id); +return IRQ_NONE ; + } + +spin_lock (&s3cchan->vc.lock); + txd = s3cchan->at; +if (txd) { + s3cchan->at =NULL ; +vchan_cookie_complete (&txd->vd); + +/* +* And start the next descriptor (if any), +* otherwise free this channel.
drivers/dma/s3c24xx-dma.c line 579
Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10
-0+*/ +if (vchan_next_desc (&s3cchan->vc)) +s3c24xx_dma_start_next_txd (s3cchan); +else +s3c24xx_dma_phy_free (s3cchan); + } +spin_unlock (&s3cchan->vc.lock); + +return IRQ_HANDLED ; +}
OK so one IRQ per channel. Is there really no status register to check or flag to clear on these IRQs?
Apart from these smallish things it looks good to me:
Yours,
Linus Walleij
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Am Mittwoch, 15. Mai 2013, 20:53:32 schrieb Linus Walleij:
Quoted 35 lines · Heiko St?bner
Quoted 18 lines
This adds a new driver to support the s3c24xx dma using the dmaengine and make the old one in mach-s3c24xx obsolete in the long run.
Conceptually the s3c24xx-dma feels like a distant relative of the pl08x with numerous virtual channels being mapped to a lot less physical ones. The driver therefore borrows a lot from the amba-pl08x driver in this regard. Functionality-wise the driver gains a memcpy ability in addition to the
slave_sgone.The driver currently only supports the "newer" SoCs which can use any physical channel for any dma slave. Support for the older SoCs where each channel only supports a subset of possible dma slaves will have to be added later.
Tested on a s3c2416-based board, memcpy using the dmatest module and
slave_sgpartially using the spi-s3c64xx driver.Signed-off-by Heiko Stuebner <[email protected]>(...)
Quoted 13 lines
drivers/dma/s3c24xx-dma.c new file +13
-0+static u32 s3c24xx_dma_getbytes_chan (struct s3c24xx_dma_chan *s3cchan) +{ +struct s3c24xx_dma_phy *phy = s3cchan->phy; +struct s3c24xx_txd *txd = s3cchan->at; +u32 tc =readl (phy->base +DSTAT ) &DSTAT_CURRTC_MASK ; + +switch (txd->dcon &DCON_DSZ_MASK ) { +case DCON_DSZ_BYTE : +return tc; +case DCON_DSZ_HALFWORD : +return tc *2 ; +case DCON_DSZ_WORD : +return tc *4 ;
Quoted 8 lines
drivers/dma/s3c24xx-dma.c line 326
Quoted 5 lines
drivers/dma/s3c24xx-dma.c new file +5
-0+default : +break ; + } + +BUG ();Isn't that a bit nasty. This macro should be used with care and we should recover if possible.
dev_err()?
runtime_config already denies any settings not in the 1,2 or 4bytes range - the default-part should therefore never be reached. So if any other value magically appears in the register and triggers the default-part, something is seriously wrong. So my guess is, the BUG might be appropriate.
On the other hand the whole default+BUG part could also simply go away, for the same reasons.
Quoted 69 lines
Quoted 69 lines
drivers/dma/s3c24xx-dma.c new file +37
-0+/* +* Set the initial DMA register values. +* Put them into the hardware and start the transfer. +*/ +static void s3c24xx_dma_start_next_txd (struct s3c24xx_dma_chan *s3cchan) +{ +struct s3c24xx_dma_engine *s3cdma = s3cchan->host; +struct s3c24xx_dma_phy *phy = s3cchan->phy; +struct virt_dma_desc *vd =vchan_next_desc (&s3cchan->vc); +struct s3c24xx_txd *txd =to_s3c24xx_txd (&vd->tx); +u32 dcon = txd->dcon; +u32 val; + +list_del (&txd->vd.node); + + s3cchan->at = txd; + +/* Wait for channel inactive */ +while (s3c24xx_dma_phy_busy (phy)) +cpu_relax (); + +/* transfer-size and -count from len and width */ +switch (txd->width) { +case 1 : + dcon |=DCON_DSZ_BYTE | txd->len; +break ; +case 2 : + dcon |=DCON_DSZ_HALFWORD | (txd->len /2 ); +break ; +case 4 : + dcon |=DCON_DSZ_WORD | (txd->len /4 ); +break ; + } + +if (s3cchan->slave) { +if (s3cdma->sdata->has_reqsel) { + int reqsel =s3cdma->pdata->reqsel_map[s3cchan->id]; +
writel((reqsel << 1) |DMAREQSEL_HW,drivers/dma/s3c24xx-dma.c new file +3
-0+ phy->base + DMAREQSEL); + }else { + dev_err(&s3cdma->pdev->dev, "non-reqselunsupported\n"); + return;
drivers/dma/s3c24xx-dma.c new file +7
-0+ dcon |=DCON_HWTRIG ; + } + }else { +if (s3cdma->sdata->has_reqsel) { +writel (0 , phy->base +DMAREQSEL ); + }else { + dev_err(&s3cdma->pdev->dev, "non-reqselunsupported\n"); + return;
drivers/dma/s3c24xx-dma.c new file +18
-0+ } + } + +writel (txd->src_addr, phy->base +DISRC ); +writel (txd->disrcc, phy->base +DISRCC ); +writel (txd->dst_addr, phy->base +DIDST ); +writel (txd->didstc, phy->base +DIDSTC ); + +writel (dcon, phy->base +DCON ); + + val =readl (phy->base +DMASKTRIG ); + val &= ~DMASKTRIG_STOP ; + val |=DMASKTRIG_ON ; +writel (val, phy->base +DMASKTRIG ); + +/* trigger the dma operation for memcpy transfers */ +if (!s3cchan->slave) { + val =readl (phy->base +DMASKTRIG );
Quoted 8 lines
drivers/dma/s3c24xx-dma.c line 427
Quoted 4 lines
drivers/dma/s3c24xx-dma.c new file +4
-0+ val |=DMASKTRIG_SWTRIG ; +writel (val, phy->base +DMASKTRIG ); + } +}Since you have a few
readl()andwritel()in potentially time-critical code, consider usingreadl_relaxed()andwritel_relaxed().
You're right of course.
If I understand the writel semantics and the thread from you from 2011 [0] correctly, only the writel to DMASKTRIG mustn't be relaxed to make sure the settings registers are written to before, so like:
writel_relaxed(txd->src_addr, phy->base + DISRC);
writel_relaxed(txd->disrcc, phy->base + DISRCC);
writel_relaxed(txd->dst_addr, phy->base + DIDST);
writel_relaxed(txd->didstc, phy->base + DIDSTC);
writel_relaxed(dcon, phy->base + DCON);
val = readl_relaxed(phy->base + DMASKTRIG);
val &= ~DMASKTRIG_STOP;
val |= DMASKTRIG_ON;
writel(val, phy->base + DMASKTRIG);And note to self: check if the memcpy-speciality can move into the first DMASKTRIG write.
Quoted 28 lines
Quoted 28 lines
drivers/dma/s3c24xx-dma.c new file +7
-0+static irqreturn_t s3c24xx_dma_irq (int irq,void *data) +{ +struct s3c24xx_dma_phy *phy = data; +struct s3c24xx_dma_chan *s3cchan = phy->serving; +struct s3c24xx_txd *txd; + + dev_dbg(&phy->host->pdev->dev, "interrupt on channel %d\n",
phy->id); +(quoted diff) +2
-0+ if (!s3cchan) { + dev_err(&phy->host->pdev->dev, "interrupt on unusedchannel %d\n", +
phy->id);drivers/dma/s3c24xx-dma.c new file +17
-0+return IRQ_NONE ; + } + +spin_lock (&s3cchan->vc.lock); + txd = s3cchan->at; +if (txd) { + s3cchan->at =NULL ; +vchan_cookie_complete (&txd->vd); + +/* +* And start the next descriptor (if any), +* otherwise free this channel. +*/ +if (vchan_next_desc (&s3cchan->vc)) +s3c24xx_dma_start_next_txd (s3cchan); +else +s3c24xx_dma_phy_free (s3cchan);
Quoted 8 lines
drivers/dma/s3c24xx-dma.c line 579
Quoted 5 lines
drivers/dma/s3c24xx-dma.c new file +5
-0+ } +spin_unlock (&s3cchan->vc.lock); + +return IRQ_HANDLED ; +}OK so one IRQ per channel. Is there really no status register to check or flag to clear on these IRQs?
Nope there are none. The only status you get from the controller is busy/non- busy and remaining transfers for the transaction - the DSTAT register in the code. And not listed in the code the current memory addresses (source and destination) in use. There are no other registers at all.
And the irq itself only triggers when all transfers of the transaction are done (transfer_count is 0).
Quoted 2 lines
Apart from these smallish things it looks good to me:
Acked-by Linus Walleij <[email protected]>
really? Cool.
Part of me was expecting tomatoes or other vegetables to be thrown ;-) .
Thanks for looking thru the driver.
Heiko
[0] http://comments.gmane.org/gmane.linux.ports.arm.kernel/117626
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Quoted 5 lines · Heiko St?bner
Quoted 4 lines
Quoted 4 lines
+
BUG();Isn't that a bit nasty. This macro should be used with care and we should recover if possible.
dev_err()?
Quoted 7 lines
runtime_configalready denies any settings not in the 1,2 or 4bytes range - the default-part should therefore never be reached. So if any other value magically appears in the register and triggers the default-part, something is seriously wrong. So my guess is, the BUG might be appropriate.On the other hand the whole default+BUG part could also simply go away, for the same reasons.
IMHO BUG() is not needed at all. As Linus suggested dev_err() is such case or WARN_ON() would be more appropriate. This has been discussed in the past extensively, not sure if you are aware of the other Linus' opinion on BUG()/BUG_ON() proliferation: https://lkml.org/lkml/2012/9/27/461
Regards,
Sylwester
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Am Mittwoch, 15. Mai 2013, 23:20:08 schrieb Sylwester Nawrocki:
Quoted 12 lines · Heiko St?bner
Quoted 11 lines
Quoted 4 lines
Quoted 4 lines
+
BUG();Isn't that a bit nasty. This macro should be used with care and we should recover if possible.
dev_err()?
runtime_configalready denies any settings not in the 1,2 or 4bytes range
- the default-part should therefore never be reached. So if any other value magically appears in the register and triggers the default-part, something is seriously wrong. So my guess is, the BUG might be appropriate.
Quoted 7 lines
Quoted 2 lines
On the other hand the whole default+BUG part could also simply go away, for the same reasons.
IMHO
BUG()is not needed at all. As Linus suggesteddev_err()is such case orWARN_ON()would be more appropriate. This has been discussed in the past extensively, not sure if you are aware of the other Linus' opinion on BUG()/BUG_ON() proliferation: https://lkml.org/lkml/2012/9/27/461
Very interesting read and I'll keep this in mind in the future. What about the other option ... i.e. simply getting rid of the whole "error handling", as the other code paths should already make sure that only valid values get written into the register.
Can the value change in the register somehow on its own without kernel intervention, or does this not happen?
Thanks
Heiko
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Quoted 23 lines · On Wednesday 15 of May 2013 23:48:31 Heiko St?bner wrote:
Am Mittwoch, 15. Mai 2013, 23:20:08 schrieb Sylwester Nawrocki:
Quoted 17 lines · Heiko St?bner
Quoted 12 lines
Quoted 5 lines
Quoted 5 lines
+
BUG();Isn't that a bit nasty. This macro should be used with care and we
should recover if possible.dev_err()?
runtime_configalready denies any settings not in the 1,2 or 4bytes range - the default-part should therefore never be reached. So if any other value magically appears in the register and triggers the default-part, something is seriously wrong. So my guess is, the BUG might be appropriate.Quoted 3 lines
On the other hand the whole default+BUG part could also simply go away,
for the same reasons.Quoted 5 lines
IMHO
BUG()is not needed at all. As Linus suggesteddev_err()is such case orWARN_ON()would be more appropriate. This has been discussed in the past extensively, not sure if you are aware of the other Linus' opinion on BUG()/BUG_ON() proliferation:
https://lkml.org/lkml/2012/9/27/461
Quoted 7 lines
Very interesting read and I'll keep this in mind in the future. What about the other option ... i.e. simply getting rid of the whole "error handling", as the other code paths should already make sure that only valid values get written into the register.
Can the value change in the register somehow on its own without kernel intervention, or does this not happen?
Hmm, it depends on hardware, I guess. Not sure how it works on this particular IP.
Still, the mentioned BUG() was about a value in a driver-filled struct, wasn't it?
/* Quoting the the code for reference */
Quoted 8 lines
drivers/dma/s3c24xx-dma.c new file +8
-0+static u32 s3c24xx_dma_getbytes_chan (struct s3c24xx_dma_chan *s3cchan) +{ +struct s3c24xx_dma_phy *phy = s3cchan->phy; +struct s3c24xx_txd *txd = s3cchan->at; +u32 tc =readl (phy->base +DSTAT ) &DSTAT_CURRTC_MASK ; + +switch (txd->dcon &DCON_DSZ_MASK ) { +case DCON_DSZ_BYTE :
drivers/dma/s3c24xx-dma.c line 326
Quoted 10 lines
drivers/dma/s3c24xx-dma.c new file +10
-0+return tc; +case DCON_DSZ_HALFWORD : +return tc *2 ; +case DCON_DSZ_WORD : +return tc *4 ; +default : +break ; + } + +BUG ();
(Btw. I don't see anything setting the DCON_DSZ bits in this field. Am I missing something?)
Best regards,
Tomasz
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Am Donnerstag, 16. Mai 2013, 00:02:40 schrieb Tomasz Figa:
Quoted 54 lines · On Wednesday 15 of May 2013 23:48:31 Heiko St?bner wrote:
Quoted 24 lines
Am Mittwoch, 15. Mai 2013, 23:20:08 schrieb Sylwester Nawrocki:
Quoted 17 lines · Heiko St?bner
Quoted 12 lines
Quoted 5 lines
Quoted 5 lines
+
BUG();Isn't that a bit nasty. This macro should be used with care and we
should recover if possible.dev_err()?
runtime_configalready denies any settings not in the 1,2 or 4bytes range - the default-part should therefore never be reached. So if any other value magically appears in the register and triggers the default-part, something is seriously wrong. So my guess is, the BUG might be appropriate.Quoted 3 lines
On the other hand the whole default+BUG part could also simply go away,
for the same reasons.Quoted 5 lines
IMHO
BUG()is not needed at all. As Linus suggesteddev_err()is such case orWARN_ON()would be more appropriate. This has been discussed in the past extensively, not sure if you are aware of the other Linus' opinion on BUG()/BUG_ON() proliferation:
https://lkml.org/lkml/2012/9/27/461Quoted 7 lines
Very interesting read and I'll keep this in mind in the future. What about the other option ... i.e. simply getting rid of the whole "error handling", as the other code paths should already make sure that only valid values get written into the register.
Can the value change in the register somehow on its own without kernel intervention, or does this not happen?
Hmm, it depends on hardware, I guess. Not sure how it works on this particular IP.
Still, the mentioned
BUG()was about a value in a driver-filled struct, wasn't it?/* Quoting the the code for reference */
Quoted 13 lines
drivers/dma/s3c24xx-dma.c new file +13
-0+static u32 s3c24xx_dma_getbytes_chan (struct s3c24xx_dma_chan *s3cchan) +{ +struct s3c24xx_dma_phy *phy = s3cchan->phy; +struct s3c24xx_txd *txd = s3cchan->at; +u32 tc =readl (phy->base +DSTAT ) &DSTAT_CURRTC_MASK ; + +switch (txd->dcon &DCON_DSZ_MASK ) { +case DCON_DSZ_BYTE : +return tc; +case DCON_DSZ_HALFWORD : +return tc *2 ; +case DCON_DSZ_WORD : +return tc *4 ;
Quoted 8 lines
drivers/dma/s3c24xx-dma.c line 326
Quoted 5 lines
drivers/dma/s3c24xx-dma.c new file +5
-0+default : +break ; + } + +BUG ();(Btw. I don't see anything setting the
DCON_DSZbits in this field. Am I missing something?)
this is for calculating the remaining bytes of the transaction. which is used in s3c24xx_dma_tx_status.
And when looking at it again, I can't really fathom why I did it this way with decoding the DSZ from the dcon value of the s3c24xx_txd again instead of simply using the width value of the same struct ....
So it can be much simpler as
(...)
u32 tc = readl(phy->base + DSTAT) & DSTAT_CURRTC_MASK;
return tc * txd->width;getting rid of this stuff alltogether
still puzzled how I came up with this strangeness in the first place Heiko
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
Quoted 85 lines · On Thursday 16 of May 2013 00:45:03 Heiko St?bner wrote:
Am Donnerstag, 16. Mai 2013, 00:02:40 schrieb Tomasz Figa:
Quoted 67 lines · On Wednesday 15 of May 2013 23:48:31 Heiko St?bner wrote:
Quoted 39 lines
Am Mittwoch, 15. Mai 2013, 23:20:08 schrieb Sylwester Nawrocki:
Quoted 23 lines · Heiko St?bner
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
+
BUG();Isn't that a bit nasty. This macro should be used with care and
we
should recover if possible.dev_err()?
runtime_configalready denies any settings not in the 1,2 or 4bytes
range - the default-part should therefore never be reached. So if
any other value magically appears in the register and triggers the
default-part, something is seriously wrong. So my guess is, the BUG
might be appropriate.Quoted 4 lines
On the other hand the whole default+BUG part could also simply go
away,
for the same reasons.Quoted 7 lines
IMHO
BUG()is not needed at all. As Linus suggesteddev_err()is such
case orWARN_ON()would be more appropriate. This has been discussed
in the past extensively, not sure if you are aware of the other Linus' opinion on BUG()/BUG_ON() proliferation:
https://lkml.org/lkml/2012/9/27/461Very interesting read and I'll keep this in mind in the future. What about the other option ... i.e. simply getting rid of the whole "error
handling", as the other code paths should already make sure that only
valid values get written into the register.Quoted 3 lines
Can the value change in the register somehow on its own without kernel
intervention, or does this not happen?Hmm, it depends on hardware, I guess. Not sure how it works on this particular IP.
Still, the mentioned
BUG()was about a value in a driver-filled struct,
wasn't it?/* Quoting the the code for reference */
Quoted 14 lines
+static u32
s3c24xx_dma_getbytes_chan(struct s3c24xx_dma_chan *s3cchan)(quoted diff) +12
-0+{ + struct s3c24xx_dma_phy *phy = s3cchan->phy; + struct s3c24xx_txd *txd = s3cchan->at; + u32 tc = readl(phy->base + DSTAT) & DSTAT_CURRTC_MASK; + + switch (txd->dcon & DCON_DSZ_MASK) { + case DCON_DSZ_BYTE: + return tc; + case DCON_DSZ_HALFWORD: + return tc * 2; + case DCON_DSZ_WORD: + return tc * 4;Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ default: + break; + } + + BUG();(Btw. I don't see anything setting the
DCON_DSZbits in this field. Am I missing something?)this is for calculating the remaining bytes of the transaction. which is used in
s3c24xx_dma_tx_status.And when looking at it again, I can't really fathom why I did it this way with decoding the DSZ from the dcon value of the
s3c24xx_txdagain instead of simply using the width value of the same struct ....So it can be much simpler as
Quoted 8 lines
(...) u32 tc = readl(phy->base + DSTAT) & DSTAT_CURRTC_MASK; return tc * txd->width;getting rid of this stuff alltogether
still puzzled how I came up with this strangeness in the first place
Hehe, happens.
I'm still yet to review the whole series, but I'm failing to find enough time. Hopefully will get to do it soon.
Best regards,
Tomasz
Re: [RFC 2/4] dma: add dmaengine driver for Samsung s3c24xx SoCs
In reply to Heiko StübnerQuoted 4 lines · Heiko St?bner
If I understand the writel semantics and the thread from you from 2011 [0] correctly, only the writel to DMASKTRIG mustn't be relaxed to make sure the settings registers are written to before, so like:
Quoted 10 lines
writel_relaxed(txd->src_addr, phy->base + DISRC);
writel_relaxed(txd->disrcc, phy->base + DISRCC);
writel_relaxed(txd->dst_addr, phy->base + DIDST);
writel_relaxed(txd->didstc, phy->base + DIDSTC);
writel_relaxed(dcon, phy->base + DCON);
val = readl_relaxed(phy->base + DMASKTRIG);
val &= ~DMASKTRIG_STOP;
val |= DMASKTRIG_ON;
writel(val, phy->base + DMASKTRIG);Yep. That will drain write buffers etc and make sure all outstanding writes hit the hardware.
Yours,
Linus Walleij