1. 25 Oct, 2021 31 commits
    • Jiaran Zhang's avatar
      net: hns3: add error recovery module and type for himac · da3fea80
      Jiaran Zhang authored
      This patch adds himac error recovery module, link_error type and
      ptp_error type for himac.
      Signed-off-by: default avatarJiaran Zhang <zhangjiaran@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      da3fea80
    • Weihang Li's avatar
      net: hns3: add new ras error type for roce · b566ef60
      Weihang Li authored
      This patch adds one ras error of bus related for roce, this error
      including RRESP/BRESP and read poison error.
      Signed-off-by: default avatarWeihang Li <liweihang@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b566ef60
    • Guangbin Huang's avatar
      net: hns3: add update ethtool advertised link modes for FIBRE port when autoneg off · 6eaed433
      Guangbin Huang authored
      Currently, the ethtool advertised link modes of FIBRE port is cleared to
      zero when autoneg is off, so user can not get the advertised link modes
      info directly from "ethtool <dev>" command.
      
      In order to ameliorate this situation, update data of speeds, fec and pause
      of advertised link modes when autoneg is off.
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6eaed433
    • Guangbin Huang's avatar
      net: hns3: modify functions of converting speed ability to ethtool link mode · 58cb422e
      Guangbin Huang authored
      The functions of converting speed ability to ethtool link mode just
      support setting mac->supported currently, to reuse these functions to
      set ethtool link mode for others(i.e. advertising), delete the argument
      mac and add argument link_mode.
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      58cb422e
    • Guangbin Huang's avatar
      net: hns3: add support pause/pfc durations for mac statistics · c8af2887
      Guangbin Huang authored
      The mac statistics add pause/pfc durations in device version V3, we can
      get total active cycle of pause/pfc from these durations.
      
      As driver gets register number from firmware to calculate desc number to
      query mac statistics, it needs to set mac statistics extended enable bit
      in firmware command 0x701A to tell firmware that driver supports extended
      mac statistics, otherwise firmware only returns register number of
      version V1.
      
      As pause/pfc durations are not supported by hardware of old version, they
      should not been shown in command "ethtool -S ethX" in this case, so add
      checking max register number of each mac statistic in their version.
      If the max register number of one mac statistic is greater than register
      number got from firmware, it means hardware does not support this mac
      statistic, so ignore this statistic when get string and data of mac
      statistic.
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c8af2887
    • Guangbin Huang's avatar
      net: hns3: device specifications add number of mac statistics · 4e4c03f6
      Guangbin Huang authored
      Currently, driver queries number of mac statistics before querying mac
      statistics. As the number of mac statistics is a fixed value in firmware,
      it is redundant to query this number everytime before querying mac
      statistics, it can just be queried once in initialization process and
      saved in device specifications.
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4e4c03f6
    • Guangbin Huang's avatar
      net: hns3: modify mac statistics update process for compatibility · 0bd7e894
      Guangbin Huang authored
      After querying mac statistics from firmware, driver copies data from
      descriptors to struct mac_stats of hdev, and the number of copied data
      is just according to the register number queried from firmware. There is
      a problem that if the register number queried from firmware is larger
      than data number of struct mac_stats, it will cause a copy overflow.
      
      So if the firmware adds more mac statistics in later version, it is not
      compatible with driver of old version.
      
      To fix this problem, the number of copied data needs to be used the
      minimum value between the register number queried from firmware and
      data number of struct mac_stats.
      
      The first descriptor has three data and there is one reserved, to
      optimize the copy process, add this reserverd data to struct mac_stats.
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0bd7e894
    • Huazhong Tan's avatar
      net: hns3: add debugfs support for interrupt coalesce · c99fead7
      Huazhong Tan authored
      Since user may need to check the current configuration of the
      interrupt coalesce, so add debugfs support for query this info.
      
      Create a single file "coalesce_info" for it, and query it by
      "cat coalesce_info", return the result to userspace.
      
      For device whose version is above V3(include V3), the GL's register
      contains usecs and 1us unit configuration. When get the usecs
      configuration from this register, it will include the confusing unit
      configuration, so add a GL mask to get the correct value, and add
      a QL mask for the frames configuration as well.
      
      The display style is below:
      $ cat coalesce_info
      tx interrupt coalesce info:
      VEC_ID  ALGO_STATE  PROFILE_ID  CQE_MODE  TUNE_STATE  STEPS_LEFT...
      0       IN_PROG     4           EQE       ON_TOP      0...
      1       START       3           EQE       LEFT        1...
      
      rx interrupt coalesce info:
      VEC_ID  ALGO_STATE  PROFILE_ID  CQE_MODE  TUNE_STATE  STEPS_LEFT...
      0       IN_PROG     3           EQE       LEFT        1...
      1       IN_PROG     0           EQE       ON_TOP      0...
      Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c99fead7
    • David S. Miller's avatar
      Merge branch 's390-qeth-next' · 6047862d
      David S. Miller authored
      Julian Wiedmann says:
      
      ====================
      s390/qeth: updates 2021-10-25
      
      please apply the following patch series for qeth to netdev's net-next tree.
      
      This brings some minor maintenance improvements, and a bunch of cleanups
      so that the W=1 build passes without warning.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6047862d
    • Julian Wiedmann's avatar
      s390/qeth: update kerneldoc for qeth_add_hw_header() · 56c5af25
      Julian Wiedmann authored
      qeth_add_hw_header() is missing documentation for some of its
      parameters, fix that up.
      Reported-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      56c5af25
    • Heiko Carstens's avatar
      s390/qeth: fix kernel doc comments · 7ffaef82
      Heiko Carstens authored
      Fix kernel doc comments and remove incorrect kernel doc indicators.
      Acked-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7ffaef82
    • Heiko Carstens's avatar
      s390/qeth: add __printf format attribute to qeth_dbf_longtext · 79140e22
      Heiko Carstens authored
      Allow the compiler to recognize and check format strings and parameters.
      
      As reported with allmodconfig and W=1:
      
      drivers/s390/net/qeth_core_main.c: In function ‘qeth_dbf_longtext’:
      drivers/s390/net/qeth_core_main.c:6190:9: error: function ‘qeth_dbf_longtext’ might be a candidate for ‘gnu_printf’ format attribute [-Werror=suggest-attribute=format]
       6190 |         vsnprintf(dbf_txt_buf, sizeof(dbf_txt_buf), fmt, args);
            |         ^~~~~~~~~
      Acked-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      79140e22
    • Heiko Carstens's avatar
      s390/qeth: fix various format strings · 22e2b5cd
      Heiko Carstens authored
      Various format strings don't match with types of parameters.
      Fix all of them.
      Acked-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      22e2b5cd
    • Julian Wiedmann's avatar
      s390/qeth: don't keep track of Input Queue count · dc15012b
      Julian Wiedmann authored
      The only actual user of qdio.no_input_queues is qeth_qdio_establish(),
      and there we already have full awareness of the current Input Queue
      configuration (1 RX queue, plus potentially 1 TX Completion queue).
      
      So avoid this state tracking, and the ambiguity it brings with it.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dc15012b
    • Julian Wiedmann's avatar
      s390/qeth: clarify remaining dev_kfree_skb_any() users · fdd3c5f0
      Julian Wiedmann authored
      For none of the users we are under risk of running in HW IRQ context or
      or with IRQs disabled. Thus we always end up in consume_skb().
      
      But the two occurences in the RX path should really report the dropped
      packet to dropmon, so have them use kfree_skb() instead. That's also
      consistent with what napi_free_frags() does internally.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fdd3c5f0
    • Julian Wiedmann's avatar
      s390/qeth: move qdio's QAOB cache into qeth · a18c28f0
      Julian Wiedmann authored
      qdio.ko no longer needs to care about how the QAOBs are allocated,
      from its perspective they are merely another parameter to do_QDIO().
      
      So for a start, shift the cache into the only qdio driver that uses
      QAOBs (ie. qeth). Here there's further opportunity to optimize its
      usage in the future - eg. make it per-{device, TX queue}, or only
      compile it when the driver is built with CQ/QAOB support.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Reviewed-by: default avatarBenjamin Block <bblock@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a18c28f0
    • Julian Wiedmann's avatar
      s390/qeth: remove .do_ioctl() callback from driver discipline · 2decb0b7
      Julian Wiedmann authored
      With commit 18787eee ("qeth: use ndo_siocdevprivate") this callback
      is now actually used to handle transport mode-specific _private_ ioctls.
      
      We only have such ioctls for L3 devices. So wire up a L3-specific
      .ndo_siocdevprivate() callback that handles those ioctls, and defers to
      the core qeth_siocdevprivate() for all other private ioctls.
      
      This takes the discipline one step closer to its original purpose of
      providing an internal extension for the qeth_core_ccwgroup_driver.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2decb0b7
    • Julian Wiedmann's avatar
      s390/qeth: improve trace entries for MAC address (un)registration · 0969becb
      Julian Wiedmann authored
      Add the failed MAC address into the trace message. Also fix up one
      format string to use %x instead of %u for the CARD_DEVID.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Reviewed-by: default avatarAlexandra Winter <wintera@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0969becb
    • David S. Miller's avatar
      Merge branch 'dsa-rtnl' · 57bb1132
      David S. Miller authored
      Vladimir Oltean says:
      
      ====================
      Drop rtnl_lock from DSA .port_fdb_{add,del}
      
      As mentioned in the RFC posted 2 months ago:
      https://patchwork.kernel.org/project/netdevbpf/cover/20210824114049.3814660-1-vladimir.oltean@nxp.com/
      
      DSA is transitioning to a driver API where the rtnl_lock is not held
      when calling ds->ops->port_fdb_add() and ds->ops->port_fdb_del().
      Drivers cannot take that lock privately from those callbacks either.
      
      This change is required so that DSA can wait for switchdev FDB work
      items to finish before leaving the bridge. That change will be made in a
      future patch series.
      
      A small selftest is provided with the patch set in the hope that
      concurrency issues uncovered by this series, but not spotted by me by
      code inspection, will be caught.
      
      A status of the existing drivers:
      
      - mv88e6xxx_port_fdb_add() and mv88e6xxx_port_fdb_del() take
        mv88e6xxx_reg_lock() so they should be safe.
      
      - qca8k_fdb_add() and qca8k_fdb_del() take mutex_lock(&priv->reg_mutex)
        so they should be safe.
      
      - hellcreek_fdb_add() and hellcreek_fdb_add() take mutex_lock(&hellcreek->reg_lock)
        so they should be safe.
      
      - ksz9477_port_fdb_add() and ksz9477_port_fdb_del() take mutex_lock(&dev->alu_mutex)
        so they should be safe.
      
      - b53_fdb_add() and b53_fdb_del() did not have locking, so I've added a
        scheme based on my own judgement there (not tested).
      
      - felix_fdb_add() and felix_fdb_del() did not have locking, I've added
        and tested a locking scheme there.
      
      - mt7530_port_fdb_add() and mt7530_port_fdb_del() take
        mutex_lock(&priv->reg_mutex), so they should be safe.
      
      - gswip_port_fdb() did not have locking, so I've added a non-expert
        locking scheme based on my own judgement (not tested).
      
      - lan9303_alr_add_port() and lan9303_alr_del_port() take
        mutex_lock(&chip->alr_mutex) so they should be safe.
      
      - sja1105_fdb_add() and sja1105_fdb_del() did not have locking, I've
        added and tested a locking scheme.
      
      Changes in v3:
      Unlock arl_mutex only once in b53_fdb_dump().
      
      Changes in v4:
      - Use __must_hold in ocelot and b53
      - Add missing mutex_init in lantiq_gswip
      - Clean up the selftest a bit.
      
      Changes in v5:
      - Replace __must_hold with a comment.
      - Add a new patch (01/10).
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      57bb1132
    • Vladimir Oltean's avatar
      selftests: net: dsa: add a stress test for unlocked FDB operations · eccd0a80
      Vladimir Oltean authored
      This test is a bit strange in that it is perhaps more manual than
      others: it does not transmit a clear OK/FAIL verdict, because user space
      does not have synchronous feedback from the kernel. If a hardware access
      fails, it is in deferred context.
      
      Nonetheless, on sja1105 I have used it successfully to find and solve a
      concurrency issue, so it can be used as a starting point for other
      driver maintainers too.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      eccd0a80
    • Vladimir Oltean's avatar
      selftests: lib: forwarding: allow tests to not require mz and jq · d70b51f2
      Vladimir Oltean authored
      These programs are useful, but not all selftests require them.
      
      Additionally, on embedded boards without package management (things like
      buildroot), installing mausezahn or jq is not always as trivial as
      downloading a package from the web.
      
      So it is actually a bit annoying to require programs that are not used.
      Introduce options that can be set by scripts to not enforce these
      dependencies. For compatibility, default to "yes".
      
      Cc: Nikolay Aleksandrov <nikolay@nvidia.com>
      Cc: Ido Schimmel <idosch@nvidia.com>
      Cc: Guillaume Nault <gnault@redhat.com>
      Cc: Po-Hsu Lin <po-hsu.lin@canonical.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d70b51f2
    • Vladimir Oltean's avatar
      net: dsa: drop rtnl_lock from dsa_slave_switchdev_event_work · 0faf890f
      Vladimir Oltean authored
      After talking with Ido Schimmel, it became clear that rtnl_lock is not
      actually required for anything that is done inside the
      SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE deferred work handlers.
      
      The reason why it was probably added by Arkadi Sharshevsky in commit
      c9eb3e0f ("net: dsa: Add support for learning FDB through
      notification") was to offer the same locking/serialization guarantees as
      .ndo_fdb_{add,del} and avoid reworking any drivers.
      
      DSA has implemented .ndo_fdb_add and .ndo_fdb_del until commit
      b117e1e8 ("net: dsa: delete dsa_legacy_fdb_add and
      dsa_legacy_fdb_del") - that is to say, until fairly recently.
      
      But those methods have been deleted, so now we are free to drop the
      rtnl_lock as well.
      
      Note that exposing DSA switch drivers to an unlocked method which was
      previously serialized by the rtnl_mutex is a potentially dangerous
      affair. Driver writers couldn't ensure that their internal locking
      scheme does the right thing even if they wanted.
      
      We could err on the side of paranoia and introduce a switch-wide lock
      inside the DSA framework, but that seems way overreaching. Instead, we
      could check as many drivers for regressions as we can, fix those first,
      then let this change go in once it is assumed to be fairly safe.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0faf890f
    • Vladimir Oltean's avatar
      net: dsa: introduce locking for the address lists on CPU and DSA ports · 338a3a47
      Vladimir Oltean authored
      Now that the rtnl_mutex is going away for dsa_port_{host_,}fdb_{add,del},
      no one is serializing access to the address lists that DSA keeps for the
      purpose of reference counting on shared ports (CPU and cascade ports).
      
      It can happen for one dsa_switch_do_fdb_del to do list_del on a dp->fdbs
      element while another dsa_switch_do_fdb_{add,del} is traversing dp->fdbs.
      We need to avoid that.
      
      Currently dp->mdbs is not at risk, because dsa_switch_do_mdb_{add,del}
      still runs under the rtnl_mutex. But it would be nice if it would not
      depend on that being the case. So let's introduce a mutex per port (the
      address lists are per port too) and share it between dp->mdbs and
      dp->fdbs.
      
      The place where we put the locking is interesting. It could be tempting
      to put a DSA-level lock which still serializes calls to
      .port_fdb_{add,del}, but it would still not avoid concurrency with other
      driver code paths that are currently under rtnl_mutex (.port_fdb_dump,
      .port_fast_age). So it would add a very false sense of security (and
      adding a global switch-wide lock in DSA to resynchronize with the
      rtnl_lock is also counterproductive and hard).
      
      So the locking is intentionally done only where the dp->fdbs and dp->mdbs
      lists are traversed. That means, from a driver perspective, that
      .port_fdb_add will be called with the dp->addr_lists_lock mutex held on
      the CPU port, but not held on user ports. This is done so that driver
      writers are not encouraged to rely on any guarantee offered by
      dp->addr_lists_lock.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      338a3a47
    • Vladimir Oltean's avatar
      net: dsa: lantiq_gswip: serialize access to the PCE registers · cf231b43
      Vladimir Oltean authored
      The GSWIP switch accesses various bridging layer tables (VLANs, FDBs,
      forwarding rules) indirectly through PCE registers. These hardware
      accesses are non-atomic, being comprised of several register reads and
      writes.
      
      These accesses are currently serialized by the rtnl_lock, but DSA is
      changing its driver API and that lock will no longer be held when
      calling ->port_fdb_add() and ->port_fdb_del().
      
      So this driver needs to serialize the access to the PCE registers using
      its own locking scheme. This patch adds that.
      
      Note that the driver also uses the gswip_pce_load_microcode() function
      to load a static configuration for the packet classification engine into
      a table using the same registers. It is currently not protected, but
      since that configuration is only done from the dsa_switch_ops :: setup
      method, there is no risk of it being concurrent with other operations.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cf231b43
    • Vladimir Oltean's avatar
      net: dsa: b53: serialize access to the ARL table · f7eb4a1c
      Vladimir Oltean authored
      The b53 driver performs non-atomic transactions to the ARL table when
      adding, deleting and reading FDB and MDB entries.
      
      Traditionally these were all serialized by the rtnl_lock(), but now it
      is possible that DSA calls ->port_fdb_add and ->port_fdb_del without
      holding that lock.
      
      So the driver must have its own serialization logic. Add a mutex and
      hold it from all entry points (->port_fdb_{add,del,dump},
      ->port_mdb_{add,del}).
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f7eb4a1c
    • Vladimir Oltean's avatar
      net: mscc: ocelot: serialize access to the MAC table · 2468346c
      Vladimir Oltean authored
      DSA would like to remove the rtnl_lock from its
      SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE handlers, and the felix driver uses
      the same MAC table functions as ocelot.
      
      This means that the MAC table functions will no longer be implicitly
      serialized with respect to each other by the rtnl_mutex, we need to add
      a dedicated lock in ocelot for the non-atomic operations of selecting a
      MAC table row, reading/writing what we want and polling for completion.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2468346c
    • Vladimir Oltean's avatar
      net: dsa: sja1105: serialize access to the dynamic config interface · eb016afd
      Vladimir Oltean authored
      The sja1105 hardware seems as concurrent as can be, but when we create a
      background script that adds/removes a rain of FDB entries without the
      rtnl_mutex taken, then in parallel we do another operation like run
      'bridge fdb show', we can notice these errors popping up:
      
      sja1105 spi2.0: port 2 failed to read back entry for 00:01:02:03:00:40 vid 0: -ENOENT
      sja1105 spi2.0: port 2 failed to add 00:01:02:03:00:40 vid 0 to fdb: -2
      sja1105 spi2.0: port 2 failed to read back entry for 00:01:02:03:00:46 vid 0: -ENOENT
      sja1105 spi2.0: port 2 failed to add 00:01:02:03:00:46 vid 0 to fdb: -2
      
      Luckily what is going on does not require a major rework in the driver.
      The sja1105_dynamic_config_read() function sends multiple SPI buffers to
      the peripheral until the operation completes. We should not do anything
      until the hardware clears the VALID bit.
      
      But since there is no locking (i.e. right now we are implicitly
      serialized by the rtnl_mutex, but if we remove that), it might be
      possible that the process which performs the dynamic config read is
      preempted and another one performs a dynamic config write.
      
      What will happen in that case is that sja1105_dynamic_config_read(),
      when it resumes, expects to see VALIDENT set for the entry it reads
      back. But it won't.
      
      This can be corrected by introducing a mutex for serializing SPI
      accesses to the dynamic config interface which should be atomic with
      respect to each other.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      eb016afd
    • Vladimir Oltean's avatar
      net: dsa: sja1105: wait for dynamic config command completion on writes too · df405910
      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>
      df405910
    • Vladimir Oltean's avatar
      net: dsa: avoid refcount warnings when ->port_{fdb,mdb}_del returns error · 232deb3f
      Vladimir Oltean authored
      At present, when either of ds->ops->port_fdb_del() or ds->ops->port_mdb_del()
      return a non-zero error code, we attempt to save the day and keep the
      data structure associated with that switchdev object, as the deletion
      procedure did not complete.
      
      However, the way in which we do this is suspicious to the checker in
      lib/refcount.c, who thinks it is buggy to increment a refcount that
      became zero, and that this is indicative of a use-after-free.
      
      Fixes: 161ca59d ("net: dsa: reference count the MDB entries at the cross-chip notifier level")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      232deb3f
    • David S. Miller's avatar
      Revert "Merge branch 'dsa-rtnl'" · 2d7e73f0
      David S. Miller authored
      This reverts commit 965e6b26, reversing
      changes made to 4d98bb0d.
      2d7e73f0
    • David S. Miller's avatar
      Merge tag 'linux-can-next-for-5.16-20211024' of... · 12f241f2
      David S. Miller authored
      Merge tag 'linux-can-next-for-5.16-20211024' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next
      
      Marc Kleine-Budde says:
      
      ====================
      pull-request: can-next 2021-10-24
      
      this is a pull request of 15 patches for net-next/master.
      
      The first patch is by Thomas Gleixner and makes use of
      hrtimer_forward_now() in the CAN broad cast manager (bcm).
      
      The next patch is by me and changes the type of the variables used in
      the CAN bit timing calculation can_fixup_bittiming() to unsigned int.
      
      Vincent Mailhol provides 6 patches targeting the CAN device
      infrastructure. The CAN-FD specific Transmitter Delay Compensation
      (TDC) is updated and configuration via the CAN netlink interface is
      added.
      
      Qing Wang's patch updates the at91 and janz-ican3 drivers to use
      sysfs_emit() instead of snprintf() in the sysfs show functions.
      
      Geert Uytterhoeven's patch drops the unneeded ARM dependency from the
      rar Kconfig.
      
      Cai Huoqing's patch converts the mscan driver to make use of the
      dev_err_probe() helper function.
      
      A patch by me against the gsusb driver changes the printf format
      strings to use %u to print unsigned values.
      
      Stephane Grosjean's patch updates the peak_usb CAN-FD driver to use
      the 64 bit timestamps provided by the hardware.
      
      The last 2 patches target the xilinx_can driver. Michal Simek provides
      a patch that removes repeated word from the kernel-doc and Dongliang
      Mu's patch removes a redundant netif_napi_del() from the xcan_remove()
      function.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      12f241f2
  2. 24 Oct, 2021 9 commits