Page MenuHomeFreeBSD

amdsmu: Fix model-specific matching
ClosedPublic

Authored by olce on Fri, Sep 18, 7:52 AM.
Tags
None
Referenced Files
F172880956: D59788.id187031.diff
Mon, Sep 21, 7:45 PM
F172864269: D59788.id187090.diff
Mon, Sep 21, 4:44 PM
F172855516: D59788.diff
Mon, Sep 21, 3:12 PM
Unknown Object (File)
Sat, Sep 19, 10:41 PM
Unknown Object (File)
Sat, Sep 19, 10:13 PM
Unknown Object (File)
Sat, Sep 19, 10:12 PM
Unknown Object (File)
Sat, Sep 19, 10:11 PM
Unknown Object (File)
Fri, Sep 18, 9:44 PM
Subscribers

Details

Summary

For Krackan Point, model-specific matching would not work because
amdsmu_match() browses amdsmu_products[] in order and returns the first
match, and the Krackan Point's 'struct amdsmu_product' object variant
with a 'model' field of 0, indicating that any model matches, is listed
before the variant with model 0x70 in amdsmu_products[].

In practice, this means that reporting of IP blocks for Krackan Point
model 0x70 only was broken. Specifically, not all the existing blocks
were reported and most statistics were not attributed to the right
blocks.

Fix this by making amdsmu_match() parse amdsmu_products[] in reverse, so
model-generic entries can continue to appear first.

While here, since the CPU model is between 0 and 255, change the type
used for CPU models to an 'int' and use the special value -1 to skip
model match, as there exist CPUs reporting 0 as the model (even if, to
our knowledge, only old CPUs seem to be doing that).

While here, fix alignement and whitespace in amdsmu_products[]'s
initializers.

Fixes: 9c77fb6aaa36 ("amdsmu: Add Krackan Point support")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

olce requested review of this revision.Fri, Sep 18, 7:52 AM

does it not make more sense to go through amdsmu_products forwards and just reverse the list? then the list can read more naturally as "the product will be the first one that matches an element in this list"

This revision is now accepted and ready to land.Fri, Sep 18, 10:58 AM

does it not make more sense to go through amdsmu_products forwards and just reverse the list? then the list can read more naturally as "the product will be the first one that matches an element in this list"

My first version was actually doing that, but then I had to exchange the two Krackan Point lines and looking at the result, it felt odd to have 0x70 before 0x0 (or -1 after my change), with the number of IP blocks of 0x70 being greater.

I also reasoned that, going forward, we would probably be first adding support for a new generation, and then only refine it per model as necessary, in a kind of chronological order, so reading from the end would probably allow to most of the time add new refinements at the end of the array instead of before existing entries (except of course in the case of model refinement for older platforms, but then the alternative has the same problem).

This revision was automatically updated to reflect the committed changes.