• Lars-Peter Clausen's avatar
    ASoC: dapm: Consolidate input and output path handling · a3423b02
    Lars-Peter Clausen authored
    After the recent cleanups and generalizations of the DAPM algorithm the
    handling of input and output paths is now fully symmetric. This means by
    making some slight changes to the data structure and using arrays with one
    entry for each direction, rather than separate fields, it is possible to
    create a generic implementation that is capable of handling both input and
    output paths.
    
    Unfortunately this generalization significantly increases the code size on
    the hot path of is_connected_{input,output}_ep() and
    dapm_widget_invalidate_{input,output}_paths(), which has a negative impact
    on the overall performance. The inner loops of those functions are quite
    small and the generic implementation adds extra pointer arithmetic in a few
    places.
    
    Testing on ARM shows that the combined code size of the specialized
    functions is about 50% larger than the generalized function in relative
    numbers. But in absolute numbers its less than 200 bytes, which is still
    quite small. On the other hand the generalized function increases the
    execution time of dapm_power_one_widget() by 30%. Given that this function
    is one of the most often called functions of the DAPM framework the
    trade-off of getting better performance at expense of generating slightly
    larger code at seems to be worth it.
    
    To avoid this still keep two versions of these functions around, one for
    input and one for output. But have a generic implementation of the
    algorithm which gets inlined by those two versions. And then let the
    compiler take care of optimizing it and removing he extra instructions.
    
    This still reduces the source code size as well as the makes making changes
    to the implementation more straight forward since the same change does no
    longer need to be done in two separate places. Also on the slow paths we
    can use a generic implementations that handle both input and output paths.
    Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    a3423b02
soc-dapm.h 29.1 KB