Skip to contentSkip to conversation

i2c: mxs: Handle i2c DMA failure properly

PATCH In review Marek Vasut 3 participants 6 messages Nov 14, 2012 – Nov 16, 2012 6 messages not in the archive

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

PATCH 1/1 i2c: mxs: Handle i2c DMA failure properly

Properly terminate the DMA transfer in case the DMA PIO transfer or setup fails for any reason. While at it, enable support for SMBUS_QUICK. This essentially fixes i2c-detect on this IP.

Cc Fabio Estevam <[email protected]>
Cc Tim Michals <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/i2c/busses/i2c-mxs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-mxs.c +3 -1
index 286ca19..6ed53da 100644
@@ -287,12 +287,14 @@ read_init_dma_fail:
 select_init_dma_fail:
 	dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE);
 select_init_pio_fail:
+	dmaengine_terminate_all(i2c->dmach);
 	return -EINVAL;
 
 /* Write failpath. */
 write_init_dma_fail:
 	dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE);
 write_init_pio_fail:
+	dmaengine_terminate_all(i2c->dmach);
 	return -EINVAL;
 }
 
@@ -357,7 +359,7 @@ static int mxs_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
 
 static u32 mxs_i2c_func(struct i2c_adapter *adap)
 {
-	return I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK);
+	return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
 }
 
 static irqreturn_t mxs_i2c_isr(int this_irq, void *dev_id)
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1352903508-18113-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org

#2 lore raw

Hi Marek,

Quoted 3 lines · Marek Vasut

Properly terminate the DMA transfer in case the DMA PIO transfer or setup fails for any reason. While at it, enable support for SMBUS_QUICK. This essentially fixes i2c-detect on this IP.

Shouldn't this be split into two patches?

Regards,

Fabio Estevam

A message that is not in the archive (sent off-list or not yet received): CAOMZO5AVDXeu59ZwB35k_0yYx5XwTzdmtj+QXXEoQRMs7Br-KA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw

Dear Fabio Estevam,

Quoted 8 lines

Hi Marek,

Quoted 3 lines · Marek Vasut

Properly terminate the DMA transfer in case the DMA PIO transfer or setup fails for any reason. While at it, enable support for SMBUS_QUICK. This essentially fixes i2c-detect on this IP.

Shouldn't this be split into two patches?

It should, but then it fixes one problem, so I stuck it into one ...

Quoted 3 lines

Regards,

Fabio Estevam

Best regards,
Marek Vasut

A message that is not in the archive (sent off-list or not yet received): CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#7 lore raw

Dear Tim Michals,

Quoted 23 lines · Marek Vasut
Quoted 11 lines

Dear Fabio Estevam,

Quoted 8 lines

Hi Marek,

Quoted 3 lines · Marek Vasut

Properly terminate the DMA transfer in case the DMA PIO transfer or setup fails for any reason. While at it, enable support for SMBUS_QUICK. This essentially fixes i2c-detect on this IP.

Shouldn't this be split into two patches?

Quoted 8 lines

It should, but then it fixes one problem, so I stuck it into one ...

Quoted 3 lines

Regards,

Fabio Estevam

Best regards,
Marek Vasut

Dear Marek Vasut,

Quoted 8 lines

This patch
@@ -150,8 +150,6 @@ static void mxs_i2c_reset(struct mxs_i2c
writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2);

writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
-
- dmaengine_terminate_all(i2c->dmach);
}

This patch doesn't apply, can you elaborate ?

Moreover ... read either RFC1855 properly [1] and/or read the mailing list etiquette please (!). Especially the part about top-posting. Do us a favor.

Quoted 4 lines

This patch fixes current DMA requests which time out or error returned by the ISR.

Tim

[1] http://www.ietf.org/rfc/rfc1855.txt

Best regards,
Marek Vasut

#8 lore raw
In reply to a message not in the archive

Tim,

Quoted 11 lines · Tim Michals
   This patch
   �@@ -150,8 +150,6 @@ static void mxs_i2c_reset(struct mxs_i2c
   �       writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2);
   �
   �       writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
   -
   -       dmaengine_terminate_all(i2c->dmach);
   �}��
   This patch fixes current DMA requests which time out or error returned by
   the ISR.�
   Tim

Please elaborate because I am confused. Did you see problems after applying Marek's patch and if so, please describe in what circumstances so we could reproduce.

Thanks,

Wolfram

Signature · 2 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

A message that is not in the archive (sent off-list or not yet received): CANqk_c8xocNsdbj+FFowPjjj_7vWuZ3OEurRHc+fFF-=pYRu0w@mail.gmail.com

A message that is not in the archive (sent off-list or not yet received): CANqk_c8xocNsdbj+FFowPjjj_7vWuZ3OEurRHc+fFF-=pYRu0w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Hi Tim,

Quoted 4 lines · Tim Michals

My suggestion was to always clear the DMA in the reset i2c code. This way if there is an error reported from the ISR or a timeout, it always clears it. I've tested this approach with I2C devices connected and and doing a i2cdetect -r 0.

Thanks for the explanation.

Maybe you could post your proposed patch?

Thanks,

Fabio Estevam