• Alison Schofield's avatar
    cxl/region: Calculate a target position in a region interleave · a3e00c96
    Alison Schofield authored
    Introduce a calculation to find a target's position in a region
    interleave. Perform a self-test of the calculation on user-defined
    regions.
    
    The region driver uses the kernel sort() function to put region
    targets in relative order. Positions are assigned based on each
    target's index in that sorted list. That relative sort doesn't
    consider the offset of a port into its parent port which causes
    some auto-discovered regions to fail creation. In one failure case,
    a 2 + 2 config (2 host bridges each with 2 endpoints), the sort
    puts all the targets of one port ahead of another port when they
    were expected to be interleaved.
    
    In preparation for repairing the autodiscovery region assembly,
    introduce a new method for discovering a target position in the
    region interleave.
    
    cxl_calc_interleave_pos() adds a method to find the target position by
    ascending from an endpoint to a root decoder. The calculation starts
    with the endpoint's local position and position in the parent port. It
    traverses towards the root decoder and examines both position and ways
    in order to allow the position to be refined all the way to the root
    decoder.
    
    This calculation: position = position * parent_ways + parent_pos;
    applied iteratively yields the correct position.
    
    Include a self-test that exercises this new position calculation against
    every successfully configured user-defined region.
    Signed-off-by: default avatarAlison Schofield <alison.schofield@intel.com>
    Link: https://lore.kernel.org/r/0ac32c75cf81dd8b86bf07d70ff139d33c2300bc.1698263080.git.alison.schofield@intel.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
    a3e00c96
region.c 75.4 KB