dmaengine: APM X-Gene SoC DMA engine driver support
v7 cover dmaengine: APM X-Gene SoC DMA engine driver support
This patch set implements the APM X-Gene SoC DMA driver support to offload the DMA operations such as memory copy(memcpy), scatter gather memory copy, raid5 xor and raid6 p+q.
v7 changes:
1. Added raid5 xor offload support.
2. Added raid6 p+q offload support.
v6 changes:
1. Maintained sw queue for pending, running, and completed requests. Used link list as queue.
2. Fixed issue_pending and tx_submit routines.
3. Fixed prep_dma routines.
4. Fixed free_irqs.
v5 changes:
1. Minor changes in coding style.
2. Added DMA_CTRL_ACK flag initialization
v4 changes:
1. Fixed dma-ranges property on DTS.
---
Rameshwar Prasad Sahu (3):
dmaengine: Add support for APM X-Gene SoC DMA engine driver
arm64: dts: Add APM X-Gene DMA device and DMA clock DTS nodes
Documentation: dma: Add APM X-Gene SoC DMA engine driver documentation
.../devicetree/bindings/dma/apm-xgene-dma.txt | 47 + arch/arm64/boot/dts/apm/apm-storm.dtsi | 26 + drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/xgene-dma.c | 2156 ++++++++++++++++++++ 5 files changed, 2239 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/apm-xgene-dma.txt create mode 100755 drivers/dma/xgene-dma.c
--
1.8.2.1
PATCH v7 1/3 dmaengine: Add support for APM X-Gene SoC DMA engine driver
This patch implements the APM X-Gene SoC DMA engine driver. The APM X-Gene SoC DMA engine consists of 4 DMA channels for performing DMA operations. These DMA operations include memory copy, scatter-gather memory copy, raid5 xor, and raid6 p+q offloading.
--- drivers/dma/Kconfig | 9 + drivers/dma/Makefile | 1 + drivers/dma/xgene-dma.c | 2156 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 2166 insertions(+) create mode 100755 drivers/dma/xgene-dma.c
drivers/dma/Kconfig +9 -0
@@ -425,6 +425,15 @@ config IMG_MDC_DMA help Enable support for the IMG multi-threaded DMA controller (MDC). +config XGENE_DMA + tristate "APM X-Gene DMA support" + depends on ARCH_XGENE + select DMA_ENGINE + select DMA_ENGINE_RAID + select ASYNC_TX_ENABLE_CHANNEL_SWITCH + help + Enable support for the APM X-Gene SoC DMA engine. + config DMA_ENGINE bool
drivers/dma/Makefile +1 -0
@@ -51,3 +51,4 @@ obj-$(CONFIG_INTEL_MIC_X100_DMA) += mic_x100_dma.o obj-$(CONFIG_NBPFAXI_DMA) += nbpfaxi.o obj-$(CONFIG_DMA_SUN6I) += sun6i-dma.o obj-$(CONFIG_IMG_MDC_DMA) += img-mdc-dma.o +obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
drivers/dma/xgene-dma.c new file +2156 -0
2,156 lines not on this page · raw message
--
1.8.2.1
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Quoted 30 lines · Rameshwar Prasad Sahu
drivers/dma/xgene-dma.c new file +30
-0+/* DMA ring csr registers and bit definations */ +#define DMA_RING_CONFIG 0x04 +#define DMA_RING_ENABLE BIT(31) +#define DMA_RING_ID 0x08 +#define DMA_RING_ID_SETUP (v) ((v) | BIT(31)) +#define DMA_RING_ID_BUF 0x0C +#define DMA_RING_ID_BUF_SETUP (v) (((v) << 9) | BIT(21)) +#define DMA_RING_THRESLD0_SET1 0x30 +#define DMA_RING_THRESLD0_SET1_VAL 0X64 +#define DMA_RING_THRESLD1_SET1 0x34 +#define DMA_RING_THRESLD1_SET1_VAL 0xC8 +#define DMA_RING_HYSTERESIS 0x68 +#define DMA_RING_HYSTERESIS_VAL 0xFFFFFFFF +#define DMA_RING_STATE 0x6C +#define DMA_RING_STATE_WR_BASE 0x70 +#define DMA_RING_NE_INT_MODE 0x017C +#define DMA_RING_NE_INT_MODE_SET (m, v) \ + ((m) = ((m) & ~BIT(31 - (v))) | BIT(31 - (v))) +#define DMA_RING_NE_INT_MODE_RESET (m, v) \ + ((m) &= (~BIT(31 - (v)))) +#define DMA_RING_CLKEN 0xC208 +#define DMA_RING_SRST 0xC200 +#define DMA_RING_MEM_RAM_SHUTDOWN 0xD070 +#define DMA_RING_BLK_MEM_RDY 0xD074 +#define DMA_RING_BLK_MEM_RDY_VAL 0xFFFFFFFF +#define DMA_RING_DESC_CNT (v) (((v) & 0x0001FFFE) >> 1) +#define DMA_RING_ID_GET (owner, num) (((owner) << 6) | (num)) +#define DMA_RING_DST_ID (v) ((1 << 10) | (v)) +#define DMA_RING_CMD_OFFSET 0x2C +#define DMA_RING_CMD_BASE_OFFSET (v) ((v) << 6)
drivers/dma/xgene-dma.c line 75
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+#define DMA_RING_COHERENT_SET (m) (((u32 *)(m))[2] |= BIT(4)) +#define DMA_RING_ADDRL_SET (m, v) (((u32 *)(m))[2] |= (((v) >> 8) << 5)) +#define DMA_RING_ADDRH_SET (m, v) (((u32 *)(m))[3] |= ((v) >> 35)) +#define DMA_RING_ACCEPTLERR_SET (m) (((u32 *)(m))[3] |= BIT(19)) +#define DMA_RING_SIZE_SET (m, v) (((u32 *)(m))[3] |= ((v) << 23)) +#define DMA_RING_RECOMBBUF_SET (m) (((u32 *)(m))[3] |= BIT(27)) +#define DMA_RING_RECOMTIMEOUTL_SET (m) (((u32 *)(m))[3] |= (0x7 << 28)) +#define DMA_RING_RECOMTIMEOUTH_SET (m) (((u32 *)(m))[4] |= 0x3) +#define DMA_RING_SELTHRSH_SET (m) (((u32 *)(m))[4] |= BIT(3)) +#define DMA_RING_TYPE_SET (m, v) (((u32 *)(m))[4] |= ((v) << 19))
These are very generic name as can conflicts, can you please namespace these...
Quoted 16 lines
drivers/dma/xgene-dma.c new file +16
-0+/* DMA device csr registers and bit definitions */ +#define DMA_IPBRR 0x0 +#define DMA_DEV_ID_RD (v) ((v) & 0x00000FFF) +#define DMA_BUS_ID_RD (v) (((v) >> 12) & 3) +#define DMA_REV_NO_RD (v) (((v) >> 14) & 3) +#define DMA_GCR 0x10 +#define DMA_CH_SETUP (v) ((v) = ((v) & ~0x000FFFFF) | 0x000AAFFF) +#define DMA_ENABLE (v) ((v) |= BIT(31)) +#define DMA_DISABLE (v) ((v) &= ~BIT(31)) +#define DMA_RAID6_CONT 0x14 +#define DMA_RAID6_MULTI_CTRL (v) ((v) << 24) +#define DMA_INT 0x70 +#define DMA_INT_MASK 0x74 +#define DMA_INT_ALL_MASK 0xFFFFFFFF +#define DMA_INT_ALL_UNMASK 0x0 +#define DMA_INT_MASK_SHIFT 0x14
drivers/dma/xgene-dma.c line 102
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+#define DMA_RING_INT0_MASK 0x90A0 +#define DMA_RING_INT1_MASK 0x90A8 +#define DMA_RING_INT2_MASK 0x90B0 +#define DMA_RING_INT3_MASK 0x90B8 +#define DMA_RING_INT4_MASK 0x90C0 +#define DMA_CFG_RING_WQ_ASSOC 0x90E0 +#define DMA_ASSOC_RING_MNGR1 0xFFFFFFFF +#define DMA_MEM_RAM_SHUTDOWN 0xD070 +#define DMA_BLK_MEM_RDY 0xD074 +#define DMA_BLK_MEM_RDY_VAL 0xFFFFFFFF
same here and throughout the driver..
drivers/dma/xgene-dma.c line 585
Quoted 6 lines
drivers/dma/xgene-dma.c new file +6
-0+static void xgene_dma_free_descriptor (struct xgene_dma_chan *chan, +struct xgene_dma_desc_sw *desc) +{ +list_del (&desc->node); +chan_dbg (chan,"LD %p free\n" , desc); +dma_pool_free (chan->desc_pool, desc, desc->tx.phys);
where is the descriptor freed? Perhpas we can say clean rather than free here to not confuse...
drivers/dma/xgene-dma.c line 596
Quoted 11 lines
drivers/dma/xgene-dma.c new file +11
-0+} + +static struct xgene_dma_desc_sw *xgene_dma_alloc_descriptor ( +struct xgene_dma_chan *chan) +{ +struct xgene_dma_desc_sw *desc; +dma_addr_t phys; + + desc =dma_pool_alloc (chan->desc_pool,GFP_NOWAIT , &phys); +if (!desc) { +chan_dbg (chan,"Failed to allocate LDs\n" );
not error?
drivers/dma/xgene-dma.c line 916
Quoted 2 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)
do we really care about free order?
Quoted 76 lines
drivers/dma/xgene-dma.c new file +76
-0+{ +struct xgene_dma_desc_sw *desc, *_desc; + +list_for_each_entry_safe_reverse (desc, _desc, list, node) +xgene_dma_free_descriptor (chan, desc); +} + +static void xgene_dma_free_chan_resources (struct dma_chan *dchan) +{ +struct xgene_dma_chan *chan =to_dma_chan (dchan); + +chan_dbg (chan,"Free all resources\n" ); + +if (!chan->desc_pool) +return ; + +spin_lock_bh (&chan->lock); + +/* Process all running descriptor */ +xgene_dma_cleanup_descriptors (chan); + +/* Clean all link descriptor queues */ +xgene_dma_free_desc_list (chan, &chan->ld_pending); +xgene_dma_free_desc_list (chan, &chan->ld_running); +xgene_dma_free_desc_list (chan, &chan->ld_completed); + +spin_unlock_bh (&chan->lock); + +/* Delete this channel DMA pool */ +dma_pool_destroy (chan->desc_pool); + chan->desc_pool =NULL ; +} + +static struct dma_async_tx_descriptor *xgene_dma_prep_memcpy ( +struct dma_chan *dchan,dma_addr_t dst,dma_addr_t src, +size_t len,unsigned long flags) +{ +struct xgene_dma_desc_sw *first =NULL , *new; +struct xgene_dma_chan *chan; +size_t copy; +u32 desc_id; + +if (unlikely (!dchan || !len)) +return NULL ; + + chan =to_dma_chan (dchan); + +/* Get the id for this group of descriptors */ + desc_id =atomic_inc_return (&chan->desc_id); + + do { + /* Allocate the link descriptor from DMA pool */ + new = xgene_dma_alloc_descriptor(chan); + if (!new) + goto fail; + + /* Create the largest transaction possible */ + copy = min_t(size_t, len, DMA_MAX_64B_DESC_BYTE_CNT); + + /* Prepare DMA descriptor */ + xgene_dma_prep_cpy_desc(chan, new, dst, src, copy, desc_id); + + if (!first) + first = new; + + new->first = first; + first->desc_cnt++; + new->desc_id = desc_id; + + new->tx.cookie = 0; + async_tx_ack(&new->tx); + + /* Update metadata */ + len -= copy; + dst += copy; + src += copy;
drivers/dma/xgene-dma.c line 1002
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+ +/* Insert the link descriptor to the LD ring */ +list_add_tail (&new->node, &first->tx_list); + }while (len); + + first->tx.flags = flags;/* client is in control of this ack */ + first->tx.cookie = -EBUSY ; + first->flags |=DMA_FLAG_FIRST_DESC ; + +return &first->tx;
where are you mapping dma buffers?
drivers/dma/xgene-dma.c line 1291
Quoted 12 lines
drivers/dma/xgene-dma.c new file +12
-0+static enum dma_status xgene_dma_find_tx_desc_status ( +struct xgene_dma_chan *chan,dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct xgene_dma_desc_sw *desc; + +spin_lock_bh (&chan->lock); + +/* Check if this tx descriptor is still in pending queue */ +list_for_each_entry (desc, &chan->ld_pending, node) { +if (desc->tx.cookie == cookie) { +xgene_chan_xfer_ld_pending (chan);
why are you calling this here, status check shouldnt do this...
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;
residue here is size of transacation.
drivers/dma/xgene-dma.c line 1301
Quoted 8 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +/* Check if this descriptor is in running queue */ +list_for_each_entry (desc, &chan->ld_running, node) { +if (desc->tx.cookie == cookie) { +/* Cleanup any running and executed descriptors */ +xgene_dma_cleanup_descriptors (chan);
ditto?
drivers/dma/xgene-dma.c line 1304
Quoted 3 lines
drivers/dma/xgene-dma.c new file +3
-0+spin_unlock_bh (&chan->lock); +return dma_cookie_status (&chan->dma_chan, + cookie, txstate);
and you havent touched txstate so what is the intent here...?
Quoted 8 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +spin_unlock_bh (&chan->lock); + +return DMA_COMPLETE ; +} +
drivers/dma/xgene-dma.c line 1322
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+static enum dma_status xgene_dma_tx_status (struct dma_chan *dchan, +dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct xgene_dma_chan *chan =to_dma_chan (dchan); + +enum dma_status status; + + status =dma_cookie_status (dchan, cookie, txstate); +if (status ==DMA_COMPLETE )
you should do this if txstate in NULL, no point doing calculations..
Quoted 21 lines
drivers/dma/xgene-dma.c new file +21
-0+return status; + +return xgene_dma_find_tx_desc_status (chan, cookie, txstate); +} + +static void xgene_dma_tasklet_cb (unsigned long data) +{ +struct xgene_dma_chan *chan = (struct xgene_dma_chan *)data; + +spin_lock_bh (&chan->lock); + +/* Run all cleanup for descriptors which have been completed */ +xgene_dma_cleanup_descriptors (chan); + +/* Re-enable DMA channel IRQ */ +enable_irq (chan->rx_irq); + +spin_unlock_bh (&chan->lock); +} + +static irqreturn_t xgene_dma_chan_ring_isr (int irq,void *id)
drivers/dma/xgene-dma.c line 1353
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+{ +struct xgene_dma_chan *chan = (struct xgene_dma_chan *)id; + +BUG_ON (!chan); + +/* +* Disable DMA channel IRQ until we process completed +* descriptors +*/ +disable_irq_nosync (chan->rx_irq);
and why is that?
drivers/dma/xgene-dma.c line 1360
Quoted 7 lines
drivers/dma/xgene-dma.c new file +7
-0+ +/* +* Schedule the tasklet to handle all cleanup of the current +* transaction. It will start a new transaction if there is +* one pending. +*/ +tasklet_schedule (&chan->tasklet);
for better results why not schedule the next transaction here..?
drivers/dma/xgene-dma.c line 1927
Quoted 11 lines
drivers/dma/xgene-dma.c new file +10
-0+ +return IRQ_HANDLED ; +} + +static void xgene_dma_async_unregister (struct xgene_dma *pdma) +{ +int i; + +for (i =0 ; i <DMA_MAX_CHANNEL ; i++) +dma_async_device_unregister (&pdma->dma_dev[i]);
how do you ensure irq is disabled and tasklets killed?
drivers/dma/xgene-dma.c line 2156
Quoted 5 lines
drivers/dma/xgene-dma.c new file +5
-0+MODULE_DESCRIPTION ("APM X-Gene SoC DMA driver" ); +MODULE_AUTHOR ("Rameshwar Prasad Sahu <[email protected]>" ); +MODULE_AUTHOR ("Loc Ho <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_VERSION ("1.0" );
why do you need this?
Quoted 3 lines
--
1.8.2.1
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Hi Vinod,
Quoted 35 lines · Vinod Koul
Quoted 34 lines · Rameshwar Prasad Sahu
drivers/dma/xgene-dma.c new file +34
-0+/* DMA ring csr registers and bit definations */ +#define DMA_RING_CONFIG 0x04 +#define DMA_RING_ENABLE BIT(31) +#define DMA_RING_ID 0x08 +#define DMA_RING_ID_SETUP (v) ((v) | BIT(31)) +#define DMA_RING_ID_BUF 0x0C +#define DMA_RING_ID_BUF_SETUP (v) (((v) << 9) | BIT(21)) +#define DMA_RING_THRESLD0_SET1 0x30 +#define DMA_RING_THRESLD0_SET1_VAL 0X64 +#define DMA_RING_THRESLD1_SET1 0x34 +#define DMA_RING_THRESLD1_SET1_VAL 0xC8 +#define DMA_RING_HYSTERESIS 0x68 +#define DMA_RING_HYSTERESIS_VAL 0xFFFFFFFF +#define DMA_RING_STATE 0x6C +#define DMA_RING_STATE_WR_BASE 0x70 +#define DMA_RING_NE_INT_MODE 0x017C +#define DMA_RING_NE_INT_MODE_SET (m, v) \ + ((m) = ((m) & ~BIT(31 - (v))) | BIT(31 - (v))) +#define DMA_RING_NE_INT_MODE_RESET (m, v) \ + ((m) &= (~BIT(31 - (v)))) +#define DMA_RING_CLKEN 0xC208 +#define DMA_RING_SRST 0xC200 +#define DMA_RING_MEM_RAM_SHUTDOWN 0xD070 +#define DMA_RING_BLK_MEM_RDY 0xD074 +#define DMA_RING_BLK_MEM_RDY_VAL 0xFFFFFFFF +#define DMA_RING_DESC_CNT (v) (((v) & 0x0001FFFE) >> 1) +#define DMA_RING_ID_GET (owner, num) (((owner) << 6) | (num)) +#define DMA_RING_DST_ID (v) ((1 << 10) | (v)) +#define DMA_RING_CMD_OFFSET 0x2C +#define DMA_RING_CMD_BASE_OFFSET (v) ((v) << 6) +#define DMA_RING_COHERENT_SET (m) (((u32 *)(m))[2] |= BIT(4)) +#define DMA_RING_ADDRL_SET (m, v) (((u32 *)(m))[2] |= (((v) >> 8) << 5)) +#define DMA_RING_ADDRH_SET (m, v) (((u32 *)(m))[3] |= ((v) >> 35)) +#define DMA_RING_ACCEPTLERR_SET (m) (((u32 *)(m))[3] |= BIT(19))
Quoted 8 lines
drivers/dma/xgene-dma.c line 75
Quoted 6 lines
drivers/dma/xgene-dma.c new file +6
-0+#define DMA_RING_SIZE_SET (m, v) (((u32 *)(m))[3] |= ((v) << 23)) +#define DMA_RING_RECOMBBUF_SET (m) (((u32 *)(m))[3] |= BIT(27)) +#define DMA_RING_RECOMTIMEOUTL_SET (m) (((u32 *)(m))[3] |= (0x7 << 28)) +#define DMA_RING_RECOMTIMEOUTH_SET (m) (((u32 *)(m))[4] |= 0x3) +#define DMA_RING_SELTHRSH_SET (m) (((u32 *)(m))[4] |= BIT(3)) +#define DMA_RING_TYPE_SET (m, v) (((u32 *)(m))[4] |= ((v) << 19))These are very generic name as can conflicts, can you please namespace these...
Okay
Quoted 20 lines
Quoted 20 lines
drivers/dma/xgene-dma.c new file +19
-0+/* DMA device csr registers and bit definitions */ +#define DMA_IPBRR 0x0 +#define DMA_DEV_ID_RD (v) ((v) & 0x00000FFF) +#define DMA_BUS_ID_RD (v) (((v) >> 12) & 3) +#define DMA_REV_NO_RD (v) (((v) >> 14) & 3) +#define DMA_GCR 0x10 +#define DMA_CH_SETUP (v) ((v) = ((v) & ~0x000FFFFF) | 0x000AAFFF) +#define DMA_ENABLE (v) ((v) |= BIT(31)) +#define DMA_DISABLE (v) ((v) &= ~BIT(31)) +#define DMA_RAID6_CONT 0x14 +#define DMA_RAID6_MULTI_CTRL (v) ((v) << 24) +#define DMA_INT 0x70 +#define DMA_INT_MASK 0x74 +#define DMA_INT_ALL_MASK 0xFFFFFFFF +#define DMA_INT_ALL_UNMASK 0x0 +#define DMA_INT_MASK_SHIFT 0x14 +#define DMA_RING_INT0_MASK 0x90A0 +#define DMA_RING_INT1_MASK 0x90A8 +#define DMA_RING_INT2_MASK 0x90B0
Quoted 9 lines
drivers/dma/xgene-dma.c line 102
Quoted 7 lines
drivers/dma/xgene-dma.c new file +7
-0+#define DMA_RING_INT3_MASK 0x90B8 +#define DMA_RING_INT4_MASK 0x90C0 +#define DMA_CFG_RING_WQ_ASSOC 0x90E0 +#define DMA_ASSOC_RING_MNGR1 0xFFFFFFFF +#define DMA_MEM_RAM_SHUTDOWN 0xD070 +#define DMA_BLK_MEM_RDY 0xD074 +#define DMA_BLK_MEM_RDY_VAL 0xFFFFFFFFsame here and throughout the driver..
Okay...
Quoted 8 lines
drivers/dma/xgene-dma.c line 585
Quoted 6 lines
drivers/dma/xgene-dma.c new file +6
-0+static void xgene_dma_free_descriptor (struct xgene_dma_chan *chan, +struct xgene_dma_desc_sw *desc) +{ +list_del (&desc->node); +chan_dbg (chan,"LD %p free\n" , desc); +dma_pool_free (chan->desc_pool, desc, desc->tx.phys);where is the descriptor freed? Perhpas we can say clean rather than free here to not confuse...
xgene_dma_clean_completed_descriptor() is freeing the descriptor once descriptor acked by client.
This is in the completion path.
Quoted 13 lines
drivers/dma/xgene-dma.c line 596
Quoted 12 lines
drivers/dma/xgene-dma.c new file +11
-0+} + +static struct xgene_dma_desc_sw *xgene_dma_alloc_descriptor ( +struct xgene_dma_chan *chan) +{ +struct xgene_dma_desc_sw *desc; +dma_addr_t phys; + + desc =dma_pool_alloc (chan->desc_pool,GFP_NOWAIT , &phys); +if (!desc) { +chan_dbg (chan,"Failed to allocate LDs\n" );not error?
Yes it's error only by lacking of dma memory, do I need to use dev_err to show the error msg ??
Quoted 4 lines
drivers/dma/xgene-dma.c line 916
Quoted 3 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
Quoted 80 lines
Quoted 80 lines
drivers/dma/xgene-dma.c new file +79
-0+{ +struct xgene_dma_desc_sw *desc, *_desc; + +list_for_each_entry_safe_reverse (desc, _desc, list, node) +xgene_dma_free_descriptor (chan, desc); +} + +static void xgene_dma_free_chan_resources (struct dma_chan *dchan) +{ +struct xgene_dma_chan *chan =to_dma_chan (dchan); + +chan_dbg (chan,"Free all resources\n" ); + +if (!chan->desc_pool) +return ; + +spin_lock_bh (&chan->lock); + +/* Process all running descriptor */ +xgene_dma_cleanup_descriptors (chan); + +/* Clean all link descriptor queues */ +xgene_dma_free_desc_list (chan, &chan->ld_pending); +xgene_dma_free_desc_list (chan, &chan->ld_running); +xgene_dma_free_desc_list (chan, &chan->ld_completed); + +spin_unlock_bh (&chan->lock); + +/* Delete this channel DMA pool */ +dma_pool_destroy (chan->desc_pool); + chan->desc_pool =NULL ; +} + +static struct dma_async_tx_descriptor *xgene_dma_prep_memcpy ( +struct dma_chan *dchan,dma_addr_t dst,dma_addr_t src, +size_t len,unsigned long flags) +{ +struct xgene_dma_desc_sw *first =NULL , *new; +struct xgene_dma_chan *chan; +size_t copy; +u32 desc_id; + +if (unlikely (!dchan || !len)) +return NULL ; + + chan =to_dma_chan (dchan); + +/* Get the id for this group of descriptors */ + desc_id =atomic_inc_return (&chan->desc_id); + + do { + /* Allocate the link descriptor from DMA pool */ + new = xgene_dma_alloc_descriptor(chan); + if (!new) + goto fail; + + /* Create the largest transaction possible */ + copy = min_t(size_t, len, DMA_MAX_64B_DESC_BYTE_CNT); + + /* Prepare DMA descriptor */ + xgene_dma_prep_cpy_desc(chan, new, dst, src, copy, desc_id); + + if (!first) + first = new; + + new->first = first; + first->desc_cnt++; + new->desc_id = desc_id; + + new->tx.cookie = 0; + async_tx_ack(&new->tx); + + /* Update metadata */ + len -= copy; + dst += copy; + src += copy; + + /* Insert the link descriptor to the LD ring */ + list_add_tail(&new->node, &first->tx_list);
Quoted 8 lines
drivers/dma/xgene-dma.c line 1002
Quoted 7 lines
drivers/dma/xgene-dma.c new file +7
-0+ }while (len); + + first->tx.flags = flags;/* client is in control of this ack */ + first->tx.cookie = -EBUSY ; + first->flags |=DMA_FLAG_FIRST_DESC ; + +return &first->tx;where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.
Quoted 14 lines
drivers/dma/xgene-dma.c line 1291
Quoted 13 lines
drivers/dma/xgene-dma.c new file +12
-0+static enum dma_status xgene_dma_find_tx_desc_status ( +struct xgene_dma_chan *chan,dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct xgene_dma_desc_sw *desc; + +spin_lock_bh (&chan->lock); + +/* Check if this tx descriptor is still in pending queue */ +list_for_each_entry (desc, &chan->ld_pending, node) { +if (desc->tx.cookie == cookie) { +xgene_chan_xfer_ld_pending (chan);why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Quoted 9 lines
drivers/dma/xgene-dma.c line 1301
Quoted 8 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +/* Check if this descriptor is in running queue */ +list_for_each_entry (desc, &chan->ld_running, node) { +if (desc->tx.cookie == cookie) { +/* Cleanup any running and executed descriptors */ +xgene_dma_cleanup_descriptors (chan);ditto?
Okay
Quoted 4 lines
drivers/dma/xgene-dma.c line 1304
Quoted 3 lines
drivers/dma/xgene-dma.c new file +3
-0+spin_unlock_bh (&chan->lock); +return dma_cookie_status (&chan->dma_chan, + cookie, txstate);and you havent touched txstate so what is the intent here...?
txstate can filled by caller, so it may be NULL or not NULL, we are passing same.
Quoted 44 lines
Quoted 8 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +spin_unlock_bh (&chan->lock); + +return DMA_COMPLETE ; +} +drivers/dma/xgene-dma.c line 1322
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+static enum dma_status xgene_dma_tx_status (struct dma_chan *dchan, +dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct xgene_dma_chan *chan =to_dma_chan (dchan); + +enum dma_status status; + + status =dma_cookie_status (dchan, cookie, txstate); +if (status ==DMA_COMPLETE )you should do this if txstate in NULL, no point doing calculations..
Quoted 24 lines
drivers/dma/xgene-dma.c new file +24
-0+return status; + +return xgene_dma_find_tx_desc_status (chan, cookie, txstate); +} + +static void xgene_dma_tasklet_cb (unsigned long data) +{ +struct xgene_dma_chan *chan = (struct xgene_dma_chan *)data; + +spin_lock_bh (&chan->lock); + +/* Run all cleanup for descriptors which have been completed */ +xgene_dma_cleanup_descriptors (chan); + +/* Re-enable DMA channel IRQ */ +enable_irq (chan->rx_irq); + +spin_unlock_bh (&chan->lock); +} + +static irqreturn_t xgene_dma_chan_ring_isr (int irq,void *id) +{ +struct xgene_dma_chan *chan = (struct xgene_dma_chan *)id; +
Quoted 8 lines
drivers/dma/xgene-dma.c line 1353
Quoted 7 lines
drivers/dma/xgene-dma.c new file +7
-0+BUG_ON (!chan); + +/* +* Disable DMA channel IRQ until we process completed +* descriptors +*/ +disable_irq_nosync (chan->rx_irq);and why is that?
This will reduce the interrupt overheads and will give us better performance. we are enabling it again when we are done with tasklet function.
Quoted 9 lines
drivers/dma/xgene-dma.c line 1360
Quoted 8 lines
drivers/dma/xgene-dma.c new file +7
-0+ +/* +* Schedule the tasklet to handle all cleanup of the current +* transaction. It will start a new transaction if there is +* one pending. +*/ +tasklet_schedule (&chan->tasklet);for better results why not schedule the next transaction here..?
I agree, I will do this.
Quoted 5 lines
Quoted 4 lines
drivers/dma/xgene-dma.c new file +4
-0+ +return IRQ_HANDLED ; +} +
Quoted 7 lines
drivers/dma/xgene-dma.c line 1927
Quoted 6 lines
drivers/dma/xgene-dma.c new file +6
-0+static void xgene_dma_async_unregister (struct xgene_dma *pdma) +{ +int i; + +for (i =0 ; i <DMA_MAX_CHANNEL ; i++) +dma_async_device_unregister (&pdma->dma_dev[i]);how do you ensure irq is disabled and tasklets killed?
After un-registering async dma device we are freeing irqs and killing tasklet. Does this make sense. and do we need to add some way to make sure about irq disabled.
Quoted 7 lines
drivers/dma/xgene-dma.c line 2156
Quoted 6 lines
drivers/dma/xgene-dma.c new file +5
-0+MODULE_DESCRIPTION ("APM X-Gene SoC DMA driver" ); +MODULE_AUTHOR ("Rameshwar Prasad Sahu <[email protected]>" ); +MODULE_AUTHOR ("Loc Ho <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_VERSION ("1.0" );why do you need this?
I don't see really use of this, but this will give us idea which version of dma driver support what offload functionality for later.
Quoted 5 lines
Quoted 3 lines
--
1.8.2.1--
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Quoted 11 lines · Rameshwar Sahu
Quoted 10 lines
drivers/dma/xgene-dma.c line 596
Quoted 9 lines
drivers/dma/xgene-dma.c new file +9
-0+static struct xgene_dma_desc_sw *xgene_dma_alloc_descriptor ( +struct xgene_dma_chan *chan) +{ +struct xgene_dma_desc_sw *desc; +dma_addr_t phys; + + desc =dma_pool_alloc (chan->desc_pool,GFP_NOWAIT , &phys); +if (!desc) { +chan_dbg (chan,"Failed to allocate LDs\n" );not error?
Quoted 2 lines
Yes it's error only by lacking of dma memory, do I need to use
dev_errto show the error msg ??
yes
Quoted 7 lines
Quoted 5 lines
drivers/dma/xgene-dma.c line 916
Quoted 4 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
Quoted 5 lines
Quoted 1 line
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.
not for memcpy, that is true for slave transfers
For mempcy the idea is that drivers will do buffer mapping
Quoted 11 lines
Quoted 1 line
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
Quoted 14 lines
Quoted 10 lines
drivers/dma/xgene-dma.c line 1301
Quoted 9 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +/* Check if this descriptor is in running queue */ +list_for_each_entry (desc, &chan->ld_running, node) { +if (desc->tx.cookie == cookie) { +/* Cleanup any running and executed descriptors */ +xgene_dma_cleanup_descriptors (chan);ditto?
Okay
Quoted 7 lines
Quoted 4 lines
drivers/dma/xgene-dma.c line 1304
Quoted 3 lines
drivers/dma/xgene-dma.c new file +3
-0+spin_unlock_bh (&chan->lock); +return dma_cookie_status (&chan->dma_chan, + cookie, txstate);and you havent touched txstate so what is the intent here...?
txstate can filled by caller, so it may be NULL or not NULL, we are passing same.
something seems very wrong here. Status should return the current satue of queried descriptor and if residue value in txstate, you seem to be doing something else, quotesion is what and why :)
Signature · 1 line
~Vinod
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Hi Vinod,
Quoted 13 lines · Vinod Koul
Quoted 11 lines · Rameshwar Sahu
Quoted 10 lines
drivers/dma/xgene-dma.c line 596
Quoted 9 lines
drivers/dma/xgene-dma.c new file +9
-0+static struct xgene_dma_desc_sw *xgene_dma_alloc_descriptor ( +struct xgene_dma_chan *chan) +{ +struct xgene_dma_desc_sw *desc; +dma_addr_t phys; + + desc =dma_pool_alloc (chan->desc_pool,GFP_NOWAIT , &phys); +if (!desc) { +chan_dbg (chan,"Failed to allocate LDs\n" );not error?
Quoted 3 lines
Quoted 2 lines
Yes it's error only by lacking of dma memory, do I need to use
dev_errto show the error msg ??yes
Okay fine.
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
drivers/dma/xgene-dma.c line 916
Quoted 5 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
We can free allocated descriptor in forward order from head or in reverse order, I just followed here fsldma.c driver. Does this make sense ??
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.not for memcpy, that is true for slave transfers
For mempcy the idea is that drivers will do buffer mapping
Still I am clear here, why memcpy will do buffer mapping, I see other drivers and also async_memcpy.c , they only map it and pass mapped physical dma address to driver.
Buffer mapping mean you here is dma_map_xxx ?? Am I correct.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
So basically case here for me is completion of dma descriptor submitted to hw is not same as order of submission to hw. So scenario coming in multithread running :e.g. let's assume we have submitted two descriptors first has cookie 1001 and second has 1002, now 1002 is completed first, so updated last_completed_cookie as 1002 but not yer checked for dma_tx_status, and then first cookie completes and update last_completed_cookie as 1001, now second transaction check for tx_status and it get DMA_IN_PROGRESS, because last_completed_cookie(1001) is less than second transaction's cookie(1002).
Due to this issue I am traversing that transaction in pending list and running list, if not there means we are done.
Does this make sense??
Quoted 18 lines
Quoted 18 lines
Quoted 11 lines
drivers/dma/xgene-dma.c line 1301
Quoted 10 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +/* Check if this descriptor is in running queue */ +list_for_each_entry (desc, &chan->ld_running, node) { +if (desc->tx.cookie == cookie) { +/* Cleanup any running and executed descriptors */ +xgene_dma_cleanup_descriptors (chan);ditto?
Okay
Quoted 3 lines
Quoted 3 lines
drivers/dma/xgene-dma.c new file +3
-0+spin_unlock_bh (&chan->lock); +return dma_cookie_status (&chan->dma_chan, + cookie, txstate);
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
and you havent touched txstate so what is the intent here...?
txstate can filled by caller, so it may be NULL or not NULL, we are passing same.
something seems very wrong here. Status should return the current satue of queried descriptor and if residue value in txstate, you seem to be doing something else, quotesion is what and why :)
Please see my above comment.
Thanks
Quoted 3 lines
--
~Vinod
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Quoted 9 lines · Rameshwar Sahu
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
drivers/dma/xgene-dma.c line 916
Quoted 2 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
We can free allocated descriptor in forward order from head or in reverse order, I just followed here
fsldma.cdriver. Does this make sense ??
No, you have two APIs to free list. Why do you need two?
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
Quoted 4 lines
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.not for memcpy, that is true for slave transfers
Quoted 7 lines
Quoted 1 line
For mempcy the idea is that drivers will do buffer mapping
Still I am clear here, why memcpy will do buffer mapping, I see other drivers and also
async_memcpy.c, they only map it and pass mapped physical dma address to driver.Buffer mapping mean you here is
dma_map_xxx?? Am I correct.
Yes
Quoted 26 lines
Quoted 7 lines
Quoted 7 lines
Quoted 3 lines
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
So basically case here for me is completion of dma descriptor submitted to hw is not same as order of submission to hw. So scenario coming in multithread running :e.g. let's assume we have submitted two descriptors first has cookie 1001 and second has 1002, now 1002 is completed first, so updated
last_completed_cookieas 1002 but not yer checked fordma_tx_status, and then first cookie completes and updatelast_completed_cookieas 1001, now second transaction check fortx_statusand it getDMA_IN_PROGRESS, becauselast_completed_cookie(1001)is less than second transaction's cookie(1002).
Quoted 4 lines
Due to this issue I am traversing that transaction in pending list and running list, if not there means we are done.
Does this make sense??
That only convinces me that there is something not so correct.
To help me understand pls let me know if below is fine:
- for a physical channel, do you submit multiple transactions?
- if yes, how does DMA deal with multiple transactions, how does it schedule them?
Signature · 1 line
~Vinod
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Hi Vinod,
Quoted 11 lines · Vinod Koul
Quoted 9 lines · Rameshwar Sahu
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
drivers/dma/xgene-dma.c line 916
Quoted 2 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
We can free allocated descriptor in forward order from head or in reverse order, I just followed here
fsldma.cdriver. Does this make sense ??No, you have two APIs to free list. Why do you need two?
Yes, basically we have tow API to free list. xgene_dma_free_desc_list_reverse will call if any failure in allocation of memory from DMA pool in prep routines.
Like e.g. in prep routing we have some descriptors allocated and still need to get descriptor to complete the DMA request and failure happen, so we need to free all allocated descriptor.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 5 lines
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.not for memcpy, that is true for slave transfers
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
For mempcy the idea is that drivers will do buffer mapping
Still I am clear here, why memcpy will do buffer mapping, I see other drivers and also
async_memcpy.c, they only map it and pass mapped physical dma address to driver.Buffer mapping mean you here is
dma_map_xxx?? Am I correct.Yes
I have confusion here, I don't see any driver dma buffer mapping in prep_dma_memcpy.
Can you please clear me here if driver does this on behalf of client, like any example so that I can proceed further.
Quoted 27 lines
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
So basically case here for me is completion of dma descriptor submitted to hw is not same as order of submission to hw. So scenario coming in multithread running :e.g. let's assume we have submitted two descriptors first has cookie 1001 and second has 1002, now 1002 is completed first, so updated
last_completed_cookieas 1002 but not yer checked fordma_tx_status, and then first cookie completes and updatelast_completed_cookieas 1001, now second transaction check fortx_statusand it getDMA_IN_PROGRESS, becauselast_completed_cookie(1001)is less than second transaction's cookie(1002).
Quoted 8 lines
Quoted 4 lines
Due to this issue I am traversing that transaction in pending list and running list, if not there means we are done.
Does this make sense??
That only convinces me that there is something not so correct.
To help me understand pls let me know if below is fine:
- for a physical channel, do you submit multiple transactions?
Yes
Quoted 2 lines
- if yes, how does DMA deal with multiple transactions, how does it schedule them?
So , basically we submit multiple descriptor to dma physical channel, and dma engine execute it one by one and give us completion callback. So in this way we expect callback on same order as submission order and it does also, no issue.
But problem is with supporting p+q offload, here we have P functionality supports in dma physical channel 0 and Q functionality supports in dma physical channel 1. So for pq we need to submit two descriptor, one to channel 0 and second to channel1, in this case we can't expect the completion order, because channnel 0 can finish P before Q or vice versa, and we need to wait to complete both before calling client callback() and completing cookie.
Second thing we submit memcpy and sg on same channel, and can complete before even though if it submitted after PQ.
Quoted 7 lines
--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Hi Vinod,
Quoted 39 lines · Rameshwar Sahu
Hi Vinod,
Quoted 11 lines · Vinod Koul
Quoted 9 lines · Rameshwar Sahu
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static void xgene_dma_free_desc_list_reverse(struct xgene_dma_chan *chan, + struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
We can free allocated descriptor in forward order from head or in reverse order, I just followed here
fsldma.cdriver. Does this make sense ??No, you have two APIs to free list. Why do you need two?
Yes, basically we have tow API to free list.
xgene_dma_free_desc_list_reversewill call if any failure in allocation of memory from DMA pool in prep routines.
Like e.g. in prep routing we have some descriptors allocated and still need to get descriptor to complete the DMA request and failure happen, so we need to free all allocated descriptor.Quoted 17 lines
Quoted 17 lines
Quoted 4 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.not for memcpy, that is true for slave transfers
For mempcy the idea is that drivers will do buffer mapping
Still I am clear here, why memcpy will do buffer mapping, I see other drivers and also
async_memcpy.c, they only map it and pass mapped physical dma address to driver.
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Buffer mapping mean you here is
dma_map_xxx?? Am I correct.Yes
I have confusion here, I don't see any driver dma buffer mapping in
prep_dma_memcpy.
Can you please clear me here if driver does this on behalf of client, like any example so that I can proceed further.
Any comment here ??
Quoted 46 lines
Quoted 27 lines
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
So basically case here for me is completion of dma descriptor submitted to hw is not same as order of submission to hw. So scenario coming in multithread running :e.g. let's assume we have submitted two descriptors first has cookie 1001 and second has 1002, now 1002 is completed first, so updated
last_completed_cookieas 1002 but not yer checked fordma_tx_status, and then first cookie completes and updatelast_completed_cookieas 1001, now second transaction check fortx_statusand it getDMA_IN_PROGRESS, becauselast_completed_cookie(1001)is less than second transaction's cookie(1002).Quoted 8 lines
Quoted 4 lines
Due to this issue I am traversing that transaction in pending list and running list, if not there means we are done.
Does this make sense??
That only convinces me that there is something not so correct.
To help me understand pls let me know if below is fine:
- for a physical channel, do you submit multiple transactions?Yes
Quoted 2 lines
- if yes, how does DMA deal with multiple transactions, how does it schedule them?
So , basically we submit multiple descriptor to dma physical channel, and dma engine execute it one by one and give us completion callback. So in this way we expect callback on same order as submission order and it does also, no issue.
Quoted 9 lines
But problem is with supporting p+q offload, here we have P functionality supports in dma physical channel 0 and Q functionality supports in dma physical channel 1. So for pq we need to submit two descriptor, one to channel 0 and second to channel1, in this case we can't expect the completion order, because channnel 0 can finish P before Q or vice versa, and we need to wait to complete both before calling client
callback()and completing cookie.
Second thing we submit memcpy and sg on same channel, and can complete before even though if it submitted after PQ.
So our SoC dma engine hw design idea was to get more throughput while running two channel concurrent and calculating the P and Q together, but somehow now today we came to scenario where running P and Q on different channel causing hang to dmaengine, some hw bug, So now I am going to support P and Q generation in same channel, so above mentioned cookie status scenario will never come.
I will send you the patch for review.
Thanks,
Quoted 8 lines
Quoted 8 lines
--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Quoted 43 lines · Rameshwar Sahu
Hi Vinod,
Quoted 40 lines · Rameshwar Sahu
Hi Vinod,
Quoted 11 lines · Vinod Koul
Quoted 9 lines · Rameshwar Sahu
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static void xgene_dma_free_desc_list_reverse(struct xgene_dma_chan *chan, + struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
We can free allocated descriptor in forward order from head or in reverse order, I just followed here
fsldma.cdriver. Does this make sense ??No, you have two APIs to free list. Why do you need two?
Yes, basically we have tow API to free list.
xgene_dma_free_desc_list_reversewill call if any failure in allocation of memory from DMA pool in prep routines.
Like e.g. in prep routing we have some descriptors allocated and still need to get descriptor to complete the DMA request and failure happen, so we need to free all allocated descriptor.Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.not for memcpy, that is true for slave transfers
For mempcy the idea is that drivers will do buffer mapping
Still I am clear here, why memcpy will do buffer mapping, I see other drivers and also
async_memcpy.c, they only map it and pass mapped physical dma address to driver.Buffer mapping mean you here is
dma_map_xxx?? Am I correct.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Yes
I have confusion here, I don't see any driver dma buffer mapping in
prep_dma_memcpy.
Can you please clear me here if driver does this on behalf of client, like any example so that I can proceed further.Any comment here ??
The advise typically is that for memcpy the dma mapping should be done by client. For now this is okay as we have precedence, let me check with Dan.
Quoted 57 lines
Quoted 47 lines
Quoted 28 lines
Quoted 28 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
So basically case here for me is completion of dma descriptor submitted to hw is not same as order of submission to hw. So scenario coming in multithread running :e.g. let's assume we have submitted two descriptors first has cookie 1001 and second has 1002, now 1002 is completed first, so updated
last_completed_cookieas 1002 but not yer checked fordma_tx_status, and then first cookie completes and updatelast_completed_cookieas 1001, now second transaction check fortx_statusand it getDMA_IN_PROGRESS, becauselast_completed_cookie(1001)is less than second transaction's cookie(1002).Quoted 8 lines
Quoted 4 lines
Due to this issue I am traversing that transaction in pending list and running list, if not there means we are done.
Does this make sense??
That only convinces me that there is something not so correct.
To help me understand pls let me know if below is fine:
- for a physical channel, do you submit multiple transactions?Yes
Quoted 2 lines
- if yes, how does DMA deal with multiple transactions, how does it schedule them?
So , basically we submit multiple descriptor to dma physical channel, and dma engine execute it one by one and give us completion callback. So in this way we expect callback on same order as submission order and it does also, no issue.
Quoted 9 lines
But problem is with supporting p+q offload, here we have P functionality supports in dma physical channel 0 and Q functionality supports in dma physical channel 1. So for pq we need to submit two descriptor, one to channel 0 and second to channel1, in this case we can't expect the completion order, because channnel 0 can finish P before Q or vice versa, and we need to wait to complete both before calling client
callback()and completing cookie.
Second thing we submit memcpy and sg on same channel, and can complete before even though if it submitted after PQ.
Quoted 7 lines
So our SoC dma engine hw design idea was to get more throughput while running two channel concurrent and calculating the P and Q together, but somehow now today we came to scenario where running P and Q on different channel causing hang to dmaengine, some hw bug, So now I am going to support P and Q generation in same channel, so above mentioned cookie status scenario will never come.
I will send you the patch for review.
Okay, so I am going to expect the status callback will do as per API expectations and these kinds of hacks will be absent in the code :)
Signature · 1 line
~Vinod
Quoted 10 lines
Thanks,
Quoted 8 lines
Quoted 8 lines
--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
Hi Vinod,
Quoted 118 lines · Vinod Koul
Quoted 43 lines · Rameshwar Sahu
Hi Vinod,
Quoted 40 lines · Rameshwar Sahu
Hi Vinod,
Quoted 11 lines · Vinod Koul
Quoted 9 lines · Rameshwar Sahu
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+static void xgene_dma_free_desc_list_reverse(struct xgene_dma_chan *chan, + struct list_head *list)do we really care about free order?
Yes it start dellocation of descriptor by tail.
and why by tail is not clear.
We can free allocated descriptor in forward order from head or in reverse order, I just followed here
fsldma.cdriver. Does this make sense ??No, you have two APIs to free list. Why do you need two?
Yes, basically we have tow API to free list.
xgene_dma_free_desc_list_reversewill call if any failure in allocation of memory from DMA pool in prep routines.
Like e.g. in prep routing we have some descriptors allocated and still need to get descriptor to complete the DMA request and failure happen, so we need to free all allocated descriptor.Quoted 18 lines
Quoted 18 lines
Quoted 4 lines
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
where are you mapping dma buffers?
I didn't get you here. Can you please explain me here what you mean.
As per my understanding client should map the dma buffer and give the physical address and size to this callback prep routines.not for memcpy, that is true for slave transfers
For mempcy the idea is that drivers will do buffer mapping
Still I am clear here, why memcpy will do buffer mapping, I see other drivers and also
async_memcpy.c, they only map it and pass mapped physical dma address to driver.Buffer mapping mean you here is
dma_map_xxx?? Am I correct.Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Yes
I have confusion here, I don't see any driver dma buffer mapping in
prep_dma_memcpy.
Can you please clear me here if driver does this on behalf of client, like any example so that I can proceed further.Any comment here ??
The advise typically is that for memcpy the dma mapping should be done by client. For now this is okay as we have precedence, let me check with Dan.
Quoted 57 lines
Quoted 47 lines
Quoted 28 lines
Quoted 28 lines
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
why are you calling this here, status check shouldnt do this...
Okay, I will remove it.
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
We can't calculate here residue size. We don't have any controller register which will tell about remaining transaction size.
Okay if you cant calculate residue why do we have this fn?
So basically case here for me is completion of dma descriptor submitted to hw is not same as order of submission to hw. So scenario coming in multithread running :e.g. let's assume we have submitted two descriptors first has cookie 1001 and second has 1002, now 1002 is completed first, so updated
last_completed_cookieas 1002 but not yer checked fordma_tx_status, and then first cookie completes and updatelast_completed_cookieas 1001, now second transaction check fortx_statusand it getDMA_IN_PROGRESS, becauselast_completed_cookie(1001)is less than second transaction's cookie(1002).Quoted 8 lines
Quoted 4 lines
Due to this issue I am traversing that transaction in pending list and running list, if not there means we are done.
Does this make sense??
That only convinces me that there is something not so correct.
To help me understand pls let me know if below is fine:
- for a physical channel, do you submit multiple transactions?Yes
Quoted 2 lines
- if yes, how does DMA deal with multiple transactions, how does it schedule them?
So , basically we submit multiple descriptor to dma physical channel, and dma engine execute it one by one and give us completion callback. So in this way we expect callback on same order as submission order and it does also, no issue.
Quoted 9 lines
But problem is with supporting p+q offload, here we have P functionality supports in dma physical channel 0 and Q functionality supports in dma physical channel 1. So for pq we need to submit two descriptor, one to channel 0 and second to channel1, in this case we can't expect the completion order, because channnel 0 can finish P before Q or vice versa, and we need to wait to complete both before calling client
callback()and completing cookie.
Second thing we submit memcpy and sg on same channel, and can complete before even though if it submitted after PQ.Quoted 7 lines
So our SoC dma engine hw design idea was to get more throughput while running two channel concurrent and calculating the P and Q together, but somehow now today we came to scenario where running P and Q on different channel causing hang to dmaengine, some hw bug, So now I am going to support P and Q generation in same channel, so above mentioned cookie status scenario will never come.
I will send you the patch for review.
Quoted 2 lines
Okay, so I am going to expect the status callback will do as per API expectations and these kinds of hacks will be absent in the code :)
Yes, I will send patch ASAP for further review.
Quoted 15 lines
--
~VinodQuoted 10 lines
Thanks,
Quoted 8 lines
Quoted 8 lines
--
~Vinod
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html--
Re: [PATCH v7 1/3] dmaengine: Add support for APM X-Gene SoC DMA engine driver
In reply to Vinod KoulHi Vinod,
Quoted 226 lines · Vinod Koul
Quoted 30 lines · Rameshwar Prasad Sahu
drivers/dma/xgene-dma.c new file +30
-0+/* DMA ring csr registers and bit definations */ +#define DMA_RING_CONFIG 0x04 +#define DMA_RING_ENABLE BIT(31) +#define DMA_RING_ID 0x08 +#define DMA_RING_ID_SETUP (v) ((v) | BIT(31)) +#define DMA_RING_ID_BUF 0x0C +#define DMA_RING_ID_BUF_SETUP (v) (((v) << 9) | BIT(21)) +#define DMA_RING_THRESLD0_SET1 0x30 +#define DMA_RING_THRESLD0_SET1_VAL 0X64 +#define DMA_RING_THRESLD1_SET1 0x34 +#define DMA_RING_THRESLD1_SET1_VAL 0xC8 +#define DMA_RING_HYSTERESIS 0x68 +#define DMA_RING_HYSTERESIS_VAL 0xFFFFFFFF +#define DMA_RING_STATE 0x6C +#define DMA_RING_STATE_WR_BASE 0x70 +#define DMA_RING_NE_INT_MODE 0x017C +#define DMA_RING_NE_INT_MODE_SET (m, v) \ + ((m) = ((m) & ~BIT(31 - (v))) | BIT(31 - (v))) +#define DMA_RING_NE_INT_MODE_RESET (m, v) \ + ((m) &= (~BIT(31 - (v)))) +#define DMA_RING_CLKEN 0xC208 +#define DMA_RING_SRST 0xC200 +#define DMA_RING_MEM_RAM_SHUTDOWN 0xD070 +#define DMA_RING_BLK_MEM_RDY 0xD074 +#define DMA_RING_BLK_MEM_RDY_VAL 0xFFFFFFFF +#define DMA_RING_DESC_CNT (v) (((v) & 0x0001FFFE) >> 1) +#define DMA_RING_ID_GET (owner, num) (((owner) << 6) | (num)) +#define DMA_RING_DST_ID (v) ((1 << 10) | (v)) +#define DMA_RING_CMD_OFFSET 0x2C +#define DMA_RING_CMD_BASE_OFFSET (v) ((v) << 6)drivers/dma/xgene-dma.c line 75
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+#define DMA_RING_COHERENT_SET (m) (((u32 *)(m))[2] |= BIT(4)) +#define DMA_RING_ADDRL_SET (m, v) (((u32 *)(m))[2] |= (((v) >> 8) << 5)) +#define DMA_RING_ADDRH_SET (m, v) (((u32 *)(m))[3] |= ((v) >> 35)) +#define DMA_RING_ACCEPTLERR_SET (m) (((u32 *)(m))[3] |= BIT(19)) +#define DMA_RING_SIZE_SET (m, v) (((u32 *)(m))[3] |= ((v) << 23)) +#define DMA_RING_RECOMBBUF_SET (m) (((u32 *)(m))[3] |= BIT(27)) +#define DMA_RING_RECOMTIMEOUTL_SET (m) (((u32 *)(m))[3] |= (0x7 << 28)) +#define DMA_RING_RECOMTIMEOUTH_SET (m) (((u32 *)(m))[4] |= 0x3) +#define DMA_RING_SELTHRSH_SET (m) (((u32 *)(m))[4] |= BIT(3)) +#define DMA_RING_TYPE_SET (m, v) (((u32 *)(m))[4] |= ((v) << 19))These are very generic name as can conflicts, can you please namespace these...
Quoted 16 lines
drivers/dma/xgene-dma.c new file +16
-0+/* DMA device csr registers and bit definitions */ +#define DMA_IPBRR 0x0 +#define DMA_DEV_ID_RD (v) ((v) & 0x00000FFF) +#define DMA_BUS_ID_RD (v) (((v) >> 12) & 3) +#define DMA_REV_NO_RD (v) (((v) >> 14) & 3) +#define DMA_GCR 0x10 +#define DMA_CH_SETUP (v) ((v) = ((v) & ~0x000FFFFF) | 0x000AAFFF) +#define DMA_ENABLE (v) ((v) |= BIT(31)) +#define DMA_DISABLE (v) ((v) &= ~BIT(31)) +#define DMA_RAID6_CONT 0x14 +#define DMA_RAID6_MULTI_CTRL (v) ((v) << 24) +#define DMA_INT 0x70 +#define DMA_INT_MASK 0x74 +#define DMA_INT_ALL_MASK 0xFFFFFFFF +#define DMA_INT_ALL_UNMASK 0x0 +#define DMA_INT_MASK_SHIFT 0x14drivers/dma/xgene-dma.c line 102
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+#define DMA_RING_INT0_MASK 0x90A0 +#define DMA_RING_INT1_MASK 0x90A8 +#define DMA_RING_INT2_MASK 0x90B0 +#define DMA_RING_INT3_MASK 0x90B8 +#define DMA_RING_INT4_MASK 0x90C0 +#define DMA_CFG_RING_WQ_ASSOC 0x90E0 +#define DMA_ASSOC_RING_MNGR1 0xFFFFFFFF +#define DMA_MEM_RAM_SHUTDOWN 0xD070 +#define DMA_BLK_MEM_RDY 0xD074 +#define DMA_BLK_MEM_RDY_VAL 0xFFFFFFFFsame here and throughout the driver..
drivers/dma/xgene-dma.c line 585
Quoted 6 lines
drivers/dma/xgene-dma.c new file +6
-0+static void xgene_dma_free_descriptor (struct xgene_dma_chan *chan, +struct xgene_dma_desc_sw *desc) +{ +list_del (&desc->node); +chan_dbg (chan,"LD %p free\n" , desc); +dma_pool_free (chan->desc_pool, desc, desc->tx.phys);where is the descriptor freed? Perhpas we can say clean rather than free here to not confuse...
drivers/dma/xgene-dma.c line 596
Quoted 11 lines
drivers/dma/xgene-dma.c new file +11
-0+} + +static struct xgene_dma_desc_sw *xgene_dma_alloc_descriptor ( +struct xgene_dma_chan *chan) +{ +struct xgene_dma_desc_sw *desc; +dma_addr_t phys; + + desc =dma_pool_alloc (chan->desc_pool,GFP_NOWAIT , &phys); +if (!desc) { +chan_dbg (chan,"Failed to allocate LDs\n" );not error?
drivers/dma/xgene-dma.c line 916
Quoted 2 lines
drivers/dma/xgene-dma.c new file +2
-0+static void xgene_dma_free_desc_list_reverse (struct xgene_dma_chan *chan, +struct list_head *list)do we really care about free order?
Quoted 76 lines
drivers/dma/xgene-dma.c new file +76
-0+{ +struct xgene_dma_desc_sw *desc, *_desc; + +list_for_each_entry_safe_reverse (desc, _desc, list, node) +xgene_dma_free_descriptor (chan, desc); +} + +static void xgene_dma_free_chan_resources (struct dma_chan *dchan) +{ +struct xgene_dma_chan *chan =to_dma_chan (dchan); + +chan_dbg (chan,"Free all resources\n" ); + +if (!chan->desc_pool) +return ; + +spin_lock_bh (&chan->lock); + +/* Process all running descriptor */ +xgene_dma_cleanup_descriptors (chan); + +/* Clean all link descriptor queues */ +xgene_dma_free_desc_list (chan, &chan->ld_pending); +xgene_dma_free_desc_list (chan, &chan->ld_running); +xgene_dma_free_desc_list (chan, &chan->ld_completed); + +spin_unlock_bh (&chan->lock); + +/* Delete this channel DMA pool */ +dma_pool_destroy (chan->desc_pool); + chan->desc_pool =NULL ; +} + +static struct dma_async_tx_descriptor *xgene_dma_prep_memcpy ( +struct dma_chan *dchan,dma_addr_t dst,dma_addr_t src, +size_t len,unsigned long flags) +{ +struct xgene_dma_desc_sw *first =NULL , *new; +struct xgene_dma_chan *chan; +size_t copy; +u32 desc_id; + +if (unlikely (!dchan || !len)) +return NULL ; + + chan =to_dma_chan (dchan); + +/* Get the id for this group of descriptors */ + desc_id =atomic_inc_return (&chan->desc_id); + + do { + /* Allocate the link descriptor from DMA pool */ + new = xgene_dma_alloc_descriptor(chan); + if (!new) + goto fail; + + /* Create the largest transaction possible */ + copy = min_t(size_t, len, DMA_MAX_64B_DESC_BYTE_CNT); + + /* Prepare DMA descriptor */ + xgene_dma_prep_cpy_desc(chan, new, dst, src, copy, desc_id); + + if (!first) + first = new; + + new->first = first; + first->desc_cnt++; + new->desc_id = desc_id; + + new->tx.cookie = 0; + async_tx_ack(&new->tx); + + /* Update metadata */ + len -= copy; + dst += copy; + src += copy;drivers/dma/xgene-dma.c line 1002
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+ +/* Insert the link descriptor to the LD ring */ +list_add_tail (&new->node, &first->tx_list); + }while (len); + + first->tx.flags = flags;/* client is in control of this ack */ + first->tx.cookie = -EBUSY ; + first->flags |=DMA_FLAG_FIRST_DESC ; + +return &first->tx;where are you mapping dma buffers?
drivers/dma/xgene-dma.c line 1291
Quoted 12 lines
drivers/dma/xgene-dma.c new file +12
-0+static enum dma_status xgene_dma_find_tx_desc_status ( +struct xgene_dma_chan *chan,dma_cookie_t cookie, +struct dma_tx_state *txstate) +{ +struct xgene_dma_desc_sw *desc; + +spin_lock_bh (&chan->lock); + +/* Check if this tx descriptor is still in pending queue */ +list_for_each_entry (desc, &chan->ld_pending, node) { +if (desc->tx.cookie == cookie) { +xgene_chan_xfer_ld_pending (chan);why are you calling this here, status check shouldnt do this...
Review
Quoted 2 lines
(quoted diff) +2
-0+ spin_unlock_bh(&chan->lock); + return DMA_IN_PROGRESS;residue here is size of transacation.
drivers/dma/xgene-dma.c line 1301
Quoted 8 lines
drivers/dma/xgene-dma.c new file +8
-0+ } + } + +/* Check if this descriptor is in running queue */ +list_for_each_entry (desc, &chan->ld_running, node) { +if (desc->tx.cookie == cookie) { +/* Cleanup any running and executed descriptors */ +xgene_dma_cleanup_descriptors (chan);ditto?
drivers/dma/xgene-dma.c line 1304
Quoted 3 lines
drivers/dma/xgene-dma.c new file +3
-0+spin_unlock_bh (&chan->lock); +return dma_cookie_status (&chan->dma_chan, + cookie, txstate);and you havent touched txstate so what is the intent here...?
Quoted 11 lines
drivers/dma/xgene-dma.c new file +11
-0+ } + } + +spin_unlock_bh (&chan->lock); + +return DMA_COMPLETE ; +} + +static enum dma_status xgene_dma_tx_status (struct dma_chan *dchan, +dma_cookie_t cookie, +struct dma_tx_state *txstate)
Quoted 8 lines
drivers/dma/xgene-dma.c line 1322
Quoted 7 lines
drivers/dma/xgene-dma.c new file +7
-0+{ +struct xgene_dma_chan *chan =to_dma_chan (dchan); + +enum dma_status status; + + status =dma_cookie_status (dchan, cookie, txstate); +if (status ==DMA_COMPLETE )you should do this if txstate in NULL, no point doing calculations..
I didn't get you here. Can you explain me.
Quoted 66 lines
Quoted 22 lines
drivers/dma/xgene-dma.c new file +21
-0+return status; + +return xgene_dma_find_tx_desc_status (chan, cookie, txstate); +} + +static void xgene_dma_tasklet_cb (unsigned long data) +{ +struct xgene_dma_chan *chan = (struct xgene_dma_chan *)data; + +spin_lock_bh (&chan->lock); + +/* Run all cleanup for descriptors which have been completed */ +xgene_dma_cleanup_descriptors (chan); + +/* Re-enable DMA channel IRQ */ +enable_irq (chan->rx_irq); + +spin_unlock_bh (&chan->lock); +} + +static irqreturn_t xgene_dma_chan_ring_isr (int irq,void *id)drivers/dma/xgene-dma.c line 1353
Quoted 10 lines
drivers/dma/xgene-dma.c new file +10
-0+{ +struct xgene_dma_chan *chan = (struct xgene_dma_chan *)id; + +BUG_ON (!chan); + +/* +* Disable DMA channel IRQ until we process completed +* descriptors +*/ +disable_irq_nosync (chan->rx_irq);and why is that?
drivers/dma/xgene-dma.c line 1360
Quoted 7 lines
drivers/dma/xgene-dma.c new file +7
-0+ +/* +* Schedule the tasklet to handle all cleanup of the current +* transaction. It will start a new transaction if there is +* one pending. +*/ +tasklet_schedule (&chan->tasklet);for better results why not schedule the next transaction here..?
drivers/dma/xgene-dma.c line 1927
Quoted 11 lines
drivers/dma/xgene-dma.c new file +10
-0+ +return IRQ_HANDLED ; +} + +static void xgene_dma_async_unregister (struct xgene_dma *pdma) +{ +int i; + +for (i =0 ; i <DMA_MAX_CHANNEL ; i++) +dma_async_device_unregister (&pdma->dma_dev[i]);how do you ensure irq is disabled and tasklets killed?
drivers/dma/xgene-dma.c line 2156
Quoted 5 lines
drivers/dma/xgene-dma.c new file +5
-0+MODULE_DESCRIPTION ("APM X-Gene SoC DMA driver" ); +MODULE_AUTHOR ("Rameshwar Prasad Sahu <[email protected]>" ); +MODULE_AUTHOR ("Loc Ho <[email protected]>" ); +MODULE_LICENSE ("GPL" ); +MODULE_VERSION ("1.0" );why do you need this?
Quoted 3 lines
--
1.8.2.1--
PATCH v7 2/3 arm64: dts: Add APM X-Gene DMA device and DMA clock DTS nodes
In reply to Rameshwar Prasad SahuThis patch adds the device tree node for APM X-Gene SoC DMA controller and DMA clock.
--- arch/arm64/boot/dts/apm/apm-storm.dtsi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm64/boot/dts/apm/apm-storm.dtsi +26 -0
@@ -102,6 +102,7 @@ #address-cells = <2>; #size-cells = <2>; ranges; + dma-ranges = <0x0 0x0 0x0 0x0 0x400 0x0>; clocks { #address-cells = <2>;
@@ -352,6 +353,15 @@ reg-names = "csr-reg"; clock-output-names = "pcie4clk"; }; + + dmaclk: dmaclk at 1f27c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + reg = <0x0 0x1f27c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "dmaclk"; + }; }; pcie0: pcie at 1f2b0000 {
@@ -656,5 +666,21 @@ interrupts = <0x0 0x41 0x4>; clocks = <&rngpkaclk 0>; }; + + dma: dma at 1f270000 { + compatible = "apm,xgene-storm-dma"; + device_type = "dma"; + reg = <0x0 0x1f270000 0x0 0x10000>, + <0x0 0x1f200000 0x0 0x10000>, + <0x0 0x1b008000 0x0 0x2000>, + <0x0 0x1054a000 0x0 0x100>; + interrupts = <0x0 0x82 0x4>, + <0x0 0xb8 0x4>, + <0x0 0xb9 0x4>, + <0x0 0xba 0x4>, + <0x0 0xbb 0x4>; + dma-coherent; + clocks = <&dmaclk 0>; + }; }; };
--
1.8.2.1
PATCH v7 3/3 Documentation: dma: Add APM X-Gene SoC DMA engine driver documentation
In reply to Rameshwar Prasad SahuThis patch adds device tree binding for APM X-Gene SoC DMA engine driver.
--- .../devicetree/bindings/dma/apm-xgene-dma.txt | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/apm-xgene-dma.txt
Documentation/devicetree/bindings/dma/apm-xgene-dma.txt new file +47 -0
@@ -0,0 +1,47 @@ +Applied Micro X-Gene SoC DMA nodes + +DMA nodes are defined to describe on-chip DMA interfaces in +APM X-Gene SoC. + +Required properties for DMA interfaces: +- compatible: Should be "apm,xgene-dma". +- device_type: set to "dma". +- reg: Address and length of the register set for the device. + It contains the information of registers in the following order: + 1st - DMA control and status register address space. + 2nd - Descriptor ring control and status register address space. + 3rd - Descriptor ring command register address space. + 4th - Soc efuse register address space. +- interrupts: DMA has 5 interrupts sources. 1st interrupt is + DMA error reporting interrupt. 2nd, 3rd, 4th and 5th interrupts + are completion interrupts for each DMA channels. +- clocks: Reference to the clock entry. + +Optional properties: +- dma-coherent : Present if dma operations are coherent + +Example: + dmaclk: dmaclk at 1f27c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + reg = <0x0 0x1f27c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "dmaclk"; + }; + + dma: dma at 1f270000 { + compatible = "apm,xgene-storm-dma"; + device_type = "dma"; + reg = <0x0 0x1f270000 0x0 0x10000>, + <0x0 0x1f200000 0x0 0x10000>, + <0x0 0x1b008000 0x0 0x2000>, + <0x0 0x1054a000 0x0 0x100>; + interrupts = <0x0 0x82 0x4>, + <0x0 0xb8 0x4>, + <0x0 0xb9 0x4>, + <0x0 0xba 0x4>, + <0x0 0xbb 0x4>; + dma-coherent; + clocks = <&dmaclk 0>; + };
--
1.8.2.1
Re: [PATCH v7 3/3] Documentation: dma: Add APM X-Gene SoC DMA engine driver documentation
Quoted 1 line · Rameshwar Prasad Sahu
This patch adds device tree binding for APM X-Gene SoC DMA engine driver.
The patch title should be to add the bindings and not Documentation
Signature · 1 line
~Vinod
Quoted 64 lines
Signed-off-by Rameshwar Prasad Sahu <[email protected]>Signed-off-by Loc Ho <[email protected]>--- .../devicetree/bindings/dma/apm-xgene-dma.txt | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/apm-xgene-dma.txtDocumentation/devicetree/bindings/dma/apm-xgene-dma.txt new file +47
-1@@ -0,0 +1,47 @@ +Applied Micro X-Gene SoC DMA nodes + +DMA nodes are defined to describe on-chip DMA interfaces in +APM X-Gene SoC. + +Required properties for DMA interfaces: +- compatible: Should be "apm,xgene-dma". +- device_type: set to "dma". +- reg: Address and length of the register set for the device. + It contains the information of registers in the following order: + 1st - DMA control and status register address space. + 2nd - Descriptor ring control and status register address space. + 3rd - Descriptor ring command register address space. + 4th - Soc efuse register address space. +- interrupts: DMA has 5 interrupts sources. 1st interrupt is + DMA error reporting interrupt. 2nd, 3rd, 4th and 5th interrupts + are completion interrupts for each DMA channels. +- clocks: Reference to the clock entry. + +Optional properties: +- dma-coherent : Present if dma operations are coherent + +Example: + dmaclk: dmaclk at 1f27c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + reg = <0x0 0x1f27c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "dmaclk"; + }; + + dma: dma at 1f270000 { + compatible = "apm,xgene-storm-dma"; + device_type = "dma"; + reg = <0x0 0x1f270000 0x0 0x10000>, + <0x0 0x1f200000 0x0 0x10000>, + <0x0 0x1b008000 0x0 0x2000>, + <0x0 0x1054a000 0x0 0x100>; + interrupts = <0x0 0x82 0x4>, + <0x0 0xb8 0x4>, + <0x0 0xb9 0x4>, + <0x0 0xba 0x4>, + <0x0 0xbb 0x4>; + dma-coherent; + clocks = <&dmaclk 0>; + }; --1.8.2.1
Re: [PATCH v7 3/3] Documentation: dma: Add APM X-Gene SoC DMA engine driver documentation
Hi Vinod,
Quoted 3 lines · Vinod Koul
Quoted 1 line · Rameshwar Prasad Sahu
This patch adds device tree binding for APM X-Gene SoC DMA engine driver.
The patch title should be to add the bindings and not Documentation
Got it, thanks
Quoted 69 lines
--
~VinodQuoted 62 lines
Signed-off-by Rameshwar Prasad Sahu <[email protected]>Signed-off-by Loc Ho <[email protected]>--- .../devicetree/bindings/dma/apm-xgene-dma.txt | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/apm-xgene-dma.txtDocumentation/devicetree/bindings/dma/apm-xgene-dma.txt new file +47
-1@@ -0,0 +1,47 @@ +Applied Micro X-Gene SoC DMA nodes + +DMA nodes are defined to describe on-chip DMA interfaces in +APM X-Gene SoC. + +Required properties for DMA interfaces: +- compatible: Should be "apm,xgene-dma". +- device_type: set to "dma". +- reg: Address and length of the register set for the device. + It contains the information of registers in the following order: + 1st - DMA control and status register address space. + 2nd - Descriptor ring control and status register address space. + 3rd - Descriptor ring command register address space. + 4th - Soc efuse register address space. +- interrupts: DMA has 5 interrupts sources. 1st interrupt is + DMA error reporting interrupt. 2nd, 3rd, 4th and 5th interrupts + are completion interrupts for each DMA channels. +- clocks: Reference to the clock entry. + +Optional properties: +- dma-coherent : Present if dma operations are coherent + +Example: + dmaclk: dmaclk at 1f27c000 { + compatible = "apm,xgene-device-clock"; + #clock-cells = <1>; + clocks = <&socplldiv2 0>; + reg = <0x0 0x1f27c000 0x0 0x1000>; + reg-names = "csr-reg"; + clock-output-names = "dmaclk"; + }; + + dma: dma at 1f270000 { + compatible = "apm,xgene-storm-dma"; + device_type = "dma"; + reg = <0x0 0x1f270000 0x0 0x10000>, + <0x0 0x1f200000 0x0 0x10000>, + <0x0 0x1b008000 0x0 0x2000>, + <0x0 0x1054a000 0x0 0x100>; + interrupts = <0x0 0x82 0x4>, + <0x0 0xb8 0x4>, + <0x0 0xb9 0x4>, + <0x0 0xba 0x4>, + <0x0 0xbb 0x4>; + dma-coherent; + clocks = <&dmaclk 0>; + }; --Quoted 2 lines
1.8.2.1
--