On 5/28/2026 11:07 AM, Erni Sri Satya Vennela wrote: > mana_query_link_cfg() sends an HWC command to firmware on every call, > but the link speed and QoS values it returns only change when the > driver explicitly calls mana_set_bw_clamp(). This function is called > not only by userspace via ethtool get_link_ksettings, but also > periodically by hv_netvsc through netvsc_get_link_ksettings and by > the sysfs speed_show attribute via dev_attr_show, resulting in > unnecessary HWC traffic every few minutes. > > Add a link_cfg_error field to mana_port_context to cache the query > result. The field uses three states: 1 (not yet queried, initial > value set during mana_probe_port), 0 (success, speed/max_speed are > valid), or a negative errno for permanent errors like -EOPNOTSUPP > when the hardware does not support the command. Transient errors and > qos_unconfigured responses are not cached so that subsequent calls > will retry. > > To prevent a concurrent mana_set_bw_clamp() from racing with an > in-flight query and publishing stale pre-clamp speed/max_speed, > serialize the firmware transaction and the cache update under a new > per-port mutex (link_cfg_mutex). The mutex covers both the HWC > request and the subsequent stores in mana_query_link_cfg(), and the > HWC request and invalidation in mana_set_bw_clamp(). With this lock > held, two queries can no longer interleave their speed/max_speed > stores, and an invalidation can no longer slip in between a query's > response and its publish. > > Invalidate the cache inside mana_set_bw_clamp() on success, so all > current and future callers that change the link configuration > automatically trigger a fresh query on the next mana_query_link_cfg() > call. Also reset link_cfg_error during resume in mana_probe() under > link_cfg_mutex, so that any slow-path query already in flight cannot > later store 0 and silently overwrite the post-resume invalidation. > > Signed-off-by: Erni Sri Satya Vennela <[email protected]> > Reviewed-by: Haiyang Zhang <[email protected]> > ---
Reviewed-by: Jacob Keller <[email protected]>

