Skip to contentSkip to conversation

DMA: fsldma: Disable DMA_INTERRUPT when Async_tx enabled

PATCH In review Vishnu Suresh 5 participants 8 messages Oct 15, 2009 – Nov 3, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 DMA: fsldma: Disable DMA_INTERRUPT when Async_tx enabled

This patch disables the use of DMA_INTERRUPT capability with Async_tx

The fsldma produces a null transfer with DMA_INTERRUPT capability when used with Async_tx. When RAID devices queue a transaction via Async_tx, this results in a hang.

---
 drivers/dma/fsldma.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/dma/fsldma.c +6 -0
index 296f9e7..66d9b39 100644
@@ -1200,7 +1200,13 @@ static int __devinit of_fsl_dma_probe(struct of_device *dev,
 						- fdev->reg.start + 1);
 
 	dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask);
+#ifndef CONFIG_ASYNC_CORE
+	/*
+	 * The DMA_INTERRUPT async_tx is a NULL transfer, which will
+	 * triger a PE interrupt.
+	 */
 	dma_cap_set(DMA_INTERRUPT, fdev->common.cap_mask);
+#endif
 	dma_cap_set(DMA_SLAVE, fdev->common.cap_mask);
 	fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources;
 	fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources;
Signature · 1 line
1.6.4.2
#1 lore raw

PATCH 2/2 Crypto: Talitos: Support for Async_tx XOR offload

Expose Talitos's XOR functionality to be used for RAID Parity calculation via the Async_tx layer.

Thanks to Surender Kumar and Lee Nipper for their help in realising this driver

---
 drivers/crypto/Kconfig   |    2 +
 drivers/crypto/talitos.c |  423 +++++++++++++++++++++++++++++++++++++++++++++-
 drivers/crypto/talitos.h |    2 +
 3 files changed, 426 insertions(+), 1 deletions(-)
drivers/crypto/Kconfig +2 -0
index b08403d..343e578 100644
@@ -192,6 +192,8 @@ config CRYPTO_DEV_TALITOS
 	select CRYPTO_ALGAPI
 	select CRYPTO_AUTHENC
 	select HW_RANDOM
+	select DMA_ENGINE
+	select ASYNC_XOR
 	depends on FSL_SOC
 	help
 	  Say 'Y' here to use the Freescale Security Engine (SEC)
drivers/crypto/talitos.c +422 -1

459 lines not on this page · raw message

drivers/crypto/talitos.h +2 -0
index ff5a145..b6197bc 100644
@@ -155,6 +155,7 @@
 /* primary execution unit mode (MODE0) and derivatives */
 #define	DESC_HDR_MODE0_ENCRYPT		cpu_to_be32(0x00100000)
 #define	DESC_HDR_MODE0_AESU_CBC		cpu_to_be32(0x00200000)
+#define	DESC_HDR_MODE0_AESU_XOR		cpu_to_be32(0x0c600000)
 #define	DESC_HDR_MODE0_DEU_CBC		cpu_to_be32(0x00400000)
 #define	DESC_HDR_MODE0_DEU_3DES		cpu_to_be32(0x00200000)
 #define	DESC_HDR_MODE0_MDEU_INIT	cpu_to_be32(0x01000000)
@@ -202,6 +203,7 @@
 #define DESC_HDR_TYPE_IPSEC_ESP			cpu_to_be32(1 << 3)
 #define DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU	cpu_to_be32(2 << 3)
 #define DESC_HDR_TYPE_HMAC_SNOOP_NO_AFEU	cpu_to_be32(4 << 3)
+#define DESC_HDR_TYPE_RAID_XOR			cpu_to_be32(21 << 3)
 
 /* link table extent field bits */
 #define DESC_PTR_LNKTBL_JUMP			0x80
Signature · 1 line
1.6.4.2
#2 lore raw

Re: [PATCH v0 2/2] Crypto: Talitos: Support for Async_tx XOR offload

On Wed, Oct 14, 2009 at 11:41 PM, Vishnu Suresh <[email protected]> wrote:
[..]

Quoted 10 lines
drivers/crypto/Kconfig +0 -0
index b08403d..343e578 100644
@@ -192,6 +192,8 @@ config CRYPTO_DEV_TALITOS

       select CRYPTO_ALGAPI
       select CRYPTO_AUTHENC
       select HW_RANDOM
