• Daniel Axtens's avatar
    cxl: Allocate and release the SPA with the AFU · 05155772
    Daniel Axtens authored
    Previously the SPA was allocated and freed upon entering and leaving
    AFU-directed mode. This causes some issues for error recovery - contexts
    hold a pointer inside the SPA, and they may persist after the AFU has
    been detached.
    
    We would ideally like to allocate the SPA when the AFU is allocated, and
    release it until the AFU is released. However, we don't know how big the
    SPA needs to be until we read the AFU descriptor.
    
    Therefore, restructure the code:
    
     - Allocate the SPA only once, on the first attach.
    
     - Release the SPA only when the entire AFU is being released (not
       detached). Guard the release with a NULL check, so we don't free
       if it was never allocated (e.g. dedicated mode)
    Acked-by: default avatarCyril Bur <cyrilbur@gmail.com>
    Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    05155772
cxl.h 25.8 KB