All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: mxs: Handle i2c DMA failure properly
@ 2012-11-14 14:31 Marek Vasut
       [not found] ` <1352903508-18113-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2012-11-14 14:31 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: Marek Vasut, Fabio Estevam, Tim Michals, Wolfram Sang

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.

Signed-off-by: Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
Cc: Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Tim Michals <tcmichals-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Wolfram Sang <w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/i2c/busses/i2c-mxs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 286ca19..6ed53da 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -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)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: mxs: Handle i2c DMA failure properly
       [not found] ` <1352903508-18113-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
@ 2012-11-14 15:13   ` Fabio Estevam
       [not found]     ` <CAOMZO5AVDXeu59ZwB35k_0yYx5XwTzdmtj+QXXEoQRMs7Br-KA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Fabio Estevam @ 2012-11-14 15:13 UTC (permalink / raw)
  To: Marek Vasut; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Tim Michals, Wolfram Sang

Hi Marek,

On Wed, Nov 14, 2012 at 12:31 PM, Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: mxs: Handle i2c DMA failure properly
       [not found]     ` <CAOMZO5AVDXeu59ZwB35k_0yYx5XwTzdmtj+QXXEoQRMs7Br-KA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-11-14 15:22       ` Marek Vasut
       [not found]         ` <CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA@mail.gmail.com>
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2012-11-14 15:22 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Tim Michals, Wolfram Sang

Dear Fabio Estevam,

> Hi Marek,
> 
> On Wed, Nov 14, 2012 at 12:31 PM, Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> wrote:
> > 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 ...

> Regards,
> 
> Fabio Estevam

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: mxs: Handle i2c DMA failure properly
       [not found]           ` <CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-11-15  4:01             ` Marek Vasut
  2012-11-16 14:16             ` Wolfram Sang
  1 sibling, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2012-11-15  4:01 UTC (permalink / raw)
  To: Tim Michals; +Cc: Fabio Estevam, linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang

Dear Tim Michals,

> On Wed, Nov 14, 2012 at 9:22 AM, Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> wrote:
> > Dear Fabio Estevam,
> > 
> > > Hi Marek,
> > > 
> > > On Wed, Nov 14, 2012 at 12:31 PM, Marek Vasut <marex-ynQEQJNshbs@public.gmane.org> wrote:
> > > > 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 ...
> > 
> > > Regards,
> > > 
> > > Fabio Estevam
> > 
> > Best regards,
> > Marek Vasut
>
> Dear Marek Vasut,
> 
> 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.

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: mxs: Handle i2c DMA failure properly
       [not found]           ` <CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2012-11-15  4:01             ` Marek Vasut
@ 2012-11-16 14:16             ` Wolfram Sang
       [not found]               ` <CANqk_c8xocNsdbj+FFowPjjj_7vWuZ3OEurRHc+fFF-=pYRu0w@mail.gmail.com>
  1 sibling, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2012-11-16 14:16 UTC (permalink / raw)
  To: Tim Michals; +Cc: Marek Vasut, Fabio Estevam, linux-i2c-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 854 bytes --]

Tim,

On Wed, Nov 14, 2012 at 09:34:27PM -0600, Tim Michals wrote:
>    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

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] i2c: mxs: Handle i2c DMA failure properly
       [not found]                 ` <CANqk_c8xocNsdbj+FFowPjjj_7vWuZ3OEurRHc+fFF-=pYRu0w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2012-11-16 15:29                   ` Fabio Estevam
  0 siblings, 0 replies; 6+ messages in thread
From: Fabio Estevam @ 2012-11-16 15:29 UTC (permalink / raw)
  To: Tim Michals; +Cc: Wolfram Sang, Marek Vasut, linux-i2c

Hi Tim,

On Fri, Nov 16, 2012 at 1:24 PM, Tim Michals <tcmichals-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-11-16 15:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 14:31 [PATCH] i2c: mxs: Handle i2c DMA failure properly Marek Vasut
     [not found] ` <1352903508-18113-1-git-send-email-marex-ynQEQJNshbs@public.gmane.org>
2012-11-14 15:13   ` Fabio Estevam
     [not found]     ` <CAOMZO5AVDXeu59ZwB35k_0yYx5XwTzdmtj+QXXEoQRMs7Br-KA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-14 15:22       ` Marek Vasut
     [not found]         ` <CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA@mail.gmail.com>
     [not found]           ` <CANqk_c-f3+a=f1QqWFxEpGcMQRqMD61eHiXNLyfzciJkzPGMRA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-15  4:01             ` Marek Vasut
2012-11-16 14:16             ` Wolfram Sang
     [not found]               ` <CANqk_c8xocNsdbj+FFowPjjj_7vWuZ3OEurRHc+fFF-=pYRu0w@mail.gmail.com>
     [not found]                 ` <CANqk_c8xocNsdbj+FFowPjjj_7vWuZ3OEurRHc+fFF-=pYRu0w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-11-16 15:29                   ` Fabio Estevam

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.