+       select DMA_ENGINE
+       select ASYNC_XOR

You need only select DMA_ENGINE. ASYNC_XOR is selected by its users.

Quoted 7 lines

       depends on FSL_SOC
       help
         Say 'Y' here to use the Freescale Security Engine (SEC)

drivers/crypto/talitos.c +0 -0
index c47ffe8..84819d4 100644

[..]

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+static void talitos_process_pending(struct talitos_xor_chan *xor_chan)
+{
+       struct talitos_xor_desc *desc, *_desc;
+       unsigned long flags;
+       int status;
+
+       spin_lock_irqsave(&xor_chan->desc_lock, flags);
+
+       list_for_each_entry_safe(desc, _desc, &xor_chan->pending_q, node) {
+               status = talitos_submit(xor_chan->dev, &desc->hwdesc,

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 782

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+                                       talitos_release_xor, desc);
+               if (status != -EINPROGRESS)
+                       break;
+
+               list_del(&desc->node);
+               list_add_tail(&desc->node, &xor_chan->in_progress_q);
+       }
+
+       spin_unlock_irqrestore(&xor_chan->desc_lock, flags);
+}

The driver uses spin_lock_bh everywhere else which is either a bug, or this code is being overly protective. In any event lockdep will rightly complain about this. The API and its users do not submit operations in hard-irq context.

Quoted 18 lines
drivers/crypto/talitos.c +18 -0
+
+static void talitos_release_xor(struct device *dev, struct talitos_desc *hwdesc,
+                               void *context, int error)
+{
+       struct talitos_xor_desc *desc = context;
+       struct talitos_xor_chan *xor_chan;
+       dma_async_tx_callback callback;
+       void *callback_param;
+
+       if (unlikely(error)) {
+               dev_err(dev, "xor operation: talitos error %d\n", error);
+               BUG();
+       }
+
+       xor_chan = container_of(desc->async_tx.chan, struct talitos_xor_chan,
+                               common);
+       spin_lock_bh(&xor_chan->desc_lock);
+       if (xor_chan->completed_cookie < desc->async_tx.cookie)

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 810

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+               xor_chan->completed_cookie = desc->async_tx.cookie;
+
+       callback = desc->async_tx.callback;
+       callback_param = desc->async_tx.callback_param;
+
+       if (callback) {
+               spin_unlock_bh(&xor_chan->desc_lock);
+               callback(callback_param);
+               spin_lock_bh(&xor_chan->desc_lock);
+       }

You do not need to unlock to call the callback. Users of the API assume that they are called in bh context and that they are not allowed to submit new operations directly from the callback (this simplifies the descriptor cleanup routines in other drivers).

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 817

Quoted 7 lines
drivers/crypto/talitos.c +7 -0
+
+       list_del(&desc->node);
+       list_add_tail(&desc->node, &xor_chan->free_desc);
+       spin_unlock_bh(&xor_chan->desc_lock);
+       if (!list_empty(&xor_chan->pending_q))
+               talitos_process_pending(xor_chan);
+}

It appears this routine is missing a call to dma_run_dependencies()? This is needed if another channel is handling memory copy offload. I assume this is the case due to your other patch to fsldma. See iop_adma_run_tx_complete_actions(). If this xor resource can also handle copy operations that would be more efficient as it eliminates channel switching. See the ioatdma driver and its use of ASYNC_TX_DISABLE_CHANNEL_SWITCH.

