705-10-v5.19-net-dsa-mt753x-fix-pcs-conversion-regression.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. From 1f15b5e8733115cee65342bcaafeaf0368809fae Mon Sep 17 00:00:00 2001
  2. From: "Russell King (Oracle)" <[email protected]>
  3. Date: Mon, 25 Apr 2022 22:28:02 +0100
  4. Subject: [PATCH 10/13] net: dsa: mt753x: fix pcs conversion regression
  5. Daniel Golle reports that the conversion of mt753x to phylink PCS caused
  6. an oops as below.
  7. The problem is with the placement of the PCS initialisation, which
  8. occurs after mt7531_setup() has been called. However, burited in this
  9. function is a call to setup the CPU port, which requires the PCS
  10. structure to be already setup.
  11. Fix this by changing the initialisation order.
  12. Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020
  13. Mem abort info:
  14. ESR = 0x96000005
  15. EC = 0x25: DABT (current EL), IL = 32 bits
  16. SET = 0, FnV = 0
  17. EA = 0, S1PTW = 0
  18. FSC = 0x05: level 1 translation fault
  19. Data abort info:
  20. ISV = 0, ISS = 0x00000005
  21. CM = 0, WnR = 0
  22. user pgtable: 4k pages, 39-bit VAs, pgdp=0000000046057000
  23. [0000000000000020] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000
  24. Internal error: Oops: 96000005 [#1] SMP
  25. Modules linked in:
  26. CPU: 0 PID: 32 Comm: kworker/u4:1 Tainted: G S 5.18.0-rc3-next-20220422+ #0
  27. Hardware name: Bananapi BPI-R64 (DT)
  28. Workqueue: events_unbound deferred_probe_work_func
  29. pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
  30. pc : mt7531_cpu_port_config+0xcc/0x1b0
  31. lr : mt7531_cpu_port_config+0xc0/0x1b0
  32. sp : ffffffc008d5b980
  33. x29: ffffffc008d5b990 x28: ffffff80060562c8 x27: 00000000f805633b
  34. x26: ffffff80001a8880 x25: 00000000000009c4 x24: 0000000000000016
  35. x23: ffffff8005eb6470 x22: 0000000000003600 x21: ffffff8006948080
  36. x20: 0000000000000000 x19: 0000000000000006 x18: 0000000000000000
  37. x17: 0000000000000001 x16: 0000000000000001 x15: 02963607fcee069e
  38. x14: 0000000000000000 x13: 0000000000000030 x12: 0101010101010101
  39. x11: ffffffc037302000 x10: 0000000000000870 x9 : ffffffc008d5b800
  40. x8 : ffffff800028f950 x7 : 0000000000000001 x6 : 00000000662b3000
  41. x5 : 00000000000002f0 x4 : 0000000000000000 x3 : ffffff800028f080
  42. x2 : 0000000000000000 x1 : ffffff800028f080 x0 : 0000000000000000
  43. Call trace:
  44. mt7531_cpu_port_config+0xcc/0x1b0
  45. mt753x_cpu_port_enable+0x24/0x1f0
  46. mt7531_setup+0x49c/0x5c0
  47. mt753x_setup+0x20/0x31c
  48. dsa_register_switch+0x8bc/0x1020
  49. mt7530_probe+0x118/0x200
  50. mdio_probe+0x30/0x64
  51. really_probe.part.0+0x98/0x280
  52. __driver_probe_device+0x94/0x140
  53. driver_probe_device+0x40/0x114
  54. __device_attach_driver+0xb0/0x10c
  55. bus_for_each_drv+0x64/0xa0
  56. __device_attach+0xa8/0x16c
  57. device_initial_probe+0x10/0x20
  58. bus_probe_device+0x94/0x9c
  59. deferred_probe_work_func+0x80/0xb4
  60. process_one_work+0x200/0x3a0
  61. worker_thread+0x260/0x4c0
  62. kthread+0xd4/0xe0
  63. ret_from_fork+0x10/0x20
  64. Code: 9409e911 937b7e60 8b0002a0 f9405800 (f9401005)
  65. ---[ end trace 0000000000000000 ]---
  66. Reported-by: Daniel Golle <[email protected]>
  67. Tested-by: Daniel Golle <[email protected]>
  68. Fixes: cbd1f243bc41 ("net: dsa: mt7530: partially convert to phylink_pcs")
  69. Signed-off-by: Russell King (Oracle) <[email protected]>
  70. Reviewed-by: Florian Fainelli <[email protected]>
  71. Link: https://lore.kernel.org/r/[email protected]
  72. Signed-off-by: Jakub Kicinski <[email protected]>
  73. ---
  74. drivers/net/dsa/mt7530.c | 18 +++++++++---------
  75. 1 file changed, 9 insertions(+), 9 deletions(-)
  76. --- a/drivers/net/dsa/mt7530.c
  77. +++ b/drivers/net/dsa/mt7530.c
  78. @@ -3143,9 +3143,16 @@ static int
  79. mt753x_setup(struct dsa_switch *ds)
  80. {
  81. struct mt7530_priv *priv = ds->priv;
  82. - int ret = priv->info->sw_setup(ds);
  83. - int i;
  84. + int i, ret;
  85. + /* Initialise the PCS devices */
  86. + for (i = 0; i < priv->ds->num_ports; i++) {
  87. + priv->pcs[i].pcs.ops = priv->info->pcs_ops;
  88. + priv->pcs[i].priv = priv;
  89. + priv->pcs[i].port = i;
  90. + }
  91. +
  92. + ret = priv->info->sw_setup(ds);
  93. if (ret)
  94. return ret;
  95. @@ -3157,13 +3164,6 @@ mt753x_setup(struct dsa_switch *ds)
  96. if (ret && priv->irq)
  97. mt7530_free_irq_common(priv);
  98. - /* Initialise the PCS devices */
  99. - for (i = 0; i < priv->ds->num_ports; i++) {
  100. - priv->pcs[i].pcs.ops = priv->info->pcs_ops;
  101. - priv->pcs[i].priv = priv;
  102. - priv->pcs[i].port = i;
  103. - }
  104. -
  105. return ret;
  106. }