Skip to content
  • Peter Crosthwaite's avatar
    f0c02d15
    memory: Add address_space_init_shareable() · f0c02d15
    Peter Crosthwaite authored
    
    
    This will either create a new AS or return a pointer to an
    already existing equivalent one, if we have already created
    an AS for the specified root memory region.
    
    The motivation is to reuse address spaces as much as possible.
    It's going to be quite common that bus masters out in device land
    have pointers to the same memory region for their mastering yet
    each will need to create its own address space. Let the memory
    API implement sharing for them.
    
    Aside from the perf optimisations, this should reduce the amount
    of redundant output on info mtree as well.
    
    Thee returned value will be malloced, but the malloc will be
    automatically freed when the AS runs out of refs.
    
    Signed-off-by: default avatarPeter Crosthwaite <peter.crosthwaite@xilinx.com>
    [PMM: dropped check for NULL root as unused; added doc-comment;
     squashed Peter C's reference-counting patch into this one;
     don't compare name string when deciding if we can share ASes;
     read as->malloced before the unref of as->root to avoid possible
     read-after-free if as->root was the owner of as]
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Acked-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
    f0c02d15
    memory: Add address_space_init_shareable()
    Peter Crosthwaite authored
    
    
    This will either create a new AS or return a pointer to an
    already existing equivalent one, if we have already created
    an AS for the specified root memory region.
    
    The motivation is to reuse address spaces as much as possible.
    It's going to be quite common that bus masters out in device land
    have pointers to the same memory region for their mastering yet
    each will need to create its own address space. Let the memory
    API implement sharing for them.
    
    Aside from the perf optimisations, this should reduce the amount
    of redundant output on info mtree as well.
    
    Thee returned value will be malloced, but the malloc will be
    automatically freed when the AS runs out of refs.
    
    Signed-off-by: default avatarPeter Crosthwaite <peter.crosthwaite@xilinx.com>
    [PMM: dropped check for NULL root as unused; added doc-comment;
     squashed Peter C's reference-counting patch into this one;
     don't compare name string when deciding if we can share ASes;
     read as->malloced before the unref of as->root to avoid possible
     read-after-free if as->root was the owner of as]
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    Acked-by: default avatarEdgar E. Iglesias <edgar.iglesias@xilinx.com>
Loading