Quoted 22 lines
drivers/crypto/talitos.c +22 -0
+static struct dma_async_tx_descriptor * talitos_prep_dma_xor(
+                       struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
+                       unsigned int src_cnt, size_t len, unsigned long flags)
+{
+       struct talitos_xor_chan *xor_chan;
+       struct talitos_xor_desc *new;
+       struct talitos_desc *desc;
+       int i, j;
+
+       BUG_ON(unlikely(len > TALITOS_MAX_DATA_LEN));
+
+       xor_chan = container_of(chan, struct talitos_xor_chan, common);
+
+       spin_lock_bh(&xor_chan->desc_lock);
+       if (!list_empty(&xor_chan->free_desc)) {
+               new = container_of(xor_chan->free_desc.next,
+                                  struct talitos_xor_desc, node);
+               list_del(&new->node);
+       } else {
+               new = talitos_xor_alloc_descriptor(xor_chan, GFP_KERNEL);
+       }
+       spin_unlock_bh(&xor_chan->desc_lock);

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 975

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+
+       if (!new) {
+               dev_err(xor_chan->common.device->dev,
+                       "No free memory for XOR DMA descriptor\n");
+               return NULL;
+       }
+       dma_async_tx_descriptor_init(&new->async_tx, &xor_chan->common);
+
+       INIT_LIST_HEAD(&new->node);
+       INIT_LIST_HEAD(&new->tx_list);

You can save some overhead in the fast path by moving this initialization to talitos_xor_alloc_descriptor.

Quoted 20 lines
drivers/crypto/talitos.c +20 -0
+
+       desc = &new->hwdesc;
+       /* Set destination: Last pointer pair */
+       to_talitos_ptr(&desc->ptr[6], dest);
+       desc->ptr[6].len = cpu_to_be16(len);
+       desc->ptr[6].j_extent = 0;
+
+       /* Set Sources: End loading from second-last pointer pair */
+       for (i = 5, j = 0; (j < src_cnt) && (i > 0); i--, j++) {
+               to_talitos_ptr(&desc->ptr[i], src[j]);
+               desc->ptr[i].len = cpu_to_be16(len);
+               desc->ptr[i].j_extent = 0;
+       }
+
+       /*
+        * documentation states first 0 ptr/len combo marks end of sources
+        * yet device produces scatter boundary error unless all subsequent
+        * sources are zeroed out
+        */
+       for (; i >= 0; i--) {

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 1005

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+               to_talitos_ptr(&desc->ptr[i], 0);
+               desc->ptr[i].len = 0;
+               desc->ptr[i].j_extent = 0;
+       }
+
+       desc->hdr = DESC_HDR_SEL0_AESU | DESC_HDR_MODE0_AESU_XOR
+                   | DESC_HDR_TYPE_RAID_XOR;
+
+       new->async_tx.parent = NULL;
+       new->async_tx.next = NULL;

These fields are managed by the async_tx channel switch code. No need to manage it here.

Quoted 1 line

+       new->async_tx.cookie = 0;

This is set below to -EBUSY, it's redundant to touch it here.

Quoted 1 line

+       async_tx_ack(&new->async_tx);

This makes it impossible to attach a dependency to this operation. Not sure this is what you want.

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Re: [PATCH v0 2/2] Crypto: Talitos: Support for Async_tx XOR offload

I have tested this patch on my MPC8548 machine box, kernel version is 2.6.30. There is a problem.
#mdadm -C /dev/md0 -l5 -n3 /dev/sd{a,b,c}
Recovery can be done successfully, interrupts looks normal.

# cat /proc/interrupts
           CPU0
 16:   16091057   OpenPIC   Level     mvSata
 17:          0   OpenPIC   Level     mvSata
 18:          4   OpenPIC   Level     phy_interrupt, phy_interrupt
 20:         39   OpenPIC   Level     fsldma-channel
 21:          0   OpenPIC   Level     fsldma-channel
 22:          0   OpenPIC   Level     fsldma-channel
 23:          0   OpenPIC   Level     fsldma-channel
 29:        241   OpenPIC   Level     eth0_tx
 30:    1004692   OpenPIC   Level     eth0_rx
 34:          0   OpenPIC   Level     eth0_er
 35:          0   OpenPIC   Level     eth1_tx
 36:          0   OpenPIC   Level     eth1_rx
 40:          0   OpenPIC   Level     eth1_er
 42:      73060   OpenPIC   Level     serial
 43:       9854   OpenPIC   Level     i2c-mpc, i2c-mpc
 45:   61264188   OpenPIC   Level     talitos
BAD:          0

Then, I plan to create a VG, but problem occured.
#pvcreate /dev/md0

After I input this command, system hangs there without any messages.

BTW, all is OK before using this patch.

2009/10/30 Dan Williams <[email protected]>:

Quoted 185 lines · Vishnu Suresh

[..]

Quoted 10 lines
drivers/crypto/Kconfig +0 -0
index b08403d..343e578 100644
@@ -192,6 +192,8 @@ config CRYPTO_DEV_TALITOS

       select CRYPTO_ALGAPI
       select CRYPTO_AUTHENC
       select HW_RANDOM
+       select DMA_ENGINE
+       select ASYNC_XOR

You need only select DMA_ENGINE.  ASYNC_XOR is selected by its users.

Quoted 7 lines

       depends on FSL_SOC
       help
         Say 'Y' here to use the Freescale Security Engine (SEC)

drivers/crypto/talitos.c +0 -0
index c47ffe8..84819d4 100644

[..]

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+static void talitos_process_pending(struct talitos_xor_chan *xor_chan)
+{
+       struct talitos_xor_desc *desc, *_desc;
+       unsigned long flags;
+       int status;
+
+       spin_lock_irqsave(&xor_chan->desc_lock, flags);
+
+       list_for_each_entry_safe(desc, _desc, &xor_chan->pending_q, node) {
+               status = talitos_submit(xor_chan->dev, &desc->hwdesc,

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 782

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+                                       talitos_release_xor, desc);
+               if (status != -EINPROGRESS)
+                       break;
+
+               list_del(&desc->node);
+               list_add_tail(&desc->node, &xor_chan->in_progress_q);
+       }
+
+       spin_unlock_irqrestore(&xor_chan->desc_lock, flags);
+}

The driver uses spin_lock_bh everywhere else which is either a bug, or this code is being overly protective.  In any event lockdep will rightly complain about this.  The API and its users do not submit operations in hard-irq context.

Quoted 18 lines
drivers/crypto/talitos.c +18 -0
+
+static void talitos_release_xor(struct device *dev, struct talitos_desc *hwdesc,
+                               void *context, int error)
+{
+       struct talitos_xor_desc *desc = context;
+       struct talitos_xor_chan *xor_chan;
+       dma_async_tx_callback callback;
+       void *callback_param;
+
+       if (unlikely(error)) {
+               dev_err(dev, "xor operation: talitos error %d\n", error);
+               BUG();
+       }
+
+       xor_chan = container_of(desc->async_tx.chan, struct talitos_xor_chan,
+                               common);
+       spin_lock_bh(&xor_chan->desc_lock);
+       if (xor_chan->completed_cookie < desc->async_tx.cookie)

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 810

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+               xor_chan->completed_cookie = desc->async_tx.cookie;
+
+       callback = desc->async_tx.callback;
+       callback_param = desc->async_tx.callback_param;
+
+       if (callback) {
+               spin_unlock_bh(&xor_chan->desc_lock);
+               callback(callback_param);
+               spin_lock_bh(&xor_chan->desc_lock);
+       }

You do not need to unlock to call the callback.  Users of the API assume that they are called in bh context and that they are not allowed to submit new operations directly from the callback (this simplifies the descriptor cleanup routines in other drivers).

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 817

Quoted 7 lines
drivers/crypto/talitos.c +7 -0
+
+       list_del(&desc->node);
+       list_add_tail(&desc->node, &xor_chan->free_desc);
+       spin_unlock_bh(&xor_chan->desc_lock);
+       if (!list_empty(&xor_chan->pending_q))
+               talitos_process_pending(xor_chan);
+}

It appears this routine is missing a call to dma_run_dependencies()? This is needed if another channel is handling memory copy offload.  I assume this is the case due to your other patch to fsldma.  See iop_adma_run_tx_complete_actions().  If this xor resource can also handle copy operations that would be more efficient as it eliminates channel switching.  See the ioatdma driver and its use of ASYNC_TX_DISABLE_CHANNEL_SWITCH.

Quoted 22 lines
drivers/crypto/talitos.c +22 -0
+static struct dma_async_tx_descriptor * talitos_prep_dma_xor(
+                       struct dma_chan *chan, dma_addr_t dest, dma_addr_t *src,
+                       unsigned int src_cnt, size_t len, unsigned long flags)
+{
+       struct talitos_xor_chan *xor_chan;
+       struct talitos_xor_desc *new;
+       struct talitos_desc *desc;
+       int i, j;
+
+       BUG_ON(unlikely(len > TALITOS_MAX_DATA_LEN));
+
+       xor_chan = container_of(chan, struct talitos_xor_chan, common);
+
+       spin_lock_bh(&xor_chan->desc_lock);
+       if (!list_empty(&xor_chan->free_desc)) {
+               new = container_of(xor_chan->free_desc.next,
+                                  struct talitos_xor_desc, node);
+               list_del(&new->node);
+       } else {
+               new = talitos_xor_alloc_descriptor(xor_chan, GFP_KERNEL);
+       }
+       spin_unlock_bh(&xor_chan->desc_lock);

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 975

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+
+       if (!new) {
+               dev_err(xor_chan->common.device->dev,
+                       "No free memory for XOR DMA descriptor\n");
+               return NULL;
+       }
+       dma_async_tx_descriptor_init(&new->async_tx, &xor_chan->common);
+
+       INIT_LIST_HEAD(&new->node);
+       INIT_LIST_HEAD(&new->tx_list);

You can save some overhead in the fast path by moving this initialization to talitos_xor_alloc_descriptor.

Quoted 20 lines
drivers/crypto/talitos.c +20 -0
+
+       desc = &new->hwdesc;
+       /* Set destination: Last pointer pair */
+       to_talitos_ptr(&desc->ptr[6], dest);
+       desc->ptr[6].len = cpu_to_be16(len);
+       desc->ptr[6].j_extent = 0;
+
+       /* Set Sources: End loading from second-last pointer pair */
+       for (i = 5, j = 0; (j < src_cnt) && (i > 0); i--, j++) {
+               to_talitos_ptr(&desc->ptr[i], src[j]);
+               desc->ptr[i].len = cpu_to_be16(len);
+               desc->ptr[i].j_extent = 0;
+       }
+
+       /*
+        * documentation states first 0 ptr/len combo marks end of sources
+        * yet device produces scatter boundary error unless all subsequent
+        * sources are zeroed out
+        */
+       for (; i >= 0; i--) {

drivers/crypto/talitos.c static void talitos_unregister_rng(struct device *dev) · line 1005

Quoted 10 lines
drivers/crypto/talitos.c +10 -0
+               to_talitos_ptr(&desc->ptr[i], 0);
+               desc->ptr[i].len = 0;
+               desc->ptr[i].j_extent = 0;
+       }
+
+       desc->hdr = DESC_HDR_SEL0_AESU | DESC_HDR_MODE0_AESU_XOR
+                   | DESC_HDR_TYPE_RAID_XOR;
+
+       new->async_tx.parent = NULL;
+       new->async_tx.next = NULL;

These fields are managed by the async_tx channel switch code.  No need to manage it here.

Quoted 1 line

+       new->async_tx.cookie = 0;

This is set below to -EBUSY, it's redundant to touch it here.

Quoted 1 line

+       async_tx_ack(&new->async_tx);

This makes it impossible to attach a dependency to this operation. Not sure this is what you want.

--
Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 5 lines
The simplest is not all best but the best is surely the simplest!
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw
In reply to Vishnu Suresh

[ added Leo and Timur to the Cc ]

Quoted 19 lines · Vishnu Suresh

This patch disables the use of DMA_INTERRUPT capability with Async_tx

The fsldma produces a null transfer with DMA_INTERRUPT capability when used with Async_tx. When RAID devices queue a transaction via Async_tx, this  results in a hang.

---
 drivers/dma/fsldma.c |    6 ++++++

 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/dma/fsldma.c +0 -0
index 296f9e7..66d9b39 100644
@@ -1200,7 +1200,13 @@ static int __devinit of_fsl_dma_probe(struct of_device *dev,
                                                - fdev->reg.start + 1);
 
        dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask);

drivers/dma/fsldma.c static int __devinit of_fsl_dma_probe(struct of_device *dev, · line 1212

Quoted 10 lines
drivers/dma/fsldma.c +6 -0
+#ifndef CONFIG_ASYNC_CORE
+       /*
+        * The DMA_INTERRUPT async_tx is a NULL transfer, which will
+        * triger a PE interrupt.
+        */
        dma_cap_set(DMA_INTERRUPT, fdev->common.cap_mask);
+#endif
        dma_cap_set(DMA_SLAVE, fdev->common.cap_mask);
        fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources;
        fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources;

You are basically saying that fsl_dma_prep_interrupt() is buggy. Can that routine be fixed rather than this piecemeal solution? If it cannot be fixed (i.e. hardware issue) then fsl_dma_prep_interrupt() should just be disabled/deleted altogether.

--
Dan

#5 lore raw
Quoted 21 lines · Dan Williams

[ added Leo and Timur to the Cc ]

Quoted 18 lines · Vishnu Suresh

This patch disables the use of DMA_INTERRUPT capability with Async_tx

The fsldma produces a null transfer with DMA_INTERRUPT capability when used with Async_tx. When RAID devices queue a transaction via Async_tx, this  results in a hang.

---
 drivers/dma/fsldma.c |    6 ++++++

 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/dma/fsldma.c +0 -0
index 296f9e7..66d9b39 100644
@@ -1200,7 +1200,13 @@ static int __devinit of_fsl_dma_probe(struct of_device *dev,
                                                - fdev->reg.start + 1);
 
Quoted 17 lines

drivers/dma/fsldma.c static int __devinit of_fsl_dma_probe(struct of_device *dev, · line 1212

Quoted 11 lines
drivers/dma/fsldma.c +6 -0
        dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask);
+#ifndef CONFIG_ASYNC_CORE
+       /*
+        * The DMA_INTERRUPT async_tx is a NULL transfer, which will
+        * triger a PE interrupt.
+        */
        dma_cap_set(DMA_INTERRUPT, fdev->common.cap_mask);
+#endif
        dma_cap_set(DMA_SLAVE, fdev->common.cap_mask);
        fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources;
        fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources;

You are basically saying that fsl_dma_prep_interrupt() is buggy. Can that routine be fixed rather than this piecemeal solution? If it cannot be fixed (i.e. hardware issue) then fsl_dma_prep_interrupt() should just be disabled/deleted altogether.

For what it's worth, I've used the following code in the recent past, without any issues. This was on an 83xx, within the last few kernel releases. I haven't tried it on the latest -rc.

Using device_prep_dma_memcpy() can trigger a callback as well, so the interrupt feature isn't strictly needed. Just attach the callback to the last memcpy operation.

static dma_cookie_t dma_async_interrupt(struct dma_chan *chan,
dma_async_tx_callback callback, void *data)

{
        struct dma_device *dev = chan->device;
        struct dma_async_tx_descriptor *tx; 

        /* Set up the DMA */
        tx = dev->device_prep_dma_interrupt(chan, DMA_PREP_INTERRUPT);
        if (!tx)
                return -ENOMEM;

        tx->callback = callback;
        tx->callback_param = data;

        return tx->tx_submit(tx);
}

Ira

#6 lore raw

active/active raid0

I'm testing an active/active setup that uses md for raid0 and was hoping for some feedback.
The basic design has a storage device that runs vladed (aoe-storage) and an aoe initiator (controller) that creates a raid0 using mdadm from the aoe devices. From there, lvm (clustered/clvm) slices out storage for sharing block devices. I don't want to concentrate on the layers above that (clustered file systems, etc) but mainly the active/active portion of this interacting with raid0 (via md not lvm) and aoe.

Some diagrams that may help in understanding...
-----
"Physical" diagram:

(export network block devices [ iscsi, aoe, etc] )

               -----------
               /        \
      active  /          \  active
  +-------------+      +-------------+
  | controller1 |      | controller2 |
  +-------------+      +-------------+
             \           /
              +---------+
                   |
            +-------------+                    +-------------+
            | aoe-storage | --- drbd raid1 --- |  secondary  |
            +-------------+                    +-------------+

-----
Layer diagram:

+-----------------+
| (net block dev) | controller1/2
+-----------------+
| lvm2 clustered  | controller1/2
+-----------------+
| md: linux-raid0 | controller1/2
+-----------------+
|  aoe initiator  | controller1/2
+-----------------+
|   aoe target    | aoe-storage
+-----------------+

My main concern is interaction with buffer cache and the consistencies of the md devices between the controllers (probably not page cache since these are block devices?). Will direct/O_DIRECT bypass this keeping the state of the data purely on the aoe-storage device? I have a test setup of this running with no issues so far connecting to the controllers that run iscsi-target (iet) in blockio mode, thus bypaassing buffer/page cache.

Any feedback is appreciated.

--
Matth

#7 lore raw
In reply to Ira W. Snyder
Quoted 55 lines

-----Original Message-----
From: Ira W. Snyder [mailto:[email protected]]
Sent: Friday, October 16, 2009 9:04 PM
To: Dan Williams
Cc: Suresh Vishnu-B05022; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Tabi Timur-B04825
Subject: Re: [PATCH v0 1/2] DMA: fsldma: Disable DMA_INTERRUPT when Async_tx enabled

Quoted 3 lines · Dan Williams

[ added Leo and Timur to the Cc ]

On Wed, Oct 14, 2009 at 11:41 PM, Vishnu Suresh

Quoted 5 lines · <[email protected]> wrote:
Quoted 5 lines

This patch disables the use of DMA_INTERRUPT capability with Async_tx

The fsldma produces a null transfer with DMA_INTERRUPT capability when used with Async_tx. When RAID devices queue a

transaction via

Quoted 7 lines
Quoted 7 lines

Async_tx, this  results in a hang.

---
 drivers/dma/fsldma.c |    6 ++++++

 1 files changed, 6 insertions(+), 0 deletions(-)
Quoted 5 lines

drivers/dma/fsldma.c static int __devinit

Quoted 5 lines
drivers/dma/fsldma.c index renamed from drivers/dma/fsldma.c +0 -0

296f9e7..66d9b39 100644

drivers/dma/fsldma.c +0 -0
@@ -1200,7 +1200,13 @@ static int __devinit 

of_fsl_dma_probe(struct

Quoted 2 lines
Quoted 2 lines
drivers/dma/fsldma.c +0 -0
 of_device *dev,

                                               -

fdev->reg.start +

Quoted 6 lines
Quoted 6 lines

1);

       dma_cap_set(DMA_MEMCPY, fdev->common.cap_mask); +#ifndef CONFIG_ASYNC_CORE
+       /*
+        * The DMA_INTERRUPT async_tx is a NULL transfer,

which will

Quoted 10 lines
Quoted 9 lines

+        * triger a PE interrupt.
+        */
       dma_cap_set(DMA_INTERRUPT, fdev->common.cap_mask); +#endif
       dma_cap_set(DMA_SLAVE, fdev->common.cap_mask); fdev->common.device_alloc_chan_resources = fsl_dma_alloc_chan_resources; fdev->common.device_free_chan_resources = fsl_dma_free_chan_resources;

Quoted 5 lines
Quoted 1 line

You are basically saying that fsl_dma_prep_interrupt() is

buggy. Can

Quoted 3 lines

that routine be fixed rather than this piecemeal solution? If it cannot be fixed (i.e. hardware issue) then fsl_dma_prep_interrupt() should just be disabled/deleted altogether.

We are working to fix this issue.

Quoted 5 lines
Quoted 1 line

For what it's worth, I've used the following code in the recent past, without any issues. This was on an 83xx, within the last few kernel releases. I haven't tried it on the latest -rc.

This works fine as long as only DMA_MEMCPY is being used.
The async_tx_channel_switch does not occur and the device_prep_dma_interrupt is not called.
However, when a DMA_XOR capable device is exposed,
which is differnet from the DMA_MEMCPY/INTERRUPT device, this path is hit.

Is it proper to schedule a dma_interrupt from the channel switch call, even when the depend_tx and tx channels correspond to different devices?

Quoted 26 lines

Using device_prep_dma_memcpy() can trigger a callback as well, so the interrupt feature isn't strictly needed. Just attach the callback to the last memcpy operation.

static dma_cookie_t dma_async_interrupt(struct dma_chan *chan,
dma_async_tx_callback
callback,

                                        void *data) {
        struct dma_device *dev = chan->device;
        struct dma_async_tx_descriptor *tx; 

        /* Set up the DMA */
        tx = dev->device_prep_dma_interrupt(chan, DMA_PREP_INTERRUPT);
        if (!tx)
                return -ENOMEM;

        tx->callback = callback;
        tx->callback_param = data;

        return tx->tx_submit(tx);
}

Ira