第一步:

确定 pinmap 配置是否正确

diff --git a/target/ums9620_2h10/pinmap.c b/target/ums9620_2h10/pinmap.c
index 36624548..7fe0ed8c 100755
--- a/target/ums9620_2h10/pinmap.c
+++ b/target/ums9620_2h10/pinmap.c
@@ -433,11 +433,11 @@ static pinmap_t pinmap[]={
{REG_MISC_PIN_SD1_D0, BITS_PIN_DS(3)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_OE},//WF_SD1_D0
{REG_PIN_SD1_D1, BITS_PIN_AF(3)},
{REG_MISC_PIN_SD1_D1, BITS_PIN_DS(3)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_OE},//WF_SD1_D1
-{REG_PIN_SD1_CLK, BITS_PIN_AF(3)},
+{REG_PIN_SD1_CLK, BITS_PIN_AF(1)}, //PCIE3_RST
{REG_MISC_PIN_SD1_CLK, BITS_PIN_DS(4)|BIT_PIN_NULL|BIT_PIN_WPD|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPD|BIT_PIN_SLP_OE},//WF_SD1_CLK
-{REG_PIN_SD1_D2, BITS_PIN_AF(3)},
+{REG_PIN_SD1_D2, BITS_PIN_AF(1)}, //PCIE3_CLK
{REG_MISC_PIN_SD1_D2, BITS_PIN_DS(3)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_IE},//WF_SD1_D2
-{REG_PIN_SD1_D3, BITS_PIN_AF(3)},
+{REG_PIN_SD1_D3, BITS_PIN_AF(1)}, //PCIE3_WAKEUP
{REG_MISC_PIN_SD1_D3, BITS_PIN_DS(3)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_OE},//WF_SD1_D3
{REG_PIN_U5TXD, BITS_PIN_AF(3)},
{REG_MISC_PIN_U5TXD, BITS_PIN_DS(1)|BIT_PIN_NULL|BIT_PIN_WPU|BIT_PIN_SLP_AP|BIT_PIN_SLP_WPU|BIT_PIN_SLP_OE},//I2C5_SCL


第二部:确定EP上电时序是否正确

PCIe网口yt6801调试总结_网口

确保AVDD,正常上电

从log看 clkreq# 都没有被拉低, 正常情况下ep 启动后 会拉低这个pin,针对这个问题,需要check 下 clkrq#的pinmap 配置是否正确,在 平台PCIe 初始化时, EP(PCIe 外设)是否已经完成上电时序,处于正常工作状态? 请先确认PCIe 相关pin的pinmap 配置是否正确; PCIe 外设的初始化 阶段在哪里,最好能明确到哪行log, RC在 kernel [ 4.247078] 进行的初始化; 如果 PCIe 外设 在RC 前完成 初始化, 需要删除 dts里面 pcie1 节点的 “ep-poweron-late” 属性, 如不是需要另外调用 扫卡接口(有需要再提供)。

第三步:确保pcie正常工作,能正常枚举出 pci dev

前面提到的问题没有排查清楚 PCIe 是没有正常工作的, PCIe没有正常工作 就没有 枚举出 pci dev, 外设driver 也就match 不到device .

正常枚举出 pci dev 的log 如下:

看log 已经 枚举出 pci dev了, 外设 driver 应该可以match了

[ 4.447631] [08-16 10:07:38.447] pci 0000:11:00.0: [1f0a:6801] type 00 class 0x020000 (2023-08-18T08:20:38Z)

第4步:确保 BAR 有地址

从log 分析 , 外设的 bar0 和 bar4 都是分配了地址的, 请试下 void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) 接口能否 解析出bar 对应的虚拟地址,谢谢!

[ 4.390245] [08-16 09:39:15.390] pci 0000:11:00.0: BAR 0: assigned [mem 0x880000000-0x880003fff 64bit]

[ 4.390342] [08-16 09:39:15.390] pci 0000:11:00.0: BAR 4: assigned [io 0x1000-0x10ff] (2023-08-21T07:04:33Z)


把 pci_dev 结构体的 resource 结构体所有成员变量 打印出来看看

