• Dan Williams's avatar
    cxl/port: Fix missing target list lock · 5459e186
    Dan Williams authored
    cxl_port_setup_targets() modifies the ->targets[] array of a switch
    decoder. target_list_show() expects to be able to emit a coherent
    snapshot of that array by "holding" ->target_lock for read. The
    target_lock is held for write during initialization of the ->targets[]
    array, but it is not held for write during cxl_port_setup_targets().
    
    The ->target_lock() predates the introduction of @cxl_region_rwsem. That
    semaphore protects changes to host-physical-address (HPA) decode which
    is precisely what writes to a switch decoder's target list affects.
    
    Replace ->target_lock with @cxl_region_rwsem.
    
    Now the side-effect of snapshotting a unstable view of a decoder's
    target list is likely benign so the Fixes: tag is presumptive.
    
    Fixes: 27b3f8d1
    
     ("cxl/region: Program target lists")
    Reviewed-by: default avatarAlison Schofield <alison.schofield@intel.com>
    Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
    Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
    5459e186
cxl.h 27.2 KB