• Dan Williams's avatar
    cxl/region: Add region autodiscovery · a32320b7
    Dan Williams authored
    Region autodiscovery is an asynchronous state machine advanced by
    cxl_port_probe(). After the decoders on an endpoint port are enumerated
    they are scanned for actively enabled instances. Each active decoder is
    flagged for auto-assembly CXL_DECODER_F_AUTO and attached to a region.
    If a region does not already exist for the address range setting of the
    decoder one is created. That creation process may race with other
    decoders of the same region being discovered since cxl_port_probe() is
    asynchronous. A new 'struct cxl_root_decoder' lock, @range_lock, is
    introduced to mitigate that race.
    
    Once all decoders have arrived, "p->nr_targets == p->interleave_ways",
    they are sorted by their relative decode position. The sort algorithm
    involves finding the point in the cxl_port topology where one leg of the
    decode leads to deviceA and the other deviceB. At that point in the
    topology the target order in the 'struct cxl_switch_decoder' indicates
    the relative position of those endpoint decoders in the region.
    
    >From that point the region goes through the same setup and validation
    steps as user-created regions, but instead of programming the decoders
    it validates that driver would have written the same values to the
    decoders as were already present.
    Tested-by: default avatarFan Ni <fan.ni@samsung.com>
    Reviewed-by: default avatarVishal Verma <vishal.l.verma@intel.com>
    Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
    Link: https://lore.kernel.org/r/167601999958.1924368.9366954455835735048.stgit@dwillia2-xfh.jf.intel.comSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
    a32320b7
cxl.h 23.8 KB