[  281.505181]c7 [ T3144] fxgmac_probe callin

[  281.509241]c7 [ T3144] fuxi-gmac 0000:10:00.0: enabling device (0000 -> 0003)

[  281.516330]c7 [ T3144] resource[0] start 0x0 end 0x0 name 0000:10:00.0 flags 0 desc 0

[  281.524104]c7 [ T3144] fxgmac_probe pci_resource_len(pcidev, 0) == 0

[  281.530428]c7 [ T3144] resource[1] start 0x0 end 0x0 name 0000:10:00.0 flags 0 desc 0

[  281.538212]c7 [ T3144] fxgmac_probe pci_resource_len(pcidev, 1) == 0

[  281.544533]c7 [ T3144] resource[2] start 0x0 end 0x0 name (null) flags 0 desc 0

[  281.551799]c7 [ T3144] fxgmac_probe pci_resource_len(pcidev, 2) == 0

[  281.558121]c7 [ T3144] resource[3] start 0x0 end 0x0 name (null) flags 0 desc 0

[  281.565388]c7 [ T3144] fxgmac_probe pci_resource_len(pcidev, 3) == 0

[  281.571706]c7 [ T3144] resource[4] start 0x0 end 0x0 name (null) flags 0 desc 0

[  281.578972]c7 [ T3144] fxgmac_probe pci_resource_len(pcidev, 4) == 0

[  281.585293]c7 [ T3144] resource[5] start 0x0 end 0x0 name (null) flags 0 desc 0

[  281.592568]c7 [ T3144] fxgmac_probe pci_resource_len(pcidev, 5) == 0

[  281.598883]c7 [ T3144] resource[6] start 0x80100000 end 0x8010ffff name 0000:10:00.0 flags 287232 desc 0

第5步:确定pci dev 的vendor 和device 值

从打印的log 发现一些 问题,外设driver 的match table 有问题,请问你们为何这么修改?

    static const struct pci_device_id fxgmac_pci_tbl[] = {

    /*{ PCI_DEVICE(PCI_VENDOR_ID_SYNOPSYS, PCI_DEVICE_FUXI_GMAC) },*/

    { PCI_DEVICE(0x16c3, 0xabcd) },

    { PCI_DEVICE(0x16c3, 0xaabc) },

    { PCI_DEVICE(0x1f0a, 0x6801) },

    { 0 }

};

请把 { PCI_DEVICE(0x16c3, 0xabcd) } 删除,这个是 rc 对应的pci dev,不是 外设的pci dev(pci 0000:11:00.0: [1f0a:6801] type 00 class 0x020000),

第6步:

确保 base mem 能正常获取到

用原来的API pcim_iomap_regions 读到base mem后,后面关于 base mem的操作,全部都失败了,所以,怀疑base mem的获取这里还是有问题的,并没有获取正确的base mem,因此后面关于 base mem的读写操作全部都失败了,请协助排查下,谢谢

第7步:

经硬件排查 有一路电强制上啦后,发现yt6801 初始化成功了,但是后面open fail 使用新接口pci_ioremap_bar,可以获取到base mem reg可以正常读写成功

第8步:

/* Initialize DMA related features */
    fxgmac_config_dma_bus(pdata);
    printk(KERN_ALERT "%s fxgmac_config_dma_bus end\n", __func__);
    fxgmac_config_osp_mode(pdata);
    fxgmac_config_pblx8(pdata);
    fxgmac_config_tx_pbl_val(pdata);
    fxgmac_config_rx_pbl_val(pdata);
    fxgmac_config_rx_coalesce(pdata);
    fxgmac_config_tx_coalesce(pdata);
    fxgmac_config_rx_buffer_size(pdata);
    printk(KERN_ALERT "%s fxgmac_config_rx_buffer_size end\n", __func__);
    fxgmac_config_tso_mode(pdata);
    fxgmac_config_sph_mode(pdata);
    printk(KERN_ALERT "%s fxgmac_config_sph_mode end\n", __func__);
    fxgmac_config_rss(pdata);
    printk(KERN_ALERT "%s fxgmac_config_rss end\n", __func__);

