Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Oct 2024 14:10:04 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 280290] hms(4): Broken fresh after boot, fixed by resume
Message-ID:  <bug-280290-227-xWC9co7Typ@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-280290-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-280290-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D280290

--- Comment #31 from Edward Tomasz Napierala <trasz@FreeBSD.org> ---
Okay, after talking to jhb@ it appears the child devices are attaching too
early, and the easiest way to solve it is to move the call to
bus_generic_attach() further down, after power off.  Here's the proposed pa=
tch:

diff --git a/sys/dev/iicbus/iichid.c b/sys/dev/iicbus/iichid.c
index fc9f5c2a68b3..a2c0878697f6 100644
--- a/sys/dev/iicbus/iichid.c
+++ b/sys/dev/iicbus/iichid.c
@@ -1124,7 +1124,7 @@ iichid_attach(device_t dev)
        if (error) {
                device_printf(dev, "failed to reset hardware: %d\n", error);
                error =3D ENXIO;
-               goto done;
+               goto fail;
        }

        sc->power_on =3D true;
@@ -1162,7 +1162,7 @@ iichid_attach(device_t dev)
                        bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid,
                            sc->irq_res);
                error =3D ENXIO;
-               goto done;
+               goto fail;
 #endif
        }

@@ -1195,16 +1195,21 @@ iichid_attach(device_t dev)
                device_printf(sc->dev, "Could not add I2C device\n");
                iichid_detach(dev);
                error =3D ENOMEM;
-               goto done;
+               goto fail;
        }

+       (void)iichid_set_power(sc, I2C_HID_POWER_OFF);
+       sc->power_on =3D false;
+
        device_set_ivars(child, &sc->hw);
        error =3D bus_generic_attach(dev);
        if (error) {
                device_printf(dev, "failed to attach child: error %d\n",
error);
                iichid_detach(dev);
        }
-done:
+       return (error);
+
+fail:
        (void)iichid_set_power(sc, I2C_HID_POWER_OFF);
        sc->power_on =3D false;
        return (error);

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-280290-227-xWC9co7Typ>