Skip to contentSkip to conversation

I2C: Set I2C timing registers for mxs-i2c

PATCH New Marek Vasut 4 participants 22 messages Apr 29, 2012 – May 1, 2012

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

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Cc Linux I2C <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 drivers/i2c/busses/i2c-mxs.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/i2c/busses/i2c-mxs.c +10 -0
index 3d471d5..0d8e485 100644
@@ -43,6 +43,10 @@
 #define MXS_I2C_CTRL0_DIRECTION			0x00010000
 #define MXS_I2C_CTRL0_XFER_COUNT(v)		((v) & 0x0000FFFF)
 
+#define MXS_I2C_TIMING0		(0x10)
+#define MXS_I2C_TIMING1		(0x20)
+#define MXS_I2C_TIMING2		(0x30)
+
 #define MXS_I2C_CTRL1		(0x40)
 #define MXS_I2C_CTRL1_SET	(0x44)
 #define MXS_I2C_CTRL1_CLR	(0x48)
@@ -118,6 +122,12 @@ struct mxs_i2c_dev {
 static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
 {
 	mxs_reset_block(i2c->regs);
+
+	/* I2C is running at 400kHz */
+	writel(0x000f0007, i2c->regs + MXS_I2C_TIMING0);
+	writel(0x001f000f, i2c->regs + MXS_I2C_TIMING1);
+	writel(0x0015000d, i2c->regs + MXS_I2C_TIMING2);
+
 	writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
 	writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE,
 			i2c->regs + MXS_I2C_QUEUECTRL_SET);
Signature · 1 line
1.7.10
#1 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

This patch implements DMA support into mxs-i2c. DMA transfers are now enabled by default, though it is possible for example for debugging purposes, to disable them via i2c->dma_mode.

Cc Linux I2C <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Wolfram Sang <[email protected]>
---
 arch/arm/mach-mxs/devices/platform-mxs-i2c.c    |    5 +
 arch/arm/mach-mxs/include/mach/devices-common.h |    1 +
 drivers/i2c/busses/i2c-mxs.c                    |  261 +++++++++++++++++++++--
 3 files changed, 245 insertions(+), 22 deletions(-)
arch/arm/mach-mxs/devices/platform-mxs-i2c.c +5 -0
index 79222ec..a94f308 100644
@@ -14,6 +14,7 @@
 	{								\
 		.id = _id,						\
 		.iobase = soc ## _I2C ## _id ## _BASE_ADDR,		\
+		.dma	= soc ## _DMA_I2C ## _id,			\
 		.errirq = soc ## _INT_I2C ## _id ## _ERROR,		\
 		.dmairq = soc ## _INT_I2C ## _id ## _DMA,		\
 	}
@@ -37,6 +38,10 @@ struct platform_device *__init mxs_add_mxs_i2c(
 			.end = data->iobase + SZ_8K - 1,
 			.flags = IORESOURCE_MEM,
 		}, {
+			.start	= data->dma,
+			.end	= data->dma,
+			.flags	= IORESOURCE_DMA,
+		}, {
 			.start = data->errirq,
 			.end = data->errirq,
 			.flags = IORESOURCE_IRQ,
arch/arm/mach-mxs/include/mach/devices-common.h +1 -0
index f2e3839..791d99c 100644
@@ -80,6 +80,7 @@ mxs_add_gpmi_nand(const struct gpmi_nand_platform_data *pdata,
 struct mxs_mxs_i2c_data {
 	int id;
 	resource_size_t iobase;
+	resource_size_t dma;
 	resource_size_t errirq;
 	resource_size_t dmairq;
 };
drivers/i2c/busses/i2c-mxs.c +239 -22

363 lines not on this page · raw message

Signature · 1 line
1.7.10
#15 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

In reply to Marek Vasut
Quoted 2 lines · Marek Vasut

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Not exactly. The default values let it run at 100kHz. Since not all slaves support 400kHz, I have to NACK this one. Making it configurable is the way to go here.

Thanks,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/ce7d39c1/attachment.sig>
#2 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Marek Vasut
Quoted 10 lines · Marek Vasut

This patch implements DMA support into mxs-i2c. DMA transfers are now enabled by default, though it is possible for example for debugging purposes, to disable them via i2c->dma_mode.

Cc Linux I2C <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Wolfram Sang <[email protected]>

Looks promising, will give it a shot this week! Thanks. Very quick review.

Quoted 34 lines
---
 arch/arm/mach-mxs/devices/platform-mxs-i2c.c    |    5 +
 arch/arm/mach-mxs/include/mach/devices-common.h |    1 +
 drivers/i2c/busses/i2c-mxs.c                    |  261 +++++++++++++++++++++--
 3 files changed, 245 insertions(+), 22 deletions(-)
arch/arm/mach-mxs/devices/platform-mxs-i2c.c +5 -0
index 79222ec..a94f308 100644
@@ -14,6 +14,7 @@
 	{								\
 		.id = _id,						\
 		.iobase = soc ## _I2C ## _id ## _BASE_ADDR,		\
+		.dma	= soc ## _DMA_I2C ## _id,			\
 		.errirq = soc ## _INT_I2C ## _id ## _ERROR,		\
 		.dmairq = soc ## _INT_I2C ## _id ## _DMA,		\
 	}
@@ -37,6 +38,10 @@ struct platform_device *__init mxs_add_mxs_i2c(
 			.end = data->iobase + SZ_8K - 1,
 			.flags = IORESOURCE_MEM,
 		}, {
+			.start	= data->dma,
+			.end	= data->dma,
+			.flags	= IORESOURCE_DMA,
+		}, {
 			.start = data->errirq,
 			.end = data->errirq,
 			.flags = IORESOURCE_IRQ,
arch/arm/mach-mxs/include/mach/devices-common.h +0 -0
index f2e3839..791d99c 100644

arch/arm/mach-mxs/include/mach/devices-common.h mxs_add_gpmi_nand(const struct gpmi_nand_platform_data *pdata, · line 86

Quoted 7 lines
arch/arm/mach-mxs/include/mach/devices-common.h +1 -0
@@ -80,6 +80,7 @@ mxs_add_gpmi_nand(const struct gpmi_nand_platform_data *pdata,
 struct mxs_mxs_i2c_data {
 	int id;
 	resource_size_t iobase;
+	resource_size_t dma;
 	resource_size_t errirq;
 	resource_size_t dmairq;
 };

You need to either split this and send via alkml or I need an ACK from Shawn if it shall go in via I2C. You don't have Shawn on CC, please use scripts/get_maintainer.pl on your patchesr; you have been missing people/lists at least for the third time now.

arch/arm/mach-mxs/include/mach/devices-common.h

Quoted 4 lines

static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len) {

arch/arm/mach-mxs/include/mach/devices-common.h +1 -1
-	u32 data;
+	u32 data = 0;

Unrelated, useless change.

arch/arm/mach-mxs/include/mach/devices-common.h

Quoted 7 lines
arch/arm/mach-mxs/include/mach/devices-common.h +6 -0
 	int i;
+
+	/*
+	 * The MXS I2C DMA mode is prefered and enabled by default.
+	 * The PIO mode is still supported, but should be used only
+	 * for debuging purposes etc.
+	 */

For exactness, should be "PIOQUEUE" instead of PIO. There is a PIO mode, but we don't use it.

arch/arm/mach-mxs/include/mach/devices-common.h

Quoted 1 line
arch/arm/mach-mxs/include/mach/devices-common.h +1 -0
+	i2c->dma_mode = 1;

Have you measured the overhead of DMA? I'd still think that

	if (MX23 || msg->len > 24)
		do_dma
	else
		do_pioqueue

might be worth considered.

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/58e70bbb/attachment.sig>
#16 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

In reply to Wolfram Sang

Dear Wolfram Sang,

Quoted 5 lines · Marek Vasut
Quoted 2 lines

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Not exactly. The default values let it run at 100kHz.

Have you tried dumping the default values and comparing it with the values for 100kHz in the manual?

Quoted 3 lines

Since not all
slaves support 400kHz, I have to NACK this one. Making it configurable is the way to go here.

All right, that's a good point.

Quoted 4 lines

Thanks,

Wolfram

Best regards,
Marek Vasut

#3 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Wolfram Sang

Dear Wolfram Sang,

Quoted 83 lines · Marek Vasut
Quoted 10 lines

This patch implements DMA support into mxs-i2c. DMA transfers are now enabled by default, though it is possible for example for debugging purposes, to disable them via i2c->dma_mode.

Cc Linux I2C <[email protected]>
Cc Detlev Zundel <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Stefano Babic <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Wolfram Sang <[email protected]>

Looks promising, will give it a shot this week! Thanks. Very quick review.

Quoted 52 lines

---

 arch/arm/mach-mxs/devices/platform-mxs-i2c.c    |    5 +
 arch/arm/mach-mxs/include/mach/devices-common.h |    1 +
 drivers/i2c/busses/i2c-mxs.c                    |  261

+++++++++++++++++++++-- 3 files changed, 245 insertions(+), 22 deletions(-)

(quoted diff) +0 -0

b/arch/arm/mach-mxs/devices/platform-mxs-i2c.c index 79222ec..a94f308 100644

arch/arm/mach-mxs/devices/platform-mxs-i2c.c +1 -0
@@ -14,6 +14,7 @@
 
 	{								\
 
 		.id = _id,						\
 		.iobase = soc ## _I2C ## _id ## _BASE_ADDR,		\
 
+		.dma	= soc ## _DMA_I2C ## _id,			\
arch/arm/mach-mxs/devices/platform-mxs-i2c.c +4 -0
 		.errirq = soc ## _INT_I2C ## _id ## _ERROR,		\
 		.dmairq = soc ## _INT_I2C ## _id ## _DMA,		\
 
 	}
@@ -37,6 +38,10 @@ struct platform_device *__init mxs_add_mxs_i2c(
 
 			.end = data->iobase + SZ_8K - 1,
 			.flags = IORESOURCE_MEM,
 
 		}, {
 
+			.start	= data->dma,
+			.end	= data->dma,
+			.flags	= IORESOURCE_DMA,
+		}, {
arch/arm/mach-mxs/devices/platform-mxs-i2c.c +0 -0
 			.start = data->errirq,
 			.end = data->errirq,
 			.flags = IORESOURCE_IRQ,
(quoted diff) +0 -0

b/arch/arm/mach-mxs/include/mach/devices-common.h index f2e3839..791d99c 100644

arch/arm/mach-mxs/include/mach/devices-common.h +0 -0
@@ -80,6 +80,7 @@ mxs_add_gpmi_nand(const struct gpmi_nand_platform_data
 *pdata,
 
 struct mxs_mxs_i2c_data {

arch/arm/mach-mxs/include/mach/devices-common.h mxs_add_gpmi_nand(const struct gpmi_nand_platform_data · line 86

Quoted 10 lines
arch/arm/mach-mxs/include/mach/devices-common.h +1 -0
 
 	int id;
 	resource_size_t iobase;
 
+	resource_size_t dma;
 
 	resource_size_t errirq;
 	resource_size_t dmairq;
 
 };

You need to either split this and send via alkml or I need an ACK from Shawn if it shall go in via I2C. You don't have Shawn on CC, please use scripts/get_maintainer.pl on your patchesr; you have been missing people/lists at least for the third time now.

Quoted 7 lines

arch/arm/mach-mxs/include/mach/devices-common.h

Quoted 5 lines

static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len) {

arch/arm/mach-mxs/include/mach/devices-common.h +1 -1
-	u32 data;
+	u32 data = 0;

Unrelated, useless change.

Have you tried compiling the code with gcc 4.7?

Quoted 12 lines

arch/arm/mach-mxs/include/mach/devices-common.h

Quoted 9 lines
arch/arm/mach-mxs/include/mach/devices-common.h +6 -0
 	int i;
 
+
+	/*
+	 * The MXS I2C DMA mode is prefered and enabled by default.
+	 * The PIO mode is still supported, but should be used only
+	 * for debuging purposes etc.
+	 */

For exactness, should be "PIOQUEUE" instead of PIO. There is a PIO mode, but we don't use it.

Ok, it indeed should.

Quoted 11 lines

arch/arm/mach-mxs/include/mach/devices-common.h

Quoted 2 lines
arch/arm/mach-mxs/include/mach/devices-common.h +1 -0
+	i2c->dma_mode = 1;

Have you measured the overhead of DMA? I'd still think that

	if (MX23 || msg->len > 24)
		do_dma
	else
		do_pioqueue

might be worth considered.

It might, but in the 2.6.35.3 I have from FSL, it only does:

WARN_ONCE(len > 24, "choose DMA mode if xfer len > 24 bytes\n");

Also, I tried switching PIOQUEUE/DMA, but didn't get it working. We might as well make this dma/pioqueue mode configurable as well as speed via platform data until someone comes up with a patch that can mix pioqueue and dma?

Quoted 4 lines

Regards,

Wolfram

#17 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

In reply to Marek Vasut
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Not exactly. The default values let it run at 100kHz.

Have you tried dumping the default values and comparing it with the values for 100kHz in the manual?

Yes, sure. Doesn't it work for you? I just rechecked and the values are okay. That being said, if you make it configurable for 400kHz, it would in deed be better to rewrite the values for 100kHz, too.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/450aee0f/attachment.sig>
#4 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Marek Vasut
Quoted 10 lines
Quoted 8 lines

drivers/i2c/busses/i2c-mxs.c static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c) · line 225

Quoted 6 lines

static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len) {

drivers/i2c/busses/i2c-mxs.c +1 -1
-	u32 data;
+	u32 data = 0;

Unrelated, useless change.

Have you tried compiling the code with gcc 4.7?

What has the compiler version to do with the relevance? :) This has nothing to do with adding DMA support. Plus, nobody so far could tell me what path gcc is seeing there.

Quoted 9 lines
Quoted 9 lines

drivers/i2c/busses/i2c-mxs.c static int __devinit mxs_i2c_probe(struct platform_device *pdev) · line 564

Quoted 1 line
drivers/i2c/busses/i2c-mxs.c +1 -0
+	i2c->dma_mode = 1;

Have you measured the overhead of DMA? I'd still think that

	if (MX23 || msg->len > 24)
		do_dma
	else
		do_pioqueue
Quoted 5 lines
Quoted 1 line

might be worth considered.

It might, but in the 2.6.35.3 I have from FSL, it only does:

WARN_ONCE(len > 24, "choose DMA mode if xfer len > 24 bytes\n");

Well, we are back to the "FSL code is just a reference" topic. I truly hope that part was implemented because of laziness and not because of hardware limitations.

Quoted 3 lines

Also, I tried switching PIOQUEUE/DMA, but didn't get it working. We might as well make this dma/pioqueue mode configurable as well as speed via platform data until someone comes up with a patch that can mix pioqueue and dma?

User configuration is not an option here IMO, because PIOQUEUE would still fail for bigger transfers. "Always DMA" might be better then. But I will try to switch modes this week, that's just too tempting.

Regards,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/b81d51a3/attachment.sig>
#5 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

Dear Wolfram Sang,

Quoted 8 lines
Quoted 8 lines
Quoted 7 lines

drivers/i2c/busses/i2c-mxs.c static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c) · line 225

Quoted 5 lines

static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len) {

drivers/i2c/busses/i2c-mxs.c +1 -1
-	u32 data;
+	u32 data = 0;

Unrelated, useless change.

Quoted 5 lines
Quoted 1 line

Have you tried compiling the code with gcc 4.7?

What has the compiler version to do with the relevance? :) This has nothing to do with adding DMA support. Plus, nobody so far could tell me what path gcc is seeing there.

It complains that data might be undefined, do you want it in a separate patch then ?

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines

drivers/i2c/busses/i2c-mxs.c static int __devinit mxs_i2c_probe(struct platform_device *pdev) · line 564

Quoted 2 lines
drivers/i2c/busses/i2c-mxs.c +1 -0
+	i2c->dma_mode = 1;

Have you measured the overhead of DMA? I'd still think that

	if (MX23 || msg->len > 24)
	
		do_dma
	
	else
	
		do_pioqueue
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

might be worth considered.

It might, but in the 2.6.35.3 I have from FSL, it only does:

WARN_ONCE(len > 24, "choose DMA mode if xfer len > 24 bytes\n");

Well, we are back to the "FSL code is just a reference" topic.

Obviously.

Quoted 3 lines

I truly
hope that part was implemented because of laziness and not because of hardware limitations.

I still havent figured out how to flip between pioqueue mode and dma mode without the controller getting confused, so I prefer to postpone it into subsequent patch. Eventually, I agree it'd be cool to be able to do this switching.

Quoted 7 lines
Quoted 4 lines

Also, I tried switching PIOQUEUE/DMA, but didn't get it working. We might as well make this dma/pioqueue mode configurable as well as speed via platform data until someone comes up with a patch that can mix pioqueue and dma?

User configuration is not an option here IMO, because PIOQUEUE would still fail for bigger transfers. "Always DMA" might be better then.

Yes, that's what I have in V2.

Quoted 2 lines

But I will
try to switch modes this week, that's just too tempting.

I'll have a V2 patch for you by ... in a bit ;-) Also, you can grab latest version here (will be updated before I submit V2):
http://git.kernel.org/?p=linux/kernel/git/marex/linux-2.6.git;a=shortlog;h=refs/heads/mxs-
i2c

Quoted 4 lines

Regards,

Wolfram

Best regards,
Marek Vasut

#18 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

In reply to Wolfram Sang

Dear Wolfram Sang,

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Not exactly. The default values let it run at 100kHz.

Have you tried dumping the default values and comparing it with the values for 100kHz in the manual?

Yes, sure. Doesn't it work for you? I just rechecked and the values are okay. That being said, if you make it configurable for 400kHz, it would in deed be better to rewrite the values for 100kHz, too.

They were different for me ... did you configure the i2c bus in your bootloader possibly? Those values might have been written there since then ... I didn't run i2c in u-boot before booting linux.

Best regards,
Marek Vasut

#19 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Not exactly. The default values let it run at 100kHz.

Have you tried dumping the default values and comparing it with the values for 100kHz in the manual?

Quoted 7 lines
Quoted 3 lines

Yes, sure. Doesn't it work for you? I just rechecked and the values are okay. That being said, if you make it configurable for 400kHz, it would in deed be better to rewrite the values for 100kHz, too.

They were different for me ... did you configure the i2c bus in your bootloader possibly? Those values might have been written there since then ... I didn't run i2c in u-boot before booting linux.

Nope, no I2C involved in the bootloader at all. Do you get the correct values after soft-resetting the device?

It doesn't really matter, though. Just reinit them to the proper values depending on the user setting.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/b5db05cd/attachment.sig>
#6 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Marek Vasut
Quoted 7 lines
Quoted 4 lines

What has the compiler version to do with the relevance? :) This has nothing to do with adding DMA support. Plus, nobody so far could tell me what path gcc is seeing there.

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

Quoted 4 lines

I still havent figured out how to flip between pioqueue mode and dma mode without the controller getting confused, so I prefer to postpone it into subsequent patch. Eventually, I agree it'd be cool to be able to do this switching.

Yes, send V2 with DMA by default, and I will give a try on the mode-switching later, too.

Thanks,

Wolfram

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/49e0a24c/attachment.sig>
#7 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

Dear Wolfram Sang,

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

What has the compiler version to do with the relevance? :) This has nothing to do with adding DMA support. Plus, nobody so far could tell me what path gcc is seeing there.

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

Quoted 7 lines
Quoted 4 lines

I still havent figured out how to flip between pioqueue mode and dma mode without the controller getting confused, so I prefer to postpone it into subsequent patch. Eventually, I agree it'd be cool to be able to do this switching.

Yes, send V2 with DMA by default, and I will give a try on the mode-switching later, too.

I'd prefer to have PIOQ by default, to avoid breaking some of the boards. Or can you test on all of them?

Quoted 4 lines

Thanks,

Wolfram

Best regards,
Marek Vasut

#20 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

In reply to Wolfram Sang

Dear Wolfram Sang,

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

This sets the bus to run at 400kHz, prior to this, the bus frequency was undefined.

Not exactly. The default values let it run at 100kHz.

Have you tried dumping the default values and comparing it with the values for 100kHz in the manual?

Quoted 7 lines
Quoted 3 lines

Yes, sure. Doesn't it work for you? I just rechecked and the values are okay. That being said, if you make it configurable for 400kHz, it would in deed be better to rewrite the values for 100kHz, too.

They were different for me ... did you configure the i2c bus in your bootloader possibly? Those values might have been written there since then ... I didn't run i2c in u-boot before booting linux.

Quoted 5 lines

Nope, no I2C involved in the bootloader at all. Do you get the correct values after soft-resetting the device?

It doesn't really matter, though. Just reinit them to the proper values depending on the user setting.

Indeed. Default to 100kHz might be a good idea too, in case user entered some weird value. Eventually, it'd be nice if we could calculate the timing values for all possible frequencies, but I didn't got to deriving such formula ... dunno if it's worth it either, doubt so.

Best regards,
Marek Vasut

#8 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Marek Vasut
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

Quoted 5 lines
Quoted 2 lines

Yes, send V2 with DMA by default, and I will give a try on the mode-switching later, too.

I'd prefer to have PIOQ by default, to avoid breaking some of the boards. Or can you test on all of them?

? What kind of breakage do you expect? I think it is okay if we pull it in during the merge window; we can fix issues then till the relase (and maybe mode switching works, after all).

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/2d34f440/attachment.sig>
#21 lore raw

PATCH 1/2 I2C: Set I2C timing registers for mxs-i2c

In reply to Marek Vasut
Quoted 4 lines

Indeed. Default to 100kHz might be a good idea too, in case user entered some weird value. Eventually, it'd be nice if we could calculate the timing values for all possible frequencies, but I didn't got to deriving such formula ... dunno if it's worth it either, doubt so.

Would be awesome to have it; but we can leave it for later when it is actually needed.

Signature · 9 lines
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120430/904f919e/attachment.sig>
#9 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Wolfram Sang

Dear Wolfram Sang,

Quoted 13 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

Quoted 3 lines
Quoted 2 lines

Yes, send V2 with DMA by default, and I will give a try on the mode-switching later, too.

Quoted 6 lines
Quoted 2 lines

I'd prefer to have PIOQ by default, to avoid breaking some of the boards. Or can you test on all of them?

? What kind of breakage do you expect? I think it is okay if we pull it in during the merge window; we can fix issues then till the relase (and maybe mode switching works, after all).

Ok, so be it then.

Best regards,
Marek Vasut

#10 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Wolfram Sang
Quoted 11 lines · Wolfram Sang
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

Heh, this is coming up again. I'm not convincing you to take the change, but just curious what if this is not a compile warning but an error for the same cause that compiler is not right.

Signature · 2 lines
Regards,
Shawn
#11 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

Dear Shawn Guo,

Quoted 10 lines · Wolfram Sang
Quoted 9 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

I second this.

Quoted 3 lines

Heh, this is coming up again. I'm not convincing you to take the change, but just curious what if this is not a compile warning but an error for the same cause that compiler is not right.

Can you elaborate?

Best regards,
Marek Vasut

#12 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

Quoted 6 lines · Marek Vasut

Dear Shawn Guo,

Quoted 4 lines · Wolfram Sang
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

I second this.

I agree on this too.

Quoted 6 lines
Quoted 3 lines

Heh, this is coming up again. I'm not convincing you to take the change, but just curious what if this is not a compile warning but an error for the same cause that compiler is not right.

Can you elaborate?

Will we have the kernel not compilable for a few cycles until the compiler fixing is available, or we work it around to keep kernel compiling and working before we have the compiler fixed?

Signature · 2 lines
Regards,
Shawn
#13 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

Dear Shawn Guo,

Quoted 22 lines · Marek Vasut
Quoted 6 lines

Dear Shawn Guo,

Quoted 4 lines · Wolfram Sang
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Yes, but only if you can prove that the compiler is right.

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

I second this.

I agree on this too.

Quoted 4 lines
Quoted 3 lines

Heh, this is coming up again. I'm not convincing you to take the change, but just curious what if this is not a compile warning but an error for the same cause that compiler is not right.

Quoted 5 lines
Quoted 1 line

Can you elaborate?

Will we have the kernel not compilable for a few cycles until the compiler fixing is available, or we work it around to keep kernel compiling and working before we have the compiler fixed?

This is kind of lacmus paper showing if the compiler was fixed. On the other hand, many people won't have a fixed compiler for a long time, so I'd be for applying this patch.

Best regards,
Marek Vasut

#14 lore raw

PATCH 2/2 I2C: Implement DMA support into mxs-i2c

In reply to Shawn Guo
Quoted 7 lines · Shawn Guo
Quoted 6 lines · Wolfram Sang
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

It complains that data might be undefined, do you want it in a separate patch then ?

Yes, but only if you can prove that the compiler is right.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

It's not right, because that variable is always initialized, but this at least squashes the compile warning.

The compiler needs to be fixed, not the kernel.

Heh, this is coming up again. I'm not convincing you to take the change, but just curious what if this is not a compile warning but an error for the same cause that compiler is not right.

It's a compiler warning.

Please look at the wording of the warning. The compiler uses "may" not "is". That means it can't come to a conclusion about it.

But we, as humans with our biological inference engines, can see that the code is correct, and we _can_ choose to ignore the warning - just like I do with:

drivers/video/omap2/displays/panel-taal.c: In function 'taal_num_errors_show':
drivers/video/omap2/displays/panel-taal.c:605: warning: 'errors' may be used uninitialized in this function

static int taal_dcs_read_1(struct taal_data *td, u8 dcs_cmd, u8 *data)

{
        int r;
        u8 buf[1];
        r = dsi_vc_dcs_read(td->dssdev, td->channel, dcs_cmd, buf, 1);
        if (r < 0)
                return r;
        *data = buf[0];  
        return 0;
}
        u8 errors;

        mutex_lock(&td->lock);
        if (td->enabled) {
                dsi_bus_lock(dssdev);
                r = taal_wake_up(dssdev);
                if (!r) 
                        r = taal_dcs_read_1(td, DCS_READ_NUM_ERRORS, &errors);
                dsi_bus_unlock(dssdev);
        } else {
                r = -ENODEV;
        }
        mutex_unlock(&td->lock);

        if (r)
                return r;

        return snprintf(buf, PAGE_SIZE, "%d\n", errors);

See? We can infer from the above that that 'errors' will always be set if r is zero - but the compiler is saying it's not clever enough to do that automatically.

This doesn't mean the code _has_ to be changed - we can see that the above warning is false. Though, if there is a way to rewrite it to make it easier for us humans to read and that makes the warning go away, it _might_ be a good idea to make the change - but only for a maintainability reason.

The reverse is also true - if trying to fix a warning like this makes the code more difficult to understand, then the warning _should_ stay.

That's actually the point of programming languages - the ability to express our instructions to a computer in a way that both we and the compiler can readily understand. The most important part of that is that _we_ understand what's been written.