[   88.866439]c3 [  T615] sipa_dummy: dev eth0 evt 14
[   88.872320]c3 [  T615] fxgmac_open callin
[   88.876422]c3 [  T615] alloc_channels,channel_head=000000002aecd25d,size=ch_cnt 1*704
[   88.884236]c3 [  T615] alloc_channels,tx_ring=00000000cc177d9f,size=cnt 1*192
[   88.891661]c6 [  T615] alloc_channels,rx_ring=00000000a92a000f,size=cnt 1*192
[   88.898771]c6 [  T615] fxgmac_alloc_channels, for MSIx, channel 0 dma_irq=166
[   88.906391]c6 [  T615] alloc_channels callout ok
[   88.911732]c4 [  T615] fxgmac_alloc_ring..ch=0,tx_desc_cnt=256,rx_desc_cnt=1024
[   88.918961]c4 [  T615] alloc_rings callout ok
[   88.923341]c7 [  T615] fxgmac start callin here.
[   88.928080]c7 [  T615] fxgmac_write_ephy_reg id 16 ok, ctrl=0x08100204, data=0x0000006a
[   88.936203]c7 [  T615] fxgmac_write_ephy_reg id 30 ok, ctrl=0x081e0204, data=0x00000052
[   88.944196]c7 [  T615] fxgmac_write_ephy_reg id 31 ok, ctrl=0x081f0204, data=0x0000231d
[   88.952695]c7 [  T615] fxgmac_write_ephy_reg id 30 ok, ctrl=0x081e0204, data=0x00000051
[   88.960624]c7 [  T615] fxgmac_write_ephy_reg id 31 ok, ctrl=0x081f0204, data=0x000004a9
[   88.968579]c7 [  T615] fxgmac_write_ephy_reg id 30 ok, ctrl=0x081e0204, data=0x00000057
[   88.976552]c7 [  T615] fxgmac_write_ephy_reg id 31 ok, ctrl=0x081f0204, data=0x0000274c
[   88.984500]c7 [  T615] fxgmac_write_ephy_reg id 30 ok, ctrl=0x081e0204, data=0x0000a00c
[   88.992466]c7 [  T615] fxgmac_write_ephy_reg id 31 ok, ctrl=0x081f0204, data=0x00002600
[   89.000429]c7 [  T615] fxgmac_write_ephy_reg id 30 ok, ctrl=0x081e0204, data=0x0000a00d
[   89.008391]c7 [  T615] fxgmac_write_ephy_reg id 31 ok, ctrl=0x081f0204, data=0x00001800
[   89.016360]c7 [  T615] fxgmac_write_ephy_reg id 30 ok, ctrl=0x081e0204, data=0x0000a00e
[   89.024313]c7 [  T615] fxgmac_write_ephy_reg id 31 ok, ctrl=0x081f0204, data=0x00000000
[   89.032243]c7 [  T615] fxgmac_dismiss_all_int callin
[   89.037223]c7 [  T615] fxgmac hw init call in
[   89.041508]c7 [  T615] fxgmac_flush_tx_queues, reg=0x00000000b4f56789, val=0x001f0009
[   89.049358]c7 [  T615] fxgmac_flush_tx_queues wait... reg=0x00000000b4f56789, val=0x00000000
[   89.057695]c7 [  T615] fxgmac_hw_init Flush Tx queues end
[   89.063060]c7 [  T615] fxgmac_hw_init fxgmac_config_dma_bus end
[   89.068961]c7 [  T615] fxgmac_hw_init fxgmac_config_rx_buffer_size end
[   89.075440]c7 [  T615] fxgmac_hw_init fxgmac_config_sph_mode end
[   89.081425]c7 [  T615] <panic> p->addr = 0x0000000088bb0afd, pc = 0xffffffc0102a4338, pstate = 0x20400005
[   89.090908]c7 [  T615] sprd_serror_debug: panic hook handler
[   89.090982]c7 [  T615] Kernel panic - not syncing: CFI failure (target: 0xffffffc01ada106c)
[   89.104844]c7 [  T615] CPU: 7 PID: 615 Comm: binder:615_4 Tainted: G S      WC O      5.4.210-android12-9-668746-g152af218b824-dirty #30
[   89.117045]c7 [  T615] Hardware name: Spreadtrum UMS9620 SoC (DT)
[   89.123102]c7 [  T615] Call trace:
[   89.126481]c7 [  T615]  dump_backtrace.cfi_jt+0x0/0x4
[   89.131499]c7 [  T615]  show_stack+0x24/0x34
[   89.135740]c7 [  T615]  dump_stack+0xd8/0x158
[   89.140063]c7 [  T615]  panic+0x19c/0x42c
[   89.144042]c7 [  T615]  __ubsan_handle_cfi_check_fail_abort+0x0/0x20
[   89.150361]c7 [  T615]  __cfi_check_fail+0x0/0x20
[   89.155082]c7 [  T615]  fxgmac_hw_init+0x1384/0x13bc [yt6801]
[   89.160751]c7 [  T615]  fxgmac_start+0x108/0x508 [yt6801]
[   89.166116]c7 [  T615]  fxgmac_open+0x100/0x1e0 [yt6801]
[   89.171394]c7 [  T615]  __dev_open+0x110/0x268
[   89.175806]c7 [  T615]  __dev_change_flags+0xe0/0x238
[   89.180823]c7 [  T615]  dev_change_flags+0x40/0x84
[   89.185583]c7 [  T615]  devinet_ioctl+0x410/0x5d0
[   89.190256]c7 [  T615]  inet_ioctl+0xb8/0x1dc
[   89.194583]c7 [  T615]  sock_do_ioctl+0x68/0x1b8
[   89.199168]c7 [  T615]  sock_ioctl+0x41c/0x6b4
[   89.203585]c7 [  T615]  do_vfs_ioctl+0x3ec/0x70c
[   89.208169]c7 [  T615]  __arm64_sys_ioctl+0x7c/0xa8
[   89.213016]c7 [  T615]  el0_svc_common+0xcc/0x1bc
[   89.217687]c7 [  T615]  el0_svc_handler+0x2c/0x3c
[   89.222363]c7 [  T615]  el0_svc+0x8/0x100
[   89.226350]c7 [  T615] SMP: stopping secondary CPUs
[   89.231200]c1 [    C1] CPU1: stopping...
[   89.235224]c0 [    C0] CPU0: stopping...
[   89.239271]c2 [    C2] CPU2: stopping...
[   89.243297]c3 [    C3] CPU3: stopping...
[   89.247324]c6 [    C6] CPU6: stopping...
[   89.251269]c5 [    C5] CPU5: stopping...
[   89.255215]c4 [    C4] CPU4: stopping...
[   89.259433]c7 [  T615] ddr_cur_freq: 0
[   89.271212]c7 [  T615] unisoc-mailbox tx_fifo full, drop msg, dst = 3, rd =0, wt = 64
[   89.278940]c7 [  T615] unisoc-mailbox smsg_senddie mailbox send die smsg
[   89.285602]c7 [  T615] unisoc-mailbox smsg_senddie mailbox send die smsg
[   89.292261]c7 [  T615] sprd-sysdump: (sysdump_panic_event) ------ in (0)
[   90.299078]c7 [  T615] sprd-sysdump:
[   90.302645]c7 [  T615] sprd-sysdump: *****************************************************
[   90.310863]c7 [  T615] sprd-sysdump: *                                                   *
[   90.319084]c7 [  T615] sprd-sysdump: *  Sysdump enter, preparing debug info to dump ...  *
[   90.327306]c7 [  T615] sprd-sysdump: *                                                   *
[   90.335525]c7 [  T615] sprd-sysdump: *****************************************************
[   90.343747]c7 [  T615] sprd-sysdump:
[   90.347386]c7 [  T615] sprd-sysdump: reason: CFI failure (target: 0xffffffc01ada106c), sprd_sysdump_info->crash_key: 0
[   90.358341]c7 [  T615] sprd-sysdump: KTXT VERIFY...
[   90.429589]c7 [  T615] sprd-sysdump: KTXT [0xffffffc010081000--0xffffffc011130000]
[   90.437042]c7 [  T615] sprd-sysdump: SHA1:
[   90.441111]c7 [  T615] sprd-sysdump: 3a481cfa a01f9243 32d00d64 1c8daf9b 667af798
[   90.448552]c7 [  T615] sprd-sysdump:
[   90.452186]c7 [  T615] sprd-sysdump: *****************************************************
[   90.460408]c7 [  T615] sprd-sysdump: *                                                   *
[   90.468629]c7 [  T615] sprd-sysdump: *  Try to reboot system ...                         *
[   90.476849]c7 [  T615] sprd-sysdump: *                                                   *
[   90.485072]c7 [  T615] sprd-sysdump: *****************************************************
[   90.493292]c7 [  T615] sprd-sysdump:
[   91.497097]c7 [  T615] Kernel Offset: disabled
[   91.501444]c7 [  T615] CPU features: 0x00030006,2a00a238
[   91.506719]c7 [  T615] Memory Limit: none
[   91.510703]c7 [  T615] trusty-log panic notifier - trusty version Unisoc TEE v2.1.1, qogirn6pro, Built: 00:34:16 Feb 28 2023, 277ac0c6 (builder@cishhud0028)
[   91.535071]c7 [  T615] Rebooting in 5 seconds..

