Re: [RFC Patch net-next 0/6] net: dsa: microchip: add gPTP support for LAN937x switch

From: Christian Eggers
Date: Sun Oct 23 2022 - 16:15:31 EST


Hi Arun, hi Vladimir,

On Tuesday, 18 October 2022, 15:42:41 CEST, Arun.Ramadoss@xxxxxxxxxxxxx wrote:
> Thanks Vladimir. I will wait for Christian feedback.
>
> Hi Christian,
> To test this patch on KSZ9563, we need to increase the number of
> interrupts port_nirqs in KSZ9893 from 2 to 3. Since the chip id of
> KSZ9893 and KSZ9563 are same, I had reused the ksz_chip_data same for
> both chips. But this chip differ with number of port interrupts. So we
> need to update it. We are generating a new patch for adding the new
> element in the ksz_chip_data for KSZ9563.
> For now, you can update the code as below for testing the patch
>
> -- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -1266,7 +1266,7 @@ const struct ksz_chip_data ksz_switch_chips[] =
> {
> .num_statics = 16,
> .cpu_ports = 0x07, /* can be configured as cpu
> port */
> .port_cnt = 3, /* total port count */
> - .port_nirqs = 2,
> + .port_nirqs = 3,
> .ops = &ksz9477_dev_ops,
> .mib_names = ksz9477_mib_names,
> .mib_cnt = ARRAY_SIZE(ksz9477_mib_names),
>
> --

sorry for the delay. I'm currently quite busy with my own work and
my kids' school stuff. Additionally I had to update my internal kernel tree
from 5.15.y-stable-rt to the latest netdev which took longer than I
expected. (Preempt-RT patches tend to become smaller, my ones are only
getting larger).

Prior applying the patches, everything seems to build and run fine.

After applying the patch series, I had some trouble with linking. I had
configured nearly everything as a module:

CONFIG_PTP_1588_CLOCK=m
CONFIG_NET_DSA=m
CONFIG_NET_DSA_MICROCHIP_KSZ_COMMON=m [ksz_switch.ko]
CONFIG_NET_DSA_MICROCHIP_KSZ9477_I2C=m
CONFIG_NET_DSA_MICROCHIP_KSZ_PTP=y [builtin]

With this configuration, kbuild doesn't even try to compile ksz_ptp.c:

ERROR: modpost: "ksz_hwtstamp_get" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_hwtstamp_set" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_port_txtstamp" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_ptp_clock_register" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_port_deferred_xmit" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_ptp_clock_unregister" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_ptp_irq_free" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_tstamp_reconstruct" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_get_ts_info" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!
ERROR: modpost: "ksz_ptp_irq_setup" [drivers/net/dsa/microchip/ksz_switch.ko] undefined!

After setting all of the above to 'y', the build process works (but I would prefer
being able to build as modules). At startup I get a NULL pointer dereference (see below),
but I haven't tried to track down the source yet (will continue tomorrow).

regards,
Christian

[ 17.749629] ksz9477-switch 0-005f: Port2: using phy mode rmii instead of rgmii
[ 17.785998] 8<--- cut here ---
[ 17.789732] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[ 17.798006] [00000000] *pgd=00000000
[ 17.801573] Internal error: Oops: 805 [#1] THUMB2
[ 17.806331] Modules linked in: st_magn_i2c st_sensors_i2c st_magn as73211 usb_storage st_sensors industrialio_triggered_buffer ksz9477_i2c(+) btusb rtc_rv3028 at24 kfifo_b
spidev leds_gpio leds_pwm led_class iio_trig_sysfs imx6sx_adc industrialio micrel fec imx_napi at25 spi_imx i2c_imx nfsv3 nfs lockd grace sunrpc usb_f_ncm u_ether libcomposi
[ 17.847335] CPU: 0 PID: 201 Comm: udevd Not tainted 6.1.0-rc1+ #198
[ 17.853768] Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[ 17.860060] PC is at ksz_connect_tag_protocol+0x6/0x18
[ 17.865286] LR is at dsa_register_switch+0x5a9/0x780
[ 17.870336] pc : [<c02cc6be>] lr : [<c03a4f45>] psr: 60000033
[ 17.876774] sp : c22abc30 ip : ffffffff fp : 00000000
[ 17.882095] r10: c047660c r9 : c0476e70 r8 : c5dcb400
[ 17.887412] r7 : c4f31808 r6 : c1ba1f40 r5 : c4f31800 r4 : c1ba1f40
[ 17.894058] r3 : 00000000 r2 : c02d1325 r1 : 00000007 r0 : 00000000
[ 17.900766] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment none
[ 17.908211] Control: 50c53c7d Table: 822b0059 DAC: 00000051
[ 17.914055] Register r0 information: NULL pointer
[ 17.918929] Register r1 information: non-paged memory
[ 17.924068] Register r2 information: non-slab/vmalloc memory
[ 17.929828] Register r3 information: NULL pointer
[ 17.934613] Register r4 information: slab kmalloc-192 start c1ba1f00 pointer offset 64 size 192
[ 17.943535] Register r5 information: slab kmalloc-64 start c4f31800 pointer offset 0 size 64
[ 17.952131] Register r6 information: slab kmalloc-192 start c1ba1f00 pointer offset 64 size 192
[ 17.961071] Register r7 information: slab kmalloc-64 start c4f31800 pointer offset 8 size 64
[ 17.969665] Register r8 information: slab kmalloc-512 start c5dcb400 pointer offset 0 size 512
[ 17.978434] Register r9 information: non-slab/vmalloc memory
[ 17.984254] Register r10 information: non-slab/vmalloc memory
[ 17.990103] Register r11 information: NULL pointer
[ 17.994977] Register r12 information: non-paged memory
[ 18.000206] Process udevd (pid: 201, stack limit = 0x4afbccb6)
[ 18.006223] Stack: (0xc22abc30 to 0xc22ac000)
[ 18.010658] bc20: 00000000 c22abc48 c0c01300 ff8064a4
[ 18.018992] bc40: ffffffff 00000002 c7eee0e4 00000000 00000168 bf981240 bf9810b8 c5dcbc00
[ 18.027527] bc60: 40000113 00000004 c22abc94 c0306423 40000113 c22f8cd0 c7ef70a8 c0306423
[ 18.035857] bc80: c22abc9c c030823d c7ef73cc c22f8cd0 00000007 c2249240 00000000 c7ef70a8
[ 18.044186] bca0: 000008e0 00000007 c051acdd c05414e4 c05414f9 c02cd2fb 00000000 00000000
[ 18.052718] bcc0: 00000000 00000002 ffffffff ffffffff c0fdf020 000000c4 c2249240 c0fdf000
[ 18.061047] bce0: 00000003 c0fdf020 c224928c bf981240 bf9810b8 bf9800ab c22abd24 bf9810b3
[ 18.069375] bd00: 00000010 00000001 00000000 00000000 00000000 00000020 00000000 00000000
[ 18.077893] bd20: 00000000 00000000 00000000 00000000 00000000 bf98002f bf98002b c2249258
[ 18.086222] bd40: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 18.094611] bd60: 0000ffff 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 18.102940] bd80: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[ 18.111270] bda0: 00000001 00000001 00000000 00000000 00000000 00000000 00000000 00000000
[ 18.119684] bdc0: c32bffc0 c0fdf000 bf980033 bf98201c c0fdf020 c081f0c0 00000026 0000017b
[ 18.128019] bde0: 00000000 c02f8a8d c02f894b 00000000 c0fdf020 bf98201c 00000000 c02993f5
[ 18.136349] be00: 00000001 c0877380 c087748c bf98201c c0fdf020 c0299557 c0fdf064 00000000
[ 18.144739] be20: c0fdf020 bf98201c c080abd8 c081f0c0 c3035d34 c0299853 00000000 c0fdf020
[ 18.153068] be40: bf98201c c02997c7 c080abd8 c029880b c0d17dcc c1878ab0 bf98201c c3035d00
[ 18.153068] be40: bf98201c c02997c7 c080abd8 c029880b c0d17dcc c1878ab0 bf98201c c3035d00
[ 18.161477] be60: 00000000 c0298a93 bf98109f bf9810a0 0000006b bf98201c b6e6a290 c23dba00
[ 18.169808] be80: 00000000 c081f0c0 c23dba00 c0299c1b bf982074 bf982000 b6e6a290 c02f8875
[ 18.178137] bea0: 00000000 bf9b0001 b6e6a290 c0101907 c0c01100 00000cc0 ffffffff 00000008
[ 18.186525] bec0: 00000cc0 c01c1aa7 00006c65 00000000 00000000 c32bfc80 c0138a27 c32bfc80
[ 18.194853] bee0: 00000008 00000040 c32bfc80 c01ab021 00000cc0 ffffffff bf982080 b6e6a290
[ 18.203182] bf00: c32bfc80 0000017b c010027c c0138a41 bf982080 c7fb50e0 00000000 b6e6a290
[ 18.211592] bf20: 00000009 c0139cd1 c22abf38 7fffffff 00000000 00000002 c95aa000 c95ac958
[ 18.219922] bf40: c95aca40 c95aa000 001de8b0 c97764d0 c97762c8 c9733218 00003000 00003080
[ 18.228311] bf60: 00012340 000030e3 00000000 00000000 00000000 00000000 00000000 00012330
[ 18.236640] bf80: 00000749 0000074a 00000279 00000000 00000272 00000000 00000000 b6e7b670
[ 18.244971] bfa0: 0000017b c0100041 00000000 b6e7b670 00000009 b6e6a290 00000000 00000000
[ 18.253373] bfc0: 00000000 b6e7b670 0000017b 0000017b 00000000 b6e7b670 00020000 00000000
[ 18.261710] bfe0: b6e6a290 befaa918 b6e66a23 b6ed4c22 40000030 00000009 00000000 00000000
[ 18.270240] ksz_connect_tag_protocol from dsa_register_switch+0x5a9/0x780
[ 18.277243] dsa_register_switch from ksz_switch_register+0x417/0x48c
[ 18.283797] ksz_switch_register from ksz9477_i2c_probe+0x79/0xfce [ksz9477_i2c]
[ 18.291583] ksz9477_i2c_probe [ksz9477_i2c] from i2c_device_probe+0x143/0x15a
[ 18.299016] i2c_device_probe from really_probe+0xb1/0x188
[ 18.304597] really_probe from driver_probe_device+0x2b/0x88
[ 18.310354] driver_probe_device from __driver_attach+0x8d/0x9e
[ 18.316438] __driver_attach from bus_for_each_dev+0x2b/0x42
[ 18.322196] bus_for_each_dev from bus_add_driver+0x6f/0x128
[ 18.327955] bus_add_driver from driver_register+0x59/0x8e
[ 18.333537] driver_register from i2c_register_driver+0x35/0x54
[ 18.339642] i2c_register_driver from do_one_initcall+0x2b/0xbc
[ 18.345677] do_one_initcall from do_init_module+0x2d/0x1a0
[ 18.351347] do_init_module from sys_finit_module+0x65/0x6c
[ 18.357018] sys_finit_module from ret_fast_syscall+0x1/0x5c
[ 18.362838] Exception stack(0xc22abfa8 to 0xc22abff0)
[ 18.367982] bfa0: 00000000 b6e7b670 00000009 b6e6a290 00000000 00000000
[ 18.376311] bfc0: 00000000 b6e7b670 0000017b 0000017b 00000000 b6e7b670 00020000 00000000
[ 18.384717] bfe0: b6e6a290 befaa918 b6e66a23 b6ed4c22
[ 18.389862] Code: 0093 6a03 2000 4a02 (601a) 4a02
[ 18.394903] ---[ end trace 0000000000000000 ]---