ppc440spe-adma: ADMA driver for PPC440SP(e) systems
Subsystems (5)
PATCH v2 11/11 ppc440spe-adma: ADMA driver for PPC440SP(e) systems
Adds the platform device definitions and the architecture specific support routines for the ppc440spe adma driver.
Any board equipped with PPC440SP(e) controller may utilize this driver.
--- arch/powerpc/boot/dts/katmai.dts | 26 +- arch/powerpc/include/asm/async_tx.h | 76 + arch/powerpc/include/asm/dcr-regs.h | 20 + arch/powerpc/include/asm/ppc440spe_adma.h | 181 + arch/powerpc/include/asm/ppc440spe_dma.h | 259 ++ arch/powerpc/include/asm/ppc440spe_xor.h | 150 + arch/powerpc/platforms/44x/Makefile | 1 + arch/powerpc/platforms/44x/ppc440spe_dma_engines.c | 277 ++ drivers/dma/Kconfig | 13 + drivers/dma/Makefile | 1 + drivers/dma/ppc440spe-adma.c | 4195 ++++++++++++++++++++ 11 files changed, 5198 insertions(+), 1 deletions(-) create mode 100644 arch/powerpc/include/asm/async_tx.h create mode 100644 arch/powerpc/include/asm/ppc440spe_adma.h create mode 100644 arch/powerpc/include/asm/ppc440spe_dma.h create mode 100644 arch/powerpc/include/asm/ppc440spe_xor.h create mode 100644 arch/powerpc/platforms/44x/ppc440spe_dma_engines.c create mode 100644 drivers/dma/ppc440spe-adma.c
arch/powerpc/boot/dts/katmai.dts +25 -1
@@ -16,7 +16,7 @@ / { #address-cells = <2>; - #size-cells = <1>; + #size-cells = <2>; model = "amcc,katmai"; compatible = "amcc,katmai"; dcr-parent = <&{/cpus/cpu@0}>;
@@ -392,6 +392,30 @@ 0x0 0x0 0x0 0x3 &UIC3 0xa 0x4 /* swizzled int C */ 0x0 0x0 0x0 0x4 &UIC3 0xb 0x4 /* swizzled int D */>; }; + DMA0: dma0 { + interrupt-parent = <&DMA0>; + interrupts = <0 1>; + #interrupt-cells = <1>; + #address-cells = <0>; + #size-cells = <0>; + interrupt-map = < + 0 &UIC0 0x14 4 + 1 &UIC1 0x16 4>; + }; + DMA1: dma1 { + interrupt-parent = <&DMA1>; + interrupts = <0 1>; + #interrupt-cells = <1>; + #address-cells = <0>; + #size-cells = <0>; + interrupt-map = < + 0 &UIC0 0x16 4 + 1 &UIC1 0x16 4>; + }; + xor { + interrupt-parent = <&UIC1>; + interrupts = <0x1f 4>; + }; }; chosen {
arch/powerpc/include/asm/async_tx.h new file +76 -0
76 lines not on this page · raw message
arch/powerpc/include/asm/dcr-regs.h +20 -0
@@ -157,4 +157,24 @@#define L2C_SNP_SSR_32G 0x0000f000#define L2C_SNP_ESR 0x00000800 +#define DCRN_SDR_CONFIG_ADDR 0xe +#define DCRN_SDR_CONFIG_DATA 0xf + +/* I2O/DMA */ +#define DCRN_I2O0_IBAL 0x066 +#define DCRN_I2O0_IBAH 0x067 +#define DCRN_SDR_SRST 0x0200 +#define DCRN_SDR_SRST_I2ODMA (0x80000000 >> 15)/* Reset I2O/DMA */ + +/* 440SP/440SPe XOR DCRs */ +#define DCRN_MQ0_XORBA 0x44 +#define DCRN_MQ0_CF2H 0x46 +#define DCRN_MQ0_CFBHL 0x4f +#define DCRN_MQ0_BAUH 0x50 + +/* HB/LL Paths Configuration Register */ +#define MQ0_CFBHL_TPLM 28 +#define MQ0_CFBHL_HBCL 23 +#define MQ0_CFBHL_POLY 15 +#endif /* __DCR_REGS_H__ */
arch/powerpc/include/asm/ppc440spe_adma.h new file +181 -0
181 lines not on this page · raw message
arch/powerpc/include/asm/ppc440spe_dma.h new file +259 -0
259 lines not on this page · raw message
arch/powerpc/include/asm/ppc440spe_xor.h new file +150 -0
150 lines not on this page · raw message
arch/powerpc/platforms/44x/Makefile +1 -0
@@ -5,3 +5,4 @@ obj-$(CONFIG_SAM440EP) += sam440ep.o obj-$(CONFIG_WARP) += warp.o obj-$(CONFIG_WARP) += warp-nand.o obj-$(CONFIG_XILINX_VIRTEX_5_FXT) += virtex.o +obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc440spe_dma_engines.o
arch/powerpc/platforms/44x/ppc440spe_dma_engines.c new file +277 -0
277 lines not on this page · raw message
drivers/dma/Kconfig +13 -0
@@ -62,6 +62,19 @@ config MV_XOR ---help--- Enable support for the Marvell XOR engine. +config AMCC_PPC440SPE_ADMA + tristate "AMCC PPC440SPe ADMA support" + depends on 440SPe || 440SP + select ASYNC_CORE + select DMA_ENGINE + select ARCH_HAS_ASYNC_TX_FIND_CHANNEL + default y + ---help--- + Enable support for the AMCC PPC440SPe RAID engines. + +config ARCH_HAS_ASYNC_TX_FIND_CHANNEL + bool + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o obj-$(CONFIG_FSL_DMA) += fsldma.o obj-$(CONFIG_MV_XOR) += mv_xor.o obj-$(CONFIG_DW_DMAC) += dw_dmac.o +obj-$(CONFIG_AMCC_PPC440SPE_ADMA) += ppc440spe-adma.o
drivers/dma/ppc440spe-adma.c new file +4195 -0
1,968 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.6.0.6
Part of the diff is not shown here. View the raw message.
Quoted 10 lines · Yuri Tikhonov
Adds the platform device definitions and the architecture specific support routines for the ppc440spe adma driver.
Any board equipped with PPC440SP(e) controller may utilize this driver.
arch/powerpc/boot/dts/katmai.dts +0
-0
arch/powerpc/boot/dts/katmai.dts line 19
Quoted 5 lines
arch/powerpc/boot/dts/katmai.dts +1
-1@@ -16,7 +16,7 @@ / { #address-cells = <2>; - #size-cells = <1>; + #size-cells = <2>;
You've changed the root level size-cells, but haven't updated the sub-nodes (such as /memory) accordingly.
arch/powerpc/boot/dts/katmai.dts line 395
Quoted 8 lines
arch/powerpc/boot/dts/katmai.dts +1
-0model = "amcc,katmai"; compatible = "amcc,katmai"; dcr-parent = <&{/cpus/cpu@0}>;@@ -392,6 +392,30 @@ 0x0 0x0 0x0 0x3 &UIC3 0xa 0x4 /* swizzled int C */ 0x0 0x0 0x0 0x4 &UIC3 0xb 0x4 /* swizzled int D */>; }; + DMA0: dma0 {
No 'compatible' property, which seems dubious.
Quoted 8 lines
arch/powerpc/boot/dts/katmai.dts +8
-0+ interrupt-parent = <&DMA0>; + interrupts = <0 1>; + #interrupt-cells = <1>; + #address-cells = <0>; + #size-cells = <0>; + interrupt-map = < + 0 &UIC0 0x14 4 + 1 &UIC1 0x16 4>;
arch/powerpc/boot/dts/katmai.dts line 413
Quoted 10 lines
arch/powerpc/boot/dts/katmai.dts +10
-0+ }; + DMA1: dma1 { + interrupt-parent = <&DMA1>; + interrupts = <0 1>; + #interrupt-cells = <1>; + #address-cells = <0>; + #size-cells = <0>; + interrupt-map = < + 0 &UIC0 0x16 4 + 1 &UIC1 0x16 4>;
Are these interrupt-maps correct? The second interrupt from both dma controllers is routed to the same line on UIC1?
arch/powerpc/boot/dts/katmai.dts line 417
Quoted 4 lines
arch/powerpc/boot/dts/katmai.dts +4
-0+ }; + xor { + interrupt-parent = <&UIC1>; + interrupts = <0x1f 4>;
What the hell is this thing? No compatible property, nor even a meaningful name.
Quoted 2 lines
arch/powerpc/boot/dts/katmai.dts +1
-0+ }; };
Signature · 4 lines
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
Hello David,
Thanks a lot for review.
The general note to be made here is that the changes to the DTS file
made by this patch are necessary for a ppc440spe ADMA driver, which is a not-completed arch/powerpc port from the arch/ppc branch, and which uses DT (well, incorrectly) just to get interrupts. Otherwise, it's just a platform device driver.
We provided this ADMA driver just as the reference of driver, which
implements the RAID-6 related low-level stuff. ppc440spe ADMA in its current state is far from ready for merging. We'll elaborate on its cleaning up then (surely, taking into account all the comments made from community). But, even now, the driver works, so we publish this so interested people could use and test it.
Some comments mixed in below.
Quoted 12 lines · On Tuesday, January 13, 2009 you wrote:
Quoted 11 lines · Yuri Tikhonov
Adds the platform device definitions and the architecture specific support routines for the ppc440spe adma driver.
Any board equipped with PPC440SP(e) controller may utilize this driver.
arch/powerpc/boot/dts/katmai.dts +0
-0@@ -16,7 +16,7 @@
Quoted 7 lines
arch/powerpc/boot/dts/katmai.dts line 19
Quoted 4 lines
arch/powerpc/boot/dts/katmai.dts +1
-1/ { #address-cells = <2>; - #size-cells = <1>; + #size-cells = <2>;You've changed the root level size-cells, but haven't updated the sub-nodes (such as /memory) accordingly.
Thanks, we'll fix this in the next version of this patch.
Quoted 10 lines
arch/powerpc/boot/dts/katmai.dts line 395
Quoted 8 lines
arch/powerpc/boot/dts/katmai.dts +1
-0model = "amcc,katmai"; compatible = "amcc,katmai"; dcr-parent = <&{/cpus/cpu@0}>;@@ -392,6 +392,30 @@ 0x0 0x0 0x0 0x3 &UIC3 0xa 0x4 /* swizzled int C */ 0x0 0x0 0x0 0x4 &UIC3 0xb 0x4 /* swizzled int D */>; }; + DMA0: dma0 {No 'compatible' property, which seems dubious.
OK, we'll fix.
Quoted 19 lines
Quoted 8 lines
arch/powerpc/boot/dts/katmai.dts +8
-0+ interrupt-parent = <&DMA0>; + interrupts = <0 1>; + #interrupt-cells = <1>; + #address-cells = <0>; + #size-cells = <0>; + interrupt-map = < + 0 &UIC0 0x14 4 + 1 &UIC1 0x16 4>;arch/powerpc/boot/dts/katmai.dts line 413
Quoted 10 lines
arch/powerpc/boot/dts/katmai.dts +10
-0+ }; + DMA1: dma1 { + interrupt-parent = <&DMA1>; + interrupts = <0 1>; + #interrupt-cells = <1>; + #address-cells = <0>; + #size-cells = <0>; + interrupt-map = < + 0 &UIC0 0x16 4 + 1 &UIC1 0x16 4>;
Quoted 2 lines
Are these interrupt-maps correct? The second interrupt from both dma controllers is routed to the same line on UIC1?
The map is correct:
- first interrupts are 'DMAx Command Status FIFO Needs Service';
- second interrupt is 'DMA Error', both DMA engines share common error IRQ.
Quoted 7 lines
arch/powerpc/boot/dts/katmai.dts line 417
Quoted 4 lines
arch/powerpc/boot/dts/katmai.dts +4
-0+ }; + xor { + interrupt-parent = <&UIC1>; + interrupts = <0x1f 4>;What the hell is this thing? No compatible property, nor even a meaningful name.
This is the XOR accelerator, the dedicated DMA engine of ppc440spe
equipped with the ability to do XOR operations in h/w. I guess, it could be named like DMA2.
Regards, Yuri
--
Yuri Tikhonov, Senior Software Engineer
Emcraft Systems, www.emcraft.com
Hello Yuri,
Quoted 8 lines · Yuri Tikhonov
Adds the platform device definitions and the architecture specific support routines for the ppc440spe adma driver.
Any board equipped with PPC440SP(e) controller may utilize this driver.
Signed-off-by Yuri Tikhonov <[email protected]>Signed-off-by Ilya Yanok <[email protected]>---
Quite complex and interesting driver, I must say. Have you thought about splitting ppc440spe-adma.c into multiple files, btw?
A few comments down below...
[...]
Quoted 1 line
+typedef struct
ppc440spe_adma_device{
Please avoid typedefs.
[...]
Quoted 5 lines
arch/powerpc/include/asm/ppc440spe_dma.h new file +5
-0+/* +* Descriptor of allocated CDB +*/ +typedef struct { + dma_cdb_t *vaddr; /* virtual address of CDB */
arch/powerpc/include/asm/ppc440spe_dma.h line 154
Quoted 10 lines
arch/powerpc/include/asm/ppc440spe_dma.h new file +10
-0+dma_addr_t paddr;/* physical address of CDB */ +/* +* Additional fields +*/ +struct list_head link;/* link in processing list */ +u32 status;/* status of the CDB */ +/* status bits: */ +#define DMA_CDB_DONE (1<<0)/* CDB processing competed */ +#define DMA_CDB_CANCEL (1<<1)/* waiting thread was interrupted */ +} dma_cdbd_t;
It seems there are no users of this struct.
[...]
Quoted 5 lines
arch/powerpc/include/asm/ppc440spe_xor.h new file +5
-0+typedef struct { + xor_cb_t *vaddr; + dma_addr_t paddr; + + /*
arch/powerpc/include/asm/ppc440spe_xor.h line 114
Quoted 10 lines
arch/powerpc/include/asm/ppc440spe_xor.h new file +10
-0+* Additional fields +*/ +struct list_head link;/* link to processing CBs */ +u32 status;/* status of the CB */ +/* status bits: */ +#define XOR_CB_DONE (1<<0)/* CB processing competed */ +#define XOR_CB_CANCEL (1<<1)/* waiting thread was interrupted */ +#if 0 +#define XOR_CB_STALLOC (1<<2)/* CB allocated statically */ +#endif
Dead code.
[...]
Quoted 5 lines
arch/powerpc/platforms/44x/ppc440spe_dma_engines.c new file +5
-0+static void ppc440spe_configure_raid_devices (void ) +{ +void *fifo_buf; +volatile i2o_regs_t *i2o_reg; +volatile dma_regs_t *dma_reg0, *dma_reg1;
arch/powerpc/platforms/44x/ppc440spe_dma_engines.c line 136
Quoted 10 lines
arch/powerpc/platforms/44x/ppc440spe_dma_engines.c new file +10
-0+volatile xor_regs_t *xor_reg; +u32 mask; + +/* +* Map registers and allocate fifo buffer +*/ +if (!(i2o_reg =ioremap (I2O_MMAP_BASE ,I2O_MMAP_SIZE ))) { +printk (KERN_ERR "I2O registers mapping failed.\n" ); +return ; + }
i2o_reg = ioremap(I2O_MMAP_BASE, I2O_MMAP_SIZE);
if (!i20_reg)
...;
would look better.
Quoted 12 lines
arch/powerpc/platforms/44x/ppc440spe_dma_engines.c new file +12
-0+if (!(dma_reg0 =ioremap (DMA0_MMAP_BASE ,DMA_MMAP_SIZE ))) { +printk (KERN_ERR "DMA0 registers mapping failed.\n" ); + goto err1; + } +if (!(dma_reg1 =ioremap (DMA1_MMAP_BASE ,DMA_MMAP_SIZE ))) { +printk (KERN_ERR "DMA1 registers mapping failed.\n" ); + goto err2; + } +if (!(xor_reg =ioremap (XOR_MMAP_BASE ,XOR_MMAP_SIZE ))) { +printk (KERN_ERR "XOR registers mapping failed.\n" ); + goto err3; + }
[...]
Quoted 20 lines
arch/powerpc/platforms/44x/ppc440spe_dma_engines.c new file +15
-0+static struct platform_device *ppc440spe_devs[]__initdata = { + &ppc440spe_dma_0_channel, + &ppc440spe_dma_1_channel, + &ppc440spe_xor_channel, +}; + +static int __init ppc440spe_register_raid_devices (void ) +{ +ppc440spe_configure_raid_devices (); +platform_add_devices (ppc440spe_devs,ARRAY_SIZE (ppc440spe_devs)); + +return 0 ; +} + +arch_initcall (ppc440spe_register_raid_devices);drivers/dma/Kconfig +0
-0
drivers/dma/Kconfig config MV_XOR · line 66
Quoted 5 lines
drivers/dma/Kconfig +2
-0@@ -62,6 +62,19 @@ config MV_XOR ---help--- Enable support for the Marvell XOR engine. +config AMCC_PPC440SPE_ADMA + tristate "AMCC PPC440SPe ADMA support"
It's a tristate, but module_exit() disabled with #if 0...
[...]
drivers/dma/Kconfig config MV_XOR · line 76
Quoted 10 lines
drivers/dma/Kconfig +10
-0+/****************************************************************************** + * Command (Descriptor) Blocks low-level routines + ******************************************************************************/ +/** + * ppc440spe_desc_init_interrupt - initialize the descriptor for INTERRUPT + * pseudo operation + */ +static inline void ppc440spe_desc_init_interrupt (ppc440spe_desc_t *desc, + ppc440spe_ch_t *chan) +{
Isn't this function way too big for inline?
Quoted 18 lines
drivers/dma/Kconfig +18
-0+ xor_cb_t *p; + + switch (chan->device->id) { + case PPC440SPE_XOR_ID: + p = desc->hw_desc; + memset (desc->hw_desc, 0, sizeof(xor_cb_t)); + /* NOP with Command Block Complete Enable */ + p->cbc = XOR_CBCR_CBCE_BIT; + break; + case PPC440SPE_DMA0_ID: + case PPC440SPE_DMA1_ID: + memset (desc->hw_desc, 0, sizeof(dma_cdb_t)); + /* NOP with interrupt */ + set_bit(PPC440SPE_DESC_INT, &desc->flags); + break; + default: + printk(KERN_ERR "Unsupported id %d in %s\n", chan->device->id, + __func__);
drivers/dma/Kconfig config MV_XOR
Quoted 10 lines
drivers/dma/Kconfig +10
-0+ break; + } +} + +/** + * ppc440spe_desc_init_null_xor - initialize the descriptor for NULL XOR + * pseudo operation + */ +static inline void ppc440spe_desc_init_null_xor(ppc440spe_desc_t *desc) +{
I'd drop the inline.
drivers/dma/Kconfig
Quoted 12 lines
drivers/dma/Kconfig +12
-0+ memset (desc->hw_desc, 0, sizeof(xor_cb_t)); + desc->hw_next = NULL; + desc->src_cnt = 0; + desc->dst_cnt = 1; +} + +/** + * ppc440spe_desc_init_xor - initialize the descriptor for XOR operation + */ +static inline void ppc440spe_desc_init_xor(ppc440spe_desc_t *desc, int src_cnt, + unsigned long flags) +{
Ditto.
Quoted 10 lines
drivers/dma/Kconfig +10
-0+ xor_cb_t *hw_desc = desc->hw_desc; + + memset (desc->hw_desc, 0, sizeof(xor_cb_t)); + desc->hw_next = NULL; + desc->src_cnt = src_cnt; + desc->dst_cnt = 1; + + hw_desc->cbc = XOR_CBCR_TGT_BIT | src_cnt; + if (flags & DMA_PREP_INTERRUPT) + /* Enable interrupt on complete */
drivers/dma/Kconfig
Quoted 10 lines
drivers/dma/Kconfig +10
-0+ hw_desc->cbc |= XOR_CBCR_CBCE_BIT; +} + +/** + * ppc440spe_desc_init_dma2pq - initialize the descriptor for PQ + * operation in DMA2 controller + */ +static inline void ppc440spe_desc_init_dma2pq(ppc440spe_desc_t *desc, + int dst_cnt, int src_cnt, unsigned long flags) +{
Ditto.
Quoted 13 lines
drivers/dma/Kconfig +13
-0+ xor_cb_t *hw_desc = desc->hw_desc; + + memset (desc->hw_desc, 0, sizeof(xor_cb_t)); + desc->hw_next = NULL; + desc->src_cnt = src_cnt; + desc->dst_cnt = dst_cnt; + memset (desc->reverse_flags, 0, sizeof (desc->reverse_flags)); + desc->descs_per_op = 0; + + hw_desc->cbc = XOR_CBCR_TGT_BIT; + if (flags & DMA_PREP_INTERRUPT) + /* Enable interrupt on complete */ + hw_desc->cbc |= XOR_CBCR_CBCE_BIT;
drivers/dma/Kconfig
Quoted 10 lines
drivers/dma/Kconfig +10
-0+} + +/** + * ppc440spe_desc_init_dma01pq - initialize the descriptors for PQ operation + * qith DMA0/1 + */ +static inline void ppc440spe_desc_init_dma01pq(ppc440spe_desc_t *desc, + int dst_cnt, int src_cnt, unsigned long flags, + unsigned long op) +{
Way to big for inline. The same for all the inlines.
Btw, ppc_async_tx_find_best_channel() looks too big for inline and also too big to be in a .h file.
Quoted 98 lines
drivers/dma/Kconfig +98
-0+ dma_cdb_t *hw_desc; + ppc440spe_desc_t *iter; + u8 dopc; + + /* Common initialization of a PQ descriptors chain */ + set_bits(op, &desc->flags); + desc->src_cnt = src_cnt; + desc->dst_cnt = dst_cnt; + + /* WXOR MULTICAST if both P and Q are being computed + * MV_SG1_SG2 if Q only + */ + dopc = (desc->dst_cnt == DMA_DEST_MAX_NUM) ? + DMA_CDB_OPC_MULTICAST : DMA_CDB_OPC_MV_SG1_SG2; + + list_for_each_entry(iter, &desc->group_list, chain_node) { + hw_desc = iter->hw_desc; + memset (iter->hw_desc, 0, sizeof(dma_cdb_t)); + + if (likely(!list_is_last(&iter->chain_node, + &desc->group_list))) { + /* set 'next' pointer */ + iter->hw_next = list_entry(iter->chain_node.next, + ppc440spe_desc_t, chain_node); + clear_bit(PPC440SPE_DESC_INT, &iter->flags); + } else { + /* this is the last descriptor. + * this slot will be pasted from ADMA level + * each time it wants to configure parameters + * of the transaction (src, dst, ...) + */ + iter->hw_next = NULL; + if (flags & DMA_PREP_INTERRUPT) + set_bit(PPC440SPE_DESC_INT, &iter->flags); + else + clear_bit(PPC440SPE_DESC_INT, &iter->flags); + } + } + + /* Set OPS depending on WXOR/RXOR type of operation */ + if (!test_bit(PPC440SPE_DESC_RXOR, &desc->flags)) { + /* This is a WXOR only chain: + * - first descriptors are for zeroing destinations + * if PPC440SPE_ZERO_P/Q set; + * - descriptors remained are for GF-XOR operations. + */ + iter = list_first_entry(&desc->group_list, + ppc440spe_desc_t, chain_node); + + if (test_bit(PPC440SPE_ZERO_P, &desc->flags)) { + hw_desc = iter->hw_desc; + hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2; + iter = list_first_entry(&iter->chain_node, + ppc440spe_desc_t, chain_node); + } + + if (test_bit(PPC440SPE_ZERO_Q, &desc->flags)) { + hw_desc = iter->hw_desc; + hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2; + iter = list_first_entry(&iter->chain_node, + ppc440spe_desc_t, chain_node); + } + + list_for_each_entry_from(iter, &desc->group_list, chain_node) { + hw_desc = iter->hw_desc; + hw_desc->opc = dopc; + } + } else { + /* This is either RXOR-only or mixed RXOR/WXOR */ + + /* The first 1 or 2 slots in chain are always RXOR, + * if need to calculate P & Q, then there are two + * RXOR slots; if only P or only Q, then there is one + */ + iter = list_first_entry(&desc->group_list, + ppc440spe_desc_t, chain_node); + hw_desc = iter->hw_desc; + hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2; + + if (desc->dst_cnt == DMA_DEST_MAX_NUM) { + iter = list_first_entry(&iter->chain_node, + ppc440spe_desc_t, chain_node); + hw_desc = iter->hw_desc; + hw_desc->opc = DMA_CDB_OPC_MV_SG1_SG2; + } + + /* The remain descs (if any) are WXORs */ + if (test_bit(PPC440SPE_DESC_WXOR, &desc->flags)) { + iter = list_first_entry(&iter->chain_node, + ppc440spe_desc_t, chain_node); + list_for_each_entry_from(iter, &desc->group_list, + chain_node) { + hw_desc = iter->hw_desc; + hw_desc->opc = dopc; + } + } + } +}
[...]
Quoted 3 lines
+/**
+ *ppc440spe_chan_xor_slot_count- get the number of slots necessary for
+ * XOR operation
IIRC kerneldoc does not permit multiline short descriptions. Kdoc tools will warn about it, I presume.
[...]
drivers/dma/Kconfig
Quoted 10 lines
drivers/dma/Kconfig +10
-0+static int ppc440spe_test_raid6 (ppc440spe_ch_t *chan) +{ + ppc440spe_desc_t *sw_desc, *iter; + struct page *pg; + char *a; + dma_addr_t dma_addr, addrs[2]; + unsigned long op = 0; + int rval = 0; + + /*FIXME*/
?
Quoted 5 lines
drivers/dma/Kconfig +5
-0+ + set_bit(PPC440SPE_DESC_WXOR, &op); + + pg = alloc_page(GFP_KERNEL); + if (!pg)
drivers/dma/Kconfig
Quoted 10 lines
drivers/dma/Kconfig +9
-0+ return -ENOMEM; + + +/** + * ppc440spe_adma_probe - probe the asynch device + */ +static int __devinit ppc440spe_adma_probe(struct platform_device *pdev) +{ + struct resource *res;
Why is this a platform driver? What's the point of describing DMA nodes in the device tree w/o actually using them (don't count interrupts)? There are a lot of hard-coded addresses in the code... :-/
And arch/powerpc/platforms/44x/ppc440spe_dma_engines.c file reminds me arch/ppc-style bindings. ;-)
Quoted 9 lines
drivers/dma/Kconfig +9
-0+ int ret=0, irq1, irq2, initcode = PPC_ADMA_INIT_OK; + void *regs; + ppc440spe_dev_t *adev; + ppc440spe_ch_t *chan; + ppc440spe_aplat_t *plat_data; + struct ppc_dma_chan_ref *ref; + struct device_node *dp; + char s[10]; +
[...]
Quoted 9 lines
drivers/dma/Kconfig +9
-0+static int __init ppc440spe_adma_init (void) +{ + int rval, i; + struct proc_dir_entry *p; + + for (i = 0; i < PPC440SPE_ADMA_ENGINES_NUM; i++) + ppc_adma_devices[i] = -1; + + rval = platform_driver_register(&ppc440spe_adma_driver);
drivers/dma/Kconfig
Quoted 10 lines
drivers/dma/Kconfig +10
-0+ + if (rval == 0) { + /* Create /proc entries */ + ppc440spe_proot = proc_mkdir(PPC440SPE_R6_PROC_ROOT, NULL); + if (!ppc440spe_proot) { + printk(KERN_ERR "%s: failed to create %s proc " + "directory\n",__func__,PPC440SPE_R6_PROC_ROOT); + /* User will not be able to enable h/w RAID-6 */ + return rval; + }
/proc? Why /proc? The driver has nothing to do with Linux VM subsystem or processes. I think /sys/ interface would suit better for this, no? Either way, userspace interfaces should be documented somehow (probably Documentation/ABI/, or at least some comments in the code).
Quoted 22 lines
drivers/dma/Kconfig +22
-0+ /* GF polynome to use */ + p = create_proc_entry("poly", 0, ppc440spe_proot); + if (p) { + p->read_proc = ppc440spe_poly_read; + p->write_proc = ppc440spe_poly_write; + } + + /* RAID-6 h/w enable entry */ + p = create_proc_entry("enable", 0, ppc440spe_proot); + if (p) { + p->read_proc = ppc440spe_r6ena_read; + p->write_proc = ppc440spe_r6ena_write; + } + + /* initialization status */ + p = create_proc_entry("devices", 0, ppc440spe_proot); + if (p) { + p->read_proc = ppc440spe_status_read; + } + } + return rval; +}
[...]
drivers/dma/Kconfig
Quoted 8 lines
drivers/dma/Kconfig +8
-0+#if 0 +static void __exit ppc440spe_adma_exit (void) +{ + platform_driver_unregister(&ppc440spe_adma_driver); + return; +} +module_exit(ppc440spe_adma_exit); +#endif
Dead code.
Thanks,
Signature · 3 lines
Anton Vorontsov email: [email protected] `irc://irc.freenode.net/bd2
Hello Anton,
Thanks for review. Please note the general note I made in "Re[2]:
[PATCH 11/11][v2] ppc440spe-adma: ADMA driver for PPC440SP(e) systems".
All your comments make sense, so we'll try to address these in the
next version of the driver. Some comments below.
Quoted 8 lines · On Thursday, January 15, 2009 you wrote:
Hello Yuri,
Quoted 5 lines · Yuri Tikhonov
Adds the platform device definitions and the architecture specific support routines for the ppc440spe adma driver.
Any board equipped with PPC440SP(e) controller may utilize this driver.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Yuri Tikhonov <[email protected]>Signed-off-by Ilya Yanok <[email protected]>---
Quite complex and interesting driver, I must say. Have you thought about splitting
ppc440spe-adma.cinto multiple files, btw?
Admittedly, no. But I guess this makes sense. The driver supports two
different types of DMA devices of ppc440spe: DMA0,1 and DMA2[XOR engine]. So, we could split the driver at least in two, which would definitely simplified the code.
Quoted 6 lines
A few comments down below...
[...]
Quoted 1 line
+typedef struct
ppc440spe_adma_device{Please avoid typedefs.
OK.
Quoted 10 lines
[...]
Quoted 9 lines
arch/powerpc/include/asm/ppc440spe_dma.h new file +9
-0+/* +* Descriptor of allocated CDB +*/ +typedef struct { + dma_cdb_t *vaddr; /* virtual address of CDB */ + dma_addr_t paddr; /* physical address of CDB */ + /* + * Additional fields + */
Quoted 8 lines
arch/powerpc/include/asm/ppc440spe_dma.h line 154
Quoted 6 lines
arch/powerpc/include/asm/ppc440spe_dma.h new file +6
-0+struct list_head link;/* link in processing list */ +u32 status;/* status of the CDB */ +/* status bits: */ +#define DMA_CDB_DONE (1<<0)/* CDB processing competed */ +#define DMA_CDB_CANCEL (1<<1)/* waiting thread was interrupted */ +} dma_cdbd_t;It seems there are no users of this struct.
Indeed. This is an useless inheritance of some old version of the
driver. Will remove this in the next patch.
[..]
Quoted 11 lines
drivers/dma/ppc440spe-adma.c line 260
Quoted 8 lines
drivers/dma/ppc440spe-adma.c new file +8
-0+/** +* ppc440spe_desc_init_dma01pq - initialize the descriptors for PQ operation +* qith DMA0/1 +*/ +static inline void ppc440spe_desc_init_dma01pq (ppc440spe_desc_t *desc, +int dst_cnt,int src_cnt,unsigned long flags, +unsigned long op) +{Way to big for inline. The same for all the inlines.
Quoted 2 lines
Btw,
ppc_async_tx_find_best_channel()looks too big for inline and also too big to be in a .h file.
OK, will be moved to the appropriate .c.
[..]
Quoted 35 lines
[...]
drivers/dma/ppc440spe-adma.c line 3946
Quoted 10 lines
drivers/dma/ppc440spe-adma.c new file +10
-0+static int ppc440spe_test_raid6 (ppc440spe_ch_t *chan) +{ +ppc440spe_desc_t *sw_desc, *iter; +struct page *pg; +char *a; +dma_addr_t dma_addr, addrs[2 ]; +unsigned long op =0 ; +int rval =0 ; + +/*FIXME*/ ?
Quoted 5 lines
drivers/dma/ppc440spe-adma.c new file +5
-0+ +set_bit (PPC440SPE_DESC_WXOR , &op); + + pg =alloc_page (GFP_KERNEL ); +if (!pg)drivers/dma/ppc440spe-adma.c
Quoted 10 lines
drivers/dma/ppc440spe-adma.c new file +9
-0+return -ENOMEM ; + + +/** +* ppc440spe_adma_probe - probe the asynch device +*/ +static int __devinit ppc440spe_adma_probe (struct platform_device *pdev) +{ +struct resource *res;Why is this a platform driver? What's the point of describing DMA nodes in the device tree w/o actually using them (don't count interrupts)? There are a lot of hard-coded addresses in the code... :-/
Quoted 2 lines
And
arch/powerpc/platforms/44x/ppc440spe_dma_engines.cfile reminds mearch/ppc-stylebindings. ;-)
Right. This driver is a not-completed port from the arch/ppc branch.
Quoted 28 lines
Quoted 9 lines
drivers/dma/ppc440spe-adma.c new file +9
-0+int ret=0 , irq1, irq2, initcode =PPC_ADMA_INIT_OK ; +void *regs; +ppc440spe_dev_t *adev; +ppc440spe_ch_t *chan; +ppc440spe_aplat_t *plat_data; +struct ppc_dma_chan_ref *ref; +struct device_node *dp; +char s[10 ]; +[...]
Quoted 17 lines
drivers/dma/ppc440spe-adma.c new file +17
-0+static int __init ppc440spe_adma_init (void ) +{ +int rval, i; +struct proc_dir_entry *p; + +for (i =0 ; i <PPC440SPE_ADMA_ENGINES_NUM ; i++) + ppc_adma_devices[i] =-1 ; + + rval =platform_driver_register (&ppc440spe_adma_driver); + +if (rval ==0 ) { +/* Create /proc entries */ + ppc440spe_proot =proc_mkdir (PPC440SPE_R6_PROC_ROOT ,NULL ); +if (!ppc440spe_proot) { +printk (KERN_ERR "%s: failed to create %s proc " +"directory\n" ,__func__,PPC440SPE_R6_PROC_ROOT ); +/* User will not be able to enable h/w RAID-6 */
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return rval; + }/proc? Why /proc? The driver has nothing to do with Linux VM subsystem or processes. I think
/sys/interface would suit better for this, no? Either way, userspace interfaces should be documented somehow (probablyDocumentation/ABI/, or at least some comments in the code).
Agree, we'll fix this.
Regards, Yuri
--
Yuri Tikhonov, Senior Software Engineer
Emcraft Systems, www.emcraft.com