定位到 fxgmac_config_rss 这里发生了dump 请协助分析下

第9步:dump 解决


== Weihui.Zhang@unisoc.com On 2023-08-24T08:02:14Z (json) ==

[   89.090982]c7 [  T615] Kernel panic - not syncing: CFI failure (target: 0xffffffc01ada106c)

[   89.104844]c7 [  T615] CPU: 7 PID: 615 Comm: binder:615_4 Tainted: G S      WC O      5.4.210-android12-9-668746-g152af218b824-dirty #30

[   89.117045]c7 [  T615] Hardware name: Spreadtrum UMS9620 SoC (DT)

[   89.123102]c7 [  T615] Call trace:

[   89.126481]c7 [  T615]  dump_backtrace.cfi_jt+0x0/0x4

[   89.131499]c7 [  T615]  show_stack+0x24/0x34

[   89.135740]c7 [  T615]  dump_stack+0xd8/0x158

[   89.140063]c7 [  T615]  panic+0x19c/0x42c

[   89.144042]c7 [  T615]  __ubsan_handle_cfi_check_fail_abort+0x0/0x20

[   89.150361]c7 [  T615]  __cfi_check_fail+0x0/0x20

[   89.155082]c7 [  T615]  fxgmac_hw_init+0x1384/0x13bc [yt6801]

