• Vladimir Oltean's avatar
    net: dsa: sja1105: wait for dynamic config command completion on writes too · 643979cf
    Vladimir Oltean authored
    The hardware manual says that software should attempt a new dynamic
    config access (be it a a write or a read-back) only while the VALID bit
    is cleared. The VALID bit is set by software to 1, and it remains set as
    long as the hardware is still processing the request.
    
    Currently the driver only polls for the command completion only for
    reads, because that's when we need the actual data read back. Writes
    have been more or less "asynchronous", although this has never been an
    observable issue.
    
    This change makes sja1105_dynamic_config_write poll the VALID bit as
    well, to absolutely ensure that a follow-up access to the static config
    finds the VALID bit cleared.
    
    So VALID means "work in progress", while VALIDENT means "entry being
    read is valid". On reads we check the VALIDENT bit too, while on writes
    that bit is not always defined. So we need to factor it out of the loop,
    and make the loop provide back the unpacked command structure, so that
    sja1105_dynamic_config_read can check the VALIDENT bit.
    
    The change also attempts to convert the open-coded loop to use the
    read_poll_timeout macro, since I know this will come up during review.
    It's more code, but hey, it uses read_poll_timeout!
    
    Tested on SJA1105T, SJA1105S, SJA1110A.
    Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    643979cf
sja1105_dynamic_config.c 48.7 KB