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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+V-a8sM2mFS--zLSZt28mOUDuO2FpW0TsaV50A_VxFZ-juP4Q@mail.gmail.com>
Date: Thu, 17 Apr 2025 14:10:32 +0100
From: "Lad, Prabhakar" <prabhakar.csengg@...il.com>
To: Wolfram Sang <wsa+renesas@...g-engineering.com>, 
	Prabhakar <prabhakar.csengg@...il.com>, Chris Brandt <chris.brandt@...esas.com>, 
	Andi Shyti <andi.shyti@...nel.org>, Geert Uytterhoeven <geert+renesas@...der.be>, 
	linux-renesas-soc@...r.kernel.org, linux-i2c@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Biju Das <biju.das.jz@...renesas.com>, 
	Fabrizio Castro <fabrizio.castro.jz@...esas.com>, 
	Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>, 
	Claudiu Beznea <claudiu.beznea.uj@...renesas.com>, Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH v8] i2c: riic: Implement bus recovery

Hi Wolfram,

Thank you for the review.

Finally I got my setup out for this.

On Thu, Apr 17, 2025 at 9:32 AM Wolfram Sang
<wsa+renesas@...g-engineering.com> wrote:
>
> On Mon, Apr 07, 2025 at 01:18:59PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
> >
> > Implement bus recovery by reinitializing the hardware to reset the bus
> > state and generating 9 clock cycles (and a stop condition) to release
> > the SDA line.
> >
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
> > Tested-by: Claudiu Beznea <claudiu.beznea.uj@...renesas.com>
> > Reviewed-by: Claudiu Beznea <claudiu.beznea.uj@...renesas.com>
> > Reviewed-by: Fabrizio Castro <fabrizio.castro.jz@...esas.com>
> > Reviewed-by: Andy Shevchenko <andy@...nel.org>
>
> As I wrote in the other thread: I took your generic_scl approach and
> replaced bus_free() with get_sda(). Works fine here with my G3S:
>
As suggested I have the below now, (are there any changes Ive missed?)

+static int riic_get_sda(struct i2c_adapter *adap)
+{
+       struct riic_dev *riic = i2c_get_adapdata(adap);
+
+       /* Check if the bus is busy or SDA is not high */
+       if ((riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) ||
+           !(riic_readb(riic, RIIC_ICCR1) & ICCR1_SDAI))
+               return -EBUSY;
+
+       return 1;
+}
+
 static const struct riic_irq_desc riic_irqs[] = {
        { .res_num = 0, .isr = riic_tend_isr, .name = "riic-tend" },
        { .res_num = 1, .isr = riic_rdrf_isr, .name = "riic-rdrf" },
@@ -523,7 +568,11 @@ static const struct riic_irq_desc riic_irqs[] = {
 };

 static struct i2c_bus_recovery_info riic_bri = {
-       .recover_bus = riic_recover_bus,
+       .get_scl = riic_get_scl,
+       .set_scl = riic_set_scl,
+       .set_sda = riic_set_sda,
+       .get_sda = riic_get_sda,
+       .recover_bus = i2c_generic_scl_recovery,
 }

> # echo 0x1a > /sys/kernel/debug/i2c/i2c-2/incomplete_address_phase ; i2cget -f -y 0 0x1a 3
> 0x0c
>
> And I see 9 pulses in the scope. Can you try this with your setup
> please?
>
This seems to be unreliable on my side below are my test results.

root@...rc-rzg2l:~/i2c# cat ./incomplete_address_phase.sh
cd /sys/kernel/debug/i2c/i2c-4/
for i in {1..1}; do
        echo 0x68 > incomplete_address_phase;
        val=$(i2cget -y -f 3 0x68 8)
        if [ "$?" != "0" ] || [ "${val}" != "0x83" ]; then
                echo "I2C Read error (ret:$?) ${val}!!"
                exit 1
        fi
        echo "Read val:${val}"
done

root@...rc-rzg2l:~/i2c#
root@...rc-rzg2l:~/i2c# ./incomplete_address_phase.sh
Read val:0x83
root@...rc-rzg2l:~/i2c# ./incomplete_address_phase.sh
Error: Read failed
I2C Read error (ret:0) !!
root@...rc-rzg2l:~/i2c# ./incomplete_address_phase.sh
Read val:0x83
root@...rc-rzg2l:~/i2c# ./incomplete_address_phase.sh
Error: Read failed
I2C Read error (ret:0) !!
root@...rc-rzg2l:~/i2c#
root@...rc-rzg2l:~/i2c# ./incomplete_address_phase.sh
Read val:0x83
root@...rc-rzg2l:~/i2c# ./incomplete_address_phase.sh
Error: Read failed
I2C Read error (ret:0) !!
root@...rc-rzg2l:~/i2c#
root@...rc-rzg2l:~/i2c#

Cheers,
Prabhakar

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