Page MenuHomeFreeBSD

iicmux: do not walk a bogus OFW node on systems described by ACPI
Needs ReviewPublic

Authored by yarshure_gmail.com on Sun, Sep 27, 1:36 PM.
Referenced Files
F173970067: D60060.diff
Tue, Sep 29, 5:20 PM
Unknown Object (File)
Mon, Sep 28, 5:51 PM
Unknown Object (File)
Mon, Sep 28, 6:01 AM
Unknown Object (File)
Mon, Sep 28, 3:51 AM
Unknown Object (File)
Mon, Sep 28, 3:42 AM
Unknown Object (File)
Mon, Sep 28, 2:57 AM
Unknown Object (File)
Mon, Sep 28, 2:50 AM
Unknown Object (File)
Mon, Sep 28, 1:05 AM
Subscribers

Details

Reviewers
mmel
manu
wulf
Summary

iicmux_attach_children() reads the mux's OFW node and walks its children to
find the downstream buses. On a system with no device tree ofw_bus_get_node()
answers -1, and the walk then ran over that as if it were a node. Take the
generic path -- one iicbus child per channel the chip supports -- whenever
there is no node, and set childnodes[] to -1 explicitly there so that the
per-child ofw_bus_get_node() accessor answers "no node" rather than 0, which
is a valid phandle.

An arm64 GENERIC kernel carries both FDT and ACPI support and may be booted
either way, so this is not reachable only on ACPI-only platforms.

Test Plan

arm64 GENERIC, and a variant with iicmux/pca954x as modules.

On a SolidRun CEX7 (NXP LX2160A) booted through UEFI/ACPI -- no device tree,
the PCA9547 described in ACPI -- the mux now brings up its downstream buses:

iicbus0 <Philips I2C bus (ACPI-hinted)>
  pca954x0 <PCA9547 I2C Mux> ... handle=\_SB_.I2C0.MUX0
    iicbus1 ... iicbus8 <Philips I2C bus>

and "i2c -f /dev/iicN -s" reaches the devices on each channel. Before, the
OFW walk ran over the -1 that ofw_bus_get_node() answers for a device with no
node.

No behaviour change where a node exists: the device-tree walk is taken first
and unchanged, and childnodes[] is only written in the generic path.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

adrian added reviewers: mmel, manu, wulf.
adrian added subscribers: wulf, mmel, adrian.

@mmel and @wulf hey, this stack looks .. interesting to go and dig into as part of some other upcoming work. Would you mind taking a quick look at it and see what you think?
Thanks!

This is pure hack, imho. The ACPI mux, buses and their devices must be enumerated in exactly the same way as in the FDT case.