1. 08 2月, 2022 1 次提交
    • Y
      net: stmmac: optimize locking around PTP clock reads · 642436a1
      Yannick Vignon 提交于
      Reading the PTP clock is a simple operation requiring only 3 register
      reads. Under a PREEMPT_RT kernel, protecting those reads by a spin_lock is
      counter-productive: if the 2nd task preempting the 1st has a higher prio
      but needs to read time as well, it will require 2 context switches, which
      will pretty much always be more costly than just disabling preemption for
      the duration of the reads. Moreover, with the code logic recently added
      to get_systime(), disabling preemption is not even required anymore:
      reads and writes just need to be protected from each other, to prevent a
      clock read while the clock is being updated.
      
      Improve the above situation by replacing the PTP spinlock by a rwlock, and
      using read_lock for PTP clock reads so simultaneous reads do not block
      each other.
      Signed-off-by: NYannick Vignon <yannick.vignon@nxp.com>
      Link: https://lore.kernel.org/r/20220204135545.2770625-1-yannick.vignon@oss.nxp.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      642436a1
  2. 04 2月, 2022 1 次提交
  3. 01 2月, 2022 1 次提交
    • C
      net: stmmac: dump gmac4 DMA registers correctly · 7af037c3
      Camel Guo 提交于
      Unlike gmac100, gmac1000, gmac4 has 27 DMA registers and they are
      located at DMA_CHAN_BASE_ADDR (0x1100). In order for ethtool to dump
      gmac4 DMA registers correctly, this commit checks if a net_device has
      gmac4 and uses different logic to dump its DMA registers.
      
      This fixes the following KASAN warning, which can normally be triggered
      by a command similar like "ethtool -d eth0":
      
      BUG: KASAN: vmalloc-out-of-bounds in dwmac4_dump_dma_regs+0x6d4/0xb30
      Write of size 4 at addr ffffffc010177100 by task ethtool/1839
       kasan_report+0x200/0x21c
       __asan_report_store4_noabort+0x34/0x60
       dwmac4_dump_dma_regs+0x6d4/0xb30
       stmmac_ethtool_gregs+0x110/0x204
       ethtool_get_regs+0x200/0x4b0
       dev_ethtool+0x1dac/0x3800
       dev_ioctl+0x7c0/0xb50
       sock_ioctl+0x298/0x6c4
       ...
      
      Fixes: fbf68229 ("net: stmmac: unify registers dumps methods")
      Signed-off-by: NCamel Guo <camelg@axis.com>
      Link: https://lore.kernel.org/r/20220131083841.3346801-1-camel.guo@axis.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      7af037c3
  4. 28 1月, 2022 3 次提交
    • J
      net: stmmac: dwmac-sun8i: make clk really gated during rpm suspended · b76bbb34
      Jisheng Zhang 提交于
      Currently, the dwmac-sun8i's stmmaceth clk isn't disabled even if the
      the device has been runtime suspended. The reason is the driver gets
      the "stmmaceth" clk as tx_clk and enabling it during probe. But
      there's no other usage of tx_clk except preparing and enabling, so
      we can remove tx_clk and its usage then rely on the common routine
      stmmac_probe_config_dt() to prepare and enable the stmmaceth clk
      during driver initialization, and benefit from the runtime pm feature
      after probed.
      Signed-off-by: NJisheng Zhang <jszhang@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b76bbb34
    • J
      net: stmmac: properly handle with runtime pm in stmmac_dvr_remove() · 64495203
      Jisheng Zhang 提交于
      There are two issues with runtime pm handling in stmmac_dvr_remove():
      
      1. the mac is runtime suspended before stopping dma and rx/tx. We
      need to ensure the device is properly resumed back.
      
      2. the stmmaceth clk enable/disable isn't balanced in both exit and
      error handling code path. Take the exit code path for example, when we
      unbind the driver or rmmod the driver module, the mac is runtime
      suspended as said above, so the stmmaceth clk is disabled, but
      	stmmac_dvr_remove()
      	  stmmac_remove_config_dt()
      	    clk_disable_unprepare()
      CCF will complain this time. The error handling code path suffers
      from the similar situtaion.
      
      Here are kernel warnings in error handling code path on Allwinner D1
      platform:
      
      [    1.604695] ------------[ cut here ]------------
      [    1.609328] bus-emac already disabled
      [    1.613015] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:952 clk_core_disable+0xcc/0xec
      [    1.621039] CPU: 0 PID: 38 Comm: kworker/u2:1 Not tainted 5.14.0-rc4#1
      [    1.627653] Hardware name: Allwinner D1 NeZha (DT)
      [    1.632443] Workqueue: events_unbound deferred_probe_work_func
      [    1.638286] epc : clk_core_disable+0xcc/0xec
      [    1.642561]  ra : clk_core_disable+0xcc/0xec
      [    1.646835] epc : ffffffff8023c2ec ra : ffffffff8023c2ec sp : ffffffd00411bb10
      [    1.654054]  gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : ffffffff80ed6a6f
      [    1.661272]  t1 : ffffffff80ed6a60 t2 : 0000000000000000 s0 : ffffffe001509e00
      [    1.668489]  s1 : 0000000000000001 a0 : 0000000000000019 a1 : ffffffff80e80bd8
      [    1.675707]  a2 : 00000000ffffefff a3 : 00000000000000f4 a4 : 0000000000000002
      [    1.682924]  a5 : 0000000000000001 a6 : 0000000000000030 a7 : 00000000028f5c29
      [    1.690141]  s2 : 0000000000000800 s3 : ffffffe001375000 s4 : ffffffe01fdf7a80
      [    1.697358]  s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffffffffff
      [    1.704577]  s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001b80000
      [    1.711794]  s11: ffffffe001b80760 t3 : 0000000000000062 t4 : ffffffffffffffff
      [    1.719012]  t5 : ffffffff80e0f6d8 t6 : ffffffd00411b8f0
      [    1.724321] status: 8000000201800100 badaddr: 0000000000000000 cause: 0000000000000003
      [    1.732233] [<ffffffff8023c2ec>] clk_core_disable+0xcc/0xec
      [    1.737810] [<ffffffff80240430>] clk_disable+0x38/0x78
      [    1.742956] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
      [    1.748451] [<ffffffff8031a500>] stmmac_remove_config_dt+0x1c/0x4c
      [    1.754646] [<ffffffff8031c8ec>] sun8i_dwmac_probe+0x378/0x82c
      [    1.760484] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
      [    1.765975] [<ffffffff8029a6c8>] platform_probe+0x64/0xf0
      [    1.771382] [<ffffffff8029833c>] really_probe.part.0+0x8c/0x30c
      [    1.777305] [<ffffffff8029865c>] __driver_probe_device+0xa0/0x148
      [    1.783402] [<ffffffff8029873c>] driver_probe_device+0x38/0x138
      [    1.789324] [<ffffffff802989cc>] __device_attach_driver+0xd0/0x170
      [    1.795508] [<ffffffff802988f8>] __driver_attach_async_helper+0xbc/0xc0
      [    1.802125] [<ffffffff802965ac>] bus_for_each_drv+0x68/0xb4
      [    1.807701] [<ffffffff80298d1c>] __device_attach+0xd8/0x184
      [    1.813277] [<ffffffff802967b0>] bus_probe_device+0x98/0xbc
      [    1.818852] [<ffffffff80297904>] deferred_probe_work_func+0x90/0xd4
      [    1.825122] [<ffffffff8001f8b8>] process_one_work+0x1e4/0x390
      [    1.830872] [<ffffffff8001fd80>] worker_thread+0x31c/0x4d8
      [    1.836362] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    1.841335] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    1.846304] [<ffffffff8001fa60>] process_one_work+0x38c/0x390
      [    1.852054] [<ffffffff80026564>] kthread+0x124/0x160
      [    1.857021] [<ffffffff8002643c>] set_kthread_struct+0x5c/0x60
      [    1.862770] [<ffffffff80001f08>] ret_from_syscall_rejected+0x8/0xc
      [    1.868956] ---[ end trace 8d5c6046255f84a0 ]---
      [    1.873675] ------------[ cut here ]------------
      [    1.878366] bus-emac already unprepared
      [    1.882378] WARNING: CPU: 0 PID: 38 at drivers/clk/clk.c:810 clk_core_unprepare+0xe4/0x168
      [    1.890673] CPU: 0 PID: 38 Comm: kworker/u2:1 Tainted: G        W	5.14.0-rc4 #1
      [    1.898674] Hardware name: Allwinner D1 NeZha (DT)
      [    1.903464] Workqueue: events_unbound deferred_probe_work_func
      [    1.909305] epc : clk_core_unprepare+0xe4/0x168
      [    1.913840]  ra : clk_core_unprepare+0xe4/0x168
      [    1.918375] epc : ffffffff8023d6cc ra : ffffffff8023d6cc sp : ffffffd00411bb10
      [    1.925593]  gp : ffffffff80ec9988 tp : ffffffe00143a800 t0 : 0000000000000002
      [    1.932811]  t1 : ffffffe01f743be0 t2 : 0000000000000040 s0 : ffffffe001509e00
      [    1.940029]  s1 : 0000000000000001 a0 : 000000000000001b a1 : ffffffe00143a800
      [    1.947246]  a2 : 0000000000000000 a3 : 00000000000000f4 a4 : 0000000000000001
      [    1.954463]  a5 : 0000000000000000 a6 : 0000000005fce2a5 a7 : 0000000000000001
      [    1.961680]  s2 : 0000000000000800 s3 : ffffffff80afeb90 s4 : ffffffe01fdf7a80
      [    1.968898]  s5 : ffffffe001375010 s6 : ffffffff8001fc10 s7 : ffffffffffffffff
      [    1.976115]  s8 : 0000000000000001 s9 : ffffffff80ecb248 s10: ffffffe001b80000
      [    1.983333]  s11: ffffffe001b80760 t3 : ffffffff80b39120 t4 : 0000000000000001
      [    1.990550]  t5 : 0000000000000000 t6 : ffffffe001600002
      [    1.995859] status: 8000000201800120 badaddr: 0000000000000000 cause: 0000000000000003
      [    2.003771] [<ffffffff8023d6cc>] clk_core_unprepare+0xe4/0x168
      [    2.009609] [<ffffffff802403a0>] clk_unprepare+0x24/0x3c
      [    2.014929] [<ffffffff8031a508>] stmmac_remove_config_dt+0x24/0x4c
      [    2.021125] [<ffffffff8031c8ec>] sun8i_dwmac_probe+0x378/0x82c
      [    2.026965] [<ffffffff8001fc0c>] worker_thread+0x1a8/0x4d8
      [    2.032463] [<ffffffff8029a6c8>] platform_probe+0x64/0xf0
      [    2.037871] [<ffffffff8029833c>] really_probe.part.0+0x8c/0x30c
      [    2.043795] [<ffffffff8029865c>] __driver_probe_device+0xa0/0x148
      [    2.049892] [<ffffffff8029873c>] driver_probe_device+0x38/0x138
      [    2.055815] [<ffffffff802989cc>] __device_attach_driver+0xd0/0x170
      [    2.061999] [<ffffffff802988f8>] __driver_attach_async_helper+0xbc/0xc0
      [    2.068616] [<ffffffff802965ac>] bus_for_each_drv+0x68/0xb4
      [    2.074193] [<ffffffff80298d1c>] __device_attach+0xd8/0x184
      [    2.079769] [<ffffffff802967b0>] bus_probe_device+0x98/0xbc
      [    2.085345] [<ffffffff80297904>] deferred_probe_work_func+0x90/0xd4
      [    2.091616] [<ffffffff8001f8b8>] process_one_work+0x1e4/0x390
      [    2.097367] [<ffffffff8001fd80>] worker_thread+0x31c/0x4d8
      [    2.102858] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    2.107830] [<ffffffff80026bf4>] kthreadd+0x94/0x188
      [    2.112800] [<ffffffff8001fa60>] process_one_work+0x38c/0x390
      [    2.118551] [<ffffffff80026564>] kthread+0x124/0x160
      [    2.123520] [<ffffffff8002643c>] set_kthread_struct+0x5c/0x60
      [    2.129268] [<ffffffff80001f08>] ret_from_syscall_rejected+0x8/0xc
      [    2.135455] ---[ end trace 8d5c6046255f84a1 ]---
      
      Fixes: 5ec55823 ("net: stmmac: add clocks management for gmac driver")
      Signed-off-by: NJisheng Zhang <jszhang@kernel.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      64495203
    • Y
      net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request. · 928d6fe9
      Yuji Ishikawa 提交于
      Variable clk_sel_val is not initialized in the default case of the first switch statement.
      In that case, the function should return immediately without any changes to the hardware.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Fixes: b38dd98f ("net: stmmac: Add Toshiba Visconti SoCs glue driver")
      Signed-off-by: NYuji Ishikawa <yuji2.ishikawa@toshiba.co.jp>
      Reviewed-by: NNobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      928d6fe9
  5. 27 1月, 2022 3 次提交
  6. 26 1月, 2022 6 次提交
  7. 25 1月, 2022 1 次提交
  8. 24 1月, 2022 1 次提交
  9. 20 1月, 2022 2 次提交
  10. 14 1月, 2022 1 次提交
  11. 13 1月, 2022 1 次提交
  12. 30 12月, 2021 1 次提交
  13. 24 12月, 2021 2 次提交
  14. 23 12月, 2021 1 次提交
    • O
      net: stmmac: add tc flower filter for EtherType matching · e48cb313
      Ong Boon Leong 提交于
      This patch adds basic support for EtherType RX frame steering for
      LLDP and PTP using the hardware offload capabilities.
      
      Example steps for setting up RX frame steering for LLDP and PTP:
      $ IFDEVNAME=eth0
      $ tc qdisc add dev $IFDEVNAME ingress
      $ tc qdisc add dev $IFDEVNAME root mqprio num_tc 8 \
           map 0 1 2 3 4 5 6 7 0 0 0 0 0 0 0 0 \
           queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 0
      
      For LLDP
      $ tc filter add dev $IFDEVNAME parent ffff: protocol 0x88cc \
           flower hw_tc 5
      OR
      $ tc filter add dev $IFDEVNAME parent ffff: protocol LLDP \
           flower hw_tc 5
      
      For PTP
      $ tc filter add dev $IFDEVNAME parent ffff: protocol 0x88f7 \
           flower hw_tc 6
      
      Show tc ingress filter
      $ tc filter show dev $IFDEVNAME ingress
      
      v1->v2:
       Thanks to Kurt's and Sebastian's suggestion.
       - change from __be16 to u16 etype
       - change ETHER_TYPE_FULL_MASK to use cpu_to_be16() macro
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e48cb313
  15. 16 12月, 2021 1 次提交
    • J
      net: stmmac: dwmac-rk: fix oob read in rk_gmac_setup · 0546b224
      John Keeping 提交于
      KASAN reports an out-of-bounds read in rk_gmac_setup on the line:
      
      	while (ops->regs[i]) {
      
      This happens for most platforms since the regs flexible array member is
      empty, so the memory after the ops structure is being read here.  It
      seems that mostly this happens to contain zero anyway, so we get lucky
      and everything still works.
      
      To avoid adding redundant data to nearly all the ops structures, add a
      new flag to indicate whether the regs field is valid and avoid this loop
      when it is not.
      
      Fixes: 3bb3d6b1 ("net: stmmac: Add RK3566/RK3568 SoC support")
      Signed-off-by: NJohn Keeping <john@metanate.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0546b224
  16. 14 12月, 2021 3 次提交
    • O
      net: stmmac: fix tc flower deletion for VLAN priority Rx steering · aeb7c75c
      Ong Boon Leong 提交于
      To replicate the issue:-
      
      1) Add 1 flower filter for VLAN Priority based frame steering:-
      $ IFDEVNAME=eth0
      $ tc qdisc add dev $IFDEVNAME ingress
      $ tc qdisc add dev $IFDEVNAME root mqprio num_tc 8 \
         map 0 1 2 3 4 5 6 7 0 0 0 0 0 0 0 0 \
         queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 hw 0
      $ tc filter add dev $IFDEVNAME parent ffff: protocol 802.1Q \
         flower vlan_prio 0 hw_tc 0
      
      2) Get the 'pref' id
      $ tc filter show dev $IFDEVNAME ingress
      
      3) Delete a specific tc flower record (say pref 49151)
      $ tc filter del dev $IFDEVNAME parent ffff: pref 49151
      
      From dmesg, we will observe kernel NULL pointer ooops
      
      [  197.170464] BUG: kernel NULL pointer dereference, address: 0000000000000000
      [  197.171367] #PF: supervisor read access in kernel mode
      [  197.171367] #PF: error_code(0x0000) - not-present page
      [  197.171367] PGD 0 P4D 0
      [  197.171367] Oops: 0000 [#1] PREEMPT SMP NOPTI
      
      <snip>
      
      [  197.171367] RIP: 0010:tc_setup_cls+0x20b/0x4a0 [stmmac]
      
      <snip>
      
      [  197.171367] Call Trace:
      [  197.171367]  <TASK>
      [  197.171367]  ? __stmmac_disable_all_queues+0xa8/0xe0 [stmmac]
      [  197.171367]  stmmac_setup_tc_block_cb+0x70/0x110 [stmmac]
      [  197.171367]  tc_setup_cb_destroy+0xb3/0x180
      [  197.171367]  fl_hw_destroy_filter+0x94/0xc0 [cls_flower]
      
      The above issue is due to previous incorrect implementation of
      tc_del_vlan_flow(), shown below, that uses flow_cls_offload_flow_rule()
      to get struct flow_rule *rule which is no longer valid for tc filter
      delete operation.
      
        struct flow_rule *rule = flow_cls_offload_flow_rule(cls);
        struct flow_dissector *dissector = rule->match.dissector;
      
      So, to ensure tc_del_vlan_flow() deletes the right VLAN cls record for
      earlier configured RX queue (configured by hw_tc) in tc_add_vlan_flow(),
      this patch introduces stmmac_rfs_entry as driver-side flow_cls_offload
      record for 'RX frame steering' tc flower, currently used for VLAN
      priority. The implementation has taken consideration for future extension
      to include other type RX frame steering such as EtherType based.
      
      v2:
       - Clean up overly extensive backtrace and rewrite git message to better
         explain the kernel NULL pointer issue.
      
      Fixes: 0e039f5c ("net: stmmac: add RX frame steering based on VLAN priority in tc flower")
      Tested-by: NKurt Kanzenbach <kurt@linutronix.de>
      Signed-off-by: NOng Boon Leong <boon.leong.ong@intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aeb7c75c
    • H
      net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX · 9c9211a3
      Hangbin Liu 提交于
      Since commit 94dd016a ("bond: pass get_ts_info and SIOC[SG]HWTSTAMP
      ioctl to active device") the user could get bond active interface's
      PHC index directly. But when there is a failover, the bond active
      interface will change, thus the PHC index is also changed. This may
      break the user's program if they did not update the PHC timely.
      
      This patch adds a new hwtstamp_config flag HWTSTAMP_FLAG_BONDED_PHC_INDEX.
      When the user wants to get the bond active interface's PHC, they need to
      add this flag and be aware the PHC index may be changed.
      
      With the new flag. All flag checks in current drivers are removed. Only
      the checking in net_hwtstamp_validate() is kept.
      Suggested-by: NJakub Kicinski <kuba@kernel.org>
      Signed-off-by: NHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      9c9211a3
    • P
      bpf: Let bpf_warn_invalid_xdp_action() report more info · c8064e5b
      Paolo Abeni 提交于
      In non trivial scenarios, the action id alone is not sufficient to
      identify the program causing the warning. Before the previous patch,
      the generated stack-trace pointed out at least the involved device
      driver.
      
      Let's additionally include the program name and id, and the relevant
      device name.
      
      If the user needs additional infos, he can fetch them via a kernel
      probe, leveraging the arguments added here.
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NToke Høiland-Jørgensen <toke@redhat.com>
      Link: https://lore.kernel.org/bpf/ddb96bb975cbfddb1546cf5da60e77d5100b533c.1638189075.git.pabeni@redhat.com
      c8064e5b
  17. 13 12月, 2021 2 次提交
  18. 30 11月, 2021 1 次提交
    • B
      net: stmmac: Add platform level debug register dump feature · 4047b9db
      Bhupesh Sharma 提交于
      dwmac-qcom-ethqos currently exposes a mechanism to dump rgmii registers
      after the 'stmmac_dvr_probe()' returns. However with commit
      5ec55823 ("net: stmmac: add clocks management for gmac driver"),
      we now let 'pm_runtime_put()' disable the clocks before returning from
      'stmmac_dvr_probe()'.
      
      This causes a crash when 'rgmii_dump()' register dumps are enabled,
      as the clocks are already off.
      
      Since other dwmac drivers (possible future users as well) might
      require a similar register dump feature, introduce a platform level
      callback to allow the same.
      
      This fixes the crash noticed while enabling rgmii_dump() dumps in
      dwmac-qcom-ethqos driver as well. It also allows future changes
      to keep a invoking the register dump callback from the correct
      place inside 'stmmac_dvr_probe()'.
      
      Fixes: 5ec55823 ("net: stmmac: add clocks management for gmac driver")
      Cc: Joakim Zhang <qiangqing.zhang@nxp.com>
      Cc: David S. Miller <davem@davemloft.net>
      Signed-off-by: NBhupesh Sharma <bhupesh.sharma@linaro.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4047b9db
  19. 29 11月, 2021 2 次提交
    • H
      stmmac: remove ethtool driver version info · 09ae03e2
      Heiner Kallweit 提交于
      I think there's no benefit in reporting a date from almost 6 yrs ago.
      Let ethtool report the default (kernel version) instead.
      Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      09ae03e2
    • V
      net: stmmac: Avoid DMA_CHAN_CONTROL write if no Split Header support · f8e7dfd6
      Vincent Whitchurch 提交于
      The driver assumes that split headers can be enabled/disabled without
      stopping/starting the device, so it writes DMA_CHAN_CONTROL from
      stmmac_set_features().  However, on my system (IP v5.10a without Split
      Header support), simply writing DMA_CHAN_CONTROL when DMA is running
      (for example, with the commands below) leads to a TX watchdog timeout.
      
       host$ socat TCP-LISTEN:1024,fork,reuseaddr - &
       device$ ethtool -K eth0 tso off
       device$ ethtool -K eth0 tso on
       device$ dd if=/dev/zero bs=1M count=10 | socat - TCP4:host:1024
       <tx watchdog timeout>
      
      Note that since my IP is configured without Split Header support, the
      driver always just reads and writes the same value to the
      DMA_CHAN_CONTROL register.
      
      I don't have access to any platforms with Split Header support so I
      don't know if these writes to the DMA_CHAN_CONTROL while DMA is running
      actually work properly on such systems.  I could not find anything in
      the databook that says that DMA_CHAN_CONTROL should not be written when
      the DMA is running.
      
      But on systems without Split Header support, there is in any case no
      need to call enable_sph() in stmmac_set_features() at all since SPH can
      never be toggled, so we can avoid the watchdog timeout there by skipping
      this call.
      
      Fixes: 8c6fc097 ("net: stmmac: gmac4+: Add Split Header support")
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f8e7dfd6
  20. 27 11月, 2021 1 次提交
    • Y
      net: stmmac: Disable Tx queues when reconfiguring the interface · b270bfe6
      Yannick Vignon 提交于
      The Tx queues were not disabled in situations where the driver needed to
      stop the interface to apply a new configuration. This could result in a
      kernel panic when doing any of the 3 following actions:
      * reconfiguring the number of queues (ethtool -L)
      * reconfiguring the size of the ring buffers (ethtool -G)
      * installing/removing an XDP program (ip l set dev ethX xdp)
      
      Prevent the panic by making sure netif_tx_disable is called when stopping
      an interface.
      
      Without this patch, the following kernel panic can be observed when doing
      any of the actions above:
      
      Unable to handle kernel paging request at virtual address ffff80001238d040
      [....]
       Call trace:
        dwmac4_set_addr+0x8/0x10
        dev_hard_start_xmit+0xe4/0x1ac
        sch_direct_xmit+0xe8/0x39c
        __dev_queue_xmit+0x3ec/0xaf0
        dev_queue_xmit+0x14/0x20
      [...]
      [ end trace 0000000000000002 ]---
      
      Fixes: 5fabb012 ("net: stmmac: Add initial XDP support")
      Fixes: aa042f60 ("net: stmmac: Add support to Ethtool get/set ring parameters")
      Fixes: 0366f7e0 ("net: stmmac: add ethtool support for get/set channels")
      Signed-off-by: NYannick Vignon <yannick.vignon@nxp.com>
      Link: https://lore.kernel.org/r/20211124154731.1676949-1-yannick.vignon@oss.nxp.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      b270bfe6
  21. 26 11月, 2021 1 次提交
  22. 24 11月, 2021 1 次提交
  23. 22 11月, 2021 2 次提交
    • H
      net: stmmac: retain PTP clock time during SIOCSHWTSTAMP ioctls · a6da2bbb
      Holger Assmann 提交于
      Currently, when user space emits SIOCSHWTSTAMP ioctl calls such as
      enabling/disabling timestamping or changing filter settings, the driver
      reads the current CLOCK_REALTIME value and programming this into the
      NIC's hardware clock. This might be necessary during system
      initialization, but at runtime, when the PTP clock has already been
      synchronized to a grandmaster, a reset of the timestamp settings might
      result in a clock jump. Furthermore, if the clock is also controlled by
      phc2sys in automatic mode (where the UTC offset is queried from ptp4l),
      that UTC-to-TAI offset (currently 37 seconds in 2021) would be
      temporarily reset to 0, and it would take a long time for phc2sys to
      readjust so that CLOCK_REALTIME and the PHC are apart by 37 seconds
      again.
      
      To address the issue, we introduce a new function called
      stmmac_init_tstamp_counter(), which gets called during ndo_open().
      It contains the code snippet moved from stmmac_hwtstamp_set() that
      manages the time synchronization. Besides, the sub second increment
      configuration is also moved here since the related values are hardware
      dependent and runtime invariant.
      
      Furthermore, the hardware clock must be kept running even when no time
      stamping mode is selected in order to retain the synchronized time base.
      That way, timestamping can be enabled again at any time only with the
      need to compensate the clock's natural drifting.
      
      As a side effect, this patch fixes the issue that ptp_clock_info::enable
      can be called before SIOCSHWTSTAMP and the driver (which looks at
      priv->systime_flags) was not prepared to handle that ordering.
      
      Fixes: 92ba6888 ("stmmac: add the support for PTP hw clock driver")
      Reported-by: NMichael Olbrich <m.olbrich@pengutronix.de>
      Signed-off-by: NAhmad Fatoum <a.fatoum@pengutronix.de>
      Signed-off-by: NHolger Assmann <h.assmann@pengutronix.de>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a6da2bbb
    • H
      ethtool: extend ringparam setting/getting API with rx_buf_len · 74624944
      Hao Chen 提交于
      Add two new parameters kernel_ringparam and extack for
      .get_ringparam and .set_ringparam to extend more ring params
      through netlink.
      Signed-off-by: NHao Chen <chenhao288@hisilicon.com>
      Signed-off-by: NGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      74624944
  24. 19 11月, 2021 1 次提交
    • Z
      stmmac_pci: Fix underflow size in stmmac_rx · 0f296e78
      Zekun Shen 提交于
      This bug report came up when we were testing the device driver
      by fuzzing. It shows that buf1_len can get underflowed and be
      0xfffffffc (4294967292).
      
      This bug is triggerable with a compromised/malfunctioning device.
      We found the bug through QEMU emulation tested the patch with
      emulation. We did NOT test it on real hardware.
      
      Attached is the bug report by fuzzing.
      
      BUG: KASAN: use-after-free in stmmac_napi_poll_rx+0x1c08/0x36e0 [stmmac]
      Read of size 4294967292 at addr ffff888016358000 by task ksoftirqd/0/9
      
      CPU: 0 PID: 9 Comm: ksoftirqd/0 Tainted: G        W         5.6.0 #1
      Call Trace:
       dump_stack+0x76/0xa0
       print_address_description.constprop.0+0x16/0x200
       ? stmmac_napi_poll_rx+0x1c08/0x36e0 [stmmac]
       ? stmmac_napi_poll_rx+0x1c08/0x36e0 [stmmac]
       __kasan_report.cold+0x37/0x7c
       ? stmmac_napi_poll_rx+0x1c08/0x36e0 [stmmac]
       kasan_report+0xe/0x20
       check_memory_region+0x15a/0x1d0
       memcpy+0x20/0x50
       stmmac_napi_poll_rx+0x1c08/0x36e0 [stmmac]
       ? stmmac_suspend+0x850/0x850 [stmmac]
       ? __next_timer_interrupt+0xba/0xf0
       net_rx_action+0x363/0xbd0
       ? call_timer_fn+0x240/0x240
       ? __switch_to_asm+0x40/0x70
       ? napi_busy_loop+0x520/0x520
       ? __schedule+0x839/0x15a0
       __do_softirq+0x18c/0x634
       ? takeover_tasklets+0x5f0/0x5f0
       run_ksoftirqd+0x15/0x20
       smpboot_thread_fn+0x2f1/0x6b0
       ? smpboot_unregister_percpu_thread+0x160/0x160
       ? __kthread_parkme+0x80/0x100
       ? smpboot_unregister_percpu_thread+0x160/0x160
       kthread+0x2b5/0x3b0
       ? kthread_create_on_node+0xd0/0xd0
       ret_from_fork+0x22/0x40
      Reported-by: NBrendan Dolan-Gavitt <brendandg@nyu.edu>
      Signed-off-by: NZekun Shen <bruceshenzk@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0f296e78