You need to sign in or sign up before continuing.
  • Alvin Šipraga's avatar
    net: dsa: realtek: allow subdrivers to externally lock regmap · 907e772f
    Alvin Šipraga authored
    
    
    Currently there is no way for Realtek DSA subdrivers to serialize
    consecutive regmap accesses. In preparation for a bugfix relating to
    indirect PHY register access - which involves a series of regmap
    reads and writes - add a facility for subdrivers to serialize their
    regmap access.
    
    Specifically, a mutex is added to the driver private data structure and
    the standard regmap is initialized with custom lock/unlock ops which use
    this mutex. Then, a "nolock" variant of the regmap is added, which is
    functionally equivalent to the existing regmap except that regmap
    locking is disabled. Functions that wish to serialize a sequence of
    regmap accesses may then lock the newly introduced driver-owned mutex
    before using the nolock regmap.
    
    Doing things this way means that subdriver code that doesn't care about
    serialized register access - i.e. the vast majority of code - needn't
    worry about synchronizing register access with an external lock: it can
    just continue to use the original regmap.
    
    Another advantage of this design is that, while regmaps with locking
    disabled do not expose a debugfs interface for obvious reasons, there
    still exists the original regmap which does expose this interface. This
    interface remains safe to use even combined with driver codepaths that
    use the nolock regmap, because said codepaths will use the same mutex
    to synchronize access.
    
    With respect to disadvantages, it can be argued that having
    near-duplicate regmaps is confusing. However, the naming is rather
    explicit, and examples will abound.
    
    Finally, while we are at it, rename realtek_smi_mdio_regmap_config to
    realtek_smi_regmap_config. This makes it consistent with the naming
    realtek_mdio_regmap_config in realtek-mdio.c.
    Signed-off-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
    Reviewed-by: default avatarVladimir Oltean <olteanv@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    907e772f
realtek.h 4.37 KB