Page MenuHomeFreeBSD

The ranges parent bus address may just be a tag to the entry in the parent node. Take this in to account by searching until we find the root node's range.
ClosedPublic

Authored by andrew on Nov 14 2014, 1:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 27, 4:17 AM
Unknown Object (File)
Sun, Oct 27, 4:17 AM
Unknown Object (File)
Sun, Oct 27, 4:17 AM
Unknown Object (File)
Sun, Oct 27, 4:02 AM
Unknown Object (File)
Oct 5 2024, 1:48 AM
Unknown Object (File)
Oct 4 2024, 7:26 PM
Unknown Object (File)
Oct 2 2024, 1:55 PM
Unknown Object (File)
Oct 1 2024, 10:11 PM

Details

Test Plan

Needs testing on different boards, I've only tested on arm64

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

andrew retitled this revision from to The ranges parent bus address may just be a tag to the entry in the parent node. Take this in to account by searching until we find the root node's range..
andrew updated this object.
andrew edited the test plan for this revision. (Show Details)
andrew added reviewers: ARM, emaste.
ian added a reviewer: ian.
ian added a subscriber: ian.

If my interpretation of how to traverse up the hierarchy based on being within a mapping range rather than exactly equaling the start of a range is correct, then this whole blob of functionality is kind of insane. It's already kind of insane with the range_id thing anyway, given that the two users of this function hard-code a zero and have no basis to believe that the first tuple of their parent bus is the one with the right mapping in it.

Given that we probably can't wish this functionality away completely -- setting up the console and sometimes other specialized hardware, very early, is just always going to be needed -- we should probably replace all this stuff with something like

fdt_reg_to_physaddr(pcell_t node, int idx, u_long *phys, u_long *size)

where idx is the index into the reg=<...> tuples for the node.

But I'm NOT proposing that we do that instead of committing these fixes. These changes are clearly less broken than the current code.

Oh yeah, I also determined that this function is different than the ranges code I was talking about on irc -- that was the fill-ranges stuff in simplebus.

I gave this a quick test on my beaglebone, it boots and seems to be working fine.

sys/dev/fdt/fdt_common.c
115

This equality test bothers me. It appears to assume that the parent bus address in a child's tuple will appear as the child bus address in one of the parent's tuples. I don't see any reason why that's required, I think it is only required that it fall within one of the child ranges within a parent's tuples. Unfortunately, ePAPR doesn't give any multi-level example where this could happen.

For example, is this type of setup not valid?...

soc {
  ranges = <0x0 0xf0000000 0x10000000>;
  bus1 {
    ranges = <0x0 0x0 0x200>;
    device1 {
      reg = <0x0>; // reg is at 0xf0000000
    }
  }
  bus2 {
    ranges = <0x0 0x1000 0x400>;
    device2 {
      reg = <0x0>; // reg is at 0xf0001000;
    }
  }
}
180

If range_id is not zero things will begin to go off the rails here. I assume the intent of range_id N is to get the Nth tuple, not the Nth cell of the property.

The only two callers of this function hard-code this as zero.

This revision is now accepted and ready to land.Nov 19 2014, 5:53 AM
andrew updated this revision to Diff 2478.

Closed by commit rS274751 (authored by @andrew).

I discussed this with Ian on IRC yesterday, but for posterity: we should remove this eventually and replace it with a copy of OF_decode_addr() from /sys/powerpc/ofw/ofw_machdep.c, which already handles all the cases and is quasi-standard in the tree.