Page MenuHomeFreeBSD

Make opal_pci driver work with POWER9
ClosedPublic

Authored by jhibbits on May 25 2018, 3:13 AM.

Details

Summary

Coupled with D15461, this makes PCI work on POWER9. There is still
more to do to fully exploit the hardware capabilities, but this is sufficient to
enable USB and ethernet controllers on a Talos system.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jhibbits created this revision.May 25 2018, 3:13 AM
imp added inline comments.May 25 2018, 4:04 AM
sys/powerpc/powernv/opal_pci.c
200 ↗(On Diff #42968)

sys/param.h defines roundup2 and rounddown2 for this purpose.

276 ↗(On Diff #42968)

Is this intentional?

352 ↗(On Diff #42968)

Likewise.

jhibbits added inline comments.May 25 2018, 4:21 AM
sys/powerpc/powernv/opal_pci.c
200 ↗(On Diff #42968)

Not quite. roundup2/rounddown2 take a power of 2 as 'y', and rounds 'x' to a multiple of 'y'. In this case, I'm trying to round up to the nearest power of 2.

276 ↗(On Diff #42968)

Kind of. It's work in progress. I don't want to throw it away, because this is part of the "proper" initialization, which Linux does. It's blocked out for now, because it doesn't fully work, and I haven't yet found the missing pieces for it.

352 ↗(On Diff #42968)

This might be a casualty of my testing. I'll have to retest it to be sure.

jhibbits updated this revision to Diff 42970.May 25 2018, 4:27 AM

No need to comment out the OPAL_PCI_MAP_PE_MMIO_WINDOW. It likely was already
mapped as such by Opal.

wma added inline comments.May 25 2018, 4:32 AM
sys/powerpc/powernv/opal_pci.c
276 ↗(On Diff #42968)

I think it didn't work on P8 either, at least with the newest OPAL. However, on P8 it only produces a warning during boot and does not influence anything further.

358 ↗(On Diff #42968)

This might be worth testing on P8 also. If I recall correctly, there were sth messed up with using splitted windows...

jhibbits marked an inline comment as done.May 25 2018, 1:48 PM
jhibbits added inline comments.
sys/powerpc/powernv/opal_pci.c
358 ↗(On Diff #42968)

Yeah, it didn't work on POWER9 either, and I was pretty sure I had reverted it before submitting for review. I tested both cases, including post-revert. With split windows bge couldn't find its phy, after reverting to non-split windows, bge could initialize correctly.

nwhitehorn accepted this revision.May 26 2018, 3:21 AM

This looks good to me, though I haven't tested on P8.

This revision is now accepted and ready to land.May 26 2018, 3:21 AM
breno.leitao_gmail.com added inline comments.
sys/powerpc/powernv/opal_pci.c
414 ↗(On Diff #42970)

Can't you just call OF_getencprop() and checking if the return > 0, if so proceeding to branch other than calling OF_getproplen() and OF_getencprop()?

jhibbits marked an inline comment as done.May 29 2018, 7:09 PM
jhibbits added inline comments.
sys/powerpc/powernv/opal_pci.c
414 ↗(On Diff #42970)

Yeah, that would be saner.

This change, and most of the OF_* changes, are just a rename of ofw_bus_get_node(dev) -> node. I'll commit that change separately though, since it't a non-functional change. I plan to make further changes to this file after I get the initial working skeleton in, for performance and stability.

This revision was automatically updated to reflect the committed changes.