lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <074b39c5-55fc-2bc1-072d-aef1070e284d@axentia.se>
Date:   Thu, 9 Jun 2022 16:28:04 +0200
From:   Peter Rosin <peda@...ntia.se>
To:     linux-i2c@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, devicetree@...r.kernel.org
Cc:     Ludovic.Desroches@...rochip.com, Nicolas.Ferre@...rochip.com,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Rob Herring <robh+dt@...nel.org>,
        Wolfram Sang <wsa@...nel.org>,
        Kamel Bouhara <kamel.bouhara@...tlin.com>,
        Codrin Ciubotariu <codrin.ciubotariu@...rochip.com>
Subject: Regression: at24 eeprom writing times out on sama5d3

Hi!

I have not actually bisected this issue but reverting the effects of
patch a4bd8da893a3 ("ARM: dts: at91: sama5d3: add i2c gpio pinctrl")
makes the problem go away.

I.e. I need something like this in my dts

&i2c2 {
	status = "okay";

	pinctrl-names = "default";
	/delete-property/ pinctrl-1;
	/delete-property/ sda-gpios;
	/delete-property/ scl-gpios;

	eeprom@50 {
		compatible = "st,24c64", "atmel,24c64";
		reg = <0x50>;
		wp-gpios = <&filter_gpio 7 GPIO_ACTIVE_HIGH>;
	};
};

for multi-page eeprom writes to not time out (a page is 32 bytes on this
eeprom).

For reference, the current defaults for this SoC/I2C-bus, that I modify,
are:

	pinctrl-names = "default", "gpio";
	pinctrl-0 = <&pinctrl_i2c2>;
	pinctrl-1 = <&pinctrl_i2c2_gpio>;
	sda-gpios = <&pioA 18 GPIO_ACTIVE_HIGH>;
	scl-gpios = <&pioA 19 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;

I suspect that the underlying reason is that the bus recovery takes
too long and that the at24 eeprom driver gives up prematurely. I doubt
that this is chip specific, but I don't know that.

I can work around the issue in user space with by writing in 4 byte
chunks, like so

dd if=source.file of=/sys/bus/i2c/devices/2-0050/eeprom obs=4

but that is really ugly and gets slow too, about 20 seconds to program
the full 8kB eeprom. With the above in my dts it takes a second or
so (a bit more with dynamic debug active).


If I run

dd if=source.file of=/sys/bus/i2c/devices/2-0050/eeprom

with a source.file of 8kB and the upstream dts properties in place, I can
collect the following debug output from at24, i2c-core and i2c-at91:

Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@0 --> 0 (-23170)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:56:34 me20 kernel: i2c i2c-2: Trying i2c bus recovery
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@32 --> -121 (-23169)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@32 --> 0 (-23168)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:56:34 me20 kernel: i2c i2c-2: Trying i2c bus recovery
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@64 --> -121 (-23168)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@64 --> 0 (-23167)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:56:34 me20 kernel: i2c i2c-2: Trying i2c bus recovery
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@96 --> -121 (-23167)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: controller timed out
Jun  9 15:56:34 me20 kernel: i2c i2c-2: Trying i2c bus recovery
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@96 --> -110 (-23155)
Jun  9 15:56:34 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:56:34 me20 kernel: at91_i2c f801c000.i2c: controller timed out
Jun  9 15:56:34 me20 kernel: i2c i2c-2: Trying i2c bus recovery
Jun  9 15:56:34 me20 kernel: at24 2-0050: write 32@96 --> -110 (-23143)

And then there is no more action. I.e. only a couple of 32 byte pages
are written.

With the above mentioned dts override in place I instead get this, which is
a lot more sensible:

Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@0 --> 0 (753629)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@32 --> -121 (753629)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@32 --> 0 (753630)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@64 --> -121 (753630)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@64 --> 0 (753631)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@96 --> -121 (753631)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@96 --> 0 (753632)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@128 --> -121 (753632)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@128 --> 0 (753633)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@160 --> -121 (753633)
Jun  9 15:48:53 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:53 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:53 me20 kernel: at24 2-0050: write 32@160 --> 0 (753634)
... snip ...
Jun  9 15:48:55 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:55 me20 kernel: at24 2-0050: write 32@...8 --> -121 (753883)
Jun  9 15:48:55 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:55 me20 kernel: at24 2-0050: write 32@...8 --> 0 (753884)
Jun  9 15:48:55 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: received nack
Jun  9 15:48:55 me20 kernel: at24 2-0050: write 32@...0 --> -121 (753884)
Jun  9 15:48:55 me20 kernel: i2c i2c-2: at91_xfer: processing 1 messages:
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: transfer: write 34 bytes.
Jun  9 15:48:55 me20 kernel: at91_i2c f801c000.i2c: transfer complete
Jun  9 15:48:55 me20 kernel: at24 2-0050: write 32@...0 --> 0 (753885)

Cheers,
Peter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