[   89.160751]c7 [  T615]  fxgmac_start+0x108/0x508 [yt6801]

[   89.166116]c7 [  T615]  fxgmac_open+0x100/0x1e0 [yt6801]

[   89.171394]c7 [  T615]  __dev_open+0x110/0x268

[   89.175806]c7 [  T615]  __dev_change_flags+0xe0/0x238

[   89.180823]c7 [  T615]  dev_change_flags+0x40/0x84

[   89.185583]c7 [  T615]  devinet_ioctl+0x410/0x5d0

[   89.190256]c7 [  T615]  inet_ioctl+0xb8/0x1dc

[   89.194583]c7 [  T615]  sock_do_ioctl+0x68/0x1b8

[   89.199168]c7 [  T615]  sock_ioctl+0x41c/0x6b4

[   89.203585]c7 [  T615]  do_vfs_ioctl+0x3ec/0x70c

[   89.208169]c7 [  T615]  __arm64_sys_ioctl+0x7c/0xa8

[   89.213016]c7 [  T615]  el0_svc_common+0xcc/0x1bc

[   89.217687]c7 [  T615]  el0_svc_handler+0x2c/0x3c

[   89.222363]c7 [  T615]  el0_svc+0x8/0x100

这个CFI check失败,往往是函数指针的定义与初始化不一致引起的。 比如返回值 传参等不一致。void * 变成int * 等各种不规范。第三方问题,请第三方主导解决


经排查,是数组越界了,但是android11,上可以跑起来,奇怪,解决后,现在可以看到eth0
eth0      Link encap:Ethernet  HWaddr 00:55:7b:b5:7d:f7  Driver fuxi-gmac
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0