i2c: mxs: Handle i2c DMA failure properly
Subsystems (2)
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.
--- drivers/i2c/busses/i2c-mxs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-mxs.c +3 -1
@@ -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
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
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
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 VasutDear Marek Vasut,
Quoted 8 lines
This patch
@@ -150,8 +150,6 @@ static void mxs_i2c_reset(structmxs_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
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/ |
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