oz1010's blog

记录生活或技能

以下代码示例都是以Linux开源社区代码为示例,其他版本可能存在差异,版本信息如下:

tag : v6.6.64

commit : 22a054ea1f081d7837cc8e24ad4c7aa36e8bba04

URL : https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tag/?h=v6.6.64

打印与日志

这是最基础且常用的手段。

  • printk:内核最经典的打印函数。通过设置不同的日志级别(如 KERN_ERRKERN_INFO),可以控制输出。配合启动参数 loglevel=8 可查看全部信息。
  • dev_dbg / pr_debug:动态调试的核心。只有在定义了 DEBUG 宏或通过动态调试框架开启后才会输出,适合精细控制打印量。
  • no_printk:用于保留调试语句的格式检查,但编译后不产生实际输出,避免性能损耗。

内核日志

功能配置

配合启动参数 loglevel=8 可查看全部信息。

使用 dmesg 命令查看内核环形缓冲区,或通过 tail -f /var/log/kern.log 实时监控。

动态调试

功能配置

CONFIG_DYNAMIC_DEBUG 动态调试总开关

调整日志等级

DEBUG_KERNEL 内核调试总开关

CONSOLE_LOGLEVEL_DEFAULT 控制台打印等级

CONSOLE_LOGLEVEL_QUIET 安静模式(quiet),控制台打印等级

MESSAGE_LOGLEVEL_DEFAULT 指定未标明等级printk的日志等级

或启动参数增加loglevel=8

使用 dmesg 命令查看内核环形缓冲区

核心模块列表

查看模块名称:ls /sys/module

作用典型日志内容
usbcoreUSB核心层设备枚举、配置、电源管理、URB提交/完成
xhci_hcdUSB 3.0主机控制器XHCI协议事件、端口状态变化、TRB(传输请求块)处理
ehci_hcdUSB 2.0主机控制器EHCI调度、QH/TD(队列头/传输描述符)操作
uhci_hcdohci_hcdUSB 1.1主机控制器低速/全速设备控制
hubUSB集线器驱动端口连接/断开事件、电源管理
usb-storageUSB存储设备驱动SCSI命令转换、批量传输日志
hidHID设备(如键盘鼠标)HID报告描述符解析、中断传输

全局开启USB核心调试

1
2
3
4
# 启用usbcore所有调试信息
echo "module usbcore +p" > /sys/kernel/debug/dynamic_debug/control
# 启用Hub事件日志
echo "module hub +p" > /sys/kernel/debug/dynamic_debug/control

开启SCSI相关(调试存储设备会涉及)调试

1
2
3
4
# 启用 scsi_mod 的调试(SCSI 核心层)
echo 'module scsi_mod +p' > /sys/kernel/debug/dynamic_debug/control
# 启用 sd_mod 的调试(SCSI 磁盘驱动)
echo 'module sd_mod +p' > /sys/kernel/debug/dynamic_debug/control

按需开启主机控制器驱动

1
2
3
# 根据实际使用的控制器选择(通过lsusb -t查看)
echo "module xhci_hcd +p" > /sys/kernel/debug/dynamic_debug/control # USB 3.0
echo "module ehci_hcd +p" > /sys/kernel/debug/dynamic_debug/control # USB 2.0

设备驱动调试

1
2
3
4
5
# 例如调试USB存储设备
echo "module usb-storage +p" > /sys/kernel/debug/dynamic_debug/control
# 调试HID设备
echo "module hid +p" > /sys/kernel/debug/dynamic_debug/control
echo "module hid_generic +p" > /sys/kernel/debug/dynamic_debug/control

按文件过滤

1
2
3
4
5
6
7
8
# 打开特定文件
echo file drivers/usb/core/hub.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/usb/core/hcd.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/usb/dwc3/dwc3-*.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/scsi/sd.c +p > /sys/kernel/debug/dynamic_debug/control

# 仅打印xhci_hcd中关于端口状态的日志
echo "file drivers/usb/host/xhci*.c line 1000-2000 +p" > /sys/kernel/debug/dynamic_debug/control

使用示例:打开usb文件日志——hub、hcd、dwc3和sd

开启模块调试

1
2
3
4
5
6
7
8
9
10
11
12
13
# 启用usbcore所有调试信息
echo "module usbcore +p" > /sys/kernel/debug/dynamic_debug/control
# 启用Hub事件日志
echo "module hub +p" > /sys/kernel/debug/dynamic_debug/control
# 启用 scsi_mod 的调试(SCSI 核心层)
echo 'module scsi_mod +p' > /sys/kernel/debug/dynamic_debug/control
# 启用 sd_mod 的调试(SCSI 磁盘驱动)
echo 'module sd_mod +p' > /sys/kernel/debug/dynamic_debug/control
# 根据实际使用的控制器选择(通过lsusb -t查看)
echo "module xhci_hcd +p" > /sys/kernel/debug/dynamic_debug/control # USB 3.0
# 例如调试USB存储设备
echo "module usb-storage +p" > /sys/kernel/debug/dynamic_debug/control

开启文件

1
2
3
4
echo file drivers/usb/core/hub.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/usb/core/hcd.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/usb/dwc3/dwc3-*.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/scsi/sd.c +p > /sys/kernel/debug/dynamic_debug/control

主控注册

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
[root@tst ]# echo host > /sys/class/usb_role/22100000.dwc3-role-switch/role

[ 22.527815][ T67] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 22.538005][ T67] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[ 22.547638][ T67] xhci-hcd xhci-hcd.0.auto: // Halt the HC
[ 22.553300][ T67] xhci-hcd xhci-hcd.0.auto: Resetting HCD
[ 22.558871][ T67] xhci-hcd xhci-hcd.0.auto: // Reset the HC
[ 22.564809][ T67] xhci-hcd xhci-hcd.0.auto: Wait for controller to be ready for doorbell rings
[ 22.573592][ T67] xhci-hcd xhci-hcd.0.auto: Reset complete
[ 22.579250][ T67] xhci-hcd xhci-hcd.0.auto: Enabling 64-bit DMA addresses.
[ 22.586296][ T67] xhci-hcd xhci-hcd.0.auto: Calling HCD init
[ 22.592127][ T67] xhci-hcd xhci-hcd.0.auto: xhci_init
[ 22.597351][ T67] xhci-hcd xhci-hcd.0.auto: xHCI doesn't need link TRB QUIRK
[ 22.604572][ T67] xhci-hcd xhci-hcd.0.auto: Supported page size register = 0x1
[ 22.611970][ T67] xhci-hcd xhci-hcd.0.auto: Supported page size of 8K
[ 22.618583][ T67] xhci-hcd xhci-hcd.0.auto: HCD page size set to 4K
[ 22.625024][ T67] xhci-hcd xhci-hcd.0.auto: // xHC can handle at most 64 device slots.
[ 22.633112][ T67] xhci-hcd xhci-hcd.0.auto: // Setting Max device slots reg = 0x40.
[ 22.640946][ T67] xhci-hcd xhci-hcd.0.auto: // Device context base array address = 0x0x000000081224b000 (DMA), (____ptrval____) (virt)
[ 22.653210][ T67] xhci-hcd xhci-hcd.0.auto: Allocated command ring at (____ptrval____)
[ 22.661298][ T67] xhci-hcd xhci-hcd.0.auto: First segment DMA is 0x0x000000081224d000
[ 22.669299][ T67] xhci-hcd xhci-hcd.0.auto: // Setting command ring address to 0x000000081224d001
[ 22.678344][ T67] xhci-hcd xhci-hcd.0.auto: // Doorbell array is located at offset 0x2000 from cap regs base addr
[ 22.688793][ T67] xhci-hcd xhci-hcd.0.auto: Allocating primary event ring
[ 22.695767][ T67] xhci-hcd xhci-hcd.0.auto: // Write event ring dequeue pointer, preserving EHB bit
[ 22.705030][ T67] xhci-hcd xhci-hcd.0.auto: Allocating 2 scratchpad buffers
[ 22.712173][ T67] xhci-hcd xhci-hcd.0.auto: Ext Cap (____ptrval____), port offset = 1, count = 1, revision = 0x2
[ 22.722519][ T67] xhci-hcd xhci-hcd.0.auto: xHCI 1.0: support USB2 hardware lpm
[ 22.730002][ T67] xhci-hcd xhci-hcd.0.auto: Ext Cap (____ptrval____), port offset = 2, count = 1, revision = 0x3
[ 22.740349][ T67] xhci-hcd xhci-hcd.0.auto: PSIV:4 PSIE:3 PLT:0 PFD:1 LP:0 PSIM:5
[ 22.748005][ T67] xhci-hcd xhci-hcd.0.auto: PSIV:5 PSIE:3 PLT:0 PFD:1 LP:1 PSIM:10
[ 22.755746][ T67] xhci-hcd xhci-hcd.0.auto: Found 1 USB 2.0 ports and 1 USB 3.0 ports.
[ 22.763835][ T67] xhci-hcd xhci-hcd.0.auto: Finished xhci_init
[ 22.769840][ T67] xhci-hcd xhci-hcd.0.auto: Called HCD init
[ 22.775585][ T67] xhci-hcd xhci-hcd.0.auto: hcc params 0x0118ffcd hci version 0x120 quirks 0x0000008000000010
[ 22.785671][ T67] xhci-hcd xhci-hcd.0.auto: supports USB remote wakeup
[ 22.792382][ T67] xhci-hcd xhci-hcd.0.auto: irq 18, io mem 0x22100000
[ 22.798997][ T67] xhci-hcd xhci-hcd.0.auto: xhci_run
[ 22.804135][ T67] xhci-hcd xhci-hcd.0.auto: ERST deq = 64'h812c21000
[ 22.810661][ T67] xhci-hcd xhci-hcd.0.auto: // Set the interrupt modulation register
[ 22.818576][ T67] xhci-hcd xhci-hcd.0.auto: Finished xhci_run for main hcd
[ 22.825670][ T67] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 22.831852][ T67] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2
[ 22.840204][ T67] xhci-hcd xhci-hcd.0.auto: Host supports USB 3.1 Enhanced SuperSpeed
[ 22.848206][ T67] xhci-hcd xhci-hcd.0.auto: supports USB remote wakeup
[ 22.854906][ T67] xhci-hcd xhci-hcd.0.auto: Enable interrupts
[ 22.860823][ T67] xhci-hcd xhci-hcd.0.auto: Enable primary interrupter
[ 22.867520][ T67] xhci-hcd xhci-hcd.0.auto: // Turn on HC, cmd = 0x5.
[ 22.874158][ T67] usb usb1: default language 0x0409
[ 22.879221][ T67] usb usb1: udev 1, busnum 1, minor = 0
[ 22.884743][ T67] usb usb1: usb_probe_device
[ 22.889193][ T67] usb usb1: configuration #1 chosen from 1 choice
[ 22.895462][ T67] xHCI xhci_add_endpoint called for root hub
[ 22.901294][ T67] xHCI xhci_check_bandwidth called for root hub
[ 22.907396][ T67] usb usb1: adding 1-0:1.0 (config #1, interface 0)
[ 22.913862][ T67] hub 1-0:1.0: usb_probe_interface
[ 22.918829][ T67] hub 1-0:1.0: usb_probe_interface - got id
[ 22.924576][ T67] hub 1-0:1.0: USB hub found
[ 22.929026][ T67] hub 1-0:1.0: 1 port detected
[ 22.933645][ T67] hub 1-0:1.0: standalone hub
[ 22.938176][ T67] hub 1-0:1.0: individual port power switching
[ 22.944182][ T67] hub 1-0:1.0: individual port over-current protection
[ 22.950881][ T67] hub 1-0:1.0: Single TT
[ 22.954978][ T67] hub 1-0:1.0: TT requires at most 8 FS bit times (666 ns)
[ 22.962026][ T67] hub 1-0:1.0: power on to power good time: 20ms
[ 22.968211][ T67] hub 1-0:1.0: local power source is good
[ 22.973809][ T67] hub 1-0:1.0: enabling power on all ports
[ 22.979470][ T67] xhci-hcd xhci-hcd.0.auto: set port power 1-1 ON, portsc: 0x2a0
[ 22.987101][ T67] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 22.995897][ T67] usb usb2: skipped 1 descriptor after endpoint
[ 23.001995][ T67] usb usb2: default language 0x0409
[ 23.007055][ T67] usb usb2: udev 1, busnum 2, minor = 128
[ 23.012638][ T10] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.012711][ T67] usb usb2: usb_probe_device
[ 23.021006][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.025437][ T67] usb usb2: configuration #1 chosen from 1 choice
[ 23.025440][ T67] xHCI xhci_add_endpoint called for root hub
[ 23.031621][ T69] hub 1-0:1.0: hub_suspend
[ 23.037882][ T67] xHCI xhci_check_bandwidth called for root hub
[ 23.043717][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.047991][ T67] usb usb2: adding 2-0:1.0 (config #1, interface 0)
[ 23.054074][ T69] usb usb1: suspend raced with wakeup event
[ 23.059406][ T67] hub 2-0:1.0: usb_probe_interface
[ 23.065821][ T69] usb usb1: usb auto-resume
[ 23.065827][ T69] hub 1-0:1.0: hub_resume
[ 23.071568][ T67] hub 2-0:1.0: usb_probe_interface - got id
[ 23.076529][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.080888][ T67] hub 2-0:1.0: USB hub found
[ 23.085066][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.090818][ T67] hub 2-0:1.0: 1 port detected
[ 23.099156][ T69] hub 1-0:1.0: hub_suspend
[ 23.103600][ T67] hub 2-0:1.0: standalone hub
[ 23.109779][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.114390][ T67] hub 2-0:1.0: individual port power switching
[ 23.118659][ T69] usb usb1: suspend raced with wakeup event
[ 23.123186][ T67] hub 2-0:1.0: individual port over-current protection
[ 23.128495][ T69] usb usb1: usb auto-resume
[ 23.134498][ T67] hub 2-0:1.0: TT requires at most 8 FS bit times (666 ns)
[ 23.140244][ T69] hub 1-0:1.0: hub_resume
[ 23.146938][ T67] hub 2-0:1.0: power on to power good time: 100ms
[ 23.151293][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.177129][ T67] hub 2-0:1.0: local power source is good
[ 23.177129][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.177132][ T69] hub 1-0:1.0: hub_suspend
[ 23.182717][ T67] usb usb2-port1: peered to usb1-port1
[ 23.188880][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.193148][ T67] hub 2-0:1.0: enabling power on all ports
[ 23.198457][ T69] usb usb1: suspend raced with wakeup event
[ 23.203767][ T67] xhci-hcd xhci-hcd.0.auto: set port power 2-1 ON, portsc: 0x2a0
[ 23.209420][ T69] usb usb1: usb auto-resume
[ 23.227086][ T69] hub 1-0:1.0: hub_resume
[ 23.231270][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.239623][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.245805][ T69] hub 1-0:1.0: hub_suspend
[ 23.250078][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.255392][ T69] usb usb1: suspend raced with wakeup event
[ 23.261137][ T69] usb usb1: usb auto-resume
[ 23.265495][ T69] hub 1-0:1.0: hub_resume
[ 23.269677][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.278030][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.284211][ T69] hub 1-0:1.0: hub_suspend
[ 23.288482][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.293794][ T69] usb usb1: suspend raced with wakeup event
[ 23.299539][ T69] usb usb1: usb auto-resume
[ 23.315980][ T69] hub 1-0:1.0: hub_resume
[ 23.315984][ T10] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x2a0, return 0x2a0
[ 23.328509][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.328530][ T73] hub 2-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.336865][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.343046][ T73] xhci-hcd xhci-hcd.0.auto: set port remote wake mask, actual port 2-1 status = 0xe0002a0
[ 23.349219][ T69] hub 1-0:1.0: hub_suspend
[ 23.359045][ T73] hub 2-0:1.0: hub_suspend
[ 23.363309][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.367580][ T73] usb usb2: bus auto-suspend, wakeup 1
[ 23.372888][ T69] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb1 port polling
[ 23.386805][ T73] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling

设备接入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
[ 5722.347763][    C0] xhci-hcd xhci-hcd.0.auto: Port change event, 2-1, id 2, portsc: 0xa021603
[ 5722.356288][ C0] xhci-hcd xhci-hcd.0.auto: resume root hub
[ 5722.362033][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb2 port polling.
[ 5722.370566][ T69] usb usb2: usb wakeup-resume
[ 5722.375105][ T69] usb usb2: usb auto-resume
[ 5722.379475][ T69] hub 2-0:1.0: hub_resume
[ 5722.411484][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x21603, return 0x10203
[ 5722.420195][ T69] usb usb2-port1: status 0203 change 0001
[ 5722.425776][ T69] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x1603
[ 5722.511471][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 5722.539486][ T69] hub 2-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 5722.545668][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 5722.554288][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1603, return 0x203
[ 5722.562733][ T69] usb usb2-port1: status 0203, change 0000, 10.0 Gb/s
[ 5722.569352][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5722.574937][ T69] xhci-hcd xhci-hcd.0.auto: Slot 1 output ctx = 0x0x0000000812d0e000 (dma)
[ 5722.583374][ T69] xhci-hcd xhci-hcd.0.auto: Slot 1 input ctx = 0x0x0000000812d23000 (dma)
[ 5722.591730][ T69] xhci-hcd xhci-hcd.0.auto: Set slot id 1 dcbaa entry (____ptrval____) to 0x812d0e000
[ 5722.601166][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1603, return 0x203
[ 5722.609618][ T69] xhci-hcd xhci-hcd.0.auto: set port reset, actual port 2-1 status = 0x1711
[ 5722.618231][ C0] xhci-hcd xhci-hcd.0.auto: Port change event, 2-1, id 2, portsc: 0x201603
[ 5722.626665][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb2 port polling.
[ 5722.699481][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x201603, return 0x100203
[ 5722.708368][ T69] xhci-hcd xhci-hcd.0.auto: clear port1 reset change, portsc: 0x1603
[ 5722.716297][ T69] xhci-hcd xhci-hcd.0.auto: clear port1 warm(BH) reset change, portsc: 0x1603
[ 5722.725007][ T69] xhci-hcd xhci-hcd.0.auto: clear port1 link state change, portsc: 0x1603
[ 5722.733370][ T69] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x1603
[ 5722.741473][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1603, return 0x203
[ 5722.759470][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 5722.807486][ T69] xhci-hcd xhci-hcd.0.auto: Set root hub portnum to 2
[ 5722.814098][ T69] xhci-hcd xhci-hcd.0.auto: Set fake root hub portnum to 1
[ 5722.821146][ T69] xhci-hcd xhci-hcd.0.auto: udev->tt = 0000000000000000
[ 5722.827932][ T69] xhci-hcd xhci-hcd.0.auto: udev->ttport = 0x0
[ 5722.833939][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5722.839524][ T69] xhci-hcd xhci-hcd.0.auto: Successful setup address command
[ 5722.846748][ T69] xhci-hcd xhci-hcd.0.auto: Op regs DCBAA ptr = 0x00000812ca1000
[ 5722.854316][ T69] xhci-hcd xhci-hcd.0.auto: Slot ID 1 dcbaa entry @(____ptrval____) = 0x00000812d0e000
[ 5722.863794][ T69] xhci-hcd xhci-hcd.0.auto: Output Context DMA address = 0x812d0e000
[ 5722.871711][ T69] xhci-hcd xhci-hcd.0.auto: Internal device address = 1
[ 5722.878500][ T69] usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 4 using xhci-hcd
[ 5722.903806][ T69] usb 2-1: skipped 1 descriptor after endpoint
[ 5722.909813][ T69] usb 2-1: skipped 1 descriptor after endpoint
[ 5722.915818][ T69] usb 2-1: skipped 2 descriptors after endpoint
[ 5722.921909][ T69] usb 2-1: skipped 2 descriptors after endpoint
[ 5722.928001][ T69] usb 2-1: skipped 2 descriptors after endpoint
[ 5722.934092][ T69] usb 2-1: skipped 2 descriptors after endpoint
[ 5722.940214][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 5722.947270][ T69] usb 2-1: default language 0x0409
[ 5722.952260][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 5722.959345][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 5722.966427][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 5722.973486][ T69] usb 2-1: udev 4, busnum 2, minor = 131
[ 5722.979085][ T69] usb 2-1: usb_probe_device
[ 5722.983447][ T69] usb 2-1: configuration #1 chosen from 1 choice
[ 5722.989645][ T69] xhci-hcd xhci-hcd.0.auto: add ep 0x81, slot id 1, new drop flags = 0x0, new add flags = 0x8
[ 5722.999744][ T69] xhci-hcd xhci-hcd.0.auto: add ep 0x2, slot id 1, new drop flags = 0x0, new add flags = 0x18
[ 5723.009832][ T69] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev (____ptrval____)
[ 5723.018885][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5723.024472][ T69] xhci-hcd xhci-hcd.0.auto: Successful Endpoint Configure command
[ 5723.032185][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5723.037763][ C0] xhci-hcd xhci-hcd.0.auto: Stopped on No-op or Link TRB for slot 1 ep 2
[ 5723.046037][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5723.051634][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5723.057212][ C0] xhci-hcd xhci-hcd.0.auto: Stopped on No-op or Link TRB for slot 1 ep 3
[ 5723.065487][ T69] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 5723.071119][ T69] usb 2-1: adding 2-1:1.0 (config #1, interface 0)
[ 5723.078010][ T69] usb-storage 2-1:1.0: usb_probe_interface
[ 5723.084267][ T69] usb-storage 2-1:1.0: usb_probe_interface - got id
[ 5723.090711][ T69] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 5723.097634][ T69] scsi host0: usb-storage 2-1:1.0
[ 5723.102573][ T69] scsi host0: scsi_runtime_idle
[ 5723.107281][ T69] scsi host0: scsi_runtime_suspend
[ 5724.115518][ T69] scsi host0: scsi_runtime_resume
[ 5724.121177][ T69] scsi 0:0:0:0: Direct-Access Seagate One Touch SSD PMAP PQ: 0 ANSI: 6
[ 5724.131109][ T103] sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[ 5724.139523][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 5724.148658][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 5724.158962][ T103] sd 0:0:0:0: [sda] Write Protect is off
[ 5724.164453][ T103] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[ 5724.170582][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 5724.179713][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 5724.190015][ T103] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 5724.201057][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 5724.210187][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 5724.220866][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 5724.229994][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 5724.240742][ T103] sd 0:0:0:0: [sda] Attached SCSI disk

读写数据

1
2
3
4
[root@tst ]# dd if=/dev/urandom of=/dev/sda bs=1K count=8K
8192+0 records in
8192+0 records out
8388608 bytes (8.0MB) copied, 0.381332 seconds, 21.0MB/s

移除SCSI缓存

1
2
3
4
[root@tst ]# echo 1 > /sys/class/block/sda/device/delete 
[ 884.515984][ T85] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[ 884.522985][ T31] scsi host0: scsi_runtime_idle
[ 884.528762][ T31] scsi host0: scsi_runtime_suspend

安全弹出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@tst ]# echo 1 > /sys/bus/usb/devices/2-1/remove
[ 961.784696][ T85] usb 2-1: unregistering interface 2-1:1.0
[ 961.790540][ T85] scsi host0: scsi_runtime_resume
[ 961.828044][ T85] usb 2-1: usb_disable_device nuking non-ep0 URBs
[ 961.834323][ T85] xhci-hcd xhci-hcd.0.auto: xhci_drop_endpoint called for udev 00000000450bf705
[ 961.843213][ T85] xhci-hcd xhci-hcd.0.auto: drop ep 0x81, slot id 1, new drop flags = 0x8, new add flags = 0x0
[ 961.853387][ T85] xhci-hcd xhci-hcd.0.auto: xhci_drop_endpoint called for udev 00000000450bf705
[ 961.862268][ T85] xhci-hcd xhci-hcd.0.auto: drop ep 0x2, slot id 1, new drop flags = 0x18, new add flags = 0x0
[ 961.872443][ T85] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev 00000000450bf705
[ 961.881493][ T85] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 961.887079][ T85] xhci-hcd xhci-hcd.0.auto: Successful Endpoint Configure command
[ 961.894743][ T85] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev 00000000450bf705
[ 961.903819][ T85] usb usb2-port1: logical disconnect
[ 961.908963][ T85] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 961.914540][ C0] xhci-hcd xhci-hcd.0.auto: Stopped on No-op or Link TRB for slot 1 ep 0
[ 961.922811][ T85] xhci-hcd xhci-hcd.0.auto: Set port 2-1 link state, portsc: 0x1603, write 0x11661
[ 961.939962][ T71] hub 2-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 961.946148][ T71] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1663, return 0x263
[ 961.954591][ T71] usb usb2-port1: status 0263, change 0000, 10.0 Gb/s
[ 961.961207][ T71] usb 2-1: USB disconnect, device number 2
[ 961.967992][ T71] usb 2-1: unregistering device
[ 961.972696][ T71] usb 2-1: usb_disable_device nuking all URBs
[ 961.978615][ T71] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev 00000000450bf705
[ 961.987776][ T71] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 961.993366][ T71] xhci-hcd xhci-hcd.0.auto: Set port 2-1 link state, portsc: 0x1663, write 0x11661
[ 962.007982][ T71] xhci-hcd xhci-hcd.0.auto: set port remote wake mask, actual port 2-1 status = 0xe001663
[ 962.017814][ T71] hub 2-0:1.0: hub_suspend
[ 962.022098][ T71] usb usb2: bus auto-suspend, wakeup 1
[ 962.027413][ T71] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling

设备拔出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[  981.667755][    C0] xhci-hcd xhci-hcd.0.auto: Port change event, 2-1, id 2, portsc: 0xc0202a0
[ 981.676279][ C0] xhci-hcd xhci-hcd.0.auto: resume root hub
[ 981.682023][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb2 port polling.
[ 981.690550][ T119] usb usb2: usb wakeup-resume
[ 981.695086][ T119] usb usb2: usb auto-resume
[ 981.699448][ T119] hub 2-0:1.0: hub_resume
[ 981.727974][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x202a0, return 0x102a0
[ 981.736682][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x2a0
[ 981.851977][ T119] hub 2-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 981.858160][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 981.866771][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x2a0, return 0x2a0
[ 981.875125][ T119] usb usb2-port1: status 02a0, change 0000, 10.0 Gb/s
[ 981.881743][ T119] xhci-hcd xhci-hcd.0.auto: set port remote wake mask, actual port 2-1 status = 0xe0002a0
[ 981.891570][ T119] hub 2-0:1.0: hub_suspend
[ 981.895842][ T119] usb usb2: bus auto-suspend, wakeup 1
[ 981.901153][ T119] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling

文件系统接口

  • procfs:通常用于展示进程或系统全局信息。驱动常在此创建只读文件,方便快速查看内部状态。
  • sysfs:内核推荐的属性接口,位于 /sys/。既是调试工具,也是驱动与用户空间的标准配置接口,支持读写。
  • debugfs:专门为开发者设计的接口,位于 /sys/kernel/debug/不应用于生产功能,适合存放驱动内部状态、寄存器快照等调试信息。

sysfs

功能配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
static struct device_attribute dev_attr_xx_read = __ATTR_WO(xx_read);
static struct device_attribute dev_attr_xx_parameters = __ATTR_RW(xx_parameters);
static const struct attribute *usb_attrs[] = {
&dev_attr_xx_read.attr,
&dev_attr_xx_parameters.attr,
NULL,
};
static const struct attribute_group usb_attr_group = {
.attrs = (struct attribute **)usb_attrs,
};

int usb_sysfs_create(struct device *dev)
{
if (dev)
return sysfs_create_group(&dev->kobj, &usb_attr_group);
else
return -1;
}
void usb_sysfs_remove(struct device *dev)
{
if (dev)
sysfs_remove_group(&dev->kobj, &usb_attr_group);
}

static int usb_probe(struct platform_device *pdev)
{
usb_sysfs_create(&pdev->dev);
}

使用示例:usb驱动

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@tst ]# ls /sys/class/udc/
22000000.dwc3

[root@tst ]# ls /sys/class/usb_role/
22000000.dwc3-role-switch 22100000.dwc3-role-switch

[root@tst ]# ls /sys/bus/usb/devices/
1-0:1.0 2-0:1.0 usb1 usb2

[root@tst ]# ls /sys/devices/platform/amba_apu@0/23003000.phy/
consumer:platform:amba_apu@0:usb3 orientation
cr_read parameters
cr_write phy
driver power
driver_override subsystem
modalias uevent
of_node

debugfs

功能配置

参考linux-6.6.64/drivers/usb/dwc3/debugfs.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
static const struct debugfs_reg32 dwc3_regs[] = {
dump_register(GSBUSCFG0), // {&"GSBUSCFG0"[0], 0xc100}
dump_register(GSBUSCFG1), // {&"GSBUSCFG1"[0], 0xc104}
...
}

static const struct file_operations dwc3_lsp_fops = {
.open = dwc3_lsp_open,
.write = dwc3_lsp_write,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

void dwc3_debugfs_init(struct dwc3 *dwc)
{
dwc->regset = kzalloc(sizeof(*dwc->regset), GFP_KERNEL);
dwc->regset->regs = dwc3_regs;
dwc->regset->nregs = ARRAY_SIZE(dwc3_regs);
dwc->regset->base = dwc->regs - DWC3_GLOBALS_REGS_START;
dwc->regset->dev = dwc->dev;

root = debugfs_create_dir(dev_name(dwc->dev), usb_debug_root);
debugfs_create_regset32("regdump", 0444, root, dwc->regset);
debugfs_create_file("lsp_dump", 0644, root, dwc, &dwc3_lsp_fops);
}

使用示例:访问usb驱动属性

查看是否挂载debugfs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 查看是否挂载debugfs
$ mount | grep debugfs
# 手动挂载debugfs
$ mount -t debugfs none /sys/kernel/debug
$ ls /sys/kernel/debug/dwc3/<controller>/<endpoint>
tx_fifo_size
rx_fifo_size
tx_request_queue
rx_request_queue
rx_info_queue
descriptor_fetch_queue
event_queue
transfer_type
trb_ring
GDBGEPINFO

使用示例:增加驱动显示trb缓存

linux-6.6.64/drivers/usb/dwc3/debugfs.c加入桩节点:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index ebf03468f..b8933e16f 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -986,6 +986,55 @@ static const struct dwc3_ep_file_map dwc3_ep_file_map[] = {
{ "GDBGEPINFO", &dwc3_ep_info_register_fops, },
};

+static void (*dwc3_debug_hook)(struct seq_file *s);
+static ssize_t (*dwc3_debug_write_hook)(struct file *file,
+ const char __user *buf,
+ size_t len, loff_t *ppos);
+static int trb_ring_buffer_show(struct seq_file *s, void *unused)
+{
+ seq_puts(s, "trb_ring_buffer: default simple output\n");
+
+ /* 如果模块已注册 hook,则调用模块提供的函数 */
+ if (dwc3_debug_hook)
+ dwc3_debug_hook(s);
+
+ return 0;
+}
+
+static int trb_ring_buffer_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, trb_ring_buffer_show, NULL);
+}
+
+static ssize_t trb_ring_buffer_write(struct file *file,
+ const char __user *buf,
+ size_t len, loff_t *ppos)
+{
+ if (dwc3_debug_write_hook)
+ return dwc3_debug_write_hook(file, buf, len, ppos);
+
+ return len; // 默认忽略写
+}
+static DEFINE_MUTEX(trb_lock);
+static const struct file_operations dwc3_ep_trb_ring_buffer_fops = {
+ .owner = THIS_MODULE,
+ .open = trb_ring_buffer_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = trb_ring_buffer_write,
+};
+void register_dwc3_debug_hook(void (*show)(struct seq_file *),
+ ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *))
+{
+ mutex_lock(&trb_lock);
+ dwc3_debug_hook = show;
+ dwc3_debug_write_hook = write;
+ mutex_unlock(&trb_lock);
+}
+EXPORT_SYMBOL(register_dwc3_debug_hook);
+
+
void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep)
{
struct dentry *dir;
@@ -998,6 +1047,8 @@ void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep)

debugfs_create_file(name, 0444, dir, dep, fops);
}
+
+ debugfs_create_file("trb_ring_buffer", 0444, dir, dep, &dwc3_ep_trb_ring_buffer_fops);
}

void dwc3_debugfs_remove_endpoint_dir(struct dwc3_ep *dep)

dwc3_trb_buffer_debug.c模块文件内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// 文件: dwc3_debug.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/seq_file.h>
#include <linux/uaccess.h>

#define MAX_EP 32
#define MAX_TRB 128

/* 模拟 TRB buffer 数据结构 */
struct dwc3_ep {
char name[16];
unsigned num_trbs;
u32 trb_pool[MAX_TRB][4]; // 每个 TRB 16 bytes
};

/* 调试配置 */
// static int dump_ep_list[MAX_EP];
static int dump_size = 16; // 每 TRB 默认打印 16 bytes

/* hook 回调实现 */
static void dwc3_debug_show(struct seq_file *s)
{
struct dwc3_ep ep = { "ep1", 4 }; // 模拟 EP
int i, j;

seq_printf(s, "Module TRB dump for EP %s\n", ep.name);

for (i = 0; i < ep.num_trbs; i++) {
seq_printf(s, "TRB[%d]: ", i);
for (j = 0; j < dump_size / 4; j++)
seq_printf(s, "%08x ", ep.trb_pool[i][j]);
seq_puts(s, "\n");
}
}

static ssize_t dwc3_debug_write(struct file *file,
const char __user *buf,
size_t len, loff_t *ppos)
{
char cmd[64];
if (len >= sizeof(cmd))
return -EINVAL;

if (copy_from_user(cmd, buf, len))
return -EFAULT;
cmd[len] = 0;

// 简单解析数字配置 TRB 打印大小
// kstrtoint(cmd, 0, &dump_size);
// kstrtoul(cmd, 0, &dump_size)

pr_info("dwc3_debug: dump_size set to %d\n", dump_size);
return len;
}

/* 模块初始化注册 hook */
static int __init dwc3_debug_init(void)
{
extern void register_dwc3_debug_hook(void (*show)(struct seq_file *),
ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *));

register_dwc3_debug_hook(dwc3_debug_show, dwc3_debug_write);
pr_info("dwc3_debug: module loaded\n");
return 0;
}

static void __exit dwc3_debug_exit(void)
{
pr_info("dwc3_debug: module unloaded\n");
}

module_init(dwc3_debug_init);
module_exit(dwc3_debug_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Generated Example");
MODULE_DESCRIPTION("dwc3 debug module for TRB buffer");

Makefile内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
KDIR ?= ../linux-6.6.64
KOUT ?= ../linux-6.6.64/build
CROSS_COMPILETOOL ?= aarch64-linux-gnu-

PWD := $(shell pwd)

obj-m := dwc3_trb_debug.o

all:
$(MAKE) CROSS_COMPILE=$(CROSS_COMPILETOOL) ARCH=arm64 -C $(KDIR) O=$(KOUT) M=$(PWD) modules

clean:
$(MAKE) CROSS_COMPILE=$(CROSS_COMPILETOOL) ARCH=arm64 -C $(KDIR) O=$(KOUT) M=$(PWD) clean

使用示例

1
2
$ echo "all all 256" > trb_ring_buffer
$ echo "1,3 normal,link 512" > trb_ring_buffer

追踪与剖析

  • Ftrace:内核内置的追踪器。可用于查看函数调用流程、分析延时。常用 function_graph 跟踪器查看驱动函数的调用栈,或使用 trace_printk 在追踪日志中加入自定义信息,其性能通常优于 printk
  • Perf:主要用于性能分析,可以定位驱动中的CPU占用过高、缓存命中率低等问题。
  • eBPF:现代Linux的高性能调试利器。可在不修改内核代码的情况下,挂载kprobe/uprobe追踪驱动函数,安全性高且性能开销极小。

FTrace

功能配置

配置内核参数,依赖CONFIG_DEBUG_FS功能

1
2
3
4
5
6
7
8
9
./make.sh menuconfig

Kernel hacking > Tracers
-*- Kernel Function Tracer
[*] Kernel Function Graph Tracer (NEW)
[*] Kernel Function Graph Return Value
-*- enable/disable function tracing dynamically
[*] Kernel function profiler
[*] Trace max stack

ftrace的控制接口位于/sys/kernel/debug/tracing

或者手动挂载/sys/kernel/tracing

1
mount -t tracefs nodev /sys/kernel/tracing

基本使用方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 查看支持的追踪器 function_graph function
cat available_tracers

# 设置追踪器为函数图
echo function_graph > current_tracer

# 设置要追踪的根函数(支持通配符)
echo dwc3* > set_graph_function
# 设置追踪函数
echo xhci_* >> set_ftrace_filter
# 设置函数过滤器
echo _dev_info >> set_ftrace_notrace
echo mutex* >> set_ftrace_notrace

# 开启追踪
echo 1 > tracing_on

# 等待一段时间后停止
echo 0 > tracing_on

# 查看结果
cat trace | head -n 50

# 隐藏函数执行时间 (去掉 280.765 us 这种干扰)
echo nosleep-time > trace_options
echo nograph-time > trace_options

# 隐藏 CPU 编号 (去掉 7) 这种列)
echo nocpu-vis-graph > trace_options

# 隐藏中断/上下文标志 (去掉 ! 或 + 等符号)
echo noirq-info > trace_options

# 如果不需要查看每行的绝对时间戳
echo noannotate > trace_options

# 设置最大层次
echo 5 > max_graph_depth

Trace Events

使用示例:追踪usb

假设要跟踪 进程创建进程退出 事件,它们都包含 pidcomm(进程名)字段,可以使用 DECLARE_EVENT_CLASS 复用代码:

定义事件类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// 基本用法
DECLARE_EVENT_CLASS(
name, // 事件类名称
TP_PROTO(arguments), // 事件的原型 (参数列表)
TP_ARGS(arguments), // 事件的参数
TP_STRUCT__entry(...), // 结构体字段定义
TP_fast_assign(...), // 事件字段的赋值
TP_printk(fmt, ...) // 事件的格式化打印
);
// 示例
DECLARE_EVENT_CLASS(
process_event,
TP_PROTO(pid_t pid, const char *comm),
TP_ARGS(pid, comm),
TP_STRUCT__entry(
__field(pid_t, pid)
__string(comm, comm)
),
TP_fast_assign(
__entry->pid = pid;
__assign_str(comm, comm);
),
TP_printk("pid=%d comm=%s", __entry->pid, __get_str(comm))
);

定义 forkexit 事件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// 基本用法
DEFINE_EVENT(
name, // 事件类名称(与 DECLARE_EVENT_CLASS 一致)
event_name, // 具体事件的名称
TP_PROTO(...),
TP_ARGS(...)
);
// 示例
DEFINE_EVENT(process_event,
process_fork,
TP_PROTO(pid_t pid, const char *comm),
TP_ARGS(pid, comm));
DEFINE_EVENT(process_event,
process_exit,
TP_PROTO(pid_t pid, const char *comm),
TP_ARGS(pid, comm));

代码中触发事件

1
2
3
4
5
// 基本用法
trace_EVENTNAME(...)
// 示例
trace_process_fork(current->pid, current->comm);
trace_process_exit(current->pid, current->comm);

这样就可以高效地记录进程 fork 和退出的事件,而不用重复定义 TP_STRUCT__entryTP_fast_assignTP_printk

tracepoints

使用示例:追踪usb

查看功能是否开启

1
2
3
ls /sys/kernel/debug/tracing
mount -t tracefs nodev /sys/kernel/tracing
mount -t debugfs none /sys/kernel/debug

查看trace支持的event

1
2
3
grep "^usb:" /sys/kernel/debug/tracing/available_events
grep "^xhci" /sys/kernel/debug/tracing/available_events
grep "^dwc3" /sys/kernel/debug/tracing/available_events

配置trace的event

1
2
3
4
5
6
# 开启某个trace
echo 1 > /sys/kernel/debug/tracing/events/usb/usb_submit_urb/enable
echo 1 > /sys/kernel/debug/tracing/events/usb/usb_complete_urb/enable
# 开启模块trace
echo 1 > /sys/kernel/debug/tracing/events/dwc3/enable
echo 1 > /sys/kernel/debug/tracing/events/xhci/enable

查看trace

1
2
3
4
# 查看trace
cat /sys/kernel/debug/tracing/trace
# 实时trace
cat /sys/kernel/debug/tracing/trace_pipe

trace写文件

1
2
3
4
5
6
7
echo > /sys/kernel/debug/tracing/trace
echo 0 > /sys/kernel/debug/tracing/tracing_on
# 配置trace的event
echo 1 > /sys/kernel/debug/tracing/tracing_on
# 在这里进行你的 USB 操作(插拔、传输等)
echo 0 > /sys/kernel/debug/tracing/tracing_on
cp /sys/kernel/debug/tracing/trace usb_trace.log

内核崩溃分析

  • Kdump:系统崩溃(如内核态空指针访问)时,Kdump 会捕获并保存内存转储文件(vmcore)。
  • 分析工具:结合 Crash 工具进行分析,可查看崩溃时的全局变量、调用栈、内存数据。在开发阶段,也可使用 BUG_ONWARN_ON 等断言宏来主动预警。

静态检查

在运行前排查潜在问题。

  • Sparse:专门用于检查内核代码的端序问题(如 __bitwise)和地址空间类型(如 __user)。
  • Smatch / Coccinelle:分别用于检查空指针、资源泄漏等逻辑错误,以及进行语义匹配和自动修改。
  • 编译器警告:建议使用 WallWerror 以及内核推荐的 W=1 编译参数,尽可能消除警告。

硬件辅助调试

  • JTAG:使用仿真器(如BDI3000、ULINK)进行源码级单步调试、设置硬件断点。在调试早期启动代码或DMA(直接内存访问)导致的“内存被谁改写”问题时,效果显著。
  • 逻辑分析仪 / 示波器:用于排查硬件时序、总线协议(I2C、SPI)是否正确,可确认数据是否真正被硬件发送出去。

JTAG

调试模式内核编译

主要参考:QEMU调试Linux内核环境搭建

1
./make.sh menuconfig

在配置菜单中,启用内核debug,关闭地址随机化,不然断点处无法停止。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 6.1.64版本内核选项
# 优化选项需要直接从顶层Makefile修改即可
# General setup --->
# Compiler optimization level (Optimize for size (-Os)) --->
# (X) Optimize for size (-Os)
Kernel Features --->
[] Randomize the address of the kernel image
Kernel hacking --->
[*] Kernel debugging
Compile-time checks and compiler options --->
[*] Provide GDB scripts for kernel debuggin
[*] Make section mismatch errors non-fatal

# 4.14.191
# 需要关闭优化项 Compiler optimization level (Optimize for size (-Os))
Kernel hacking --->
[*] Kernel debugging
Compile-time checks and compiler options --->
[*] Compile the kernel with debug info
[*] Provide GDB scripts for kernel debuggin
Processor type and features ---->
[] Randomize the address of the kernel image (KASLR)

调整全局优化等级

强行修改优化选项改为-Og(-O0 可以完全禁用优化,但生成的代码体积有点大)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/Makefile b/Makefile
index c809b21c3..7b189d210 100644
--- a/Makefile
+++ b/Makefile
@@ -848,10 +848,10 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)

ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
-KBUILD_CFLAGS += -O2
+KBUILD_CFLAGS += -Og
KBUILD_RUSTFLAGS += -Copt-level=2
else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-KBUILD_CFLAGS += -Os
+KBUILD_CFLAGS += -Og
KBUILD_RUSTFLAGS += -Copt-level=s
endif

校验是否将static函数优化掉

1
2
// hub_port_connect_change在android-kernel-6.1/drivers/usb/core/hub.c中的static函数,默认不应该内联
nm build/vmlinux | grep "hub_port_connect_change"

使用混合编译方式编译内核,否则部分模块会报错

1
./make.sh CFLAGS_patching.o="-O2" CFLAGS_pci.o="-O2" -j8

调整模块级优化等级

这里调整usb模块的优化等级,全局依然保持(-O2)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
index 1e7868497..0e9875a29 100644
--- a/drivers/usb/dwc3/Makefile
+++ b/drivers/usb/dwc3/Makefile
@@ -1,9 +1,13 @@
# SPDX-License-Identifier: GPL-2.0
# define_trace.h needs to know how to find our header
CFLAGS_trace.o := -I$(src)
+# 模块使用指定优化等级
+ccflags-y += -Og -g

+# core.o使用指定优化等级
+# CFLAGS_core.o := -Og -g
dwc3-y := core.o

ifneq ($(CONFIG_TRACING),)

启动OpenOCD

【不可用】wsl中启动(USB无法绑定)

wsl中使用OpenOCD需要将JTAG设备连接到子系统中,管理员权限运行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ usbipd list
Connected:
BUSID VID:PID DEVICE STATE
2-1 1fc9:5601 USB 串行设备 (COM18), USB 输入设备 Not shared
2-8 0483:5130 USB 输入设备 Not shared
2-9 0a12:0001 Generic Bluetooth Radio Not shared
2-13 5000:0220 USB 输入设备 Not shared
3-1 04e2:1414 XR21V1414 USB UART Ch A (COM7), XR21V1414 USB UART Ch B (... Not shared

Persisted:
GUID DEVICE
3d92583e-5954-49b4-8cc0-881a70c3d5de XR21V1414 USB UART Ch A (COM20), XR21V1414 USB UART Ch B ...M
96fd4531-5c1f-432e-be0a-b9cde47306fa J-Link

$ usbipd bind --force --busid 2-1

$ usbipd attach --wsl --auto-attach --busid 2-1

windows中启动

暂时无法在飞书文档外展示此内容

容器中访问主机,需要暴露调试端口3333,并增加绑定网络

允许端口通过防火墙,确保外部请求可达:

  1. 打开 设置 > 搜索 “Windows Defender 防火墙”。
  2. 点击 高级设置 进入高级安全防火墙。
  3. 在左侧选择 入站规则 > 右侧点击 新建规则。
  4. 规则类型选择 端口 > 点击 下一步。
  5. 选择 TCP,输入特定端口 3333 > 点击 下一步。
  6. 选择 允许连接 > 点击 下一步。
  7. 勾选所有网络类型(域、专用、公用)> 点击 下一步。
  8. 输入规则名称(如 openocd-调试端口)> 点击 完成。

openocd-dap.cfg

1
2
3
4
adapter driver cmsis-dap
transport select jtag
adapter speed 12000
bindto 0.0.0.0

windows终端启动OpenOCD

1
$ .\bin\openocd -c "set _CORES [range 0 8]" -c "set _DEF_RTOS linux" -f .\openocd\scripts\interface\cmsis-dap.cfg -f .\openocd\scripts\target\cpu-a78.cfg

windows终端中查看绑定的端口

1
2
$ netstat -ano | findstr :3333
TCP 0.0.0.0:3333 0.0.0.0:0 LISTENING 25976

启动GDB开启远程调试

容器中启动

1
2
aarch64-linux-gnu-gdb kernel/android-kernel-6.1/build/vmlinux
target remote 10.28.11.217:3333

使用.gdbinit文件可以避免重复输入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
define add_user_break
hb *$arg0
commands
printf "hit breakpoint, pc:%#lx id:%d\n", $pc, $_hit_bpnum
continue
end
end

target extended-remote :3333
d
add_user_break 0xffff800080946ec8
add_user_break 0xffff800080946f84
add_user_break 0xffff800080946fb4
add_user_break 0xffff800080946fec
add_user_break 0xffff80008094700c
add_user_break 0xffff80008094701c
c

驱动专用手段

USB Monitor

usbmon是内核监控工具,需要手动开启(或修改宏CONFIG_USB_MON

1
2
3
4
5
6
7
8
9
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 O=build menuconfig

Device Drivers --->
[*] USB support --->
<M> USB Monitor

make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 O=build -j8
make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 O=build modules -j8
# usbmon模块存在路径 build/drivers/usb/mon/usbmon.ko

将模块上传板端并加载

1
2
3
adb push .\build\drivers\usb\mon\usbmon.ko /home/root
insmod ./usbmon.ko
# modprobe usbmon # 自动解决依赖,但需要模块文件在/lib/modules/6.1.64/kernel中

查看统计信息,0u表示所有USB总线,

1
2
3
# mount -t debugfs none_debugs /sys/kernel/debug # 挂载调试文件系统
root@tst:~# ls /sys/kernel/debug/usb/usbmon
0s 0u 1s 1t 1u 2s 2t 2u

usbmon.rst官方说明文档

usbmon数据结构说明

1
2
3
4
5
# 直接抓取所有总线数据
cat /sys/kernel/debug/usb/usbmon/0u

# URB Tag Timestamp (us) Event "Address" Status Length Data
# ffff000820a6b228 1283730040 S Bo:2:003:2 -115 24 = 4f50454e ...

Event:

  • S:submission
  • C:callback
  • E:submission error

“Address”结构:URB type & direction:Bus number:Device address:Endpoint number

URB type & direction:

  • Ci Co Control input and output
  • Zi Zo Isochronous input and output
  • Ii Io Interrupt input and output
  • Bi Bo Bulk input and output

wireshark解析usbmon数据

1
2
3
4
5
6
7
8
9
10
11
12
13
# 编译libpcap
wget https://www.tcpdump.org/release/libpcap-1.10.4.tar.gz
./configure --prefix=/opt/arm/libpcap --host=arm-linux --with-pcap=linux ac_cv_linux_vers=2 CC=aarch64-linux-gnu-gcc
make -j8
make install
# 编译tcpdump
wget https://www.tcpdump.org/release/tcpdump-4.99.4.tar.gz
./configure --prefix=/opt/arm/tcpdump --host=arm-linux CC=aarch64-linux-gnu-gcc --with-system-libpcap=/opt/arm/libpcap
make -j8
make install

# cat /sys/kernel/debug/usb/usbmon/0u > usb_data.log
tcpdump -i usbmon0 -w usb_capture.pcap

实例说明:硬盘识别过程

状态码:-115-EINPROGRESS)—— 操作仍在进行;经常出现在BULK out/in中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
ffff0008c53b1300 304760007 S Ci:2:001:0 s a3 00 0000 0001 0004 4 <
ffff0008c53b1300 304760010 C Ci:2:001:0 0 4 = 03020100
ffff0008c53b1300 304760013 S Co:2:001:0 s 23 01 0010 0001 0000 0
ffff0008c53b1300 304760016 C Co:2:001:0 0 0
ffff0008c38a9500 304880006 S Ii:2:001:1 -115:2048 4 <
ffff0008c53b1300 304880013 S Ci:2:001:0 s a3 00 0000 0001 0004 4 <
ffff0008c53b1300 304880075 C Ci:2:001:0 0 4 = 03020000
ffff0008c53b1300 304880134 S Ci:2:001:0 s a3 00 0000 0001 0004 4 <
ffff0008c53b1300 304880141 C Ci:2:001:0 0 4 = 03020000
ffff0008c53b1300 304880143 S Co:2:001:0 s 23 03 0004 0001 0000 0
ffff0008c53b1300 304880146 C Co:2:001:0 0 0
ffff0008c53b1300 304960006 S Ci:2:001:0 s a3 00 0002 0001 0008 8 <
ffff0008c53b1300 304960010 C Ci:2:001:0 0 8 = 03021000 55000000
ffff0008c53b1300 304960013 S Co:2:001:0 s 23 01 0014 0001 0000 0
ffff0008c53b1300 304960092 C Co:2:001:0 0 0
ffff0008c53b1300 304960092 S Co:2:001:0 s 23 01 001d 0001 0000 0
ffff0008c53b1300 304960095 C Co:2:001:0 0 0
ffff0008c53b1300 304960097 S Co:2:001:0 s 23 01 0019 0001 0000 0
ffff0008c53b1300 304960100 C Co:2:001:0 0 0
ffff0008c53b1300 304960101 S Co:2:001:0 s 23 01 0010 0001 0000 0
ffff0008c53b1300 304960104 C Co:2:001:0 0 0
ffff0008c53b1300 304960105 S Ci:2:001:0 s a3 00 0000 0001 0004 4 <
ffff0008c53b1300 304960107 C Ci:2:001:0 0 4 = 03020000

// 设备描述符请求,主机请求设备描述符(0x0100)
// 设备响应:USB 2.0设备,厂商ID 0x1201,产品ID 0x2003
ffff0008c53b1300 305060007 S Ci:2:003:0 s 80 06 0100 0000 0008 8 <
ffff0008c53b1300 305060669 C Ci:2:003:0 0 8 = 12012003 00000009
ffff0008c53b1300 305060673 S Co:2:003:0 s 00 31 0028 0000 0000 0
ffff0008c53b1300 305060686 C Co:2:003:0 0 0
// 配置描述符请求
ffff0008c53b1300 305060688 S Ci:2:003:0 s 80 06 0100 0000 0012 18 <
ffff0008c53b1300 305060718 C Ci:2:003:0 0 18 = 12012003 00000009 c20b3c20 10010102 0301
ffff0008c53b1300 305060721 S Ci:2:003:0 s 80 06 0f00 0000 0005 5 <
ffff0008c53b1300 305060745 C Ci:2:003:0 0 5 = 050f2a00 03
ffff0008c53b1300 305060747 S Ci:2:003:0 s 80 06 0f00 0000 002a 42 <
ffff0008c53b1300 305060772 C Ci:2:003:0 0 42 = 050f2a00 03071002 06000000 0a100300 0e00020a ff071410 0a000100 00000011
ffff0008c53b1300 305060778 S Ci:2:003:0 s 80 06 0200 0000 0009 9 <
ffff0008c53b1300 305060799 C Ci:2:003:0 0 9 = 09027900 01010080 70
ffff0008c53b1300 305060800 S Ci:2:003:0 s 80 06 0200 0000 0079 121 <
ffff0008c53b1300 305060825 C Ci:2:003:0 0 121 = 09027900 01010080 70090400 00020806 50000705 81020004 00063007 00000007
// 字符串描述符请求
// 返回支持英语(0x0409)
ffff0008c53b0500 305060836 S Ci:2:003:0 s 80 06 0300 0000 00ff 255 <
ffff0008c53b0500 305060856 C Ci:2:003:0 0 4 = 04030904
// 产品字符串请求
// 解码为"One Touch SSD"(西数One Touch固态硬盘)
ffff0008c53b0500 305060858 S Ci:2:003:0 s 80 06 0302 0409 00ff 255 <
ffff0008c53b0500 305060882 C Ci:2:003:0 0 28 = 1c034f00 6e006500 20005400 6f007500 63006800 20005300 53004400
// 厂商字符串请求
// 解码为"Seagate"(西数硬盘)
ffff0008c53b0500 305060884 S Ci:2:003:0 s 80 06 0301 0409 00ff 255 <
ffff0008c53b0500 305060909 C Ci:2:003:0 0 16 = 10035300 65006100 67006100 74006500
// 序列号请求:
// 解码为"000000000000NAD13NE"
ffff0008c53b0500 305060911 S Ci:2:003:0 s 80 06 0303 0409 00ff 255 <
ffff0008c53b0500 305060938 C Ci:2:003:0 0 34 = 22033000 30003000 30003000 30003000 30004e00 41004400 31003300 4e004500
ffff0008c53b0500 305141003 S Co:2:003:0 s 00 09 0001 0000 0000 0
ffff0008c53b0500 305141023 C Co:2:003:0 0 0
ffff0008c53b1900 305141152 S Co:2:003:0 s 01 0b 0001 0000 0000 0
ffff0008c53b1900 305141166 C Co:2:003:0 0 0
ffff0008cae05800 305160089 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305160106 S Bi:2:003:1 -115 36 <

// 大容量存储设备初始化
// SCSI命令交换
// 主机发送INQUIRY命令,设备响应确认是SCSI设备
ffff0008cae04400 305160113 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12000000 24000000 00000000 00000000
ffff0008cae04400 305160138 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305160339 C Bi:2:003:1 0 36 = 00000602 5b000002 53656167 61746520 4f6e6520 546f7563 68205353 44000000
ffff0008cae05800 305160343 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305160379 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305160383 S Bi:2:003:1 -115 96 <
ffff0008cae04400 305160387 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12000000 60000000 00000000 00000000
ffff0008cae04400 305160401 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305160766 C Bi:2:003:1 0 96 = 00000602 5b000002 53656167 61746520 4f6e6520 546f7563 68205353 44000000
ffff0008cae05800 305160770 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305190196 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305190201 S Bi:2:003:1 -115 4 <
ffff0008cae04400 305190204 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12010000 04000000 00000000 00000000
ffff0008cae04400 305190219 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305190588 C Bi:2:003:1 0 4 = 00000008
ffff0008cae05800 305190591 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305190597 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305190600 S Bi:2:003:1 -115 12 <
ffff0008cae04400 305190603 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12010000 0c000000 00000000 00000000
ffff0008cae04400 305190617 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305190979 C Bi:2:003:1 0 12 = 00000008 008083b0 b1b2c1c2
ffff0008cae05800 305190982 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305190986 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305190990 S Bi:2:003:1 -115 4 <
ffff0008cae04400 305190993 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12010000 04000000 00000000 00000000
ffff0008cae04400 305191008 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305191369 C Bi:2:003:1 0 4 = 00000008
ffff0008cae05800 305191372 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305191376 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305191379 S Bi:2:003:1 -115 12 <
ffff0008cae04400 305191382 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12010000 0c000000 00000000 00000000
ffff0008cae04400 305191396 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305191760 C Bi:2:003:1 0 12 = 00000008 008083b0 b1b2c1c2
ffff0008cae05800 305191763 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305191767 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305191770 S Bi:2:003:1 -115 4 <
ffff0008cae04400 305191773 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12018000 04000000 00000000 00000000
ffff0008cae04400 305191787 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305192151 C Bi:2:003:1 0 4 = 00800010
ffff0008cae05800 305192154 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305192157 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305192160 S Bi:2:003:1 -115 20 <

// 读取容量命令:
// 主机请求磁盘容量信息
ffff0008cae04400 305192163 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12018000 14000000 00000000 00000000
ffff0008cae04400 305192177 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305192541 C Bi:2:003:1 0 20 = 00800010 30303030 30303030 4e414431 334e4551
ffff0008cae05800 305192544 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305192551 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305192554 S Bi:2:003:1 -115 4 <
ffff0008cae04400 305192557 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12018300 04000000 00000000 00000000
ffff0008cae04400 305192571 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305192936 C Bi:2:003:1 0 4 = 0083000c
ffff0008cae05800 305192939 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305192943 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305192946 S Bi:2:003:1 -115 16 <
ffff0008cae04400 305192950 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 12018300 10000000 00000000 00000000
ffff0008cae04400 305192968 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305193326 C Bi:2:003:1 0 16 = 0083000c 01030008 500014a0 00000001
ffff0008cae05800 305193330 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305193333 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305193336 S Bi:2:003:1 -115 4 <
ffff0008cae04400 305193340 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 1201b000 04000000 00000000 00000000
ffff0008cae04400 305193353 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305193717 C Bi:2:003:1 0 4 = 00b0003c
ffff0008cae05800 305193720 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305193723 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305193727 S Bi:2:003:1 -115 64 <
ffff0008cae04400 305193730 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 1201b000 40000000 00000000 00000000
ffff0008cae04400 305193744 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305194110 C Bi:2:003:1 0 64 = 00b0003c 00000008 0000ffff 0000ffff 0000ffff ffffffff 000000ff 00000000
ffff0008cae05800 305194113 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305194117 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305194120 S Bi:2:003:1 -115 4 <
ffff0008cae04400 305194123 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 1201b100 04000000 00000000 00000000
ffff0008cae04400 305194136 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305194501 C Bi:2:003:1 0 4 = 00b1003c
ffff0008cae05800 305194504 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008cae05800 305194509 S Bi:2:003:3 -115 112 <
ffff0008cae04d00 305194513 S Bi:2:003:1 -115 64 <
ffff0008cae04400 305194516 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 1201b100 40000000 00000000 00000000
ffff0008cae04400 305194530 C Bo:2:003:4 0 32 >
ffff0008cae04d00 305194890 C Bi:2:003:1 0 64 = 00b1003c 00010003 00000000 00000000 00000000 00000000 00000000 00000000
ffff0008cae05800 305194893 C Bi:2:003:3 0 16 = 03000001 00000000 00000000 00000000
ffff0008ca19a900 305224435 S Bi:2:003:3 -115 112 <
ffff0008ca19bf00 305224445 S Bi:2:003:1 -115 4 <
ffff0008ca19a700 305235102 S Bi:2:003:3 -115 112 <
ffff0008ca19aa00 305235490 C Bi:2:003:1 0 4 = 17000000
ffff0008ca19b600 305291732 S Bi:2:003:3 -115 112 <

// 数据交换,开始大量数据交换,可能是读取分区表或文件系统信息?
ffff0008ca19aa00 305291737 S Bo:2:003:4 -115 32 = 01000001 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ffff0008ca19aa00 305291752 C Bo:2:003:4 0 32 >
ffff0008cb0c2e00 305300390 S Bi:2:003:3 -115 112 <
ffff0008c9bf9500 305308043 C Bi:2:003:1 0 4096 = 20800000 20800100 20800200 20800300 20800400 20800c00 20800d00 20801800
ffff00081ac17800 305308471 C Bi:2:003:1 0 4096 = 40800000 40800100 40800200 40800300 40800400 40800c00 40800d00 40801800
ffff00081ac16900 305318660 S Bi:2:003:3 -115 112 <
ffff00081ac17600 305318671 S Bi:2:003:1 -115 4096 <

实例说明:adb shell

Bo:2:003:2表示:Bulk输出,总线2,设备3,端点2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
ffff000820a6b228 1283730040 S Bo:2:003:2 -115 24 = 4f50454e 1d000000 00000000 22000000 00000000 b0afbab1
ffff000820a6be28 1283730048 S Bo:2:003:2 -115 34 = 7368656c 6c2c7632 2c544552 4d3d7874 65726d2d 32353663 6f6c6f72 2c707479
ffff000820a6b228 1283730203 C Bo:2:003:2 0 24 >
ffff000820a6be28 1283730217 C Bo:2:003:2 0 34 >
ffff0008c07e22f8 1283731484 C Bi:2:003:1 0 24 = 4f4b4159 05000000 1d000000 00000000 00000000 b0b4bea6
ffff0008c07e23f0 1283749814 C Bi:2:003:1 0 24 = 57525445 05000000 1d000000 18000000 00000000 a8adabba
ffff0008c07e24e8 1283749820 C Bi:2:003:1 0 24 = 01130000 00726f6f 74406331 3230302d 61646173 3a2f2320
ffff0008c07e22f8 1283770012 S Bi:2:003:1 -115 1048576 <
ffff000820a6be28 1283770043 S Bo:2:003:2 -115 24 = 57525445 1d000000 05000000 10000000 00000000 a8adabba
ffff000820a6b228 1283770046 S Bo:2:003:2 -115 16 = 050b0000 00333078 3132302c 30783000
ffff0008c07e23f0 1283770046 S Bi:2:003:1 -115 1048576 <
ffff0008c07e24e8 1283770047 S Bi:2:003:1 -115 1048576 <
ffff000820a6a028 1283770051 S Bo:2:003:2 -115 24 = 4f4b4159 1d000000 05000000 00000000 00000000 b0b4bea6
ffff000820a6be28 1283770092 C Bo:2:003:2 0 24 >
ffff000820a6b228 1283770097 C Bo:2:003:2 0 16 >
ffff000820a6a028 1283770099 C Bo:2:003:2 0 24 >
ffff0008c07e25e0 1283770226 C Bi:2:003:1 0 24 = 4f4b4159 05000000 1d000000 00000000 00000000 b0b4bea6
ffff0008c07e2010 1283770355 C Bi:2:003:1 0 24 = 57525445 05000000 1d000000 1d000000 00000000 a8adabba
ffff0008c07e2108 1283770358 C Bi:2:003:1 0 29 = 01180000 000d1b5b 4b0d726f 6f744063 31323030 2d616461 733a2f23 20
ffff0008c07e25e0 1283810009 S Bi:2:003:1 -115 1048576 <
ffff0008c07e2010 1283810011 S Bi:2:003:1 -115 1048576 <
ffff0008c07e2108 1283810011 S Bi:2:003:1 -115 1048576 <
ffff000820a6a028 1283810032 S Bo:2:003:2 -115 24 = 4f4b4159 1d000000 05000000 00000000 00000000 b0b4bea6
ffff000820a6a028 1283810045 C Bo:2:003:2 0 24 >

实例说明:硬盘拷贝4k文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root@tst:~# mount /dev/sdb1 /mnt/usbcat /sys/kernel/debug/usb/usbmon/0^C
root@tst:~# mkdir /mnt/dev
root@tst:~# mount /dev/sdb1 /mnt/dev
root@tst:~# dd if=/dev/urandom of=/mnt/dev/testfile-4k bs=1 count=4K
4096+0 records in
4096+0 records out
4096 bytes (4.1 kB, 4.0 KiB) copied, 0.00742903 s, 551 kB/s
root@tst:~# sync
root@tst:~# umount /mnt/dev
root@tst:~# echo 1 > /sys/bus/usb/devices/4-1/remove
root@tst:/# cat /proc/cmdline
earlycon=uart8250,mmio32,0x20008000 console=ttyS0,115200n8 rw boot_delay=32 rootwait maxcpus=8 loglevel=0 crash_kexec_post_notifiers=1 mrdump_cb=0xeac20000,0x200000 fsck.mode=skip root=/dev/sda7 boot=/dev/sda1 swiotlb=noforce loglevel=7 crashkernel=128M@0x9b0000000 mrdump_cb=0x94ca00000,0x200000 crash_kexec_post_notifiers=1 cma=0x60000000 device_type=scsi
root@tst:/# mkdir /mnt/boot
root@tst:/# mount /dev/sda1

常用分析组合

开发阶段使用 动态调试 配合 debugfs

遇到死锁或流程问题时使用 Ftrace

发生崩溃时则依赖 Kdump + Crash 进行分析。

ASCII码表

控制字符(0x00 ~ 0x1F)

HexDec缩写英文全称典型作用 / 说明
0x000NULNull空字符 / 字符串结束
0x011SOHStart of Heading标题开始
0x022STXStart of Text正文开始
0x033ETXEnd of Text文本结束 / Ctrl+C
0x044EOTEnd of Transmission传输结束 / Ctrl+D
0x055ENQEnquiry查询
0x066ACKAcknowledge确认应答
0x077BELBell蜂鸣
0x088BSBackspace退格
0x099HTHorizontal Tab制表符
0x0A10LFLine Feed换行()
0x0B11VTVertical Tab垂直制表
0x0C12FFForm Feed换页
0x0D13CRCarriage Return回车(
0x0E14SOShift Out切换字符集
0x0F15SIShift In恢复字符集
0x1016DLEData Link Escape数据链路转义
0x1117DC1Device Control 1XON
0x1218DC2Device Control 2设备控制
0x1319DC3Device Control 3XOFF
0x1420DC4Device Control 4设备控制
0x1521NAKNegative Acknowledge否认应答
0x1622SYNSynchronous Idle同步空闲
0x1723ETBEnd of Transmission Block块结束
0x1824CANCancel取消操作
0x1925EMEnd of Medium介质结束
0x1A26SUBSubstituteEOF / Ctrl+Z
0x1B27ESCEscape转义(ANSI)
0x1C28FSFile Separator文件分隔
0x1D29GSGroup Separator组分隔
0x1E30RSRecord Separator记录分隔
0x1F31USUnit Separator单元分隔

可打印字符(0x20~0x7E)

标点表1(0x20~0x2F)

HexDec缩写英文全称典型作用 / 说明
0x2032SPSpace空格
0x2133!Exclamation Mark感叹号
0x2234Quotation Mark双引号
0x2335#Number Sign井号
0x2436$Dollar Sign美元符
0x2537%Percent Sign百分号
0x2638&Ampersand
0x2739Apostrophe单引号
0x2840(Left Parenthesis左括号
0x2941)Right Parenthesis右括号
0x2A42*Asterisk星号
0x2B43+Plus Sign加号
0x2C44,Comma逗号
0x2D45-Hyphen-Minus连字符
0x2E46.Full Stop句点
0x2F47/Solidus斜杠

数字(0x30 ~ 0x39)

HexDec缩写英文全称典型作用 / 说明
0x30480Digit Zero数字 0
0x31491Digit One数字 1
0x32502Digit Two数字 2
0x33513Digit Three数字 3
0x34524Digit Four数字 4
0x35535Digit Five数字 5
0x36546Digit Six数字 6
0x37557Digit Seven数字 7
0x38568Digit Eight数字 8
0x39579Digit Nine数字 9

标点表2(0x3A ~ 0x40)

HexDec缩写英文全称典型作用 / 说明
0x3A58:Colon冒号
0x3B59;Semicolon分号
0x3C60<Less-Than Sign小于
0x3D61=Equals Sign等号
0x3E62>Greater-Than Sign大于
0x3F63?Question Mark问号
0x4064@Commercial At@

大写字母(0x41 ~ 0x5A)

HexDec缩写英文全称典型作用 / 说明
0x4165ALatin Capital Letter A大写 A
0x4266BLatin Capital Letter B大写 B
0x4367CLatin Capital Letter C大写 C
0x4468DLatin Capital Letter D大写 D
0x4569ELatin Capital Letter E大写 E
0x4670FLatin Capital Letter F大写 F
0x4771GLatin Capital Letter G大写 G
0x4872HLatin Capital Letter H大写 H
0x4973ILatin Capital Letter I大写 I
0x4A74JLatin Capital Letter J大写 J
0x4B75KLatin Capital Letter K大写 K
0x4C76LLatin Capital Letter L大写 L
0x4D77MLatin Capital Letter M大写 M
0x4E78NLatin Capital Letter N大写 N
0x4F79OLatin Capital Letter O大写 O
0x5080PLatin Capital Letter P大写 P
0x5181QLatin Capital Letter Q大写 Q
0x5282RLatin Capital Letter R大写 R
0x5383SLatin Capital Letter S大写 S
0x5484TLatin Capital Letter T大写 T
0x5585ULatin Capital Letter U大写 U
0x5686VLatin Capital Letter V大写 V
0x5787WLatin Capital Letter W大写 W
0x5888XLatin Capital Letter X大写 X
0x5989YLatin Capital Letter Y大写 Y
0x5A90ZLatin Capital Letter Z大写 Z

标点表3(0x5B ~ 0x60)

HexDec缩写英文全称典型作用 / 说明
0x5B91[Left Square Bracket左中括号
0x5C92\Reverse Solidus反斜杠
0x5D93]Right Square Bracket右中括号
0x5E94^Circumflex Accent脱字符
0x5F95_Low Line下划线
0x6096`Grave Accent反引号

小写字母(0x61 ~ 0x7A)

HexDec缩写英文全称典型作用 / 说明
0x6197aLatin Small Letter a小写 a
0x6298bLatin Small Letter b小写 b
0x6399cLatin Small Letter c小写 c
0x64100dLatin Small Letter d小写 d
0x65101eLatin Small Letter e小写 e
0x66102fLatin Small Letter f小写 f
0x67103gLatin Small Letter g小写 g
0x68104hLatin Small Letter h小写 h
0x69105iLatin Small Letter i小写 i
0x6A106jLatin Small Letter j小写 j
0x6B107kLatin Small Letter k小写 k
0x6C108lLatin Small Letter l小写 l
0x6D109mLatin Small Letter m小写 m
0x6E110nLatin Small Letter n小写 n
0x6F111oLatin Small Letter o小写 o
0x70112pLatin Small Letter p小写 p
0x71113qLatin Small Letter q小写 q
0x72114rLatin Small Letter r小写 r
0x73115sLatin Small Letter s小写 s
0x74116tLatin Small Letter t小写 t
0x75117uLatin Small Letter u小写 u
0x76118vLatin Small Letter v小写 v
0x77119wLatin Small Letter w小写 w
0x78120xLatin Small Letter x小写 x
0x79121yLatin Small Letter y小写 y
0x7A122zLatin Small Letter z小写 z

标点表4(0x7B ~ 0x7E)

HexDec缩写英文全称典型作用 / 说明
0x7B123{Left Curly Brace左大括号
0x7C124|Vertical Line竖线
0x7D125}Right Curly Brace右大括号
0x7E126~Tilde波浪号

特殊字符(0x7F)

HexDec缩写英文全称典型作用 / 说明
0x7F127DELDelete删除

英文原文:Linux USB API

协议层

包格式

USB协议层都是以包为基本单元,采用LSB(先发送低位)字节序。

Host发出SOP信号后,就会发出SYNC信号:它是一系列的、最大传输频率的脉冲,接收方使用它来同步数据。对于低速/全速设备,SYNC信号是8位数据(从做到右是00000001);对于高速设备,SYNC信号是32位数据(从左到右是00000000000000000000000000000001)。使用NRZI编码时,前面每个”0”都对应一个跳变。具体包格式见下图(来自百问网):

img

USB包各部分介绍:

  • SOP 用来表示包起始
  • SYNC 用来同步时钟
  • Packet 实际有效的包数据
  • EOP 用来表示包结束

包(Packet)的具体结构:

  • PID 包类型
  • 地址 USB设备的逻辑地址,Host发出的包中一般都需要包含目标设备的地址
  • 帧号数据 需要由包类型确定,具体需要查看协议文档
  • CRC 校验码

包类型(PID)

USB中数据方向都是基于Host角度来看的,out表示从Host发送数据到设备,in表示从设备发送数据到Host。由于设备都是被动响应的,因此完整的传输,都是由Host发起第一个包。

包数据里的PID按照bit1-0可以分为四大类:

  • 令牌包(Token):01B
  • 数据包(Data):11B
  • 握手包(Handshake):10B
  • 特殊包(Special):00B

PID低4位可以确定包类型,如下表所示:

image-20220819095112885

PID决定了后续数据类型,为了降低出错的概率,额外增加4位用于取反校验。实际包中的PID由8位来表示,格式如下:

image-20220819100829291

令牌包(Token)

令牌类的包作用是通知设备。

SOF(Start-of-Frame)令牌包是由主机固定频率发送的包。对于FS(full-speed)速率总线是间隔1.00 ms ±0.0005 ms,对于HS(high-speed)速率总线是间隔125 µs ±0.0625 µs。作用是通知所有设备,SOF令牌包格式如下:

image-20251014095756916

IN/OUT/SETUP令牌包通知特定设备,格式如下:

image-20251014094921786

数据包(Data)

数据包包含PID域、0或多字节数据域和一个CRC域,如下图所示。有四种类型的数据包:DATA0、DATA1、DATA2、MDATA。

image-20251014101326036

握手包(Handshake)

握手包只包含PID域。握手包用于汇报数据传输的状态,返回一个值表示数据成功接收、命令接收或拒绝、流控制、halt状态。

有四种类型的握手包和一种特殊的握手包:

  • ACK,表明数据包成功接收或数据域没有CRC错误且PID域正确。
  • NAK,表明设备不能从host接收数据(OUT)或向host发送数据(IN)。
  • STALL,设备返回的响应,可以是对IN令牌包的响应、OUT的数据阶段的响应、PING传输的响应。
  • NYET,仅适用于HS设备。可以用于响应PING协议,或用于响应split传输时FS/HS设备未完成。
  • ERR,仅适用于HS设备。允许HS HUB报告总线上的错误。

数据翻转同步和重试

USB提供一种确保在数据收发者间数据序列同步的机制,通过使用DATA0和DATA1包和数据收发者的序列位翻转来实现。

初始化

控制传输使用SETUP令牌包初始化host和设备序列位,如下图所示:

image-20251014191445444

成功的数据传输

在每次传输中,接收者需要比较发送者的序列位(数据包PID域编码是DATA0或DATA1)是否与接收者序列位一致。若数据可接收并且收发序列位一致,序列位需要翻转。

image-20251014191858456

数据损坏或不可接收

若不能接收数据或数据已经损坏,接受者会发送NAK或STALL握手包,并且不会翻转它的序列位。

image-20251014192428739

损坏的ACK握手包

当发送者没有收到正确的ACK,不会翻转序列位。当超时后会重试发送相同数据,直到接收到正确的ACK。

image-20251014192458575

事务(Transaction)与传输(Transfer)

USB传输最基本的单元是包(Packet),包类型是PID域表示。单一的包无法完成完整数据的传输。一个完整数据传输往往需要包含到多个包:令牌包、数据包、握手包,而这个过程被称为事务(Transaction)。单个或多个事务组合起来就是一个传输(Transfer)。

不同事务类型包含包的数量不完全相同,它取决于端点(endpoint)类型。这里有四种端点类型:批量(bulk)、控制(control)、中断(interrupt)和实时(isochronous)。

如下就是一个完整的BOT SCSI CMD传输,总共包含三个批量事务:CBW事务、SCSI DATA事务和CSW事务。而每个事务都是一个批量事务类型,都是一个三阶段的事务。

image-20251017111355123

批量事务(Bulk)

批量事务类型的特点是能够通过错误检测和重试,在主机与功能之间保证数据无错误的传输。它使用三阶段的事务包括:令牌包、数据包、握手包。

image-20251014195341690

常见支持批量事务的设备有:USB存储设备。

控制传输(Control)

控制传输至少有两个事务阶段:设置(Setup)和状态(Status)。控制传输可选择在设置阶段和状态阶段之间包含一个数据(Data)阶段。在设置阶段,使用 SETUP 事务将信息传送到功能的控制端点。SETUP 事务的格式类似于 OUT,但使用的是 SETUP PID 而不是 OUT PID。

下图是一个SETUP事务包含三个包:SETUP包、DATA0包、ACK包。

image-20251014195855230

若存在,控制传输会包含数据阶段,由一个或多个IN或OUT事务组成,遵循与批量事务相同的协议规则。所有在数据阶段的传输事务保持相同的方向(例如全IN事务或全OUT事务)。一个SETUP总是使用DATA0的PID作为SETUP事务的数据域。

控制传输的状态阶段是序列上的最后一个事务。状态阶段事物遵循与批量事务相同的协议序列。例如,当数据阶段包含全OUT事务,状态就是一个IN事务。若控制序列没有数据阶段,则状态就是一个IN事务。

image-20251014195928566

所有的USB设备必须支持的传输类型。

中断事务(Interrupt)

中断事务使用三阶段的事务包括:令牌包、数据包、握手包。

image-20251017113514694

中断事务跟批量事务非常类似,不同的是Host会周期性地发送事务进行数据读写。常见支持中断事务的设备有:USB鼠标、USB键盘等。

实时事务(Isochronous)

实时事务包含一个令牌和一个数据阶段,但没有握手阶段。实时事务不支持握手阶段或重试能力。

image-20251022144041260

实时事务需要Host周期性的发起,相比中断事务,不要求准确性,传输的数据量比较大。常见支持实时事务的设备有USB摄像头。

dwc3协议栈

为分析流程,需要打开动态调试,具体方法见 Linux驱动-内核调试手段

⚠️注意:以下内核以linux-6.1为模板编写,切换到6.6版本有部分地方有问题

简略流程-接入ssp固态硬盘设备

当xHCI 控制器检测到 USB 端口状态变化,这里是有ssp设备接入。硬件生成 Port Status Change Event TRB,放入 Event Ring。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// xhci - xhci_hc_driver
irqreturn_t xhci_irq(struct usb_hcd *hcd)
|-xhci_handle_event(xhci, ir)
|-handle_port_status(xhci, ir, event) // work_struct机制唤醒 hcd_resume_work

// usb core - usb_generic_xhci_driver
void hcd_resume_work(struct work_struct *work)
|-usb_remote_wakeup(udev)
|-usb_autoresume_device(udev)
|-pm_runtime_get_sync(&udev->dev)
|-__pm_runtime_resume(dev, RPM_GET_PUT)
--|-callback = RPM_GET_CALLBACK(dev, runtime_resume)
--|-rpm_callback(callback, dev) // 调用 usb_runtime_resume
|-rpm_resume(dev, rpmflags)
int rpm_resume(struct device *dev, int rpmflags)
int usb_runtime_resume(struct device *dev)
|-usb_resume_interface(udev, intf, msg, udev->reset_resume)
|-driver->resume(intf) // 调用 hub_resume
int hub_resume(struct usb_interface *intf)
|-hub_activate(hub, HUB_RESUME)
|-kick_hub_wq(hub) // 触发 hub->events hub_event
void hub_event(struct work_struct *work)
|-port_event(hub, i)
|-hub_port_connect_change(hub, port1, portstatus, portchange)
|-hub_port_connect(hub, port1, portstatus, portchange)
|-usb_new_device(udev)
|-device_add(&udev->dev) // 注册设备,其中bus_probe_device(dev)会触发
int usb_probe_device(struct device *dev)
|-usb_generic_driver_probe(udev)
|-usb_set_configuration(udev, c) // 注册设备,会触发 usb_probe_interface
int usb_probe_interface(struct device *dev)
|-driver->probe(intf, id) // 调用驱动探测, 这里调用 uas_probe

// uas
int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
|-INIT_WORK(&devinfo->scan_work, uas_scan_work) // 延时调用,调用uas_scan_work
|-scsi_add_host(shost, &intf->dev) // 同步调用
|-scsi_add_host_with_dma(host, dev, dev)
void uas_scan_work(struct work_struct *work)
|-scsi_scan_host(shost)

// scsi
int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, struct device *dma_dev)
/* scsi设备注册到内核 */
void scsi_scan_host(struct Scsi_Host *shost)
|-do_scsi_scan_host(shost)
|-scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, SCAN_WILD_CARD, 0)
|-scsi_scan_channel(shost, channel, id, lun, rescan)
|-__scsi_scan_target(&shost->shost_gendev, channel, id, lun, rescan)
|-scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL)
|-scsi_add_lun(sdev, result, &bflags, shost->async_scan)
|-scsi_sysfs_add_sdev(sdev) // 通过调用 device_add 触发 sd_probe
int sd_probe(struct device *dev)
|-sd_revalidate_disk(gd)
/* 重新识别scsi disk基本信息 */

详细流程

中断处理流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// linux-6.6.64/drivers/usb/host/xhci.c
// xhci hc驱动
struct hc_driver xhci_hc_driver = {
.description = "xhci-hcd",
.product_desc = "xHCI Host Controller",
.irq = xhci_irq,
.flags = HCD_MEMORY | HCD_DMA | HCD_USB3 | HCD_SHARED | HCD_BH,
};
// linux-6.6.64/drivers/usb/host/xhci-ring.c
irqreturn_t xhci_irq(struct usb_hcd *hcd)
struct xhci_hcd *xhci = hcd_to_xhci(hcd)
/* 读取状态,确保是event中断 */
status = readl(&xhci->op_regs->status)
/* 清除 STS_EINT */
status |= STS_EINT;
writel(status, &xhci->op_regs->status)
/*
循环 更新Event Ring Dequeue Pointer
*/
{
xhci_handle_event(xhci)
xhci_update_erst_dequeue(xhci, event_ring_deq)
}
// linux-6.6.64/drivers/usb/host/xhci-ring.c
static int xhci_handle_event(struct xhci_hcd *xhci)
union xhci_trb *event
event = xhci->event_ring->dequeue
trb_type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->event_cmd.flags))
/*
根据类型调用不同的处理函数
*/
TRB_COMPLETION: handle_cmd_completion(xhci, &event->event_cmd)
TRB_PORT_STATUS: handle_port_status(xhci, event)
TRB_TRANSFER: handle_tx_event(xhci, &event->trans_event)
TRB_DEV_NOTE: handle_device_notification(xhci, event)
default: handle_vendor_event(xhci, event, trb_type) // >= TRB_VENDOR_DEFINED_LOW 为自定义TRB
// linux-6.6.64/drivers/usb/host/xhci-ring.c
static void handle_port_status(struct xhci_hcd *xhci, union xhci_trb *event)
usb_hcd_resume_root_hub(hcd)
// 打印 Port change event, xx-xx

唤醒设备流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// linux-6.6.64/drivers/usb/gadget/udc/dummy_hcd.c
// 注册探测
static struct platform_driver dummy_hcd_driver = {
.probe = dummy_hcd_probe,
}
// dummy初始化
// 打印dummy_hcd dummy_hcd.0: USB Host+Gadget Emulator, driver 02 May 2005
dummy_hcd_probe
usb_create_shared_hcd
// linux-6.6.64/drivers/usb/core/hcd.c
usb_create_shared_hcd
__usb_create_hcd
INIT_WORK(&hcd->wakeup_work, hcd_resume_work); // 注册hcd wakeup工作队列

// drivers/usb/core/hcd.c
// hcd wakeup工作队列被唤醒
void hcd_resume_work(struct work_struct *work)
struct usb_hcd *hcd = container_of(work, struct usb_hcd, wakeup_work)
struct usb_device *udev = hcd->self.root_hub
usb_remote_wakeup(udev)
{// 当设备状态为USB_STATE_SUSPENDED,执行下面语句
// 打印 usb wakeup-resume
usb_autoresume_device(udev)
usb_autosuspend_device(udev) // autoresume执行成功后调用
}

// linux-6.6.64/drivers/usb/core/driver.c
// 自动唤醒设备,成功返回0
int usb_autoresume_device(struct usb_device *udev)
// udev->dev.power.usage_count引用计数加1,并返回计数设备状态;
// 0--已激活;正数--已唤醒(很少使用);负数--错误码
pm_runtime_get_sync(&udev->dev)
{ /* 当获取的status<0时 */
// udev->dev.power.usage_count引用计数减1
pm_runtime_put_sync(&udev->dev)
}
// 打印 usb_autoresume_device: cnt 1 -> 0

// linux-6.6.64/include/linux/pm_runtime.h
int pm_runtime_get_sync(struct device *dev)
__pm_runtime_resume(dev, RPM_GET_PUT)

// linux-6.6.64/drivers/base/power/runtime.c
int __pm_runtime_resume(struct device *dev, int rpmflags)
rpm_resume(dev, rpmflags)
if (!parent && dev->parent) { // 递归先唤醒父设备
rpm_resume(parent, 0)
}
/* 调用设备 runtime_resume 回调函数 */
callback = RPM_GET_CALLBACK(dev, runtime_resume)
rpm_callback(callback, dev) // 调用设备的 dev_pm_ops->runtime_resume 函数

// linux-6.6.64/drivers/usb/core/usb.c
static const struct dev_pm_ops usb_device_pm_ops = {
...
.runtime_resume = usb_runtime_resume,
}

// linux-6.6.64/drivers/usb/core/driver.c
int usb_runtime_resume(struct device *dev)
struct usb_device *udev = to_usb_device(dev)
usb_resume_both(udev, PMSG_AUTO_RESUME)
usb_resume_device(udev, msg) // 唤醒设备
/* 循环遍历唤醒所有 interface
intf = udev->actconfig->interface[i]
*/
usb_resume_interface(udev, intf, msg, udev->reset_resume)
int usb_resume_device(struct usb_device *udev, pm_message_t msg)
udriver = to_usb_device_driver(udev->dev.driver)
usb_generic_driver_resume(udev, msg) // 调用通用恢复接口,处理标准USB请求,如设置配置、接口
udriver->resume(udev, msg) // 特定恢复接口,如固件加载、寄存器配置
int usb_resume_interface(struct usb_device *udev,
struct usb_interface *intf, pm_message_t msg, int reset_resume)
driver = to_usb_driver(intf->dev.driver)
/* 若设置 reset_resume */
driver->reset_resume(intf) // 调用 usb_driver->reset_resume 函数
/* 若没有设置 reset_resume */
driver->resume(intf) // 调用 usb_driver->resume 函数

// linux-6.6.64/drivers/usb/core/hub.c
struct usb_driver hub_driver = {
.resume = hub_resume,
}
int hub_resume(struct usb_interface *intf)
// 打印 hub_resume
hub_activate(hub, HUB_RESUME)
report_wakeup_requests(hub)
/*
初始化Hub(HUB_INIT/HUB_INIT2/HUB_INIT3):分阶段完成Hub电源开启、端口检测和状态同步。
恢复Hub(HUB_RESUME/HUB_RESET_RESUME):处理系统休眠唤醒后的端口状态恢复。
端口状态管理:检测连接状态变化、处理去抖(Debounce)延迟、触发事件处理。
*/
void hub_activate(struct usb_hub *hub, enum hub_activation_type type)
/*
循环遍历port
struct usb_port *port_dev = hub->ports[port1 - 1];
struct usb_device *udev = port_dev->child;
*/
usb_hub_port_status(hub, port1, &portstatus, &portchange)
// 端口有链接状态 USB_PORT_STAT_CONNECTION,打印 status 0203 change 0001
hub_port_warm_reset_required(hub, port1, portstatus) // 端口warm reset
/* 判断portchange各bit位,处理去抖(Debounce) */
usb_clear_port_feature(hub->hdev, port1, USB_PORT_FEAT_xxx)
/* 若port状态处于 USB_SS_PORT_LS_U0 */
set_bit(port1, hub->event_bits)
usb_submit_urb(hub->urb, GFP_NOIO)
kick_hub_wq(hub) // 触发 hub->events ,让hub工作队列继续处理event
void report_wakeup_requests(struct usb_hub *hub)
/*
获取hub 端口状态和变化信息
*/
int usb_hub_port_status(struct usb_hub *hub, int port1,
u16 *status, u16 *change)
hub_ext_port_status(hub, port1, HUB_PORT_STATUS, status, change, NULL)
get_port_status(hub->hdev, port1, &hub->status->port, type, len)
/* USB_STS_RETRIES=5 多次重试
发送GET_STATUS控制消息
*/
usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0),
USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, value,
port1, data, length, USB_STS_TIMEOUT)

// linux-6.6.64/drivers/usb/core/message.c
/*
发送控制消息,不会超过超时时间
*/
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
__u8 requesttype, __u16 value, __u16 index, void *data,
__u16 size, int timeout)

// linux-6.6.64/drivers/usb/core/driver.c
// 自动挂起设备,成功返回0
void usb_autosuspend_device(struct usb_device *udev)
usb_mark_last_busy(udev) // 更新设备的“最后一次活动时间戳”,用于延迟自动挂起。
pm_runtime_put_sync_autosuspend(&udev->dev) // 减少设备的引用计数,并根据条件触发自动挂起。

event处理流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// linux-6.6.64/drivers/usb/core/hub.c
// 检测到hub时,注册hub_event
int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
INIT_WORK(&hub->events, hub_event);
// hub event处理流程
void hub_event(struct work_struct *work)
hub = container_of(work, struct usb_hub, events);
// 打印 state 7 ports 1 chg 0002 evt 0000
{/*
遍历并处理端口状态变化
*/
struct usb_port *port_dev = hub->ports[i - 1];
port_event(hub, i);
}
// 处理端口event
void port_event(struct usb_hub *hub, int port1)
hub_port_connect_change(hub, port1, portstatus, portchange)
// 打印 status 0203, change 0000, 10.0 Gb/s
hub_port_connect(hub, port1, portstatus, portchange)
struct usb_port *port_dev = hub->ports[port1 - 1]
{ /* PORT_INIT_TRIES=4 多次初始化端口 */
udev = usb_alloc_dev(hdev, hdev->bus, port1)
/* 设置 usb_device 的状态及速度 */
usb_set_device_state(udev, USB_STATE_POWERED)
udev->speed = USB_SPEED_SUPER
hub_port_init(hub, udev, port1, i, NULL)
port_dev->child = udev // 将设备加入到child中管理
usb_new_device(udev) // 注册设备并绑定驱动
}
int hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1,
int retry_counter, struct usb_device_descriptor *dev_descr)
int usb_new_device(struct usb_device *udev)
usb_enumerate_device(udev) // 读取设备描述符
// 打印 usb 3-1: udev 2, busnum 3, minor = 257
/*
打印更多设备信息
usb 3-1: New USB device found, idVendor=0bc2, idProduct=203c, bcdDevice= 1.10
usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 3-1: Product: One Touch SSD
usb 3-1: Manufacturer: Seagate
usb 3-1: SerialNumber: 00000000NAD13NEQ
*/
announce_device(udev)
set_usb_port_removable(udev) // 设置设备的可卸载性
device_add(&udev->dev) // 注册设备,其中bus_probe_device(dev)会触发 usb_probe_device
usb_create_ep_devs(&udev->dev, &udev->ep0, udev) // 创建ep0,作为默认的控制端点

设备探测流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// linux-6.6.64/drivers/usb/core/driver.c
// usb设备probe处理
int usb_probe_device(struct device *dev)
usb_autoresume_device(udev) // 若不支持自动挂起,探测期间恢复供电
usb_generic_driver_probe(udev) // 通用USB驱动探测
udriver->probe(udev) // 专用驱动探测,

// linux-6.6.64/drivers/usb/core/generic.c
int usb_generic_driver_probe(struct usb_device *udev)
c = usb_choose_configuration(udev)
usb_set_configuration(udev, c)

// linux-6.6.64/drivers/usb/core/message.c
int usb_set_configuration(struct usb_device *dev, int configuration)
// 发送 SET_CONFIGURATION 控制消息
usb_control_msg_send(dev, 0, USB_REQ_SET_CONFIGURATION, 0,
configuration, 0, NULL, 0,
USB_CTRL_SET_TIMEOUT, GFP_NOIO)
usb_set_device_state(dev, USB_STATE_CONFIGURED) // 状态切换为 USB_STATE_CONFIGURED
/* 遍历所有 interface */
{
struct usb_interface *intf = cp->interface[i]
device_add(&intf->dev) // 注册设备,会触发 usb_probe_interface
}

interface探测流程

1
2
3
4
5
6
7
8
9
10
11
// linux-6.6.64/drivers/usb/core/driver.c
int usb_probe_interface(struct device *dev)
struct usb_driver *driver = to_usb_driver(dev->driver);
struct usb_interface *intf = to_usb_interface(dev);
// 打印 uas 3-1:1.0: usb_probe_interface
/* 尝试匹配id */
usb_match_dynamic_id(intf, driver)
usb_match_id(intf, driver->id_table)
// 打印 uas 3-1:1.0: usb_probe_interface - got id
driver->probe(intf, id) // 调用驱动探测, 这里调用 uas_probe

uas探测流程

USB Attached SCSI驱动探测

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// linux-6.6.64/drivers/usb/storage/uas.c
int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
/* uas兼容性检查,并切换为uas专用接口 */
uas_use_uas_driver(intf, id, &dev_flags)
uas_switch_interface(udev, intf)
/* 申请 scsi 主机结构, 并配置相关数据 */
struct Scsi_Host *shost
shost = scsi_host_alloc(&uas_host_template, sizeof(struct uas_dev_info))
init_usb_anchor(&devinfo->cmd_urbs); // Command的URB锚点
init_usb_anchor(&devinfo->sense_urbs); // Sense的URB锚点
init_usb_anchor(&devinfo->data_urbs); // Data的URB锚点
INIT_WORK(&devinfo->work, uas_do_work);
INIT_WORK(&devinfo->scan_work, uas_scan_work); // 延时扫描任务
devinfo = (struct uas_dev_info *)shost->hostdata
/*
配置 uas 的4个端点
0--命令pipe bulk-out
1--状态pipe bulk-in
2--in数据pipe
3--out数据pipe
*/
uas_configure_endpoints(devinfo)
scsi_add_host(shost, &intf->dev) // scsi设备注册到内核

// linux-6.6.64/include/scsi/scsi_host.h
int scsi_add_host(struct Scsi_Host *host, struct device *dev)
scsi_add_host_with_dma(host, dev, dev)

// linux-6.6.64/drivers/scsi/hosts.c
/*
将SCSI主机适配器注册到内核,创建设备节点:
/sys/class/scsi_host/host0
*/
int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev,
struct device *dma_dev)
// 打印 scsi host0: uas
scsi_init_sense_cache(shost) // 初始化sense数据缓存
scsi_mq_setup_tags(shost) // 设置scsi标签集,启用调试可以查看 cat /sys/kernel/debug/scsi/scsi_host/hostX/tags
device_add(&shost->shost_gendev) // 注册通用设备
scsi_host_set_state(shost, SHOST_RUNNING)
shost->work_q = alloc_workqueue(xxx) // 创建工作队列 名称:scsi_wq_xx
/*
注册SCSI专用设备
创建节点 /sys/class/scsi_host/hostX /sys/bus/scsi/devices
*/
device_add(&shost->shost_dev)
scsi_sysfs_add_host(shost) // 添加sysfs属性节点 /sys/class/scsi_host/hostX/proc_name
scsi_proc_host_add(shost) // 添加/proc节点 /proc/scsi/[driver]/X

// linux-6.6.64/drivers/usb/storage/uas.c
void uas_scan_work(struct work_struct *work)
struct Scsi_Host *shost = usb_get_intfdata(devinfo->intf);
scsi_scan_host(shost)

// linux-6.6.64/drivers/scsi/scsi_scan.c
void scsi_scan_host(struct Scsi_Host *shost)
/*
1. 内存足够使用 async_schedule(do_scan_async, data) -> do_scsi_scan_host(shost)
2. 内存不足直接同步调用
*/
do_scsi_scan_host(shost)
scsi_scan_host_selected(shost, SCAN_WILD_CARD, SCAN_WILD_CARD, SCAN_WILD_CARD, 0)
/*
SCAN_WILD_CARD 会遍历所有通道
*/
scsi_scan_channel(shost, channel, id, lun, rescan)
__scsi_scan_target(&shost->shost_gendev, channel, id, lun, rescan)
scsi_probe_and_add_lun(starget, 0, &bflags, NULL, rescan, NULL)
scsi_device_lookup_by_target(starget, lun)
scsi_probe_lun(sdev, result, result_len, &bflags) // 使用INQUIRY探测lun
scsi_add_lun(sdev, result, &bflags, shost->async_scan)
/* 将scsi信息解析后添加到设备中存储 */
sdev->inquiry = kmemdup(inq_result, max_t(size_t, sdev->inquiry_len, 36), GFP_KERNEL)
// 打印 scsi 0:0:0:0: Direct-Access Seagate One Touch SSD PMAP PQ: 0 ANSI: 6
scsi_device_set_state(sdev, SDEV_RUNNING)
transport_configure_device(&sdev->sdev_gendev)
/*
scsi设备注册
创建 /sys/class/scsi_device/... 和 /sys/block/sda/device 等节点
*/
scsi_sysfs_add_sdev(sdev) // 通过调用 device_add 触发 sd_probe

scsi协议OPCODES MESSAGES SENSE码见:linux-6.6.64/include/scsi/scsi_proto.h

sd探测流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// linux-6.6.64/drivers/scsi/sd.c
// 当有新的scsi设备接入系统时触发
int sd_probe(struct device *dev)
/*
申请设备结构,并填写分配盘符sdxx,请求超时等信息
*/
struct scsi_disk *sdkp
struct gendisk *gd
sdkp = kzalloc(sizeof(*sdkp), GFP_KERNEL)
gd = blk_mq_alloc_disk_for_queue(sdp->request_queue, &sd_bio_compl_lkclass)
ida_alloc(&sd_index_ida, GFP_KERNEL) // 分配索引号
sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN) // 分配盘符sdxx
sdkp->max_retries = SD_MAX_RETRIES
atomic_set(&sdkp->openers, 0)
atomic_set(&sdkp->device->ioerr_cnt, 0)
blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT) // 默认请求超时时间 30秒 ,MOD是光驱

device_initialize(&sdkp->disk_dev) // 初始化磁盘设备
device_add(&sdkp->disk_dev) // 添加设备

/* 设置磁盘参数,直到设备返回 */
sdp->sector_size = 512;
sdkp->capacity = 0;
sd_revalidate_disk(gd) // 重新验证磁盘参数
device_add_disk(dev, gd, NULL) // 添加gendisk,产生盘符节点 /dev/sdxx
// 打印 sd 0:0:0:0: [sda] Attached SCSI disk

// linux-6.6.64/drivers/scsi/sd.c
int sd_revalidate_disk(struct gendisk *disk)
sd_spinup_disk(sdkp)
sd_read_capacity(sdkp, buffer)
sd_print_capacity(sdkp, old_capacity) // 打印 sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/466 GiB)
/*
打印
sd 0:0:0:0: [sda] Write Protect is off
sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
*/
sd_read_write_protect_flag(sdkp, buffer)
sd_read_cache_type(sdkp, buffer) // 打印 sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
sd_read_app_tag_own(sdkp, buffer)
sd_read_write_same(sdkp, buffer)
sd_read_security(sdkp, buffer)
sd_config_protection(sdkp)
sd_set_flush_flag(sdkp)
sd_validate_min_xfer_size(sdkp) // 打印 sd 0:0:0:0: [sda] Preferred minimum I/O size 4096 bytes
sd_validate_opt_xfer_size(sdkp, dev_max) // 打印 sd 0:0:0:0: [sda] Optimal transfer size 33553920 bytes not a multiple of preferred minimum block size (4096 bytes)
set_capacity_and_notify(disk, logical_to_sectors(sdp, sdkp->capacity))

xhci驱动分析

抓取动态调试日志

开启模块调试

1
2
3
4
5
6
7
8
9
10
11
12
13
# 启用usbcore所有调试信息
echo "module usbcore +p" > /sys/kernel/debug/dynamic_debug/control
# 启用Hub事件日志
echo "module hub +p" > /sys/kernel/debug/dynamic_debug/control
# 启用 scsi_mod 的调试(SCSI 核心层)
echo 'module scsi_mod +p' > /sys/kernel/debug/dynamic_debug/control
# 启用 sd_mod 的调试(SCSI 磁盘驱动)
echo 'module sd_mod +p' > /sys/kernel/debug/dynamic_debug/control
# 根据实际使用的控制器选择(通过lsusb -t查看)
echo "module xhci_hcd +p" > /sys/kernel/debug/dynamic_debug/control # USB 3.0
# 例如调试USB存储设备
echo "module usb-storage +p" > /sys/kernel/debug/dynamic_debug/control

开启文件

1
2
3
4
echo file drivers/usb/core/hub.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/usb/core/hcd.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/usb/dwc3/dwc3-*.c +p > /sys/kernel/debug/dynamic_debug/control
echo file drivers/scsi/sd.c +p > /sys/kernel/debug/dynamic_debug/control

主控注册

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
[root@tst ]# echo host > /sys/class/usb_role/22100000.dwc3-role-switch/role

[ 22.527815][ T67] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 22.538005][ T67] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 1
[ 22.547638][ T67] xhci-hcd xhci-hcd.0.auto: // Halt the HC
[ 22.553300][ T67] xhci-hcd xhci-hcd.0.auto: Resetting HCD
[ 22.558871][ T67] xhci-hcd xhci-hcd.0.auto: // Reset the HC
[ 22.564809][ T67] xhci-hcd xhci-hcd.0.auto: Wait for controller to be ready for doorbell rings
[ 22.573592][ T67] xhci-hcd xhci-hcd.0.auto: Reset complete
[ 22.579250][ T67] xhci-hcd xhci-hcd.0.auto: Enabling 64-bit DMA addresses.
[ 22.586296][ T67] xhci-hcd xhci-hcd.0.auto: Calling HCD init
[ 22.592127][ T67] xhci-hcd xhci-hcd.0.auto: xhci_init
[ 22.597351][ T67] xhci-hcd xhci-hcd.0.auto: xHCI doesn't need link TRB QUIRK
[ 22.604572][ T67] xhci-hcd xhci-hcd.0.auto: Supported page size register = 0x1
[ 22.611970][ T67] xhci-hcd xhci-hcd.0.auto: Supported page size of 8K
[ 22.618583][ T67] xhci-hcd xhci-hcd.0.auto: HCD page size set to 4K
[ 22.625024][ T67] xhci-hcd xhci-hcd.0.auto: // xHC can handle at most 64 device slots.
[ 22.633112][ T67] xhci-hcd xhci-hcd.0.auto: // Setting Max device slots reg = 0x40.
[ 22.640946][ T67] xhci-hcd xhci-hcd.0.auto: // Device context base array address = 0x0x000000081224b000 (DMA), (____ptrval____) (virt)
[ 22.653210][ T67] xhci-hcd xhci-hcd.0.auto: Allocated command ring at (____ptrval____)
[ 22.661298][ T67] xhci-hcd xhci-hcd.0.auto: First segment DMA is 0x0x000000081224d000
[ 22.669299][ T67] xhci-hcd xhci-hcd.0.auto: // Setting command ring address to 0x000000081224d001
[ 22.678344][ T67] xhci-hcd xhci-hcd.0.auto: // Doorbell array is located at offset 0x2000 from cap regs base addr
[ 22.688793][ T67] xhci-hcd xhci-hcd.0.auto: Allocating primary event ring
[ 22.695767][ T67] xhci-hcd xhci-hcd.0.auto: // Write event ring dequeue pointer, preserving EHB bit
[ 22.705030][ T67] xhci-hcd xhci-hcd.0.auto: Allocating 2 scratchpad buffers
[ 22.712173][ T67] xhci-hcd xhci-hcd.0.auto: Ext Cap (____ptrval____), port offset = 1, count = 1, revision = 0x2
[ 22.722519][ T67] xhci-hcd xhci-hcd.0.auto: xHCI 1.0: support USB2 hardware lpm
[ 22.730002][ T67] xhci-hcd xhci-hcd.0.auto: Ext Cap (____ptrval____), port offset = 2, count = 1, revision = 0x3
[ 22.740349][ T67] xhci-hcd xhci-hcd.0.auto: PSIV:4 PSIE:3 PLT:0 PFD:1 LP:0 PSIM:5
[ 22.748005][ T67] xhci-hcd xhci-hcd.0.auto: PSIV:5 PSIE:3 PLT:0 PFD:1 LP:1 PSIM:10
[ 22.755746][ T67] xhci-hcd xhci-hcd.0.auto: Found 1 USB 2.0 ports and 1 USB 3.0 ports.
[ 22.763835][ T67] xhci-hcd xhci-hcd.0.auto: Finished xhci_init
[ 22.769840][ T67] xhci-hcd xhci-hcd.0.auto: Called HCD init
[ 22.775585][ T67] xhci-hcd xhci-hcd.0.auto: hcc params 0x0118ffcd hci version 0x120 quirks 0x0000008000000010
[ 22.785671][ T67] xhci-hcd xhci-hcd.0.auto: supports USB remote wakeup
[ 22.792382][ T67] xhci-hcd xhci-hcd.0.auto: irq 18, io mem 0x22100000
[ 22.798997][ T67] xhci-hcd xhci-hcd.0.auto: xhci_run
[ 22.804135][ T67] xhci-hcd xhci-hcd.0.auto: ERST deq = 64'h812c21000
[ 22.810661][ T67] xhci-hcd xhci-hcd.0.auto: // Set the interrupt modulation register
[ 22.818576][ T67] xhci-hcd xhci-hcd.0.auto: Finished xhci_run for main hcd
[ 22.825670][ T67] xhci-hcd xhci-hcd.0.auto: xHCI Host Controller
[ 22.831852][ T67] xhci-hcd xhci-hcd.0.auto: new USB bus registered, assigned bus number 2
[ 22.840204][ T67] xhci-hcd xhci-hcd.0.auto: Host supports USB 3.1 Enhanced SuperSpeed
[ 22.848206][ T67] xhci-hcd xhci-hcd.0.auto: supports USB remote wakeup
[ 22.854906][ T67] xhci-hcd xhci-hcd.0.auto: Enable interrupts
[ 22.860823][ T67] xhci-hcd xhci-hcd.0.auto: Enable primary interrupter
[ 22.867520][ T67] xhci-hcd xhci-hcd.0.auto: // Turn on HC, cmd = 0x5.
[ 22.874158][ T67] usb usb1: default language 0x0409
[ 22.879221][ T67] usb usb1: udev 1, busnum 1, minor = 0
[ 22.884743][ T67] usb usb1: usb_probe_device
[ 22.889193][ T67] usb usb1: configuration #1 chosen from 1 choice
[ 22.895462][ T67] xHCI xhci_add_endpoint called for root hub
[ 22.901294][ T67] xHCI xhci_check_bandwidth called for root hub
[ 22.907396][ T67] usb usb1: adding 1-0:1.0 (config #1, interface 0)
[ 22.913862][ T67] hub 1-0:1.0: usb_probe_interface
[ 22.918829][ T67] hub 1-0:1.0: usb_probe_interface - got id
[ 22.924576][ T67] hub 1-0:1.0: USB hub found
[ 22.929026][ T67] hub 1-0:1.0: 1 port detected
[ 22.933645][ T67] hub 1-0:1.0: standalone hub
[ 22.938176][ T67] hub 1-0:1.0: individual port power switching
[ 22.944182][ T67] hub 1-0:1.0: individual port over-current protection
[ 22.950881][ T67] hub 1-0:1.0: Single TT
[ 22.954978][ T67] hub 1-0:1.0: TT requires at most 8 FS bit times (666 ns)
[ 22.962026][ T67] hub 1-0:1.0: power on to power good time: 20ms
[ 22.968211][ T67] hub 1-0:1.0: local power source is good
[ 22.973809][ T67] hub 1-0:1.0: enabling power on all ports
[ 22.979470][ T67] xhci-hcd xhci-hcd.0.auto: set port power 1-1 ON, portsc: 0x2a0
[ 22.987101][ T67] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[ 22.995897][ T67] usb usb2: skipped 1 descriptor after endpoint
[ 23.001995][ T67] usb usb2: default language 0x0409
[ 23.007055][ T67] usb usb2: udev 1, busnum 2, minor = 128
[ 23.012638][ T10] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.012711][ T67] usb usb2: usb_probe_device
[ 23.021006][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.025437][ T67] usb usb2: configuration #1 chosen from 1 choice
[ 23.025440][ T67] xHCI xhci_add_endpoint called for root hub
[ 23.031621][ T69] hub 1-0:1.0: hub_suspend
[ 23.037882][ T67] xHCI xhci_check_bandwidth called for root hub
[ 23.043717][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.047991][ T67] usb usb2: adding 2-0:1.0 (config #1, interface 0)
[ 23.054074][ T69] usb usb1: suspend raced with wakeup event
[ 23.059406][ T67] hub 2-0:1.0: usb_probe_interface
[ 23.065821][ T69] usb usb1: usb auto-resume
[ 23.065827][ T69] hub 1-0:1.0: hub_resume
[ 23.071568][ T67] hub 2-0:1.0: usb_probe_interface - got id
[ 23.076529][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.080888][ T67] hub 2-0:1.0: USB hub found
[ 23.085066][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.090818][ T67] hub 2-0:1.0: 1 port detected
[ 23.099156][ T69] hub 1-0:1.0: hub_suspend
[ 23.103600][ T67] hub 2-0:1.0: standalone hub
[ 23.109779][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.114390][ T67] hub 2-0:1.0: individual port power switching
[ 23.118659][ T69] usb usb1: suspend raced with wakeup event
[ 23.123186][ T67] hub 2-0:1.0: individual port over-current protection
[ 23.128495][ T69] usb usb1: usb auto-resume
[ 23.134498][ T67] hub 2-0:1.0: TT requires at most 8 FS bit times (666 ns)
[ 23.140244][ T69] hub 1-0:1.0: hub_resume
[ 23.146938][ T67] hub 2-0:1.0: power on to power good time: 100ms
[ 23.151293][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.177129][ T67] hub 2-0:1.0: local power source is good
[ 23.177129][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.177132][ T69] hub 1-0:1.0: hub_suspend
[ 23.182717][ T67] usb usb2-port1: peered to usb1-port1
[ 23.188880][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.193148][ T67] hub 2-0:1.0: enabling power on all ports
[ 23.198457][ T69] usb usb1: suspend raced with wakeup event
[ 23.203767][ T67] xhci-hcd xhci-hcd.0.auto: set port power 2-1 ON, portsc: 0x2a0
[ 23.209420][ T69] usb usb1: usb auto-resume
[ 23.227086][ T69] hub 1-0:1.0: hub_resume
[ 23.231270][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.239623][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.245805][ T69] hub 1-0:1.0: hub_suspend
[ 23.250078][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.255392][ T69] usb usb1: suspend raced with wakeup event
[ 23.261137][ T69] usb usb1: usb auto-resume
[ 23.265495][ T69] hub 1-0:1.0: hub_resume
[ 23.269677][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.278030][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.284211][ T69] hub 1-0:1.0: hub_suspend
[ 23.288482][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.293794][ T69] usb usb1: suspend raced with wakeup event
[ 23.299539][ T69] usb usb1: usb auto-resume
[ 23.315980][ T69] hub 1-0:1.0: hub_resume
[ 23.315984][ T10] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x2a0, return 0x2a0
[ 23.328509][ T69] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 23.328530][ T73] hub 2-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.336865][ T69] hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
[ 23.343046][ T73] xhci-hcd xhci-hcd.0.auto: set port remote wake mask, actual port 2-1 status = 0xe0002a0
[ 23.349219][ T69] hub 1-0:1.0: hub_suspend
[ 23.359045][ T73] hub 2-0:1.0: hub_suspend
[ 23.363309][ T69] usb usb1: bus auto-suspend, wakeup 1
[ 23.367580][ T73] usb usb2: bus auto-suspend, wakeup 1
[ 23.372888][ T69] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb1 port polling
[ 23.386805][ T73] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling

设备接入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
[  401.013084][    C0] xhci-hcd xhci-hcd.0.auto: Port change event, 1-1, id 1, portsc: 0xa0206e1
[ 401.021610][ C0] xhci-hcd xhci-hcd.0.auto: resume root hub
[ 401.027355][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb1 port polling.
[ 401.035883][ T67] usb usb1: usb wakeup-resume
[ 401.040419][ T67] usb usb1: usb auto-resume
[ 401.044780][ T67] hub 1-0:1.0: hub_resume
[ 401.048965][ T67] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x202a0, return 0x10100
[ 401.057669][ T67] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x2a0
[ 401.082608][ C0] xhci-hcd xhci-hcd.0.auto: Port change event, 2-1, id 2, portsc: 0xa021603
[ 401.091129][ C0] xhci-hcd xhci-hcd.0.auto: resume root hub
[ 401.096872][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb2 port polling.
[ 401.105398][ T119] usb usb2: usb wakeup-resume
[ 401.109931][ T119] usb usb2: usb auto-resume
[ 401.114290][ T119] hub 2-0:1.0: hub_resume
[ 401.143975][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x21603, return 0x10203
[ 401.152674][ T119] usb usb2-port1: status 0203 change 0001
[ 401.158248][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x1603
[ 401.167969][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 401.176578][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb1 port polling
[ 401.185193][ T67] hub 1-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 401.191373][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb1 port polling
[ 401.199983][ T67] xhci-hcd xhci-hcd.0.auto: Get port status 1-1 read: 0x2a0, return 0x100
[ 401.208336][ T67] usb usb1-port1: status 0100, change 0000, 12 Mb/s
[ 401.214777][ T67] hub 1-0:1.0: hub_suspend
[ 401.219041][ T67] usb usb1: bus auto-suspend, wakeup 1
[ 401.224353][ T67] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb1 port polling
[ 401.271975][ T119] hub 2-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 401.278153][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 401.286765][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1603, return 0x203
[ 401.295203][ T119] usb usb2-port1: status 0203, change 0000, 10.0 Gb/s
[ 401.301820][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.307408][ T119] xhci-hcd xhci-hcd.0.auto: Slot 1 output ctx = 0x0x0000000810c23000 (dma)
[ 401.315846][ T119] xhci-hcd xhci-hcd.0.auto: Slot 1 input ctx = 0x0x0000000810c20000 (dma)
[ 401.324204][ T119] xhci-hcd xhci-hcd.0.auto: Set slot id 1 dcbaa entry (____ptrval____) to 0x810c23000
[ 401.333610][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1603, return 0x203
[ 401.342052][ T119] xhci-hcd xhci-hcd.0.auto: set port reset, actual port 2-1 status = 0x1711
[ 401.350668][ C0] xhci-hcd xhci-hcd.0.auto: Port change event, 2-1, id 2, portsc: 0x201603
[ 401.359102][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb2 port polling.
[ 401.431971][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x201603, return 0x100203
[ 401.440845][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 reset change, portsc: 0x1603
[ 401.448764][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 warm(BH) reset change, portsc: 0x1603
[ 401.457462][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 link state change, portsc: 0x1603
[ 401.465814][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x1603
[ 401.473904][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1603, return 0x203
[ 401.539975][ T119] xhci-hcd xhci-hcd.0.auto: Set root hub portnum to 2
[ 401.546587][ T119] xhci-hcd xhci-hcd.0.auto: Set fake root hub portnum to 1
[ 401.553634][ T119] xhci-hcd xhci-hcd.0.auto: udev->tt = 0000000000000000
[ 401.560420][ T119] xhci-hcd xhci-hcd.0.auto: udev->ttport = 0x0
[ 401.566425][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.572008][ T119] xhci-hcd xhci-hcd.0.auto: Successful setup address command
[ 401.579229][ T119] xhci-hcd xhci-hcd.0.auto: Op regs DCBAA ptr = 0x0000081224b000
[ 401.586796][ T119] xhci-hcd xhci-hcd.0.auto: Slot ID 1 dcbaa entry @(____ptrval____) = 0x00000810c23000
[ 401.596273][ T119] xhci-hcd xhci-hcd.0.auto: Output Context DMA address = 0x810c23000
[ 401.604188][ T119] xhci-hcd xhci-hcd.0.auto: Internal device address = 1
[ 401.610976][ T119] usb 2-1: new SuperSpeed Plus Gen 2x1 USB device number 2 using xhci-hcd
[ 401.636776][ T119] usb 2-1: skipped 1 descriptor after endpoint
[ 401.642782][ T119] usb 2-1: skipped 1 descriptor after endpoint
[ 401.648787][ T119] usb 2-1: skipped 2 descriptors after endpoint
[ 401.654878][ T119] usb 2-1: skipped 2 descriptors after endpoint
[ 401.660969][ T119] usb 2-1: skipped 2 descriptors after endpoint
[ 401.667060][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 401.675668][ T119] usb 2-1: skipped 2 descriptors after endpoint
[ 401.681771][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 401.688822][ T119] usb 2-1: default language 0x0409
[ 401.693798][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 401.700860][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 401.707921][ C0] xhci-hcd xhci-hcd.0.auto: Waiting for status stage event
[ 401.714971][ T119] usb 2-1: udev 2, busnum 2, minor = 129
[ 401.720545][ T119] usb 2-1: usb_probe_device
[ 401.724905][ T119] usb 2-1: configuration #1 chosen from 1 choice
[ 401.731096][ T119] xhci-hcd xhci-hcd.0.auto: add ep 0x81, slot id 1, new drop flags = 0x0, new add flags = 0x8
[ 401.741189][ T119] xhci-hcd xhci-hcd.0.auto: add ep 0x2, slot id 1, new drop flags = 0x0, new add flags = 0x18
[ 401.751275][ T119] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev (____ptrval____)
[ 401.760323][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.765910][ T119] xhci-hcd xhci-hcd.0.auto: Successful Endpoint Configure command
[ 401.773590][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.779165][ C0] xhci-hcd xhci-hcd.0.auto: Stopped on No-op or Link TRB for slot 1 ep 2
[ 401.787434][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.793020][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.798595][ C0] xhci-hcd xhci-hcd.0.auto: Stopped on No-op or Link TRB for slot 1 ep 3
[ 401.806866][ T119] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 401.812481][ T119] usb 2-1: adding 2-1:1.0 (config #1, interface 0)
[ 401.818861][ T119] usb-storage 2-1:1.0: usb_probe_interface
[ 401.824526][ T119] usb-storage 2-1:1.0: usb_probe_interface - got id
[ 401.830968][ T119] usb-storage 2-1:1.0: USB Mass Storage device detected
[ 401.837883][ T119] scsi host0: usb-storage 2-1:1.0
[ 401.842866][ T119] scsi host0: scsi_runtime_idle
[ 401.847573][ T119] scsi host0: scsi_runtime_suspend
[ 402.860005][ T119] scsi host0: scsi_runtime_resume
[ 402.865644][ T119] scsi 0:0:0:0: Direct-Access Seagate One Touch SSD PMAP PQ: 0 ANSI: 6
[ 402.875964][ T100] sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[ 402.884376][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 402.893509][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 402.903800][ T100] sd 0:0:0:0: [sda] Write Protect is off
[ 402.909290][ T100] sd 0:0:0:0: [sda] Mode Sense: 23 00 00 00
[ 402.915415][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 402.924546][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 402.934831][ T100] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 402.946190][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 402.955320][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 402.965981][ C0] xhci-hcd xhci-hcd.0.auto: ep 0x81 - asked for 192 bytes, 156 bytes untransferred
[ 402.975109][ C0] xhci-hcd xhci-hcd.0.auto: Giveback URB (____ptrval____), len = 36, expected = 192, status = 0
[ 402.985862][ T100] sd 0:0:0:0: [sda] Attached SCSI disk

读写数据

1
2
3
4
[root@tst ]# dd if=/dev/urandom of=/dev/sda bs=1K count=8K
8192+0 records in
8192+0 records out
8388608 bytes (8.0MB) copied, 0.381332 seconds, 21.0MB/s

移除SCSI缓存

1
2
3
4
[root@tst ]# echo 1 > /sys/class/block/sda/device/delete 
[ 884.515984][ T85] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[ 884.522985][ T31] scsi host0: scsi_runtime_idle
[ 884.528762][ T31] scsi host0: scsi_runtime_suspend

安全弹出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
[root@tst ]# echo 1 > /sys/bus/usb/devices/2-1/remove
[ 961.784696][ T85] usb 2-1: unregistering interface 2-1:1.0
[ 961.790540][ T85] scsi host0: scsi_runtime_resume
[ 961.828044][ T85] usb 2-1: usb_disable_device nuking non-ep0 URBs
[ 961.834323][ T85] xhci-hcd xhci-hcd.0.auto: xhci_drop_endpoint called for udev 00000000450bf705
[ 961.843213][ T85] xhci-hcd xhci-hcd.0.auto: drop ep 0x81, slot id 1, new drop flags = 0x8, new add flags = 0x0
[ 961.853387][ T85] xhci-hcd xhci-hcd.0.auto: xhci_drop_endpoint called for udev 00000000450bf705
[ 961.862268][ T85] xhci-hcd xhci-hcd.0.auto: drop ep 0x2, slot id 1, new drop flags = 0x18, new add flags = 0x0
[ 961.872443][ T85] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev 00000000450bf705
[ 961.881493][ T85] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 961.887079][ T85] xhci-hcd xhci-hcd.0.auto: Successful Endpoint Configure command
[ 961.894743][ T85] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev 00000000450bf705
[ 961.903819][ T85] usb usb2-port1: logical disconnect
[ 961.908963][ T85] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 961.914540][ C0] xhci-hcd xhci-hcd.0.auto: Stopped on No-op or Link TRB for slot 1 ep 0
[ 961.922811][ T85] xhci-hcd xhci-hcd.0.auto: Set port 2-1 link state, portsc: 0x1603, write 0x11661
[ 961.939962][ T71] hub 2-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 961.946148][ T71] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x1663, return 0x263
[ 961.954591][ T71] usb usb2-port1: status 0263, change 0000, 10.0 Gb/s
[ 961.961207][ T71] usb 2-1: USB disconnect, device number 2
[ 961.967992][ T71] usb 2-1: unregistering device
[ 961.972696][ T71] usb 2-1: usb_disable_device nuking all URBs
[ 961.978615][ T71] xhci-hcd xhci-hcd.0.auto: xhci_check_bandwidth called for udev 00000000450bf705
[ 961.987776][ T71] xhci-hcd xhci-hcd.0.auto: // Ding dong!
[ 961.993366][ T71] xhci-hcd xhci-hcd.0.auto: Set port 2-1 link state, portsc: 0x1663, write 0x11661
[ 962.007982][ T71] xhci-hcd xhci-hcd.0.auto: set port remote wake mask, actual port 2-1 status = 0xe001663
[ 962.017814][ T71] hub 2-0:1.0: hub_suspend
[ 962.022098][ T71] usb usb2: bus auto-suspend, wakeup 1
[ 962.027413][ T71] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling

设备拔出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[  981.667755][    C0] xhci-hcd xhci-hcd.0.auto: Port change event, 2-1, id 2, portsc: 0xc0202a0
[ 981.676279][ C0] xhci-hcd xhci-hcd.0.auto: resume root hub
[ 981.682023][ C0] xhci-hcd xhci-hcd.0.auto: handle_port_status: starting usb2 port polling.
[ 981.690550][ T119] usb usb2: usb wakeup-resume
[ 981.695086][ T119] usb usb2: usb auto-resume
[ 981.699448][ T119] hub 2-0:1.0: hub_resume
[ 981.727974][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x202a0, return 0x102a0
[ 981.736682][ T119] xhci-hcd xhci-hcd.0.auto: clear port1 connect change, portsc: 0x2a0
[ 981.851977][ T119] hub 2-0:1.0: state 7 ports 1 chg 0002 evt 0000
[ 981.858160][ C0] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling
[ 981.866771][ T119] xhci-hcd xhci-hcd.0.auto: Get port status 2-1 read: 0x2a0, return 0x2a0
[ 981.875125][ T119] usb usb2-port1: status 02a0, change 0000, 10.0 Gb/s
[ 981.881743][ T119] xhci-hcd xhci-hcd.0.auto: set port remote wake mask, actual port 2-1 status = 0xe0002a0
[ 981.891570][ T119] hub 2-0:1.0: hub_suspend
[ 981.895842][ T119] usb usb2: bus auto-suspend, wakeup 1
[ 981.901153][ T119] xhci-hcd xhci-hcd.0.auto: xhci_hub_status_data: stopping usb2 port polling

抓取函数堆栈

通过dump_stack()函数,查看特定函数的堆栈

xhci_halt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// linux-6.6.64/drivers/usb/host/xhci.c
int xhci_halt(struct xhci_hcd *xhci)

[ 88.026117][ T67] Hardware name: BST C1200 EVB (DT)
[ 88.031166][ T67] Workqueue: events_freezable __dwc3_set_mode
[ 88.037092][ T67] Call trace:
[ 88.040232][ T67] dump_backtrace+0xa4/0x134
[ 88.044678][ T67] show_stack+0x18/0x24
[ 88.048688][ T67] dump_stack_lvl+0x48/0x60
[ 88.053048][ T67] dump_stack+0x18/0x24
[ 88.057057][ T67] xhci_halt+0x18/0xac
[ 88.060979][ T67] xhci_gen_setup+0x248/0x4e4
[ 88.065508][ T67] xhci_plat_setup+0x58/0x68
[ 88.069954][ T67] usb_add_hcd+0x278/0x634
[ 88.074222][ T67] xhci_plat_probe+0x42c/0x66c
[ 88.078838][ T67] xhci_generic_plat_probe+0x7c/0xd8
[ 88.083974][ T67] platform_probe+0x68/0xd8
[ 88.088330][ T67] really_probe+0x128/0x39c
[ 88.092684][ T67] __driver_probe_device+0x88/0x170
[ 88.097734][ T67] driver_probe_device+0x3c/0x108
[ 88.102610][ T67] __device_attach_driver+0xcc/0x14c
[ 88.107746][ T67] bus_for_each_drv+0x74/0xbc
[ 88.112273][ T67] __device_attach+0xd4/0x1b8
[ 88.116801][ T67] device_initial_probe+0x14/0x20
[ 88.121677][ T67] bus_probe_device+0xa8/0xac
[ 88.126205][ T67] device_add+0x5ac/0x724
[ 88.130387][ T67] platform_device_add+0x120/0x284
[ 88.135350][ T67] dwc3_host_init+0x260/0x2fc
[ 88.139880][ T67] __dwc3_set_mode+0x148/0x3d8
[ 88.144496][ T67] process_scheduled_works+0x170/0x290
[ 88.149805][ T67] worker_thread+0x164/0x310
[ 88.154246][ T67] kthread+0x118/0x124
[ 88.158169][ T67] ret_from_fork+0x10/0x20

xhci_run

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// linux-6.6.64/drivers/usb/host/xhci.c
int xhci_run(struct usb_hcd *hcd)

[ 14.146200][ T70] Hardware name: BST C1200 EVB (DT)
[ 14.151249][ T70] Workqueue: events_freezable __dwc3_set_mode
[ 14.157177][ T70] Call trace:
[ 14.160316][ T70] dump_backtrace+0xa4/0x134
[ 14.164765][ T70] show_stack+0x18/0x24
[ 14.168773][ T70] dump_stack_lvl+0x48/0x60
[ 14.173132][ T70] dump_stack+0x18/0x24
[ 14.177141][ T70] xhci_run+0x28/0x280
[ 14.181064][ T70] xhci_plat_start+0x3c/0x4c
[ 14.185506][ T70] usb_add_hcd+0x3dc/0x634
[ 14.189773][ T70] xhci_plat_probe+0x42c/0x66c
[ 14.194389][ T70] xhci_generic_plat_probe+0x7c/0xd8
[ 14.199526][ T70] platform_probe+0x68/0xd8
[ 14.203882][ T70] really_probe+0x128/0x39c
[ 14.208237][ T70] __driver_probe_device+0x88/0x170
[ 14.213286][ T70] driver_probe_device+0x3c/0x108
[ 14.218163][ T70] __device_attach_driver+0xcc/0x14c
[ 14.223299][ T70] bus_for_each_drv+0x74/0xbc
[ 14.227826][ T70] __device_attach+0xd4/0x1b8
[ 14.232353][ T70] device_initial_probe+0x14/0x20
[ 14.237229][ T70] bus_probe_device+0xa8/0xac
[ 14.241756][ T70] device_add+0x5ac/0x724
[ 14.245939][ T70] platform_device_add+0x120/0x284
[ 14.250902][ T70] dwc3_host_init+0x260/0x2fc
[ 14.255431][ T70] __dwc3_set_mode+0x148/0x3d8
[ 14.260047][ T70] process_scheduled_works+0x170/0x290
[ 14.265357][ T70] worker_thread+0x164/0x310
[ 14.269798][ T70] kthread+0x118/0x124
[ 14.273721][ T70] ret_from_fork+0x10/0x20

usb_get_langid

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// linux-6.6.64/drivers/usb/core/message.c
static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)

[ 20.517956][ T69] Hardware name: BST C1200 EVB (DT)
[ 20.523005][ T69] Workqueue: events_freezable __dwc3_set_mode
[ 20.528932][ T69] Call trace:
[ 20.532070][ T69] dump_backtrace+0xa4/0x134
[ 20.536518][ T69] show_stack+0x18/0x24
[ 20.540526][ T69] dump_stack_lvl+0x48/0x60
[ 20.544885][ T69] dump_stack+0x18/0x24
[ 20.548894][ T69] usb_string+0x74/0x20c
[ 20.552989][ T69] usb_cache_string+0x58/0xe8
[ 20.557518][ T69] usb_new_device+0x84/0x428
[ 20.561959][ T69] register_root_hub+0xd4/0x228
[ 20.566661][ T69] usb_add_hcd+0x50c/0x634
[ 20.570928][ T69] xhci_plat_probe+0x490/0x66c
[ 20.575544][ T69] xhci_generic_plat_probe+0x7c/0xd8
[ 20.580679][ T69] platform_probe+0x68/0xd8
[ 20.585036][ T69] really_probe+0x128/0x39c
[ 20.589391][ T69] __driver_probe_device+0x88/0x170
[ 20.594440][ T69] driver_probe_device+0x3c/0x108
[ 20.599316][ T69] __device_attach_driver+0xcc/0x14c
[ 20.604451][ T69] bus_for_each_drv+0x74/0xbc
[ 20.608979][ T69] __device_attach+0xd4/0x1b8
[ 20.613507][ T69] device_initial_probe+0x14/0x20
[ 20.618383][ T69] bus_probe_device+0xa8/0xac
[ 20.622910][ T69] device_add+0x5ac/0x724
[ 20.627093][ T69] platform_device_add+0x120/0x284
[ 20.632056][ T69] dwc3_host_init+0x260/0x2fc
[ 20.636586][ T69] __dwc3_set_mode+0x148/0x3d8
[ 20.641203][ T69] process_scheduled_works+0x170/0x290
[ 20.646513][ T69] worker_thread+0x164/0x310
[ 20.650955][ T69] kthread+0x118/0x124
[ 20.654869][ T69] ret_from_fork+0x10/0x20

usb_probe_device

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// linux-6.6.64/drivers/usb/core/driver.c
static int usb_probe_device(struct device *dev)

[ 21.187959][ T69] CPU: 2 PID: 69 Comm: kworker/2:1 Not tainted 6.6.64 #13
[ 21.194918][ T69] Hardware name: BST C1200 EVB (DT)
[ 21.199967][ T69] Workqueue: events_freezable __dwc3_set_mode
[ 21.205894][ T69] Call trace:
[ 21.209033][ T69] dump_backtrace+0xa4/0x134
[ 21.213478][ T69] show_stack+0x18/0x24
[ 21.217487][ T69] dump_stack_lvl+0x48/0x60
[ 21.221845][ T69] dump_stack+0x18/0x24
[ 21.225854][ T69] usb_probe_device+0x24/0x10c
[ 21.230471][ T69] really_probe+0x128/0x39c
[ 21.234827][ T69] __driver_probe_device+0x88/0x170
[ 21.239876][ T69] driver_probe_device+0x3c/0x108
[ 21.244751][ T69] __device_attach_driver+0xcc/0x14c
[ 21.249888][ T69] bus_for_each_drv+0x74/0xbc
[ 21.254416][ T69] __device_attach+0xd4/0x1b8
[ 21.258943][ T69] device_initial_probe+0x14/0x20
[ 21.263819][ T69] bus_probe_device+0xa8/0xac
[ 21.268348][ T69] device_add+0x5ac/0x724
[ 21.272530][ T69] usb_new_device+0x1a4/0x428
[ 21.277058][ T69] register_root_hub+0xd4/0x228
[ 21.281760][ T69] usb_add_hcd+0x50c/0x634
[ 21.286028][ T69] xhci_plat_probe+0x490/0x66c
[ 21.290644][ T69] xhci_generic_plat_probe+0x7c/0xd8
[ 21.295779][ T69] platform_probe+0x68/0xd8
[ 21.300134][ T69] really_probe+0x128/0x39c
[ 21.304489][ T69] __driver_probe_device+0x88/0x170
[ 21.309538][ T69] driver_probe_device+0x3c/0x108
[ 21.314412][ T69] __device_attach_driver+0xcc/0x14c
[ 21.319548][ T69] bus_for_each_drv+0x74/0xbc
[ 21.324076][ T69] __device_attach+0xd4/0x1b8
[ 21.328605][ T69] device_initial_probe+0x14/0x20
[ 21.333481][ T69] bus_probe_device+0xa8/0xac
[ 21.338009][ T69] device_add+0x5ac/0x724
[ 21.342191][ T69] platform_device_add+0x120/0x284
[ 21.347154][ T69] dwc3_host_init+0x260/0x2fc
[ 21.351684][ T69] __dwc3_set_mode+0x148/0x3d8
[ 21.356299][ T69] process_scheduled_works+0x170/0x290
[ 21.361609][ T69] worker_thread+0x164/0x310
[ 21.366049][ T69] kthread+0x118/0x124
[ 21.369972][ T69] ret_from_fork+0x10/0x20

xhci_add_endpoint

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// linux-6.6.64/drivers/usb/host/xhci.c
int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
struct usb_host_endpoint *ep)

[ 14.971340][ T67] CPU: 0 PID: 67 Comm: kworker/0:2 Not tainted 6.6.64 #14
[ 14.978300][ T67] Hardware name: BST C1200 EVB (DT)
[ 14.983348][ T67] Workqueue: events_freezable __dwc3_set_mode
[ 14.989273][ T67] Call trace:
[ 14.992411][ T67] dump_backtrace+0xa4/0x134
[ 14.996856][ T67] show_stack+0x18/0x24
[ 15.000866][ T67] dump_stack_lvl+0x48/0x60
[ 15.005223][ T67] dump_stack+0x18/0x24
[ 15.009232][ T67] xhci_add_endpoint+0x30/0x2e8
[ 15.013935][ T67] usb_hcd_alloc_bandwidth+0x134/0x358
[ 15.019245][ T67] usb_set_configuration+0x104/0x91c
[ 15.024381][ T67] usb_generic_driver_probe+0x60/0x88
[ 15.029605][ T67] usb_probe_device+0x48/0x104
[ 15.034221][ T67] really_probe+0x128/0x39c
[ 15.038576][ T67] __driver_probe_device+0x88/0x170
[ 15.043625][ T67] driver_probe_device+0x3c/0x108
[ 15.048501][ T67] __device_attach_driver+0xcc/0x14c
[ 15.053636][ T67] bus_for_each_drv+0x74/0xbc
[ 15.058163][ T67] __device_attach+0xd4/0x1b8
[ 15.062691][ T67] device_initial_probe+0x14/0x20
[ 15.067568][ T67] bus_probe_device+0xa8/0xac
[ 15.072096][ T67] device_add+0x5ac/0x724
[ 15.076280][ T67] usb_new_device+0x1a4/0x428
[ 15.080808][ T67] register_root_hub+0xd4/0x228
[ 15.085508][ T67] usb_add_hcd+0x50c/0x634
[ 15.089776][ T67] xhci_plat_probe+0x490/0x66c
[ 15.094393][ T67] xhci_generic_plat_probe+0x7c/0xd8
[ 15.099529][ T67] platform_probe+0x68/0xd8
[ 15.103883][ T67] really_probe+0x128/0x39c
[ 15.108238][ T67] __driver_probe_device+0x88/0x170
[ 15.113287][ T67] driver_probe_device+0x3c/0x108
[ 15.118162][ T67] __device_attach_driver+0xcc/0x14c
[ 15.123298][ T67] bus_for_each_drv+0x74/0xbc
[ 15.127826][ T67] __device_attach+0xd4/0x1b8
[ 15.132354][ T67] device_initial_probe+0x14/0x20
[ 15.137228][ T67] bus_probe_device+0xa8/0xac
[ 15.141756][ T67] device_add+0x5ac/0x724
[ 15.145939][ T67] platform_device_add+0x120/0x284
[ 15.150901][ T67] dwc3_host_init+0x260/0x2fc
[ 15.155429][ T67] __dwc3_set_mode+0x148/0x3d8
[ 15.160045][ T67] process_scheduled_works+0x170/0x290
[ 15.165355][ T67] worker_thread+0x164/0x310
[ 15.169795][ T67] kthread+0x118/0x124
[ 15.173717][ T67] ret_from_fork+0x10/0x20

xhci_check_bandwidth

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// linux-6.6.64/drivers/usb/host/xhci.c
int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev)

[ 15.183822][ T67] CPU: 0 PID: 67 Comm: kworker/0:2 Not tainted 6.6.64 #14
[ 15.190780][ T67] Hardware name: BST C1200 EVB (DT)
[ 15.195827][ T67] Workqueue: events_freezable __dwc3_set_mode
[ 15.201746][ T67] Call trace:
[ 15.204884][ T67] dump_backtrace+0xa4/0x134
[ 15.209326][ T67] show_stack+0x18/0x24
[ 15.213335][ T67] dump_stack_lvl+0x48/0x60
[ 15.217691][ T67] dump_stack+0x18/0x24
[ 15.221700][ T67] xhci_check_bandwidth+0x28/0x2f0
[ 15.226663][ T67] usb_hcd_alloc_bandwidth+0x234/0x358
[ 15.231973][ T67] usb_set_configuration+0x104/0x91c
[ 15.237110][ T67] usb_generic_driver_probe+0x60/0x88
[ 15.242332][ T67] usb_probe_device+0x48/0x104
[ 15.246948][ T67] really_probe+0x128/0x39c
[ 15.251302][ T67] __driver_probe_device+0x88/0x170
[ 15.256351][ T67] driver_probe_device+0x3c/0x108
[ 15.261226][ T67] __device_attach_driver+0xcc/0x14c
[ 15.266362][ T67] bus_for_each_drv+0x74/0xbc
[ 15.270889][ T67] __device_attach+0xd4/0x1b8
[ 15.275417][ T67] device_initial_probe+0x14/0x20
[ 15.280292][ T67] bus_probe_device+0xa8/0xac
[ 15.284819][ T67] device_add+0x5ac/0x724
[ 15.289002][ T67] usb_new_device+0x1a4/0x428
[ 15.293529][ T67] register_root_hub+0xd4/0x228
[ 15.298231][ T67] usb_add_hcd+0x50c/0x634
[ 15.302499][ T67] xhci_plat_probe+0x490/0x66c
[ 15.307115][ T67] xhci_generic_plat_probe+0x7c/0xd8
[ 15.312250][ T67] platform_probe+0x68/0xd8
[ 15.316604][ T67] really_probe+0x128/0x39c
[ 15.320959][ T67] __driver_probe_device+0x88/0x170
[ 15.326009][ T67] driver_probe_device+0x3c/0x108
[ 15.330884][ T67] __device_attach_driver+0xcc/0x14c
[ 15.336020][ T67] bus_for_each_drv+0x74/0xbc
[ 15.340547][ T67] __device_attach+0xd4/0x1b8
[ 15.345074][ T67] device_initial_probe+0x14/0x20
[ 15.349948][ T67] bus_probe_device+0xa8/0xac
[ 15.354476][ T67] device_add+0x5ac/0x724
[ 15.358659][ T67] platform_device_add+0x120/0x284
[ 15.363621][ T67] dwc3_host_init+0x260/0x2fc
[ 15.368149][ T67] __dwc3_set_mode+0x148/0x3d8
[ 15.372765][ T67] process_scheduled_works+0x170/0x290
[ 15.378073][ T67] worker_thread+0x164/0x310
[ 15.382515][ T67] kthread+0x118/0x124
[ 15.386436][ T67] ret_from_fork+0x10/0x20

xhci_set_port_power

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// linux-6.6.64/drivers/usb/host/xhci-hub.c
static void xhci_set_port_power(struct xhci_hcd *xhci, struct xhci_port *port,
bool on, unsigned long *flags)

[ 11.736368][ T67] CPU: 0 PID: 67 Comm: kworker/0:2 Not tainted 6.6.64 #15
[ 11.743326][ T67] Hardware name: BST C1200 EVB (DT)
[ 11.748375][ T67] Workqueue: events_freezable __dwc3_set_mode
[ 11.754302][ T67] Call trace:
[ 11.757441][ T67] dump_backtrace+0xa4/0x134
[ 11.761888][ T67] show_stack+0x18/0x24
[ 11.765897][ T67] dump_stack_lvl+0x48/0x60
[ 11.770255][ T67] dump_stack+0x18/0x24
[ 11.774265][ T67] xhci_set_port_power+0x30/0x164
[ 11.779142][ T67] xhci_hub_control+0xc00/0x2458
[ 11.783930][ T67] usb_hcd_submit_urb+0x22c/0xa38
[ 11.788806][ T67] usb_submit_urb+0x340/0x5dc
[ 11.793334][ T67] usb_start_wait_urb+0x58/0x134
[ 11.798122][ T67] usb_control_msg+0xb0/0x110
[ 11.802651][ T67] set_port_feature+0x40/0x50
[ 11.807181][ T67] hub_power_on+0x60/0x128
[ 11.811451][ T67] hub_activate+0x694/0x800
[ 11.815806][ T67] hub_probe+0x830/0xd3c
[ 11.819899][ T67] usb_probe_interface+0x10c/0x2ec
[ 11.824863][ T67] really_probe+0x128/0x39c
[ 11.829219][ T67] __driver_probe_device+0x88/0x170
[ 11.834268][ T67] driver_probe_device+0x3c/0x108
[ 11.839143][ T67] __device_attach_driver+0xcc/0x14c
[ 11.844278][ T67] bus_for_each_drv+0x74/0xbc
[ 11.848805][ T67] __device_attach+0xd4/0x1b8
[ 11.853332][ T67] device_initial_probe+0x14/0x20
[ 11.858208][ T67] bus_probe_device+0xa8/0xac
[ 11.862735][ T67] device_add+0x5ac/0x724
[ 11.866918][ T67] usb_set_configuration+0x4b4/0x91c
[ 11.872054][ T67] usb_generic_driver_probe+0x60/0x88
[ 11.877276][ T67] usb_probe_device+0x48/0x104
[ 11.881893][ T67] really_probe+0x128/0x39c
[ 11.886248][ T67] __driver_probe_device+0x88/0x170
[ 11.891296][ T67] driver_probe_device+0x3c/0x108
[ 11.896171][ T67] __device_attach_driver+0xcc/0x14c
[ 11.901308][ T67] bus_for_each_drv+0x74/0xbc
[ 11.905836][ T67] __device_attach+0xd4/0x1b8
[ 11.910363][ T67] device_initial_probe+0x14/0x20
[ 11.915239][ T67] bus_probe_device+0xa8/0xac
[ 11.919766][ T67] device_add+0x5ac/0x724
[ 11.923947][ T67] usb_new_device+0x1a4/0x428
[ 11.928475][ T67] register_root_hub+0xd4/0x228
[ 11.933177][ T67] usb_add_hcd+0x50c/0x634
[ 11.937444][ T67] xhci_plat_probe+0x490/0x66c
[ 11.942060][ T67] xhci_generic_plat_probe+0x7c/0xd8
[ 11.947197][ T67] platform_probe+0x68/0xd8
[ 11.951552][ T67] really_probe+0x128/0x39c
[ 11.955906][ T67] __driver_probe_device+0x88/0x170
[ 11.960954][ T67] driver_probe_device+0x3c/0x108
[ 11.965829][ T67] __device_attach_driver+0xcc/0x14c
[ 11.970964][ T67] bus_for_each_drv+0x74/0xbc
[ 11.975491][ T67] __device_attach+0xd4/0x1b8
[ 11.980019][ T67] device_initial_probe+0x14/0x20
[ 11.984894][ T67] bus_probe_device+0xa8/0xac
[ 11.989421][ T67] device_add+0x5ac/0x724
[ 11.993603][ T67] platform_device_add+0x120/0x284
[ 11.998565][ T67] dwc3_host_init+0x260/0x2fc
[ 12.003094][ T67] __dwc3_set_mode+0x148/0x3d8
[ 12.007709][ T67] process_scheduled_works+0x170/0x290
[ 12.013019][ T67] worker_thread+0x164/0x310
[ 12.017460][ T67] kthread+0x118/0x124
[ 12.021382][ T67] ret_from_fork+0x10/0x20

usb_device_supports_lpm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// linux-6.6.64/drivers/usb/core/hub.c
int usb_device_supports_lpm(struct usb_device *udev)

[ 9.994854][ T69] CPU: 2 PID: 69 Comm: kworker/2:1 Not tainted 6.6.64 #16
[ 10.001814][ T69] Hardware name: BST C1200 EVB (DT)
[ 10.006862][ T69] Workqueue: events_freezable __dwc3_set_mode
[ 10.012788][ T69] Call trace:
[ 10.015927][ T69] dump_backtrace+0xa4/0x134
[ 10.020373][ T69] show_stack+0x18/0x24
[ 10.024382][ T69] dump_stack_lvl+0x48/0x60
[ 10.028740][ T69] dump_stack+0x18/0x24
[ 10.032749][ T69] usb_device_supports_lpm+0x18/0xf4
[ 10.037887][ T69] register_root_hub+0x1c8/0x228
[ 10.042677][ T69] usb_add_hcd+0x40c/0x634
[ 10.046944][ T69] xhci_plat_probe+0x490/0x66c
[ 10.051560][ T69] xhci_generic_plat_probe+0x7c/0xd8
[ 10.056696][ T69] platform_probe+0x68/0xd8
[ 10.061052][ T69] really_probe+0x128/0x39c
[ 10.065406][ T69] __driver_probe_device+0x88/0x170
[ 10.070455][ T69] driver_probe_device+0x3c/0x108
[ 10.075330][ T69] __device_attach_driver+0xcc/0x14c
[ 10.080466][ T69] bus_for_each_drv+0x74/0xbc
[ 10.084993][ T69] __device_attach+0xd4/0x1b8
[ 10.089520][ T69] device_initial_probe+0x14/0x20
[ 10.094396][ T69] bus_probe_device+0xa8/0xac
[ 10.098925][ T69] device_add+0x5ac/0x724
[ 10.103099][ T69] platform_device_add+0x120/0x284
[ 10.108061][ T69] dwc3_host_init+0x260/0x2fc
[ 10.112591][ T69] __dwc3_set_mode+0x148/0x3d8
[ 10.117207][ T69] process_scheduled_works+0x170/0x290
[ 10.122516][ T69] worker_thread+0x164/0x310
[ 10.126957][ T69] kthread+0x118/0x124
[ 10.130879][ T69] ret_from_fork+0x10/0x20

抓取ftrace函数调用

配置ftrace

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
cd /sys/kernel/debug/tracing
echo function_graph > current_tracer
echo __dwc3_set_mode > set_graph_function
echo uas_probe >> set_graph_function
echo scsi_add_host >> set_graph_function
echo sd_probe >> set_graph_function
echo hcd_resume_work >> set_graph_function
echo submit_bio >> set_graph_function
# echo usb_hcd_irq >> set_graph_function # 查看寄存器
echo xhci_* > set_ftrace_filter
echo usb_* >> set_ftrace_filter
echo *dwc3* >> set_ftrace_filter
echo hcd_* >> set_ftrace_filter
echo uas_* >> set_ftrace_filter
echo scsi_* >> set_ftrace_filter
echo sd_* >> set_ftrace_filter
echo _dev_info > set_ftrace_notrace
echo mutex* >> set_ftrace_notrace
echo _raw_spin* >> set_ftrace_notrace
echo __pm_runtime* >> set_ftrace_notrace
echo xhci_dbg_trace >> set_ftrace_notrace
echo nosleep-time > trace_options
echo nograph-time > trace_options
echo noirq-info > trace_options
echo noannotate > trace_options
echo 20 > max_graph_depth
cd -

抓取ftrace

1
2
3
4
5
6
7
8
9
echo device > /sys/class/usb_role/22100000.dwc3-role-switch/role
sleep 3
echo > /sys/kernel/debug/tracing/trace
echo 1 > /sys/kernel/debug/tracing/tracing_on
echo host > /sys/class/usb_role/22100000.dwc3-role-switch/role
sleep 3
echo 0 > /sys/kernel/debug/tracing/tracing_on
cat /sys/kernel/debug/tracing/trace > /tmp/trace.log

主控注册

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
echo device > /sys/class/usb_role/22100000.dwc3-role-switch/role
cd /sys/kernel/debug/tracing
echo 0 > tracing_on
echo > trace
echo function_graph > current_tracer
echo __dwc3_set_mode > set_graph_function
echo xhci_* > set_ftrace_filter
echo usb_* >> set_ftrace_filter
echo hub_* >> set_ftrace_filter
echo *dwc3* >> set_ftrace_filter
echo hcd_* >> set_ftrace_filter
echo uas_* >> set_ftrace_filter
echo scsi_* >> set_ftrace_filter
echo sd_* >> set_ftrace_filter
echo _dev_info > set_ftrace_notrace
echo mutex* >> set_ftrace_notrace
echo _raw_spin* >> set_ftrace_notrace
echo __pm_runtime* >> set_ftrace_notrace
echo xhci_dbg_trace >> set_ftrace_notrace
echo nosleep-time > trace_options
echo nograph-time > trace_options
echo noirq-info > trace_options
echo noannotate > trace_options
echo 20 > max_graph_depth
sleep 3 && echo 1 > tracing_on && echo host > /sys/class/usb_role/22100000.dwc3-role-switch/role && sleep 3 && echo 0 > tracing_on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
7) | __dwc3_set_mode() {
7) | dwc3_gadget_exit() {
7) 2.175 us | dwc3_enable_susphy();
7) | usb_del_gadget() {
7) 0.885 us | usb_udc_uevent();
7) | usb_gadget_disconnect_locked() {
7) | dwc3_gadget_pullup() {
7) | dwc3_gadget_soft_disconnect() {
7) | dwc3_stop_active_transfers() {
7) | dwc3_remove_requests() {
7) 0.520 us | dwc3_stop_active_transfer();
7) 1.320 us | }
7) | dwc3_remove_requests() {
7) 0.475 us | dwc3_stop_active_transfer();
7) 1.020 us | }
7) | dwc3_remove_requests() {
7) 0.360 us | dwc3_stop_active_transfer();
7) 1.130 us | }
7) | dwc3_remove_requests() {
7) 0.530 us | dwc3_stop_active_transfer();
7) 1.250 us | }
7) | dwc3_remove_requests() {
7) 0.460 us | dwc3_stop_active_transfer();
7) 1.005 us | }
7) | dwc3_remove_requests() {
7) 0.525 us | dwc3_stop_active_transfer();
7) 1.075 us | }
7) | dwc3_remove_requests() {
7) 0.475 us | dwc3_stop_active_transfer();
7) 1.020 us | }
7) | dwc3_remove_requests() {
7) 0.470 us | dwc3_stop_active_transfer();
7) 1.215 us | }
7) | dwc3_remove_requests() {
7) 0.515 us | dwc3_stop_active_transfer();
7) 1.070 us | }
7) | dwc3_remove_requests() {
7) 0.480 us | dwc3_stop_active_transfer();
7) 1.030 us | }
7) | dwc3_remove_requests() {
7) 0.285 us | dwc3_stop_active_transfer();
7) 0.840 us | }
7) | dwc3_remove_requests() {
7) 0.300 us | dwc3_stop_active_transfer();
7) 0.845 us | }
7) | dwc3_remove_requests() {
7) 0.290 us | dwc3_stop_active_transfer();
7) 0.835 us | }
7) | dwc3_remove_requests() {
7) 0.295 us | dwc3_stop_active_transfer();
7) 0.855 us | }
7) + 18.730 us | }
7) 4.430 us | dwc3_gadget_run_stop();
7) | __dwc3_gadget_ep_disable() {
7) | dwc3_remove_requests() {
7) 0.425 us | dwc3_stop_active_transfer();
7) 1.500 us | }
7) 3.015 us | }
7) | __dwc3_gadget_ep_disable() {
7) | dwc3_remove_requests() {
7) 0.290 us | dwc3_stop_active_transfer();
7) 1.380 us | }
7) 2.410 us | }
7) + 30.160 us | }
7) + 35.045 us | }
7) | usb_gadget_vbus_draw() {
7) 0.475 us | dwc3_gadget_vbus_draw();
7) 1.095 us | }
7) + 38.470 us | }
7) 0.330 us | dwc3_gadget_async_callbacks();
7) | usb_remove_function() {
7) | usb_ep_free_request() {
7) 0.545 us | dwc3_gadget_ep_free_request();
7) 1.605 us | }
7) | usb_ep_free_request() {
7) 0.320 us | dwc3_gadget_ep_free_request();
7) 0.915 us | }
7) | usb_ep_free_request() {
7) 0.605 us | dwc3_gadget_ep_free_request();
7) 1.175 us | }
7) | usb_ep_free_request() {
7) 0.350 us | dwc3_gadget_ep_free_request();
7) 1.045 us | }
7) | usb_ep_free_request() {
7) 1.645 us | dwc3_gadget_ep_free_request();
7) 2.385 us | }
7) | usb_ep_free_request() {
7) 0.350 us | dwc3_gadget_ep_free_request();
7) 0.915 us | }
7) | usb_ep_free_request() {
7) 0.345 us | dwc3_gadget_ep_free_request();
7) 0.920 us | }
7) | usb_ep_free_request() {
7) 0.335 us | dwc3_gadget_ep_free_request();
7) 0.900 us | }
7) | usb_ep_free_request() {
7) 0.335 us | dwc3_gadget_ep_free_request();
7) 0.895 us | }
7) | usb_ep_free_request() {
7) 0.375 us | dwc3_gadget_ep_free_request();
7) 1.100 us | }
7) | usb_ep_free_request() {
7) 0.345 us | dwc3_gadget_ep_free_request();
7) 0.910 us | }
7) | usb_ep_free_request() {
7) 0.325 us | dwc3_gadget_ep_free_request();
7) 0.895 us | }
7) | usb_ep_free_request() {
7) 0.325 us | dwc3_gadget_ep_free_request();
7) 0.890 us | }
7) | usb_ep_free_request() {
7) 0.325 us | dwc3_gadget_ep_free_request();
7) 0.935 us | }
7) | usb_ep_free_request() {
7) 0.330 us | dwc3_gadget_ep_free_request();
7) 0.885 us | }
7) | usb_ep_free_request() {
7) 0.325 us | dwc3_gadget_ep_free_request();
7) 0.890 us | }
7) | usb_ep_free_request() {
7) 0.325 us | dwc3_gadget_ep_free_request();
7) 0.875 us | }
7) | usb_ep_free_request() {
7) 0.330 us | dwc3_gadget_ep_free_request();
7) 0.890 us | }
7) | usb_ep_free_request() {
7) 0.335 us | dwc3_gadget_ep_free_request();
7) 0.910 us | }
7) | usb_ep_free_request() {
7) 0.335 us | dwc3_gadget_ep_free_request();
7) 0.890 us | }
7) 1.000 us | usb_free_all_descriptors();
7) + 82.310 us | }
7) 0.850 us | usb_put_function();
7) 8.170 us | usb_put_function_instance();
7) | usb_ep_free_request() {
7) 0.360 us | dwc3_gadget_ep_free_request();
7) 0.975 us | }
7) + 11.960 us | dwc3_gadget_stop();
7) 0.470 us | usb_udc_uevent();
7) 0.565 us | usb_udc_uevent();
7) 0.530 us | usb_udc_release();
7) ! 232.195 us | }
7) | dwc3_gadget_free_endpoints() {
7) + 33.170 us | dwc3_debugfs_remove_endpoint_dir();
7) + 25.910 us | dwc3_debugfs_remove_endpoint_dir();
7) + 21.360 us | dwc3_debugfs_remove_endpoint_dir();
7) + 23.245 us | dwc3_debugfs_remove_endpoint_dir();
7) + 22.090 us | dwc3_debugfs_remove_endpoint_dir();
7) + 22.515 us | dwc3_debugfs_remove_endpoint_dir();
7) + 24.755 us | dwc3_debugfs_remove_endpoint_dir();
7) + 22.910 us | dwc3_debugfs_remove_endpoint_dir();
7) + 22.180 us | dwc3_debugfs_remove_endpoint_dir();
7) + 22.840 us | dwc3_debugfs_remove_endpoint_dir();
7) + 24.145 us | dwc3_debugfs_remove_endpoint_dir();
7) + 22.180 us | dwc3_debugfs_remove_endpoint_dir();
7) + 20.720 us | dwc3_debugfs_remove_endpoint_dir();
7) + 21.370 us | dwc3_debugfs_remove_endpoint_dir();
7) + 20.220 us | dwc3_debugfs_remove_endpoint_dir();
7) + 21.275 us | dwc3_debugfs_remove_endpoint_dir();
7) ! 405.400 us | }
7) ! 645.525 us | }
7) 2.850 us | dwc3_event_buffers_cleanup();
7) 0.695 us | dwc3_set_prtcap();
7) | dwc3_host_init() {
7) 0.455 us | dwc3_host_fill_xhci_irq_res();
7) | xhci_generic_plat_probe() {
7) | xhci_plat_probe() {
7) 0.545 us | usb_disabled();
7) 0.385 us | usb_hcd_is_primary_hcd();
7) 0.495 us | usb_hcd_is_primary_hcd();
7) | usb_add_hcd() {
7) 0.950 us | usb_phy_roothub_alloc();
7) 0.310 us | usb_phy_roothub_init();
7) 0.475 us | usb_phy_roothub_set_mode();
7) 0.475 us | usb_phy_roothub_power_on();
7) 3.795 us | hcd_buffer_create();
7) 1.170 us | usb_notify_add_bus();
7) | usb_alloc_dev() {
7) 0.535 us | usb_get_hcd();
7) 0.460 us | usb_enable_endpoint();
7) 6.155 us | }
7) | xhci_plat_setup() {
7) 0.505 us | usb_hcd_is_primary_hcd();
7) | xhci_gen_setup() {
7) 0.405 us | usb_hcd_is_primary_hcd();
7) 0.515 us | usb_hcd_is_primary_hcd();
7) 0.515 us | xhci_plat_quirks();
7) | xhci_halt() {
7) 1.265 us | xhci_quiesce();
7) 0.950 us | xhci_handshake();
7) 4.925 us | }
7) 0.795 us | xhci_zero_64b_regs();
7) | xhci_reset() {
7) ! 192.000 us | xhci_handshake();
7) 0.975 us | xhci_handshake();
7) ! 195.145 us | }
7) | xhci_init() {
7) 0.515 us | usb_hcd_is_primary_hcd();
7) | xhci_mem_init() {
7) | xhci_ring_alloc() {
7) | xhci_alloc_segments_for_ring() {
7) 3.310 us | xhci_segment_alloc();
7) 0.870 us | xhci_link_segments.part.16();
7) 6.125 us | }
7) 7.425 us | }
7) | xhci_ring_alloc() {
7) | xhci_alloc_segments_for_ring() {
7) 2.925 us | xhci_segment_alloc();
7) 4.040 us | }
7) 4.835 us | }
7) 1.825 us | xhci_alloc_erst();
7) 0.790 us | xhci_trb_virt_to_dma();
7) 0.475 us | xhci_create_rhub_port_array();
7) 0.550 us | xhci_create_rhub_port_array();
7) + 48.770 us | }
7) + 51.560 us | }
7) 0.400 us | usb_hcd_is_primary_hcd();
7) * 10352.55 us | }
7) * 10354.68 us | }
7) 0.395 us | usb_phy_roothub_calibrate();
7) | xhci_plat_start() {
7) 0.510 us | usb_hcd_is_primary_hcd();
7) | dwc3_xhci_plat_start() {
7) 0.510 us | usb_hcd_is_primary_hcd();
7) 1.675 us | dwc3_enable_susphy();
7) 4.805 us | }
7) | xhci_run() {
7) 0.400 us | usb_hcd_is_primary_hcd();
7) 0.400 us | usb_hcd_is_primary_hcd();
7) 2.330 us | xhci_create_dbc_dev();
7) | xhci_debugfs_init() {
7) 4.105 us | xhci_debugfs_regset();
7) 2.430 us | xhci_debugfs_regset();
7) 2.780 us | xhci_debugfs_regset();
7) | xhci_debugfs_extcap_regset() {
7) 3.060 us | xhci_debugfs_regset();
7) 6.310 us | }
7) | xhci_debugfs_extcap_regset() {
7) 2.815 us | xhci_debugfs_regset();
7) 2.375 us | xhci_debugfs_regset();
7) + 10.250 us | }
7) 2.420 us | xhci_debugfs_extcap_regset();
7) + 20.340 us | xhci_debugfs_create_ring_dir.isra.15();
7) 9.700 us | xhci_debugfs_create_ring_dir.isra.15();
7) + 82.340 us | }
7) + 89.015 us | }
7) + 96.165 us | }
7) * 31651.31 us | }
7) | usb_add_hcd() {
7) 1.555 us | hcd_buffer_create();
7) 0.505 us | usb_notify_add_bus();
7) | usb_alloc_dev() {
7) 0.425 us | usb_get_hcd();
7) 0.505 us | usb_enable_endpoint();
7) 3.505 us | }
7) | xhci_plat_setup() {
7) 0.515 us | usb_hcd_is_primary_hcd();
7) | xhci_gen_setup() {
7) 0.500 us | usb_hcd_is_primary_hcd();
7) 0.410 us | usb_hcd_is_primary_hcd();
7) # 8005.515 us | xhci_hcd_init_usb3_data();
7) # 8008.440 us | }
7) # 8010.420 us | }
7) 0.370 us | usb_phy_roothub_calibrate();
7) | xhci_plat_start() {
7) 0.480 us | usb_hcd_is_primary_hcd();
7) | dwc3_xhci_plat_start() {
7) 0.510 us | usb_hcd_is_primary_hcd();
7) 1.320 us | }
7) | xhci_run() {
7) 0.400 us | usb_hcd_is_primary_hcd();
7) 0.410 us | usb_hcd_is_primary_hcd();
7) | xhci_run_finished() {
7) | xhci_start() {
7) 1.250 us | xhci_handshake();
7) 2.865 us | }
7) 5.185 us | }
7) 7.595 us | }
7) + 11.115 us | }
7) 0.855 us | usb_set_device_state();
7) | usb_get_device_descriptor() {
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.455 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.505 us | usb_get_urb.part.12();
7) 1.475 us | }
7) 0.605 us | usb_hcd_link_urb_to_ep();
7) 0.685 us | usb_hcd_unlink_urb_from_ep();
7) 4.620 us | usb_hcd_giveback_urb();
7) + 11.955 us | }
7) + 13.185 us | }
7) 0.645 us | usb_free_urb();
7) + 15.270 us | }
7) + 17.745 us | }
7) + 18.865 us | }
7) + 19.865 us | }
7) | usb_new_device() {
7) 0.565 us | usb_disable_autosuspend();
7) | usb_get_configuration() {
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.345 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.495 us | usb_get_urb.part.12();
7) 1.210 us | }
7) 0.370 us | usb_hcd_link_urb_to_ep();
7) 0.315 us | usb_hcd_unlink_urb_from_ep();
7) 1.275 us | usb_hcd_giveback_urb();
7) 5.555 us | }
7) 6.340 us | }
7) 0.340 us | usb_free_urb();
7) 7.570 us | }
7) 8.820 us | }
7) 9.440 us | }
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.335 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.865 us | }
7) 0.370 us | usb_hcd_link_urb_to_ep();
7) 0.305 us | usb_hcd_unlink_urb_from_ep();
7) 0.875 us | usb_hcd_giveback_urb();
7) 4.345 us | }
7) 4.940 us | }
7) 0.335 us | usb_free_urb();
7) 6.160 us | }
7) 7.370 us | }
7) 7.980 us | }
7) + 21.555 us | }
7) | usb_cache_string() {
7) | usb_string() {
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.340 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.890 us | }
7) 0.320 us | usb_hcd_link_urb_to_ep();
7) 0.310 us | usb_hcd_unlink_urb_from_ep();
7) 0.810 us | usb_hcd_giveback_urb();
7) 4.400 us | }
7) 5.010 us | }
7) 0.340 us | usb_free_urb();
7) 6.230 us | }
7) 7.445 us | }
7) 8.080 us | }
7) 8.680 us | }
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.335 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.460 us | usb_get_urb.part.12();
7) 1.030 us | }
7) 0.310 us | usb_hcd_link_urb_to_ep();
7) 0.310 us | usb_hcd_unlink_urb_from_ep();
7) 0.765 us | usb_hcd_giveback_urb();
7) 4.665 us | }
7) 5.235 us | }
7) 0.340 us | usb_free_urb();
7) 6.450 us | }
7) 7.660 us | }
7) 8.720 us | }
7) 9.315 us | }
7) + 19.495 us | }
7) + 20.580 us | }
7) | usb_cache_string() {
7) | usb_string() {
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.325 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.305 us | usb_get_urb.part.12();
7) 0.880 us | }
7) 0.325 us | usb_hcd_link_urb_to_ep();
7) 0.310 us | usb_hcd_unlink_urb_from_ep();
7) 0.785 us | usb_hcd_giveback_urb();
7) 4.805 us | }
7) 5.510 us | }
7) 0.345 us | usb_free_urb();
7) 6.735 us | }
7) 7.930 us | }
7) 8.490 us | }
7) 9.085 us | }
7) 9.845 us | }
7) + 10.490 us | }
7) | usb_cache_string() {
7) | usb_string() {
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.350 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.870 us | }
7) 0.320 us | usb_hcd_link_urb_to_ep();
7) 0.315 us | usb_hcd_unlink_urb_from_ep();
7) 0.745 us | usb_hcd_giveback_urb();
7) 4.290 us | }
7) 4.865 us | }
7) 0.330 us | usb_free_urb();
7) 6.075 us | }
7) 7.350 us | }
7) 7.905 us | }
7) 8.455 us | }
7) 9.145 us | }
7) 9.795 us | }
7) | usb_detect_interface_quirks() {
7) | usb_detect_static_quirks() {
7) 0.305 us | usb_match_device();
7) 1.355 us | }
7) 2.125 us | }
7) 1.225 us | usb_devnode();
7) | usb_bus_notify() {
7) 5.365 us | usb_create_sysfs_dev_files();
7) 6.245 us | }
7) 1.035 us | usb_devnode();
7) 1.135 us | usb_uevent();
7) 0.530 us | usb_dev_uevent();
7) 0.515 us | usb_device_match();
7) 0.315 us | usb_device_match();
7) | usb_device_match() {
7) | usb_driver_applicable() {
7) 1.355 us | usb_generic_driver_match();
7) 2.170 us | }
7) 3.380 us | }
7) 0.320 us | usb_bus_notify();
7) | usb_probe_device() {
7) | usb_generic_driver_probe() {
7) | usb_choose_configuration() {
7) 0.330 us | usb_device_is_owned();
7) 1.370 us | }
7) | usb_set_configuration() {
7) 0.335 us | usb_autoresume_device();
7) | usb_hcd_alloc_bandwidth() {
7) 0.350 us | usb_find_alt_setting();
7) | xhci_add_endpoint() {
7) 0.470 us | xhci_check_args();
7) 2.110 us | }
7) | xhci_check_bandwidth() {
7) 0.305 us | xhci_check_args();
7) 1.265 us | }
7) 5.525 us | }
7) 0.335 us | usb_altnum_to_altsetting();
7) | usb_enable_interface() {
7) | usb_enable_endpoint() {
7) | usb_hcd_reset_endpoint() {
7) | xhci_endpoint_reset() {
7) 0.305 us | usb_hcd_is_primary_hcd();
7) 0.895 us | }
7) 1.895 us | }
7) 2.695 us | }
7) 3.420 us | }
7) 0.355 us | usb_of_has_combined_node();
7) 0.345 us | usb_get_dev();
7) | usb_control_msg_send() {
7) | usb_control_msg() {
7) 0.350 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.335 us | usb_get_urb.part.12();
7) 0.895 us | }
7) 0.345 us | usb_hcd_link_urb_to_ep();
7) 0.325 us | usb_hcd_unlink_urb_from_ep();
7) 1.705 us | usb_hcd_giveback_urb();
7) 5.540 us | }
7) 6.235 us | }
7) 0.525 us | usb_free_urb();
7) 7.800 us | }
7) 9.020 us | }
7) 9.650 us | }
7) 0.345 us | usb_set_device_state();
7) 0.335 us | usb_cache_string();
7) | usb_unlocked_enable_lpm() {
7) 0.325 us | usb_enable_lpm();
7) 1.330 us | }
7) 0.310 us | usb_enable_ltm();
7) | usb_bus_notify() {
7) | usb_create_sysfs_intf_files() {
7) 0.370 us | usb_cache_string();
7) 1.035 us | }
7) 1.680 us | }
7) 0.875 us | usb_uevent();
7) 1.625 us | usb_if_uevent();
7) | usb_device_match() {
7) 0.365 us | usb_match_dynamic_id();
7) 1.250 us | }
7) | usb_device_match() {
7) | usb_match_id.part.16() {
7) | usb_match_one_id() {
7) 0.345 us | usb_match_device();
7) 0.950 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.895 us | }
7) | usb_match_one_id() {
7) 0.310 us | usb_match_device();
7) 0.900 us | }
7) | usb_match_one_id() {
7) 0.315 us | usb_match_device();
7) 1.080 us | }
7) | usb_match_one_id() {
7) 0.310 us | usb_match_device();
7) 0.885 us | }
7) | usb_match_one_id() {
7) 0.335 us | usb_match_device();
7) 0.905 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.890 us | }
7) | usb_match_one_id() {
7) 0.340 us | usb_match_device();
7) 0.910 us | }
7) | usb_match_one_id() {
7) 1.020 us | usb_match_device();
7) 0.365 us | usb_match_one_id_intf();
7) 2.310 us | }
7) + 13.220 us | }
7) + 14.020 us | }
7) 0.330 us | usb_bus_notify();
7) | usb_probe_interface() {
7) 0.340 us | usb_device_is_owned();
7) 0.345 us | usb_match_dynamic_id();
7) | usb_match_id.part.16() {
7) | usb_match_one_id() {
7) 0.325 us | usb_match_device();
7) 0.905 us | }
7) | usb_match_one_id() {
7) 0.315 us | usb_match_device();
7) 0.895 us | }
7) | usb_match_one_id() {
7) 0.300 us | usb_match_device();
7) 0.890 us | }
7) | usb_match_one_id() {
7) 0.295 us | usb_match_device();
7) 0.850 us | }
7) | usb_match_one_id() {
7) 0.300 us | usb_match_device();
7) 0.885 us | }
7) | usb_match_one_id() {
7) 0.300 us | usb_match_device();
7) 0.890 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.895 us | }
7) | usb_match_one_id() {
7) 0.295 us | usb_match_device();
7) 0.865 us | }
7) | usb_match_one_id() {
7) 0.330 us | usb_match_device();
7) 0.300 us | usb_match_one_id_intf();
7) 1.470 us | }
7) + 11.355 us | }
7) 0.340 us | usb_autoresume_device();
7) | hub_probe() {
7) 0.590 us | usb_enable_autosuspend();
7) 1.125 us | usb_get_intf();
7) 1.365 us | usb_get_dev();
7) | usb_control_msg() {
7) 1.365 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 1.340 us | usb_get_urb.part.12();
7) 3.780 us | }
7) 1.665 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 1.400 us | usb_hcd_is_primary_hcd();
7) 1.365 us | usb_hcd_is_primary_hcd();
7) 7.515 us | }
7) 1.350 us | usb_hub_adjust_deviceremovable();
7) 1.720 us | usb_hcd_unlink_urb_from_ep();
7) 3.700 us | usb_hcd_giveback_urb();
7) + 29.660 us | }
7) + 30.995 us | }
7) 0.385 us | usb_free_urb();
7) + 33.320 us | }
7) + 37.100 us | }
7) | usb_get_status() {
7) | usb_control_msg() {
7) 0.355 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 1.025 us | }
7) 0.320 us | usb_hcd_link_urb_to_ep();
7) 0.315 us | usb_hcd_unlink_urb_from_ep();
7) 1.575 us | usb_hcd_giveback_urb();
7) 6.010 us | }
7) 6.635 us | }
7) 0.335 us | usb_free_urb();
7) 7.880 us | }
7) 9.115 us | }
7) 9.815 us | }
7) | hub_hub_status() {
7) | usb_control_msg() {
7) 0.325 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.305 us | usb_get_urb.part.12();
7) 0.860 us | }
7) 0.310 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.295 us | usb_hcd_is_primary_hcd();
7) 0.295 us | usb_hcd_is_primary_hcd();
7) 1.480 us | }
7) 0.320 us | usb_hcd_unlink_urb_from_ep();
7) 0.850 us | usb_hcd_giveback_urb();
7) 6.110 us | }
7) 6.730 us | }
7) 0.335 us | usb_free_urb();
7) 8.105 us | }
7) 9.465 us | }
7) + 10.090 us | }
7) 0.335 us | usb_alloc_urb();
7) | usb_hub_create_port_device() {
7) 0.520 us | usb_hub_to_struct_hub();
7) + 20.835 us | }
7) | xhci_update_hub_device() {
7) 0.305 us | usb_hcd_is_primary_hcd();
7) 1.150 us | }
7) 0.560 us | usb_hub_adjust_deviceremovable();
7) | hub_activate() {
7) | hub_power_on() {
7) | usb_control_msg() {
7) 0.355 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.315 us | usb_get_urb.part.12();
7) 0.900 us | }
7) 0.310 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.295 us | usb_hcd_is_primary_hcd();
7) 0.300 us | usb_hcd_is_primary_hcd();
7) 1.575 us | xhci_set_port_power();
7) 4.255 us | }
7) 0.315 us | usb_hcd_unlink_urb_from_ep();
7) 0.960 us | usb_hcd_giveback_urb();
7) 9.185 us | }
7) 9.805 us | }
7) 0.340 us | usb_free_urb();
7) + 11.040 us | }
7) + 12.300 us | }
7) + 13.540 us | }
7) 0.350 us | usb_autopm_get_interface_no_resume();
7) + 16.430 us | }
7) # 9193.660 us | }
7) # 9208.910 us | }
7) 0.330 us | usb_bus_notify();
7) 0.865 us | usb_uevent();
7) 1.260 us | usb_if_uevent();
7) + 12.040 us | usb_create_ep_devs();
7) 0.415 us | usb_autosuspend_device();
7) # 9313.915 us | }
7) 0.370 us | usb_notify_add_device();
7) # 9317.115 us | }
7) # 9318.250 us | }
7) 0.725 us | usb_bus_notify();
7) 1.410 us | usb_devnode();
7) 0.780 us | usb_uevent();
7) 0.515 us | usb_dev_uevent();
7) 8.740 us | usb_create_ep_devs();
7) # 9496.440 us | }
7) 0.380 us | usb_set_device_state();
7) | usb_get_device_descriptor() {
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.380 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.355 us | usb_get_urb.part.12();
7) 0.950 us | }
7) 0.315 us | usb_hcd_link_urb_to_ep();
7) 0.305 us | usb_hcd_unlink_urb_from_ep();
7) 1.815 us | usb_hcd_giveback_urb();
7) 5.595 us | }
7) 6.250 us | }
7) 0.330 us | usb_free_urb();
7) 7.485 us | }
7) 8.745 us | }
7) 9.435 us | }
7) + 10.140 us | }
7) | usb_get_bos_descriptor() {
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.370 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.325 us | usb_get_urb.part.12();
7) 0.895 us | }
7) 0.325 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.325 us | usb_hcd_is_primary_hcd();
7) 0.295 us | usb_hcd_is_primary_hcd();
7) 1.850 us | }
7) 0.335 us | usb_hcd_unlink_urb_from_ep();
7) 0.850 us | usb_hcd_giveback_urb();
7) 6.615 us | }
7) 7.270 us | }
7) 0.335 us | usb_free_urb();
7) 8.645 us | }
7) 9.910 us | }
7) + 10.550 us | }
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.330 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.375 us | usb_get_urb.part.12();
7) 0.965 us | }
7) 0.315 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.315 us | usb_hcd_is_primary_hcd();
7) 0.300 us | usb_hcd_is_primary_hcd();
7) 2.720 us | }
7) 0.315 us | usb_hcd_unlink_urb_from_ep();
7) 0.830 us | usb_hcd_giveback_urb();
7) 7.330 us | }
7) 7.960 us | }
7) 0.360 us | usb_free_urb();
7) 9.265 us | }
7) + 10.520 us | }
7) + 11.145 us | }
7) + 23.105 us | }
7) | usb_device_supports_lpm() {
7) # 8806.390 us | usb_device_supports_lpm.part.47();
7) # 8807.375 us | }
7) | usb_new_device() {
7) 0.380 us | usb_disable_autosuspend();
7) | usb_get_configuration() {
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.365 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.325 us | usb_get_urb.part.12();
7) 0.895 us | }
7) 0.320 us | usb_hcd_link_urb_to_ep();
7) 0.310 us | usb_hcd_unlink_urb_from_ep();
7) 0.945 us | usb_hcd_giveback_urb();
7) 5.010 us | }
7) 5.730 us | }
7) 0.340 us | usb_free_urb();
7) 6.985 us | }
7) 8.280 us | }
7) 8.950 us | }
7) | usb_get_descriptor() {
7) | usb_control_msg() {
7) 0.340 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.880 us | }
7) 0.320 us | usb_hcd_link_urb_to_ep();
7) 0.310 us | usb_hcd_unlink_urb_from_ep();
7) 0.805 us | usb_hcd_giveback_urb();
7) 4.305 us | }
7) 4.940 us | }
7) 0.330 us | usb_free_urb();
7) 6.195 us | }
7) 7.440 us | }
7) 8.110 us | }
7) + 19.880 us | }
7) | usb_cache_string() {
7) | usb_string() {
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.350 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.315 us | usb_get_urb.part.12();
7) 0.895 us | }
7) 0.335 us | usb_hcd_link_urb_to_ep();
7) 0.335 us | usb_hcd_unlink_urb_from_ep();
7) 0.825 us | usb_hcd_giveback_urb();
7) 4.460 us | }
7) 5.065 us | }
7) 0.335 us | usb_free_urb();
7) 6.315 us | }
7) 7.565 us | }
7) 8.325 us | }
7) 8.930 us | }
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.330 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.300 us | usb_get_urb.part.12();
7) 0.860 us | }
7) 0.320 us | usb_hcd_link_urb_to_ep();
7) 0.335 us | usb_hcd_unlink_urb_from_ep();
7) 0.770 us | usb_hcd_giveback_urb();
7) 4.600 us | }
7) 5.210 us | }
7) 0.335 us | usb_free_urb();
7) 6.555 us | }
7) 7.780 us | }
7) 8.345 us | }
7) 8.925 us | }
7) + 19.185 us | }
7) + 20.145 us | }
7) | usb_cache_string() {
7) | usb_string() {
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.345 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.870 us | }
7) 0.315 us | usb_hcd_link_urb_to_ep();
7) 0.325 us | usb_hcd_unlink_urb_from_ep();
7) 0.800 us | usb_hcd_giveback_urb();
7) 4.705 us | }
7) 5.330 us | }
7) 0.365 us | usb_free_urb();
7) 6.570 us | }
7) 7.830 us | }
7) 8.380 us | }
7) 9.120 us | }
7) 9.835 us | }
7) + 10.895 us | }
7) | usb_cache_string() {
7) | usb_string() {
7) | usb_string_sub() {
7) | usb_get_string() {
7) | usb_control_msg() {
7) 0.355 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.315 us | usb_get_urb.part.12();
7) 0.875 us | }
7) 0.335 us | usb_hcd_link_urb_to_ep();
7) 0.330 us | usb_hcd_unlink_urb_from_ep();
7) 0.775 us | usb_hcd_giveback_urb();
7) 4.340 us | }
7) 4.975 us | }
7) 0.345 us | usb_free_urb();
7) 6.225 us | }
7) 7.500 us | }
7) 8.060 us | }
7) 8.630 us | }
7) 9.310 us | }
7) + 10.005 us | }
7) | usb_detect_interface_quirks() {
7) | usb_detect_static_quirks() {
7) 0.325 us | usb_match_device();
7) 1.145 us | }
7) 1.735 us | }
7) 0.900 us | usb_devnode();
7) | usb_bus_notify() {
7) 4.495 us | usb_create_sysfs_dev_files();
7) 5.290 us | }
7) 0.740 us | usb_devnode();
7) 0.860 us | usb_uevent();
7) 0.500 us | usb_dev_uevent();
7) 0.330 us | usb_device_match();
7) 0.320 us | usb_device_match();
7) | usb_device_match() {
7) | usb_driver_applicable() {
7) 0.780 us | usb_generic_driver_match();
7) 1.445 us | }
7) 2.105 us | }
7) 0.300 us | usb_bus_notify();
7) | usb_probe_device() {
7) | usb_generic_driver_probe() {
7) | usb_choose_configuration() {
7) 0.315 us | usb_device_is_owned();
7) 0.940 us | }
7) | usb_set_configuration() {
7) 0.335 us | usb_autoresume_device();
7) | usb_hcd_alloc_bandwidth() {
7) 0.350 us | usb_find_alt_setting();
7) | xhci_add_endpoint() {
7) 0.300 us | xhci_check_args();
7) 0.890 us | }
7) | xhci_check_bandwidth() {
7) 0.315 us | xhci_check_args();
7) 0.925 us | }
7) 3.960 us | }
7) 0.320 us | usb_altnum_to_altsetting();
7) | usb_enable_interface() {
7) | usb_enable_endpoint() {
7) | usb_hcd_reset_endpoint() {
7) | xhci_endpoint_reset() {
7) 0.310 us | usb_hcd_is_primary_hcd();
7) 0.900 us | }
7) 1.660 us | }
7) 2.275 us | }
7) 3.000 us | }
7) 0.330 us | usb_of_has_combined_node();
7) 0.310 us | usb_get_dev();
7) | usb_control_msg_send() {
7) | usb_control_msg() {
7) 0.340 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.875 us | }
7) 0.310 us | usb_hcd_link_urb_to_ep();
7) 0.325 us | usb_hcd_unlink_urb_from_ep();
7) 1.795 us | usb_hcd_giveback_urb();
7) 5.900 us | }
7) 6.515 us | }
7) 0.445 us | usb_free_urb();
7) 7.850 us | }
7) 9.120 us | }
7) 9.730 us | }
7) 0.395 us | usb_set_device_state();
7) 0.345 us | usb_cache_string();
7) | usb_unlocked_enable_lpm() {
7) 0.305 us | usb_enable_lpm();
7) 0.910 us | }
7) | usb_enable_ltm() {
7) | usb_control_msg() {
7) 0.335 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.500 us | usb_get_urb.part.12();
7) 1.055 us | }
7) 0.330 us | usb_hcd_link_urb_to_ep();
7) 0.340 us | usb_hcd_unlink_urb_from_ep();
7) 0.820 us | usb_hcd_giveback_urb();
7) 4.660 us | }
7) 5.415 us | }
7) 0.365 us | usb_free_urb();
7) 6.685 us | }
7) 7.955 us | }
7) 8.605 us | }
7) | usb_bus_notify() {
7) | usb_create_sysfs_intf_files() {
7) 0.335 us | usb_cache_string();
7) 0.935 us | }
7) 1.570 us | }
7) 0.725 us | usb_uevent();
7) 1.380 us | usb_if_uevent();
7) | usb_device_match() {
7) 0.340 us | usb_match_dynamic_id();
7) 0.995 us | }
7) | usb_device_match() {
7) | usb_match_id.part.16() {
7) | usb_match_one_id() {
7) 0.315 us | usb_match_device();
7) 1.075 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.880 us | }
7) | usb_match_one_id() {
7) 0.310 us | usb_match_device();
7) 0.875 us | }
7) | usb_match_one_id() {
7) 0.310 us | usb_match_device();
7) 0.880 us | }
7) | usb_match_one_id() {
7) 0.300 us | usb_match_device();
7) 1.600 us | }
7) | usb_match_one_id() {
7) 0.300 us | usb_match_device();
7) 0.900 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.910 us | }
7) | usb_match_one_id() {
7) 0.300 us | usb_match_device();
7) 0.870 us | }
7) | usb_match_one_id() {
7) 0.360 us | usb_match_device();
7) 0.305 us | usb_match_one_id_intf();
7) 1.570 us | }
7) + 12.535 us | }
7) + 13.160 us | }
7) 0.320 us | usb_bus_notify();
7) | usb_probe_interface() {
7) 0.315 us | usb_device_is_owned();
7) 0.620 us | usb_match_dynamic_id();
7) | usb_match_id.part.16() {
7) | usb_match_one_id() {
7) 0.495 us | usb_match_device();
7) 1.105 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.890 us | }
7) | usb_match_one_id() {
7) 0.315 us | usb_match_device();
7) 0.900 us | }
7) | usb_match_one_id() {
7) 0.330 us | usb_match_device();
7) 0.925 us | }
7) | usb_match_one_id() {
7) 0.325 us | usb_match_device();
7) 0.900 us | }
7) | usb_match_one_id() {
7) 0.320 us | usb_match_device();
7) 0.920 us | }
7) | usb_match_one_id() {
7) 0.295 us | usb_match_device();
7) 0.875 us | }
7) | usb_match_one_id() {
7) 0.305 us | usb_match_device();
7) 0.870 us | }
7) | usb_match_one_id() {
7) 0.315 us | usb_match_device();
7) 0.305 us | usb_match_one_id_intf();
7) 1.670 us | }
7) + 12.190 us | }
7) 0.350 us | usb_autoresume_device();
7) | hub_probe() {
7) 0.390 us | usb_enable_autosuspend();
7) 0.635 us | usb_get_intf();
7) 0.705 us | usb_get_dev();
7) | usb_control_msg() {
7) 0.550 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.515 us | usb_get_urb.part.12();
7) 1.555 us | }
7) 0.520 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.505 us | usb_hcd_is_primary_hcd();
7) 0.500 us | usb_hcd_is_primary_hcd();
7) 3.345 us | }
7) 0.500 us | usb_hub_adjust_deviceremovable();
7) 0.560 us | usb_hcd_unlink_urb_from_ep();
7) 1.945 us | usb_hcd_giveback_urb();
7) + 13.275 us | }
7) + 14.115 us | }
7) 0.350 us | usb_free_urb();
7) + 15.495 us | }
7) + 17.295 us | }
7) | usb_get_status() {
7) | usb_control_msg() {
7) 0.370 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.310 us | usb_get_urb.part.12();
7) 0.880 us | }
7) 0.315 us | usb_hcd_link_urb_to_ep();
7) 0.315 us | usb_hcd_unlink_urb_from_ep();
7) 1.560 us | usb_hcd_giveback_urb();
7) 5.180 us | }
7) 5.775 us | }
7) 0.340 us | usb_free_urb();
7) 7.035 us | }
7) 8.330 us | }
7) 9.055 us | }
7) | hub_hub_status() {
7) | usb_control_msg() {
7) 0.340 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.460 us | usb_get_urb.part.12();
7) 1.035 us | }
7) 0.315 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.300 us | usb_hcd_is_primary_hcd();
7) 0.290 us | usb_hcd_is_primary_hcd();
7) 1.475 us | }
7) 0.310 us | usb_hcd_unlink_urb_from_ep();
7) 0.810 us | usb_hcd_giveback_urb();
7) 6.255 us | }
7) 6.845 us | }
7) 0.335 us | usb_free_urb();
7) 8.180 us | }
7) 9.550 us | }
7) + 10.355 us | }
7) 0.340 us | usb_alloc_urb();
7) | usb_hub_create_port_device() {
7) 0.420 us | usb_hub_to_struct_hub();
7) + 18.710 us | }
7) | xhci_update_hub_device() {
7) 0.305 us | usb_hcd_is_primary_hcd();
7) 0.970 us | }
7) 0.420 us | usb_hub_adjust_deviceremovable();
7) | hub_activate() {
7) | hub_power_on() {
7) | usb_control_msg() {
7) 0.360 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) | usb_submit_urb() {
7) | usb_hcd_submit_urb() {
7) | usb_get_urb() {
7) 0.325 us | usb_get_urb.part.12();
7) 0.920 us | }
7) 0.325 us | usb_hcd_link_urb_to_ep();
7) | xhci_hub_control() {
7) 0.315 us | usb_hcd_is_primary_hcd();
7) 0.300 us | usb_hcd_is_primary_hcd();
7) 1.580 us | xhci_set_port_power();
7) 4.270 us | }
7) 0.320 us | usb_hcd_unlink_urb_from_ep();
7) 0.950 us | usb_hcd_giveback_urb();
7) 9.295 us | }
7) 9.925 us | }
7) 0.340 us | usb_free_urb();
7) + 11.300 us | }
7) + 12.585 us | }
7) + 13.295 us | }
7) 0.365 us | usb_autopm_get_interface_no_resume();
7) + 15.385 us | }
7) # 9147.800 us | }
7) # 9163.670 us | }
7) 0.330 us | usb_bus_notify();
7) 0.705 us | usb_uevent();
7) 1.185 us | usb_if_uevent();
7) 9.840 us | usb_create_ep_devs();
7) 0.375 us | usb_autosuspend_device();
7) # 9264.390 us | }
7) 0.415 us | usb_notify_add_device();
7) # 9267.030 us | }
7) # 9267.690 us | }
7) 0.320 us | usb_bus_notify();
7) 0.725 us | usb_devnode();
7) 0.685 us | usb_uevent();
7) 0.495 us | usb_dev_uevent();
7) 9.895 us | usb_create_ep_devs();
7) # 9428.855 us | }
7) * 50353.38 us | }
7) * 82050.31 us | }
7) * 82051.90 us | }
7) * 82170.12 us | }
7) * 82828.60 us | }

设备接入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cd /sys/kernel/debug/tracing
echo 0 > tracing_on
echo > trace
echo function_graph > current_tracer
echo __dwc3_set_mode > set_graph_function
echo uas_probe >> set_graph_function
echo scsi_add_host >> set_graph_function
echo sd_probe >> set_graph_function
echo hcd_resume_work >> set_graph_function
echo hub_event >> set_graph_function
echo submit_bio >> set_graph_function
#echo usb_hcd_irq >> set_graph_function # 默认不要打开,否则中断调用比较多
echo xhci_* > set_ftrace_filter
echo usb_* >> set_ftrace_filter
echo hub_* >> set_ftrace_filter
echo *dwc3* >> set_ftrace_filter
echo hcd_* >> set_ftrace_filter
echo uas_* >> set_ftrace_filter
echo scsi_* >> set_ftrace_filter
echo sd_* >> set_ftrace_filter
echo _dev_info > set_ftrace_notrace
echo mutex* >> set_ftrace_notrace
echo _raw_spin* >> set_ftrace_notrace
echo __pm_runtime* >> set_ftrace_notrace
echo xhci_dbg_trace >> set_ftrace_notrace
echo nosleep-time > trace_options
echo nograph-time > trace_options
echo noirq-info > trace_options
echo noannotate > trace_options
echo 20 > max_graph_depth
# echo 1 > tracing_on && sleep 10 && echo 插入设备 && echo 0 > tracing_on

屏蔽usb_hcd_irq函数的数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
0) | hcd_resume_work() {
0) | usb_remote_wakeup() {
0) | usb_autoresume_device() {
0) | usb_runtime_resume() {
0) | usb_resume_both() {
0) | usb_generic_driver_resume() {
0) | hcd_bus_resume() {
0) | xhci_bus_resume() {
0) 0.575 us | usb_hcd_is_primary_hcd();
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 7.880 us | }
0) 0.310 us | usb_phy_roothub_calibrate();
0) 0.460 us | usb_set_device_state();
0) 0.390 us | usb_hub_find_child();
0) 0.315 us | usb_hub_find_child();
0) # 4368.280 us | }
0) # 4369.485 us | }
0) | usb_resume_interface.isra.13() {
0) | hub_resume() {
0) | hub_activate() {
0) | hub_ext_port_status() {
0) | usb_control_msg() {
0) 0.425 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.350 us | usb_get_urb.part.12();
0) 1.015 us | }
0) 0.500 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.315 us | usb_hcd_is_primary_hcd();
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_get_port_status.isra.17() {
0) 0.290 us | usb_hcd_is_primary_hcd();
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 1.570 us | }
0) # 8703.435 us | }
0) 0.315 us | usb_hcd_unlink_urb_from_ep();
0) 2.040 us | usb_hcd_giveback_urb();
0) # 8710.875 us | }
0) # 8711.840 us | }
0) 0.380 us | usb_free_urb();
0) # 8713.275 us | }
0) # 8715.220 us | }
0) # 8716.370 us | }
0) 0.540 us | hub_port_warm_reset_required();
0) | usb_clear_port_feature() {
0) | usb_control_msg() {
0) 0.380 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.470 us | usb_get_urb.part.12();
0) 1.155 us | }
0) 0.320 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.300 us | usb_hcd_is_primary_hcd();
0) # 8092.335 us | }
0) 0.465 us | usb_hcd_unlink_urb_from_ep();
0) 1.130 us | usb_hcd_giveback_urb();
0) # 8097.990 us | }
0) # 8098.745 us | }
0) 0.500 us | usb_free_urb();
0) # 8100.150 us | }
0) # 8101.515 us | }
0) # 8102.225 us | }
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.355 us | usb_get_urb.part.12();
0) 0.985 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) 2.970 us | }
0) 3.730 us | }
0) 0.375 us | usb_autopm_get_interface_no_resume();
0) * 22405.71 us | }
0) | xhci_get_resuming_ports() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 1.025 us | }
0) * 26591.95 us | }
0) * 26592.78 us | }
0) * 30963.48 us | }
0) * 30964.18 us | }
0) * 30966.35 us | }
0) | usb_autosuspend_device() {
0) 0.455 us | usb_runtime_suspend();
0) 1.735 us | }
0) * 35505.47 us | }
0) * 35510.29 us | }
0) | hub_event() {
0) | usb_hcd_poll_rh_status() {
0) | xhci_hub_status_data() {
0) 0.325 us | usb_hcd_is_primary_hcd();
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 3.465 us | }
0) 4.215 us | }
0) 0.845 us | usb_autopm_get_interface();
0) | hub_ext_port_status() {
0) | usb_control_msg() {
0) 0.355 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.465 us | usb_get_urb.part.12();
0) 1.165 us | }
0) 0.305 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.295 us | usb_hcd_is_primary_hcd();
0) | xhci_get_port_status.isra.17() {
0) 0.285 us | usb_hcd_is_primary_hcd();
0) 0.285 us | usb_hcd_is_primary_hcd();
0) 1.430 us | }
0) # 8439.305 us | }
0) 0.310 us | usb_hcd_unlink_urb_from_ep();
0) 1.135 us | usb_hcd_giveback_urb();
0) # 8445.020 us | }
0) # 8445.650 us | }
0) 0.375 us | usb_free_urb();
0) # 8446.925 us | }
0) # 8448.525 us | }
0) # 8449.160 us | }
0) 0.310 us | hub_port_warm_reset_required();
0) | usb_alloc_dev() {
0) 0.335 us | usb_get_hcd();
0) | xhci_alloc_dev() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.430 us | xhci_alloc_command();
0) | xhci_queue_slot_control() {
0) 0.720 us | xhci_mod_cmd_timer();
0) 2.670 us | }
0) | xhci_ring_cmd_db() {
0) # 5570.740 us | xhci_ring_cmd_db.part.52();
0) # 5571.330 us | }
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.315 us | usb_hcd_is_primary_hcd();
0) 1.200 us | xhci_update_erst_dequeue.isra.49();
0) 6.300 us | }
0) 6.885 us | }
0) 0.385 us | xhci_free_command();
0) | xhci_alloc_virt_device() {
0) 1.075 us | xhci_alloc_container_ctx();
0) 0.870 us | xhci_alloc_container_ctx();
0) | xhci_ring_alloc() {
0) | xhci_alloc_segments_for_ring() {
0) 1.030 us | xhci_segment_alloc();
0) 0.940 us | xhci_segment_alloc();
0) 0.620 us | xhci_link_segments.part.16();
0) 0.660 us | xhci_link_segments.part.16();
0) 5.790 us | }
0) 6.960 us | }
0) * 26187.72 us | }
0) 1.195 us | xhci_get_slot_ctx();
0) | xhci_debugfs_create_slot() {
0) 9.420 us | xhci_debugfs_create_ring_dir.isra.15();
0) + 21.690 us | }
0) * 31798.71 us | }
0) 0.385 us | usb_enable_endpoint();
0) | usb_hcd_find_raw_port_number() {
0) | xhci_find_raw_port_number() {
0) | xhci_get_rhub() {
0) 0.315 us | usb_hcd_is_primary_hcd();
0) 0.900 us | }
0) 1.670 us | }
0) 2.470 us | }
0) 0.995 us | usb_of_get_device_node();
0) * 31808.61 us | }
0) 1.660 us | usb_set_device_state();
0) | hub_port_init() {
0) | hub_port_reset() {
0) | hub_ext_port_status() {
0) | usb_control_msg() {
0) 0.350 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.310 us | usb_get_urb.part.12();
0) 0.880 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.445 us | usb_hcd_is_primary_hcd();
0) | xhci_get_port_status.isra.17() {
0) 0.285 us | usb_hcd_is_primary_hcd();
0) 0.290 us | usb_hcd_is_primary_hcd();
0) 1.405 us | }
0) # 8439.935 us | }
0) 0.315 us | usb_hcd_unlink_urb_from_ep();
0) 1.365 us | usb_hcd_giveback_urb();
0) # 8445.420 us | }
0) # 8446.080 us | }
0) 0.345 us | usb_free_urb();
0) # 8447.425 us | }
0) # 8448.695 us | }
0) # 8449.310 us | }
0) 0.315 us | hub_port_warm_reset_required();
0) | usb_control_msg() {
0) 0.350 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.315 us | usb_get_urb.part.12();
0) 0.865 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.295 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.290 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_poll_rh_status() {
0) | xhci_hub_status_data() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 1.905 us | }
0) 2.755 us | }
0) 1.190 us | xhci_update_erst_dequeue.isra.49();
0) * 16962.56 us | }
0) * 16963.19 us | }
0) * 25578.49 us | }
0) 0.415 us | usb_hcd_unlink_urb_from_ep();
0) 1.055 us | usb_hcd_giveback_urb();
0) * 25583.91 us | }
0) * 25584.54 us | }
0) 0.325 us | usb_free_urb();
0) * 25585.78 us | }
0) * 25587.19 us | }
0) | hub_ext_port_status() {
0) | usb_control_msg() {
0) 1.120 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.590 us | usb_get_urb.part.12();
0) 1.160 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_get_port_status.isra.17() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 1.465 us | }
0) # 8874.310 us | }
0) 0.340 us | usb_hcd_unlink_urb_from_ep();
0) 1.010 us | usb_hcd_giveback_urb();
0) # 8879.645 us | }
0) # 8880.270 us | }
0) 0.335 us | usb_free_urb();
0) # 8881.510 us | }
0) # 8883.830 us | }
0) # 8884.500 us | }
0) 0.305 us | hub_port_warm_reset_required();
0) | usb_clear_port_feature() {
0) | usb_control_msg() {
0) 0.340 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.315 us | usb_get_urb.part.12();
0) 0.880 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.305 us | usb_hcd_is_primary_hcd();
0) # 7918.110 us | }
0) 0.310 us | usb_hcd_unlink_urb_from_ep();
0) 1.030 us | usb_hcd_giveback_urb();
0) # 7923.100 us | }
0) # 7923.715 us | }
0) 0.340 us | usb_free_urb();
0) # 7925.155 us | }
0) # 7926.455 us | }
0) # 7927.055 us | }
0) | usb_clear_port_feature() {
0) | usb_control_msg() {
0) 0.330 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.315 us | usb_get_urb.part.12();
0) 0.870 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.290 us | usb_hcd_is_primary_hcd();
0) # 8697.840 us | }
0) 0.320 us | usb_hcd_unlink_urb_from_ep();
0) 1.010 us | usb_hcd_giveback_urb();
0) # 8702.690 us | }
0) # 8703.305 us | }
0) 0.330 us | usb_free_urb();
0) # 8704.530 us | }
0) # 8705.805 us | }
0) # 8706.390 us | }
0) | usb_clear_port_feature() {
0) | usb_control_msg() {
0) 0.335 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.305 us | usb_get_urb.part.12();
0) 0.995 us | }
0) 0.325 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.300 us | usb_hcd_is_primary_hcd();
0) # 8350.870 us | }
0) 0.305 us | usb_hcd_unlink_urb_from_ep();
0) 0.940 us | usb_hcd_giveback_urb();
0) # 8356.545 us | }
0) # 8357.355 us | }
0) 0.330 us | usb_free_urb();
0) # 8358.590 us | }
0) # 8360.145 us | }
0) # 8360.730 us | }
0) | usb_clear_port_feature() {
0) | usb_control_msg() {
0) 0.335 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.305 us | usb_get_urb.part.12();
0) 0.870 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.295 us | usb_hcd_is_primary_hcd();
0) # 8090.860 us | }
0) 0.315 us | usb_hcd_unlink_urb_from_ep();
0) 0.940 us | usb_hcd_giveback_urb();
0) # 8095.730 us | }
0) # 8096.335 us | }
0) 0.330 us | usb_free_urb();
0) # 8097.555 us | }
0) # 8098.810 us | }
0) # 8099.400 us | }
0) | hub_ext_port_status() {
0) | usb_control_msg() {
0) 0.340 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.300 us | usb_get_urb.part.12();
0) 0.865 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) | xhci_hub_control() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.285 us | usb_hcd_is_primary_hcd();
0) | xhci_get_port_status.isra.17() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.290 us | usb_hcd_is_primary_hcd();
0) 1.490 us | }
0) # 8439.505 us | }
0) 0.310 us | usb_hcd_unlink_urb_from_ep();
0) 0.925 us | usb_hcd_giveback_urb();
0) # 8444.280 us | }
0) # 8444.890 us | }
0) 0.330 us | usb_free_urb();
0) # 8446.155 us | }
0) # 8447.440 us | }
0) # 8448.095 us | }
0) 0.295 us | hub_port_warm_reset_required();
0) | xhci_discover_or_reset_device() {
0) | xhci_check_args() {
0) 0.335 us | usb_hcd_is_primary_hcd();
0) 1.155 us | }
0) 0.290 us | usb_hcd_is_primary_hcd();
0) 0.295 us | xhci_get_slot_ctx();
0) 3.220 us | }
0) 0.645 us | usb_set_device_state();
0) * 84476.62 us | }
0) 0.530 us | usb_speed_string();
0) | xhci_address_device() {
0) | xhci_setup_device() {
0) 0.290 us | usb_hcd_is_primary_hcd();
0) 0.880 us | xhci_get_slot_ctx();
0) 0.480 us | xhci_alloc_command();
0) 0.315 us | xhci_get_slot_ctx();
0) 0.300 us | xhci_get_input_control_ctx();
0) | xhci_setup_addressable_virt_dev() {
0) | xhci_find_raw_port_number() {
0) | xhci_get_rhub() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.865 us | }
0) 1.495 us | }
0) * 26453.05 us | }
0) | xhci_queue_address_device() {
0) 0.540 us | xhci_mod_cmd_timer();
0) 1.985 us | }
0) | xhci_ring_cmd_db() {
0) # 5569.510 us | xhci_ring_cmd_db.part.52();
0) # 5570.080 us | }
0) 0.485 us | xhci_get_slot_ctx();
0) * 70998.68 us | }
0) * 70999.70 us | }
0) 0.595 us | usb_set_device_state();
0) | usb_ep0_reinit() {
0) | usb_disable_endpoint() {
0) 0.335 us | usb_hcd_flush_endpoint();
0) | usb_hcd_disable_endpoint() {
0) | xhci_endpoint_disable() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 1.085 us | }
0) 1.865 us | }
0) 3.420 us | }
0) | usb_disable_endpoint() {
0) 0.320 us | usb_hcd_flush_endpoint();
0) | usb_hcd_disable_endpoint() {
0) | xhci_endpoint_disable() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.865 us | }
0) 1.435 us | }
0) 2.625 us | }
0) | usb_enable_endpoint() {
0) | usb_hcd_reset_endpoint() {
0) | xhci_endpoint_reset() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.995 us | }
0) 1.620 us | }
0) 2.200 us | }
0) 9.585 us | }
0) | usb_control_msg() {
0) 0.395 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.300 us | usb_get_urb.part.12();
0) 0.880 us | }
0) | xhci_map_urb_for_dma() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 2.225 us | usb_hcd_map_urb_for_dma();
0) 3.480 us | }
0) | xhci_urb_enqueue() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) 1.020 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.305 us | xhci_virt_ep_to_ring();
0) 1.440 us | }
0) 0.300 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.410 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 0.330 us | xhci_td_remainder();
0) 1.260 us | xhci_ring_ep_doorbell();
0) + 10.160 us | }
0) + 12.975 us | }
0) + 18.915 us | }
0) + 20.220 us | }
0) 0.365 us | usb_free_urb();
0) + 22.735 us | }
0) + 24.210 us | }
0) | usb_set_isoch_delay() {
0) | usb_control_msg_send() {
0) | usb_control_msg() {
0) 0.385 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.305 us | usb_get_urb.part.12();
0) 0.885 us | }
0) | xhci_map_urb_for_dma() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) 0.925 us | }
0) | xhci_urb_enqueue() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.865 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.285 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.285 us | xhci_virt_ep_to_ring();
0) 1.415 us | }
0) 0.290 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.310 us | xhci_get_virt_ep();
0) 0.285 us | xhci_virt_ep_to_ring();
0) 1.405 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 1.235 us | xhci_ring_ep_doorbell();
0) 8.685 us | }
0) + 11.125 us | }
0) + 14.150 us | }
0) + 14.730 us | }
0) 0.370 us | usb_free_urb();
0) + 16.975 us | }
0) + 18.315 us | }
0) + 18.915 us | }
0) + 19.590 us | }
0) | usb_get_device_descriptor() {
0) | usb_get_descriptor() {
0) | usb_control_msg() {
0) 0.340 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.310 us | usb_get_urb.part.12();
0) 0.870 us | }
0) | xhci_map_urb_for_dma() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.765 us | usb_hcd_map_urb_for_dma();
0) 1.905 us | }
0) | xhci_urb_enqueue() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 1.035 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.295 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.515 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.645 us | }
0) 0.290 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.305 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.410 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) 0.315 us | xhci_td_remainder();
0) 1.230 us | xhci_ring_ep_doorbell();
0) 9.825 us | }
0) + 13.075 us | }
0) + 17.105 us | }
0) + 17.695 us | }
0) 0.350 us | usb_free_urb();
0) + 19.770 us | }
0) + 21.195 us | }
0) + 22.030 us | }
0) + 22.815 us | }
0) | usb_detect_quirks() {
0) | usb_detect_static_quirks() {
0) 0.300 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.315 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.315 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.430 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.330 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.320 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.905 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.325 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) 0.310 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.300 us | usb_match_device();
0) 0.305 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.295 us | usb_match_device();
0) 0.290 us | usb_match_device();
0) + 71.395 us | }
0) + 72.460 us | }
0) | usb_get_bos_descriptor() {
0) | usb_get_descriptor() {
0) | usb_control_msg() {
0) 0.340 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.310 us | usb_get_urb.part.12();
0) 0.885 us | }
0) | xhci_map_urb_for_dma() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.640 us | usb_hcd_map_urb_for_dma();
0) 1.770 us | }
0) | xhci_urb_enqueue() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.865 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.420 us | }
0) 0.290 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.320 us | xhci_virt_ep_to_ring();
0) 1.430 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 0.295 us | xhci_td_remainder();
0) 1.230 us | xhci_ring_ep_doorbell();
0) 9.590 us | }
0) + 11.940 us | }
0) + 15.715 us | }
0) + 16.305 us | }
0) 0.350 us | usb_free_urb();
0) + 18.325 us | }
0) + 19.575 us | }
0) + 20.375 us | }
0) | usb_get_descriptor() {
0) | usb_control_msg() {
0) 0.335 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.890 us | usb_get_urb.part.12();
0) 1.460 us | }
0) | xhci_map_urb_for_dma() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.650 us | usb_hcd_map_urb_for_dma();
0) 1.780 us | }
0) | xhci_urb_enqueue() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.850 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.295 us | xhci_get_virt_ep();
0) 0.280 us | xhci_virt_ep_to_ring();
0) 1.405 us | }
0) 0.295 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.300 us | xhci_virt_ep_to_ring();
0) 1.415 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) 0.300 us | xhci_td_remainder();
0) 1.230 us | xhci_ring_ep_doorbell();
0) 9.630 us | }
0) + 11.925 us | }
0) + 16.300 us | }
0) + 16.890 us | }
0) 0.375 us | usb_free_urb();
0) + 18.925 us | }
0) + 20.185 us | }
0) + 20.990 us | }
0) + 42.640 us | }
0) 0.315 us | usb_device_supports_lpm.part.47();
0) | xhci_update_device() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.895 us | }
0) @ 164027.3 us | }
0) | usb_new_device() {
0) 0.610 us | usb_disable_autosuspend();
0) | usb_get_configuration() {
0) | usb_get_descriptor() {
0) | usb_control_msg() {
0) 0.335 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.325 us | usb_get_urb.part.12();
0) 0.890 us | }
0) | xhci_map_urb_for_dma() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.635 us | usb_hcd_map_urb_for_dma();
0) 1.785 us | }
0) | xhci_urb_enqueue() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.285 us | usb_hcd_is_primary_hcd();
0) 0.850 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.295 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.295 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.390 us | }
0) 0.285 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.300 us | xhci_virt_ep_to_ring();
0) 1.405 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 0.280 us | xhci_td_remainder();
0) 1.220 us | xhci_ring_ep_doorbell();
0) 9.445 us | }
0) + 12.485 us | }
0) + 16.250 us | }
0) + 16.810 us | }
0) 0.345 us | usb_free_urb();
0) + 18.860 us | }
0) + 20.100 us | }
0) + 20.885 us | }
0) | usb_get_descriptor() {
0) | usb_control_msg() {
0) 0.330 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.310 us | usb_get_urb.part.12();
0) 1.000 us | }
0) | xhci_map_urb_for_dma() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.640 us | usb_hcd_map_urb_for_dma();
0) 1.785 us | }
0) | xhci_urb_enqueue() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.850 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.315 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.400 us | }
0) 0.295 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.295 us | xhci_get_virt_ep();
0) 0.295 us | xhci_virt_ep_to_ring();
0) 1.425 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 0.290 us | xhci_td_remainder();
0) 1.215 us | xhci_ring_ep_doorbell();
0) 9.665 us | }
0) + 12.000 us | }
0) + 15.905 us | }
0) + 16.480 us | }
0) 0.340 us | usb_free_urb();
0) + 18.530 us | }
0) + 19.795 us | }
0) + 20.615 us | }
0) * 36425.95 us | }
0) | usb_cache_string() {
0) | usb_string() {
0) | usb_string_sub() {
0) | usb_get_string() {
0) | usb_control_msg() {
0) 0.335 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.310 us | usb_get_urb.part.12();
0) 0.875 us | }
0) | xhci_map_urb_for_dma() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.720 us | usb_hcd_map_urb_for_dma();
0) 1.870 us | }
0) | xhci_urb_enqueue() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.865 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.310 us | xhci_get_virt_ep();
0) 0.295 us | xhci_virt_ep_to_ring();
0) 1.415 us | }
0) 0.285 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 2.095 us | }
0) 0.345 us | usb_hcd_link_urb_to_ep();
0) 0.290 us | xhci_td_remainder();
0) 1.235 us | xhci_ring_ep_doorbell();
0) + 10.405 us | }
0) + 12.780 us | }
0) + 16.665 us | }
0) + 17.270 us | }
0) 0.375 us | usb_free_urb();
0) + 19.705 us | }
0) + 21.055 us | }
0) + 21.845 us | }
0) + 22.505 us | }
0) | usb_string_sub() {
0) | usb_get_string() {
0) | usb_control_msg() {
0) 0.355 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.465 us | usb_get_urb.part.12();
0) 1.025 us | }
0) | xhci_map_urb_for_dma() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.630 us | usb_hcd_map_urb_for_dma();
0) 1.915 us | }
0) | xhci_urb_enqueue() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.855 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.295 us | xhci_virt_ep_to_ring();
0) 1.425 us | }
0) 0.285 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.305 us | xhci_get_virt_ep();
0) 0.295 us | xhci_virt_ep_to_ring();
0) 1.405 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 0.300 us | xhci_td_remainder();
0) 1.230 us | xhci_ring_ep_doorbell();
0) 9.535 us | }
0) + 11.900 us | }
0) + 16.105 us | }
0) + 16.855 us | }
0) 0.395 us | usb_free_urb();
0) + 19.190 us | }
0) + 20.490 us | }
0) + 21.250 us | }
0) + 21.855 us | }
0) # 5009.665 us | }
0) # 5010.560 us | }
0) | usb_cache_string() {
0) | usb_string() {
0) | usb_string_sub() {
0) | usb_get_string() {
0) | usb_control_msg() {
0) 0.335 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.315 us | usb_get_urb.part.12();
0) 0.885 us | }
0) | xhci_map_urb_for_dma() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.680 us | usb_hcd_map_urb_for_dma();
0) 1.820 us | }
0) | xhci_urb_enqueue() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.855 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.280 us | xhci_virt_ep_to_ring();
0) 1.430 us | }
0) 0.300 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.300 us | xhci_get_virt_ep();
0) 0.285 us | xhci_virt_ep_to_ring();
0) 1.400 us | }
0) 0.310 us | usb_hcd_link_urb_to_ep();
0) 0.295 us | xhci_td_remainder();
0) 1.230 us | xhci_ring_ep_doorbell();
0) + 10.300 us | }
0) + 12.630 us | }
0) + 16.665 us | }
0) + 17.255 us | }
0) 0.365 us | usb_free_urb();
0) + 19.730 us | }
0) + 21.125 us | }
0) + 21.915 us | }
0) + 22.530 us | }
0) + 23.240 us | }
0) + 23.945 us | }
0) | usb_cache_string() {
0) | usb_string() {
0) | usb_string_sub() {
0) | usb_get_string() {
0) | usb_control_msg() {
0) 0.330 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.310 us | usb_get_urb.part.12();
0) 0.875 us | }
0) | xhci_map_urb_for_dma() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.680 us | usb_hcd_map_urb_for_dma();
0) 1.820 us | }
0) | xhci_urb_enqueue() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.860 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.290 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.310 us | xhci_get_virt_ep();
0) 0.290 us | xhci_virt_ep_to_ring();
0) 1.425 us | }
0) 0.295 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.305 us | xhci_get_virt_ep();
0) 0.280 us | xhci_virt_ep_to_ring();
0) 1.405 us | }
0) 0.305 us | usb_hcd_link_urb_to_ep();
0) 0.295 us | xhci_td_remainder();
0) 1.220 us | xhci_ring_ep_doorbell();
0) 9.490 us | }
0) + 11.805 us | }
0) + 15.615 us | }
0) + 16.195 us | }
0) 0.375 us | usb_free_urb();
0) + 18.380 us | }
0) + 19.635 us | }
0) + 20.430 us | }
0) + 21.020 us | }
0) + 21.750 us | }
0) + 22.485 us | }
0) | usb_detect_interface_quirks() {
0) | usb_detect_static_quirks() {
0) 0.300 us | usb_match_device();
0) 0.890 us | }
0) 1.515 us | }
0) 1.145 us | usb_devnode();
0) | usb_bus_notify() {
0) 4.780 us | usb_create_sysfs_dev_files();
0) 6.410 us | }
0) 0.705 us | usb_devnode();
0) 1.010 us | usb_uevent();
0) 0.525 us | usb_dev_uevent();
0) 0.310 us | usb_device_match();
0) 0.305 us | usb_device_match();
0) | usb_device_match() {
0) | usb_driver_applicable() {
0) 1.545 us | usb_generic_driver_match();
0) 2.350 us | }
0) 3.115 us | }
0) 0.325 us | usb_bus_notify();
0) | usb_probe_device() {
0) | usb_generic_driver_probe() {
0) | usb_choose_configuration() {
0) 0.400 us | usb_device_is_owned();
0) # 6179.885 us | }
0) | usb_set_configuration() {
0) 0.365 us | usb_autoresume_device();
0) | usb_hcd_alloc_bandwidth() {
0) 0.320 us | usb_find_alt_setting();
0) | xhci_add_endpoint() {
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.890 us | }
0) 0.310 us | usb_hcd_is_primary_hcd();
0) | xhci_get_endpoint_flag() {
0) 0.300 us | xhci_get_endpoint_index.part.25();
0) 0.930 us | }
0) 0.320 us | xhci_get_input_control_ctx();
0) 0.305 us | xhci_get_endpoint_index.part.25();
0) | xhci_endpoint_init() {
0) | xhci_get_endpoint_index() {
0) 0.310 us | xhci_get_endpoint_index.part.25();
0) 0.895 us | }
0) | xhci_ring_alloc() {
0) | xhci_alloc_segments_for_ring() {
0) 1.515 us | xhci_segment_alloc();
0) 1.495 us | xhci_segment_alloc();
0) 0.660 us | xhci_link_segments.part.16();
0) 0.660 us | xhci_link_segments.part.16();
0) 6.115 us | }
0) 6.995 us | }
0) 9.120 us | }
0) 0.350 us | xhci_get_ep_ctx();
0) * 10100.61 us | }
0) | xhci_add_endpoint() {
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.870 us | }
0) 0.440 us | usb_hcd_is_primary_hcd();
0) | xhci_get_endpoint_flag() {
0) 0.295 us | xhci_get_endpoint_index.part.25();
0) 0.875 us | }
0) 0.295 us | xhci_get_input_control_ctx();
0) 0.300 us | xhci_get_endpoint_index.part.25();
0) | xhci_endpoint_init() {
0) | xhci_get_endpoint_index() {
0) 0.290 us | xhci_get_endpoint_index.part.25();
0) 0.865 us | }
0) | xhci_ring_alloc() {
0) | xhci_alloc_segments_for_ring() {
0) 1.090 us | xhci_segment_alloc();
0) 1.115 us | xhci_segment_alloc();
0) 0.665 us | xhci_link_segments.part.16();
0) 0.665 us | xhci_link_segments.part.16();
0) 5.455 us | }
0) 6.250 us | }
0) 8.090 us | }
0) 0.355 us | xhci_get_ep_ctx();
0) * 10098.76 us | }
0) | xhci_check_bandwidth() {
0) | xhci_check_args() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 1.335 us | }
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.440 us | xhci_alloc_command();
0) 0.300 us | xhci_get_input_control_ctx();
0) 0.370 us | xhci_get_slot_ctx();
0) | xhci_configure_endpoint() {
0) 0.480 us | xhci_get_input_control_ctx();
0) 0.290 us | xhci_get_slot_ctx();
0) | xhci_queue_configure_endpoint() {
0) 0.680 us | xhci_mod_cmd_timer();
0) 2.570 us | }
0) | xhci_ring_cmd_db() {
0) # 5569.120 us | xhci_ring_cmd_db.part.52();
0) # 5569.690 us | }
0) * 13234.08 us | }
0) | xhci_zero_in_ctx.isra.52() {
0) 0.305 us | xhci_get_input_control_ctx();
0) 0.360 us | xhci_get_slot_ctx();
0) 0.480 us | xhci_get_ep_ctx();
0) 0.365 us | xhci_get_ep_ctx();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.360 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.360 us | xhci_get_ep_ctx();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.360 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.340 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.365 us | xhci_get_ep_ctx();
0) 0.380 us | xhci_get_ep_ctx();
0) 0.360 us | xhci_get_ep_ctx();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.350 us | xhci_get_ep_ctx();
0) 0.340 us | xhci_get_ep_ctx();
0) + 22.305 us | }
0) | xhci_debugfs_create_endpoint() {
0) + 10.520 us | xhci_debugfs_create_ring_dir.isra.15();
0) + 11.440 us | }
0) | xhci_debugfs_create_endpoint() {
0) 7.035 us | xhci_debugfs_create_ring_dir.isra.15();
0) 7.925 us | }
0) * 22328.79 us | }
0) * 42530.67 us | }
0) 0.320 us | usb_altnum_to_altsetting();
0) | usb_enable_interface() {
0) | usb_enable_endpoint() {
0) | usb_hcd_reset_endpoint() {
0) | xhci_endpoint_reset() {
0) 0.335 us | usb_hcd_is_primary_hcd();
0) 0.305 us | xhci_get_endpoint_index.part.25();
0) | xhci_get_endpoint_flag() {
0) 0.300 us | xhci_get_endpoint_index.part.25();
0) 0.870 us | }
0) 0.395 us | xhci_alloc_command();
0) | xhci_alloc_command_with_ctx() {
0) 0.510 us | xhci_alloc_command();
0) 1.035 us | xhci_alloc_container_ctx();
0) 2.560 us | }
0) | xhci_queue_stop_endpoint() {
0) 0.490 us | xhci_mod_cmd_timer();
0) 1.845 us | }
0) | xhci_ring_cmd_db() {
0) # 5570.580 us | xhci_ring_cmd_db.part.52();
0) # 5571.160 us | }
0) 0.350 us | xhci_get_input_control_ctx();
0) 0.545 us | xhci_slot_copy();
0) 0.540 us | xhci_endpoint_copy();
0) | xhci_queue_configure_endpoint() {
0) 0.435 us | xhci_mod_cmd_timer();
0) 1.790 us | }
0) | xhci_ring_cmd_db() {
0) # 5569.710 us | xhci_ring_cmd_db.part.52();
0) # 5570.275 us | }
0) | xhci_free_command() {
0) 0.415 us | xhci_free_container_ctx.part.36();
0) 1.300 us | }
0) 0.360 us | xhci_free_command();
0) * 11163.98 us | }
0) * 11164.59 us | }
0) * 11165.19 us | }
0) | usb_enable_endpoint() {
0) | usb_hcd_reset_endpoint() {
0) | xhci_endpoint_reset() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 0.295 us | xhci_get_endpoint_index.part.25();
0) | xhci_get_endpoint_flag() {
0) 0.295 us | xhci_get_endpoint_index.part.25();
0) 0.870 us | }
0) 0.445 us | xhci_alloc_command();
0) | xhci_alloc_command_with_ctx() {
0) 0.375 us | xhci_alloc_command();
0) 0.820 us | xhci_alloc_container_ctx();
0) 2.375 us | }
0) | xhci_queue_stop_endpoint() {
0) 0.445 us | xhci_mod_cmd_timer();
0) 1.925 us | }
0) | xhci_ring_cmd_db() {
0) # 5569.855 us | xhci_ring_cmd_db.part.52();
0) # 5570.440 us | }
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.285 us | usb_hcd_is_primary_hcd();
0) 0.310 us | xhci_get_virt_ep();
0) 0.295 us | xhci_dma_to_transfer_ring();
0) 0.300 us | xhci_get_ep_ctx();
0) 1.230 us | xhci_update_erst_dequeue.isra.49();
0) # 8267.135 us | }
0) # 8267.755 us | }
0) 0.320 us | xhci_get_input_control_ctx();
0) 0.545 us | xhci_slot_copy();
0) 0.535 us | xhci_endpoint_copy();
0) | xhci_queue_configure_endpoint() {
0) 0.465 us | xhci_mod_cmd_timer();
0) 1.790 us | }
0) | xhci_ring_cmd_db() {
0) # 5569.955 us | xhci_ring_cmd_db.part.52();
0) # 5570.570 us | }
0) | xhci_free_command() {
0) 0.390 us | xhci_free_container_ctx.part.36();
0) 1.060 us | }
0) 0.360 us | xhci_free_command();
0) * 19435.82 us | }
0) * 19437.30 us | }
0) * 19437.90 us | }
0) * 30604.01 us | }
0) 0.300 us | usb_of_has_combined_node();
0) 0.705 us | usb_of_get_interface_node();
0) 0.330 us | usb_get_dev();
0) | usb_control_msg_send() {
0) | usb_control_msg() {
0) 0.360 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) | usb_hcd_submit_urb() {
0) | usb_get_urb() {
0) 0.315 us | usb_get_urb.part.12();
0) 0.925 us | }
0) | xhci_map_urb_for_dma() {
0) 0.295 us | usb_hcd_is_primary_hcd();
0) 1.080 us | }
0) | xhci_urb_enqueue() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | xhci_check_args() {
0) 0.440 us | usb_hcd_is_primary_hcd();
0) 1.015 us | }
0) | xhci_queue_ctrl_tx() {
0) 0.300 us | xhci_get_endpoint_index();
0) | xhci_triad_to_transfer_ring() {
0) 0.295 us | xhci_get_virt_ep();
0) 0.295 us | xhci_virt_ep_to_ring();
0) 1.410 us | }
0) 0.290 us | xhci_get_ep_ctx();
0) | xhci_triad_to_transfer_ring() {
0) 0.295 us | xhci_get_virt_ep();
0) 0.295 us | xhci_virt_ep_to_ring();
0) 1.420 us | }
0) 0.315 us | usb_hcd_link_urb_to_ep();
0) 1.250 us | xhci_ring_ep_doorbell();
0) 8.520 us | }
0) + 11.085 us | }
0) + 14.585 us | }
0) + 15.180 us | }
0) 0.560 us | usb_free_urb();
0) + 17.835 us | }
0) + 19.220 us | }
0) + 19.925 us | }
0) 1.695 us | usb_set_device_state();
0) 0.310 us | usb_cache_string();
0) | usb_unlocked_enable_lpm() {
0) 0.320 us | usb_enable_lpm();
0) 1.070 us | }
0) 0.425 us | usb_enable_ltm();
0) | usb_bus_notify() {
0) | usb_create_sysfs_intf_files() {
0) 0.325 us | usb_cache_string();
0) 0.920 us | }
0) 1.630 us | }
0) 0.955 us | usb_uevent();
0) 1.495 us | usb_if_uevent();
0) | usb_device_match() {
0) 0.335 us | usb_match_dynamic_id();
0) 0.960 us | }
0) | usb_device_match() {
0) | usb_match_id.part.16() {
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.915 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.895 us | }
0) | usb_match_one_id() {
0) 0.315 us | usb_match_device();
0) 0.320 us | usb_match_one_id_intf();
0) 1.490 us | }
0) + 13.540 us | }
0) 0.330 us | usb_match_dynamic_id();
0) + 14.745 us | }
0) 0.315 us | usb_device_match();
0) | usb_device_match() {
0) | usb_match_id.part.16() {
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.890 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.850 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 1.535 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.850 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.320 us | usb_match_device();
0) 0.895 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.320 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.850 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.320 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.850 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 1.400 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 1.060 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.870 us | usb_match_device();
0) 1.425 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.910 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.845 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.850 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.325 us | usb_match_device();
0) 0.900 us | }
0) | usb_match_one_id() {
0) 0.320 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.320 us | usb_match_device();
0) 0.895 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 1.620 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.290 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.895 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.850 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.850 us | usb_match_device();
0) 1.415 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.885 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.310 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.870 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.855 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.295 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.865 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.860 us | }
0) | usb_match_one_id() {
0) 0.300 us | usb_match_device();
0) 0.880 us | }
0) | usb_match_one_id() {
0) 0.305 us | usb_match_device();
0) 0.875 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.565 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.325 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 2.020 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.550 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.390 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.565 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.565 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.540 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.430 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.535 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.515 us | }
0) | usb_match_one_id() {
0) 0.490 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.540 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.420 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.565 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.140 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 2.255 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.560 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.575 us | }
0) | usb_match_one_id() {
0) 0.530 us | usb_match_device();
0) 1.560 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.365 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.420 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.535 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.560 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.560 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.550 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.390 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.560 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 1.180 us | usb_match_device();
0) 2.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.550 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.425 us | }
0) | usb_match_one_id() {
0) 0.535 us | usb_match_device();
0) 0.540 us | usb_match_one_id_intf();
0) 2.590 us | }
0) | usb_match_one_id() {
0) 0.530 us | usb_match_device();
0) 0.500 us | usb_match_one_id_intf();
0) 2.385 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 0.515 us | usb_match_one_id_intf();
0) 2.470 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 0.495 us | usb_match_one_id_intf();
0) 2.375 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.515 us | usb_match_one_id_intf();
0) 2.480 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 0.405 us | usb_match_one_id_intf();
0) 2.185 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 0.415 us | usb_match_one_id_intf();
0) 2.365 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.410 us | usb_match_one_id_intf();
0) 2.375 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 0.515 us | usb_match_one_id_intf();
0) 2.480 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 0.525 us | usb_match_one_id_intf();
0) 2.585 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 0.510 us | usb_match_one_id_intf();
0) 2.400 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 0.410 us | usb_match_one_id_intf();
0) 2.495 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.510 us | usb_match_one_id_intf();
0) 2.395 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 0.395 us | usb_match_one_id_intf();
0) 2.285 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 0.525 us | usb_match_one_id_intf();
0) 3.055 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 0.505 us | usb_match_one_id_intf();
0) 2.180 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 0.515 us | usb_match_one_id_intf();
0) 2.095 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.535 us | usb_match_one_id_intf();
0) 2.485 us | }
0) ! 484.495 us | }
0) ! 485.420 us | }
0) 0.430 us | usb_bus_notify();
0) | usb_probe_interface() {
0) 0.570 us | usb_device_is_owned();
0) 0.600 us | usb_match_dynamic_id();
0) | usb_match_id.part.16() {
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.430 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.365 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.550 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.990 us | usb_match_device();
0) 2.020 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.365 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.365 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.335 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.740 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.260 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.370 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.320 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.155 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.135 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.265 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.850 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.140 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.470 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.490 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.985 us | usb_match_device();
0) 1.935 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.370 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.150 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.725 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.365 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.535 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.480 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.140 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.425 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.320 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.235 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.430 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.335 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.230 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.540 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.930 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.520 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.550 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.150 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.555 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.140 us | }
0) | usb_match_one_id() {
0) 0.985 us | usb_match_device();
0) 1.720 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.260 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.335 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.460 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.140 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.245 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.720 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.530 us | usb_match_device();
0) 1.545 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.390 us | usb_match_device();
0) 1.225 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.465 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 1.435 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.255 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.145 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.240 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.440 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.340 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 1.540 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.455 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.150 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.445 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.495 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 1.250 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.450 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.345 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 1.850 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 1.140 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.350 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.360 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 1.355 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 0.410 us | usb_match_one_id_intf();
0) 2.295 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 0.505 us | usb_match_one_id_intf();
0) 2.280 us | }
0) | usb_match_one_id() {
0) 0.525 us | usb_match_device();
0) 0.510 us | usb_match_one_id_intf();
0) 2.295 us | }
0) | usb_match_one_id() {
0) 0.530 us | usb_match_device();
0) 0.515 us | usb_match_one_id_intf();
0) 2.595 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.510 us | usb_match_one_id_intf();
0) 2.595 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 0.400 us | usb_match_one_id_intf();
0) 1.980 us | }
0) | usb_match_one_id() {
0) 0.410 us | usb_match_device();
0) 0.405 us | usb_match_one_id_intf();
0) 2.075 us | }
0) | usb_match_one_id() {
0) 0.500 us | usb_match_device();
0) 0.505 us | usb_match_one_id_intf();
0) 2.185 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 0.510 us | usb_match_one_id_intf();
0) 2.080 us | }
0) | usb_match_one_id() {
0) 0.515 us | usb_match_device();
0) 0.510 us | usb_match_one_id_intf();
0) 2.295 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 0.405 us | usb_match_one_id_intf();
0) 1.990 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 0.515 us | usb_match_one_id_intf();
0) 2.290 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.405 us | usb_match_one_id_intf();
0) 2.185 us | }
0) | usb_match_one_id() {
0) 0.405 us | usb_match_device();
0) 0.525 us | usb_match_one_id_intf();
0) 2.280 us | }
0) | usb_match_one_id() {
0) 0.395 us | usb_match_device();
0) 0.405 us | usb_match_one_id_intf();
0) 1.975 us | }
0) | usb_match_one_id() {
0) 0.510 us | usb_match_device();
0) 0.505 us | usb_match_one_id_intf();
0) 2.395 us | }
0) | usb_match_one_id() {
0) 0.505 us | usb_match_device();
0) 0.415 us | usb_match_one_id_intf();
0) 2.205 us | }
0) | usb_match_one_id() {
0) 0.400 us | usb_match_device();
0) 0.520 us | usb_match_one_id_intf();
0) 2.380 us | }
0) ! 593.625 us | }
0) 0.650 us | usb_autoresume_device();
0) 0.490 us | usb_usual_ignore_device();
0) | usb_stor_probe1() {
0) | scsi_host_alloc() {
0) 0.715 us | scsi_enable_async_suspend();
0) + 44.945 us | }
0) | usb_alloc_coherent() {
0) 1.245 us | hcd_buffer_alloc();
0) 1.930 us | }
0) 0.515 us | usb_stor_adjust_quirks();
0) # 6836.555 us | }
0) | usb_stor_probe2() {
0) 0.815 us | usb_find_common_endpoints();
0) 0.400 us | usb_find_common_endpoints();
0) 0.340 us | usb_alloc_urb();
0) 0.655 us | usb_autopm_get_interface_no_resume();
0) | scsi_add_host_with_dma() {
0) 0.535 us | scsi_init_sense_cache();
0) | scsi_mq_setup_tags() {
0) 1.935 us | scsi_map_queues();
0) 1.310 us | scsi_mq_init_request();
0) + 12.885 us | }
0) 0.350 us | scsi_bus_uevent();
0) 0.320 us | scsi_bus_match();
0) 1.500 us | scsi_sysfs_add_host();
0) | scsi_autopm_put_host() {
0) | scsi_runtime_idle() {
0) 0.370 us | scsi_is_sdev_device();
0) # 4706.805 us | }
0) | scsi_runtime_suspend() {
0) 0.320 us | scsi_is_sdev_device();
0) # 4966.270 us | }
0) # 9676.240 us | }
0) * 14614.52 us | }
0) * 14624.29 us | }
0) * 34162.08 us | }
0) 0.350 us | usb_bus_notify();
0) 1.165 us | usb_uevent();
0) 1.400 us | usb_if_uevent();
0) + 12.805 us | usb_create_ep_devs();
0) 8.915 us | usb_create_ep_devs();
0) 0.430 us | usb_autosuspend_device();
0) @ 114260.9 us | }
0) 0.605 us | usb_notify_add_device();
0) @ 120443.3 us | }
0) @ 124803.9 us | }
0) 0.315 us | usb_bus_notify();
0) 1.015 us | usb_devnode();
0) 0.710 us | usb_uevent();
0) 0.490 us | usb_dev_uevent();
0) 8.835 us | usb_create_ep_devs();
0) @ 171887.1 us | }
0) 0.730 us | usb_autopm_put_interface_no_suspend();
0) 0.905 us | usb_autopm_put_interface();
0) @ 397588.7 us | }
3) | sd_probe() {
3) 0.575 us | scsi_autopm_get_device();
3) 0.535 us | sd_major();
3) | sd_revalidate_disk() {
3) | scsi_execute_cmd() {
3) 2.175 us | scsi_alloc_request();
3) 1.310 us | scsi_mq_get_budget();
3) 0.300 us | scsi_mq_set_rq_budget_token();
3) | scsi_queue_rq() {
3) 0.325 us | scsi_init_command();
3) 4.050 us | }
7) 3.820 us | scsi_normalize_sense();
7) + 24.055 us | } /* scsi_execute_cmd */
7) | scsi_execute_cmd() {
7) 5.360 us | scsi_alloc_request();
7) 1.545 us | scsi_mq_get_budget();
7) 0.305 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.740 us | scsi_init_command();
7) 0.860 us | scsi_alloc_sgtables();
7) 4.720 us | }
7) 0.340 us | scsi_normalize_sense();
7) + 20.710 us | }
7) | scsi_execute_cmd() {
7) 0.805 us | scsi_alloc_request();
7) 0.390 us | scsi_mq_get_budget();
7) 0.295 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.320 us | scsi_init_command();
7) 0.440 us | scsi_alloc_sgtables();
7) 2.735 us | }
7) 8.280 us | }
7) 0.605 us | scsi_log_reserve_buffer();
7) | scsi_mode_sense() {
7) | scsi_execute_cmd() {
7) 0.835 us | scsi_alloc_request();
7) 0.485 us | scsi_mq_get_budget();
7) 0.335 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.335 us | scsi_init_command();
7) 0.460 us | scsi_alloc_sgtables();
7) 2.700 us | }
7) 0.385 us | scsi_normalize_sense();
7) 9.905 us | }
7) + 11.075 us | }
7) 0.405 us | scsi_log_reserve_buffer();
7) 0.425 us | scsi_log_reserve_buffer();
7) | scsi_mode_sense() {
7) | scsi_execute_cmd() {
7) 0.730 us | scsi_alloc_request();
7) 0.435 us | scsi_mq_get_budget();
7) 0.300 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.320 us | scsi_init_command();
7) 0.420 us | scsi_alloc_sgtables();
7) 2.845 us | }
7) 0.345 us | scsi_normalize_sense();
7) 9.050 us | }
7) 9.725 us | }
7) 0.355 us | scsi_log_reserve_buffer();
7) 0.375 us | scsi_report_opcode();
7) 0.345 us | scsi_report_opcode();
7) 0.310 us | scsi_report_opcode();
7) 0.645 us | sd_dif_config_host();
7) 0.515 us | sd_set_flush_flag();
7) 0.450 us | sd_config_write_same();
7) * 29270.32 us | } /* sd_revalidate_disk */
7) 1.170 us | scsi_mq_init_request();
7) 0.350 us | scsi_mq_init_request();
7) | sd_open() {
7) 0.575 us | scsi_device_get();
7) 0.505 us | scsi_block_when_processing_errors();
7) | sd_revalidate_disk() {
7) | scsi_execute_cmd() {
7) 1.285 us | scsi_alloc_request();
7) 0.410 us | scsi_mq_get_budget();
7) 0.330 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 1.345 us | scsi_init_command();
7) 3.475 us | }
7) 0.420 us | scsi_normalize_sense();
7) + 12.145 us | }
7) | scsi_execute_cmd() {
7) 0.565 us | scsi_alloc_request();
7) 0.405 us | scsi_mq_get_budget();
7) 0.310 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.320 us | scsi_init_command();
7) 0.555 us | scsi_alloc_sgtables();
7) 2.810 us | }
7) 0.415 us | scsi_normalize_sense();
7) 9.985 us | }
7) | scsi_execute_cmd() {
7) 0.560 us | scsi_alloc_request();
7) 0.400 us | scsi_mq_get_budget();
7) 0.290 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.315 us | scsi_init_command();
7) 0.370 us | scsi_alloc_sgtables();
7) 2.545 us | }
7) 7.695 us | }
7) | scsi_mode_sense() {
7) | scsi_execute_cmd() {
7) 0.525 us | scsi_alloc_request();
7) 0.405 us | scsi_mq_get_budget();
7) 0.290 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.325 us | scsi_init_command();
7) 0.385 us | scsi_alloc_sgtables();
7) 2.525 us | }
7) 0.350 us | scsi_normalize_sense();
7) 8.500 us | }
7) 9.355 us | }
7) | scsi_mode_sense() {
7) | scsi_execute_cmd() {
7) 0.530 us | scsi_alloc_request();
7) 0.440 us | scsi_mq_get_budget();
7) 0.320 us | scsi_mq_set_rq_budget_token();
7) | scsi_queue_rq() {
7) 0.315 us | scsi_init_command();
7) 0.355 us | scsi_alloc_sgtables();
7) 2.540 us | }
7) 0.360 us | scsi_normalize_sense();
7) 8.650 us | }
7) 9.280 us | }
7) 0.490 us | scsi_report_opcode();
7) 0.325 us | scsi_report_opcode();
7) 0.425 us | scsi_report_opcode();
7) 0.520 us | sd_dif_config_host();
7) 0.340 us | sd_set_flush_flag();
7) 0.345 us | sd_config_write_same();
7) + 57.640 us | }
7) + 61.760 us | }
7) | sd_release() {
7) 0.475 us | scsi_device_put();
7) 1.560 us | }
7) 0.375 us | scsi_log_reserve_buffer();
7) 0.950 us | scsi_autopm_put_device();
7) * 35083.09 us | } /* sd_probe */

usb_hcd_irqh函数调用情况

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.505 us | usb_hcd_is_primary_hcd();
0) 3.275 us | usb_hcd_resume_root_hub();
0) | usb_hcd_poll_rh_status() {
0) | xhci_hub_status_data() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) 0.320 us | usb_hcd_is_primary_hcd();
0) 2.655 us | }
0) 4.250 us | }
0) 1.225 us | xhci_update_erst_dequeue.isra.49();
0) + 16.345 us | }
0) + 20.665 us | }

0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) 0.315 us | xhci_get_virt_ep();
0) 0.300 us | xhci_dma_to_transfer_ring();
0) 0.310 us | xhci_get_ep_ctx();
0) 0.310 us | xhci_get_ep_ctx();
0) 0.310 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.370 us | xhci_unmap_td_bounce_buffer.isra.38();
0) | xhci_giveback_urb_in_irq.isra.39() {
0) 0.410 us | xhci_urb_free_priv();
0) 0.320 us | usb_hcd_unlink_urb_from_ep();
0) 0.350 us | usb_hcd_giveback_urb();
0) 2.300 us | }
0) 3.715 us | }
0) 1.200 us | xhci_update_erst_dequeue.isra.49();
0) + 15.620 us | }
0) + 16.405 us | }

0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) 0.310 us | xhci_get_virt_ep();
0) 0.295 us | xhci_dma_to_transfer_ring();
0) 0.290 us | xhci_get_ep_ctx();
0) 0.295 us | xhci_get_ep_ctx();
0) 0.295 us | xhci_get_virt_ep();
0) 0.295 us | xhci_dma_to_transfer_ring();
0) 0.300 us | xhci_get_ep_ctx();
0) 0.295 us | xhci_get_ep_ctx();
0) 0.300 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.295 us | xhci_unmap_td_bounce_buffer.isra.38();
0) | xhci_giveback_urb_in_irq.isra.39() {
0) 0.340 us | xhci_urb_free_priv();
0) 0.315 us | usb_hcd_unlink_urb_from_ep();
0) 0.335 us | usb_hcd_giveback_urb();
0) 2.090 us | }
0) 3.225 us | }
0) 1.225 us | xhci_update_erst_dequeue.isra.49();
0) + 16.115 us | }
0) + 16.700 us | }

读写数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cd /sys/kernel/debug/tracing
echo nop > current_tracer
echo > trace
echo > set_ftrace_filter
echo > set_graph_function
echo > set_ftrace_notrace
echo function_graph > current_tracer

cat <<EOF > set_ftrace_filter
xhci_*
usb_*
*dwc3*
hcd_*
scsi_*
sd_*
submit_bio
blk_mq_submit_bio
EOF
cat <<EOF > set_ftrace_notrace
_dev_info
mutex*
_raw_spin*
__pm_runtime*
xhci_dbg_trace
EOF

echo 4 > max_graph_depth
echo 1 > tracing_on && sleep 1 && dd if=/dev/urandom of=/dev/sda bs=4K count=4 && sleep 1 && echo 0 > tracing_on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
0) | sd_open() {
0) 1.215 us | scsi_device_get();
0) 0.925 us | scsi_block_when_processing_errors();
0) 6.820 us | }
0) | submit_bio() {
0) 8.205 us | blk_mq_submit_bio();
0) + 10.880 us | }
0) | submit_bio() {
0) 2.520 us | blk_mq_submit_bio();
0) 3.300 us | }
0) | submit_bio() {
0) 0.545 us | blk_mq_submit_bio();
0) 1.240 us | }
0) | submit_bio() {
0) 0.500 us | blk_mq_submit_bio();
0) 1.215 us | }
0) 0.935 us | scsi_mq_get_budget();
0) 0.310 us | scsi_mq_set_rq_budget_token();
0) | scsi_queue_rq() {
0) 0.760 us | scsi_init_command();
0) | sd_init_command() {
0) 2.815 us | scsi_alloc_sgtables();
0) 4.420 us | }
0) + 11.705 us | }
1) | usb_stor_transparent_scsi_command() {
1) | usb_stor_invoke_transport() {
1) | usb_stor_Bulk_transport() {
1) | usb_stor_bulk_transfer_buf() {
1) + 16.820 us | usb_stor_msg_common();
------------------------------------------
0) dd-388 => <idle>-0
------------------------------------------

0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.515 us | usb_hcd_is_primary_hcd();
0) 0.360 us | xhci_get_virt_ep();
0) 0.465 us | xhci_dma_to_transfer_ring();
0) 0.310 us | xhci_get_ep_ctx();
0) 0.305 us | xhci_get_slot_ctx();
0) 0.315 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.315 us | xhci_unmap_td_bounce_buffer.isra.38();
0) | xhci_giveback_urb_in_irq.isra.39() {
0) 0.615 us | xhci_urb_free_priv();
0) 0.380 us | usb_hcd_unlink_urb_from_ep();
0) 0.730 us | usb_hcd_giveback_urb();
0) 3.215 us | }
0) 4.675 us | }
0) 1.235 us | xhci_update_erst_dequeue.isra.49();
0) + 18.110 us | }
0) + 19.190 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.315 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.325 us | usb_hcd_unmap_urb_setup_for_dma();
0) 1.130 us | }
0) 2.310 us | }
0) 0.350 us | usb_anchor_suspend_wakeups();
0) 0.325 us | usb_unanchor_urb();
0) 1.190 us | usb_stor_blocking_completion();
0) 0.320 us | usb_anchor_resume_wakeups();
0) 0.350 us | usb_free_urb();
0) 7.755 us | }
1) + 18.030 us | }
1) | usb_stor_bulk_srb() {
1) + 15.695 us | usb_stor_bulk_transfer_sglist();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.305 us | usb_hcd_is_primary_hcd();
0) 0.330 us | xhci_get_virt_ep();
0) 0.310 us | xhci_dma_to_transfer_ring();
0) 0.345 us | xhci_get_ep_ctx();
0) 0.310 us | xhci_get_slot_ctx();
0) 0.320 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.305 us | xhci_unmap_td_bounce_buffer.isra.38();
0) | xhci_giveback_urb_in_irq.isra.39() {
0) 0.390 us | xhci_urb_free_priv();
0) 0.375 us | usb_hcd_unlink_urb_from_ep();
0) 0.365 us | usb_hcd_giveback_urb();
0) 2.235 us | }
0) 4.570 us | }
0) 1.200 us | xhci_update_erst_dequeue.isra.49();
0) + 14.295 us | }
0) + 14.855 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.315 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.335 us | usb_hcd_unmap_urb_setup_for_dma();
0) 1.775 us | }
0) 2.970 us | }
0) 0.310 us | usb_anchor_suspend_wakeups();
0) 0.330 us | usb_unanchor_urb();
0) 0.310 us | usb_anchor_resume_wakeups();
0) 0.320 us | usb_free_urb();
0) 6.965 us | }
1) + 16.385 us | }
1) | usb_stor_bulk_transfer_buf() {
1) 7.535 us | usb_stor_msg_common();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) 0.335 us | xhci_get_virt_ep();
0) 0.350 us | xhci_dma_to_transfer_ring();
0) 0.290 us | xhci_get_ep_ctx();
0) 0.305 us | xhci_get_slot_ctx();
0) 0.300 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.310 us | xhci_unmap_td_bounce_buffer.isra.38();
0) | xhci_giveback_urb_in_irq.isra.39() {
0) 0.390 us | xhci_urb_free_priv();
0) 0.385 us | usb_hcd_unlink_urb_from_ep();
0) 0.365 us | usb_hcd_giveback_urb();
0) 2.255 us | }
0) 3.440 us | }
0) 1.205 us | xhci_update_erst_dequeue.isra.49();
0) + 12.905 us | }
0) + 13.475 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.300 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.310 us | usb_hcd_unmap_urb_setup_for_dma();
0) 0.905 us | }
0) 2.050 us | }
0) 0.315 us | usb_anchor_suspend_wakeups();
0) 0.325 us | usb_unanchor_urb();
0) 0.900 us | usb_stor_blocking_completion();
0) 0.310 us | usb_anchor_resume_wakeups();
0) 0.320 us | usb_free_urb();
0) 6.245 us | }
1) 8.200 us | }
1) + 45.385 us | }
1) + 47.035 us | }
1) + 49.105 us | }
1) | scsi_done_direct() {
1) | scsi_done_internal() {
1) | scsi_complete() {
1) | scsi_decide_disposition() {
1) 0.590 us | scsi_handle_queue_ramp_up();
1) 1.695 us | }
1) | scsi_finish_command() {
1) 0.690 us | scsi_device_unbusy();
1) 0.385 us | sd_done();
1) + 17.585 us | scsi_io_completion();
1) + 20.340 us | }
1) + 23.320 us | }
1) + 24.155 us | }
1) + 24.980 us | }
------------------------------------------
0) <idle>-0 => dd-388
------------------------------------------

0) | sd_release() {
0) 0.400 us | scsi_device_put();
0) 1.070 us | }

移除SCSI缓存

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cd /sys/kernel/debug/tracing
echo nop > current_tracer
echo > trace
echo > set_ftrace_filter
echo > set_graph_function
echo > set_ftrace_notrace
echo function_graph > current_tracer

cat <<EOF > set_ftrace_filter
xhci_*
usb_*
*dwc3*
hcd_*
scsi_*
sd_*
submit_bio
blk_mq_submit_bio
EOF
cat <<EOF > set_ftrace_notrace
_dev_info
mutex*
_raw_spin*
__pm_runtime*
xhci_dbg_trace
EOF

echo 4 > max_graph_depth
echo 1 > tracing_on && sleep 1 && echo 1 > /sys/class/block/sda/device/delete && sleep 2 && echo 0 > tracing_on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
7) 3.915 us | scsi_device_get();
7) | scsi_remove_device() {
7) 0.375 us | scsi_device_set_state();
7) 0.605 us | scsi_device_cls_release();
7) | sd_remove() {
7) 0.395 us | scsi_autopm_get_device();
7) 2.090 us | scsi_mq_exit_request();
7) 0.740 us | scsi_mq_exit_request();
7) | sd_shutdown() {
7) 0.480 us | scsi_log_reserve_buffer();
7) + 17.455 us | sd_sync_cache();
5) | usb_stor_transparent_scsi_command() {
5) | usb_stor_invoke_transport() {
5) | usb_stor_Bulk_transport() {
5) + 17.935 us | usb_stor_bulk_transfer_buf();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.490 us | usb_hcd_is_primary_hcd();
0) 0.470 us | xhci_get_virt_ep();
0) 0.635 us | xhci_dma_to_transfer_ring();
0) 0.510 us | xhci_get_ep_ctx();
0) 0.370 us | xhci_get_slot_ctx();
0) 0.370 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.370 us | xhci_unmap_td_bounce_buffer.isra.38();
0) 2.180 us | xhci_giveback_urb_in_irq.isra.39();
0) 4.140 us | }
0) 1.285 us | xhci_update_erst_dequeue.isra.49();
0) + 18.805 us | }
0) + 22.445 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.380 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.320 us | usb_hcd_unmap_urb_setup_for_dma();
0) 1.270 us | }
0) 2.760 us | }
0) 0.320 us | usb_anchor_suspend_wakeups();
0) 0.335 us | usb_unanchor_urb();
0) 2.190 us | usb_stor_blocking_completion();
0) 0.515 us | usb_anchor_resume_wakeups();
0) 0.360 us | usb_free_urb();
0) 9.945 us | }
5) 8.350 us | usb_stor_bulk_transfer_buf();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) 0.325 us | xhci_get_virt_ep();
0) 0.450 us | xhci_dma_to_transfer_ring();
0) 0.310 us | xhci_get_ep_ctx();
0) 0.375 us | xhci_get_slot_ctx();
0) 0.365 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.310 us | xhci_unmap_td_bounce_buffer.isra.38();
0) 1.230 us | xhci_giveback_urb_in_irq.isra.39();
0) 2.510 us | }
0) 1.205 us | xhci_update_erst_dequeue.isra.49();
0) + 12.520 us | }
0) + 13.125 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.310 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.325 us | usb_hcd_unmap_urb_setup_for_dma();
0) 1.015 us | }
0) 2.175 us | }
0) 0.460 us | usb_anchor_suspend_wakeups();
0) 0.340 us | usb_unanchor_urb();
0) 1.450 us | usb_stor_blocking_completion();
0) 0.315 us | usb_anchor_resume_wakeups();
0) 0.335 us | usb_free_urb();
0) 7.260 us | }
5) + 28.960 us | }
5) + 30.405 us | }
5) + 33.860 us | }
5) | scsi_done_direct() {
5) | scsi_done_internal() {
5) | scsi_complete() {
5) 1.255 us | scsi_decide_disposition();
5) 5.880 us | scsi_finish_command();
5) 8.215 us | }
5) 9.020 us | }
5) 9.825 us | }
7) # 5867.955 us | }
7) | scsi_disk_free_disk() {
7) 1.295 us | scsi_disk_release();
7) 2.825 us | }
7) # 6257.110 us | }
7) 0.840 us | scsi_bus_uevent();
7) 0.525 us | scsi_bus_uevent();
7) 0.360 us | scsi_device_set_state();
7) 0.570 us | scsi_mq_exit_request();
7) | scsi_target_reap() {
7) 0.355 us | scsi_bus_uevent();
7) | scsi_target_destroy() {
7) 0.325 us | scsi_is_host_device();
7) 1.350 us | }
7) + 20.695 us | }
7) # 6424.300 us | }
7) | scsi_device_put() {
7) | scsi_device_dev_release() {
7) 0.565 us | scsi_target_dev_release();
7) 4.260 us | }
7) 5.275 us | }
------------------------------------------
7) sh-87 => kworker-483
------------------------------------------

7) | scsi_runtime_idle() {
7) 0.480 us | scsi_is_sdev_device();
7) 2.115 us | }
7) | scsi_runtime_suspend() {
7) 0.455 us | scsi_is_sdev_device();
7) 1.480 us | }

安全弹出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cd /sys/kernel/debug/tracing
echo nop > current_tracer
echo > trace
echo > set_ftrace_filter
echo > set_graph_function
echo > set_ftrace_notrace
echo function_graph > current_tracer

cat <<EOF > set_ftrace_filter
xhci_*
usb_*
*dwc3*
hcd_*
scsi_*
sd_*
submit_bio
blk_mq_submit_bio
EOF
cat <<EOF > set_ftrace_notrace
_dev_info
mutex*
_raw_spin*
__pm_runtime*
xhci_dbg_trace
EOF

echo 4 > max_graph_depth
echo 1 > tracing_on && sleep 1 && echo 1 > /sys/bus/usb/devices/2-1/remove && sleep 2 && echo 0 > tracing_on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
7) | usb_set_configuration() {
7) 1.125 us | usb_autoresume_device();
7) | usb_disable_device() {
7) + 32.590 us | usb_remove_ep_devs();
7) + 11.585 us | usb_remove_ep_devs();
7) | usb_bus_notify() {
7) 1.725 us | usb_remove_sysfs_intf_files();
7) 2.560 us | }
7) 0.385 us | usb_bus_notify();
7) | usb_unbind_interface() {
7) 0.360 us | usb_autoresume_device();
7) ! 117.190 us | usb_stor_disconnect();
7) 0.850 us | usb_enable_interface();
7) ! 122.040 us | }
7) 0.550 us | usb_bus_notify();
7) 1.740 us | usb_uevent();
7) 2.060 us | usb_if_uevent();
7) 0.395 us | usb_bus_notify();
7) 0.915 us | usb_uevent();
7) 1.405 us | usb_if_uevent();
7) | usb_release_interface() {
7) 0.355 us | usb_put_dev();
7) 1.500 us | }
7) 0.335 us | usb_disable_usb2_hardware_lpm();
7) | usb_unlocked_disable_lpm() {
7) 0.345 us | usb_disable_lpm();
7) 1.215 us | }
7) 1.180 us | usb_disable_ltm();
7) 5.390 us | usb_set_device_state();
7) | usb_disable_device_endpoints() {
7) 0.365 us | usb_disable_endpoint();
7) 0.745 us | usb_disable_endpoint();
7) 0.510 us | usb_disable_endpoint();
7) 0.430 us | usb_disable_endpoint();
7) 0.345 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.335 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.330 us | usb_disable_endpoint();
7) 0.360 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) + 63.110 us | usb_hcd_alloc_bandwidth();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.540 us | usb_hcd_is_primary_hcd();
0) 1.275 us | xhci_update_erst_dequeue.isra.49();
0) + 10.790 us | }
0) + 13.745 us | }
7) 0.345 us | usb_disable_endpoint();
7) 1.590 us | usb_disable_endpoint();
7) 1.070 us | usb_disable_endpoint();
7) 0.330 us | usb_disable_endpoint();
7) 0.335 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.325 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.320 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) 0.315 us | usb_disable_endpoint();
7) ! 104.795 us | }
7) ! 334.605 us | }
7) | usb_hcd_alloc_bandwidth() {
7) | xhci_check_bandwidth() {
7) 0.440 us | xhci_check_args();
7) 0.305 us | usb_hcd_is_primary_hcd();
7) 0.440 us | xhci_alloc_command();
7) 0.330 us | xhci_get_input_control_ctx();
7) 3.215 us | }
7) 3.895 us | }
7) | usb_control_msg_send() {
7) | usb_control_msg() {
7) 0.380 us | usb_alloc_urb();
7) + 12.350 us | usb_start_wait_urb();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.350 us | usb_hcd_is_primary_hcd();
0) 0.370 us | xhci_get_virt_ep();
0) 0.545 us | xhci_dma_to_transfer_ring();
0) 0.375 us | xhci_get_ep_ctx();
0) 0.355 us | xhci_get_ep_ctx();
0) 0.360 us | xhci_get_ep_ctx();
0) | xhci_td_cleanup() {
0) 0.480 us | xhci_unmap_td_bounce_buffer.isra.38();
0) 2.130 us | xhci_giveback_urb_in_irq.isra.39();
0) 4.045 us | }
0) 1.265 us | xhci_update_erst_dequeue.isra.49();
0) + 18.445 us | }
0) + 19.115 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.360 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.370 us | usb_hcd_unmap_urb_setup_for_dma();
0) 1.395 us | }
0) 2.980 us | }
0) 0.365 us | usb_anchor_suspend_wakeups();
0) 0.375 us | usb_unanchor_urb();
0) 1.585 us | usb_api_blocking_completion();
0) 0.465 us | usb_anchor_resume_wakeups();
0) 0.385 us | usb_free_urb();
0) 9.690 us | }
7) + 14.000 us | }
7) + 15.150 us | }
7) 1.735 us | usb_set_device_state();
7) 0.460 us | usb_autosuspend_device();
7) ! 363.760 us | }
7) | usb_remove_device() {
7) 1.175 us | usb_autopm_get_interface();
7) | usb_control_msg() {
7) 0.350 us | usb_alloc_urb();
7) | usb_start_wait_urb() {
7) + 17.530 us | usb_submit_urb();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.360 us | usb_hcd_is_primary_hcd();
0) 0.365 us | xhci_get_virt_ep();
0) 0.350 us | xhci_dma_to_transfer_ring();
0) 0.350 us | xhci_get_ep_ctx();
0) 1.245 us | xhci_update_erst_dequeue.isra.49();
0) + 12.315 us | }
0) + 13.015 us | }
------------------------------------------
7) sh-87 => ksoftir-51
------------------------------------------

7) | usb_giveback_urb_bh() {
7) | xhci_unmap_urb_for_dma() {
7) 0.335 us | usb_hcd_is_primary_hcd();
7) | usb_hcd_unmap_urb_for_dma() {
7) 0.315 us | usb_hcd_unmap_urb_setup_for_dma();
7) 1.060 us | }
7) 2.410 us | }
7) 0.320 us | usb_anchor_suspend_wakeups();
7) 0.330 us | usb_unanchor_urb();
7) 1.700 us | usb_api_blocking_completion();
7) 0.310 us | usb_anchor_resume_wakeups();
7) 0.340 us | usb_free_urb();
7) 9.195 us | }
1) 3.045 us | usb_free_urb();
1) + 28.365 us | } /* usb_start_wait_urb */
1) + 30.355 us | } /* usb_control_msg */
1) 8.410 us | usb_set_device_state();
1) 0.645 us | usb_autopm_get_interface_no_resume();
1) 1.005 us | usb_autopm_put_interface();
1) + 48.090 us | } /* usb_remove_device */
------------------------------------------
1) sh-87 => kworker-66
------------------------------------------

1) 1.095 us | usb_autopm_get_interface();
1) | usb_control_msg() {
1) 0.755 us | usb_alloc_urb();
1) | usb_start_wait_urb() {
1) | usb_submit_urb() {
1) 7.675 us | usb_hcd_submit_urb();
1) 9.015 us | }
------------------------------------------
1) kworker-66 => ksoftir-21
------------------------------------------

1) | usb_giveback_urb_bh() {
1) | xhci_unmap_urb_for_dma() {
1) 0.305 us | usb_hcd_is_primary_hcd();
1) | usb_hcd_unmap_urb_for_dma() {
1) 0.320 us | usb_hcd_unmap_urb_setup_for_dma();
1) 0.970 us | }
1) 2.145 us | }
1) 0.315 us | usb_anchor_suspend_wakeups();
1) 0.340 us | usb_unanchor_urb();
1) 1.075 us | usb_api_blocking_completion();
1) 0.315 us | usb_anchor_resume_wakeups();
1) 0.360 us | usb_free_urb();
1) 7.420 us | }
------------------------------------------
1) ksoftir-21 => kworker-66
------------------------------------------

1) 0.640 us | usb_free_urb();
1) + 12.810 us | } /* usb_start_wait_urb */
1) + 14.965 us | } /* usb_control_msg */
1) | usb_disconnect() {
1) 0.360 us | usb_set_device_state();
1) | usb_disable_device() {
1) | usb_disable_device_endpoints() {
1) 0.635 us | usb_disable_endpoint();
1) 0.510 us | usb_disable_endpoint();
1) 0.340 us | usb_disable_endpoint();
1) 0.335 us | usb_disable_endpoint();
1) 0.445 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.330 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.330 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.330 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.330 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.345 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 2.615 us | usb_hcd_alloc_bandwidth();
1) 1.160 us | usb_disable_endpoint();
1) 0.895 us | usb_disable_endpoint();
1) 0.335 us | usb_disable_endpoint();
1) 0.350 us | usb_disable_endpoint();
1) 0.330 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.340 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.325 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.320 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) 0.315 us | usb_disable_endpoint();
1) 0.310 us | usb_disable_endpoint();
1) + 45.805 us | }
1) + 46.820 us | }
1) 0.325 us | usb_hcd_synchronize_unlinks();
1) + 25.905 us | usb_remove_ep_devs();
1) | usb_bus_notify() {
1) 8.735 us | usb_remove_sysfs_dev_files();
1) 9.580 us | }
1) 2.035 us | usb_devnode();
1) 0.350 us | usb_bus_notify();
1) | usb_unbind_device() {
1) | usb_generic_driver_disconnect() {
1) 0.975 us | usb_notify_remove_device();
1) 1.765 us | }
1) 2.590 us | }
1) 0.320 us | usb_bus_notify();
1) 0.935 us | usb_devnode();
1) 1.100 us | usb_uevent();
1) 0.575 us | usb_dev_uevent();
1) 0.345 us | usb_bus_notify();
1) 0.765 us | usb_devnode();
1) 0.765 us | usb_uevent();
1) 0.520 us | usb_dev_uevent();
1) | xhci_free_dev() {
1) 0.340 us | usb_hcd_is_primary_hcd();
1) | xhci_check_args() {
1) 0.310 us | usb_hcd_is_primary_hcd();
1) 0.925 us | }
1) 0.365 us | xhci_get_slot_ctx();
1) | xhci_disable_slot() {
1) 0.425 us | xhci_alloc_command();
1) + 31.240 us | xhci_debugfs_remove_slot();
1) 2.975 us | xhci_queue_slot_control();
1) 1.535 us | xhci_ring_cmd_db();
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.360 us | usb_hcd_is_primary_hcd();
0) 0.335 us | xhci_get_slot_ctx();
0) 1.220 us | xhci_update_erst_dequeue.isra.49();
0) 8.060 us | }
1) 0.515 us | xhci_free_command();
0) 8.900 us | }
1) + 41.705 us | }
1) | xhci_free_virt_device() {
1) 1.855 us | xhci_ring_free.part.35();
1) 0.770 us | xhci_free_tt_info.isra.28();
1) 0.350 us | xhci_update_tt_active_eps();
1) 0.780 us | xhci_free_container_ctx.part.36();
1) 0.615 us | xhci_free_container_ctx.part.36();
1) 8.320 us | }
1) + 54.960 us | }
1) | usb_release_dev() {
1) | usb_destroy_configuration() {
1) 0.830 us | usb_release_interface_cache();
1) 2.220 us | }
1) 0.780 us | usb_release_bos_descriptor();
1) 0.560 us | usb_put_hcd();
1) 5.750 us | }
1) # 5907.950 us | }
1) | usb_control_msg() {
1) 0.410 us | usb_alloc_urb();
1) | usb_start_wait_urb() {
1) | usb_submit_urb() {
1) + 10.590 us | usb_hcd_submit_urb();
1) + 11.745 us | }
------------------------------------------
1) kworker-66 => ksoftir-21
------------------------------------------

1) | usb_giveback_urb_bh() {
1) | xhci_unmap_urb_for_dma() {
1) 0.305 us | usb_hcd_is_primary_hcd();
1) | usb_hcd_unmap_urb_for_dma() {
1) 0.325 us | usb_hcd_unmap_urb_setup_for_dma();
1) 0.895 us | }
1) 2.115 us | }
1) 0.310 us | usb_anchor_suspend_wakeups();
1) 0.320 us | usb_unanchor_urb();
1) 0.875 us | usb_api_blocking_completion();
1) 0.350 us | usb_anchor_resume_wakeups();
1) 0.310 us | usb_free_urb();
1) 6.555 us | }
------------------------------------------
1) ksoftir-21 => kworker-66
------------------------------------------

1) 0.440 us | usb_free_urb();
1) + 14.850 us | } /* usb_start_wait_urb */
1) + 16.245 us | } /* usb_control_msg */
1) 0.500 us | usb_autopm_put_interface_no_suspend();
1) 2.445 us | usb_autopm_put_interface();
1) | usb_runtime_idle() {
1) | usb_runtime_suspend() {
1) | usb_suspend_both() {
1) | usb_control_msg() {
------------------------------------------
1) kworker-66 => ksoftir-21
------------------------------------------

1) | usb_giveback_urb_bh() {
1) | xhci_unmap_urb_for_dma() {
1) 0.330 us | usb_hcd_is_primary_hcd();
1) | usb_hcd_unmap_urb_for_dma() {
1) 0.315 us | usb_hcd_unmap_urb_setup_for_dma();
1) 0.910 us | }
1) 2.115 us | }
1) 0.340 us | usb_anchor_suspend_wakeups();
1) 0.325 us | usb_unanchor_urb();
1) 0.790 us | usb_api_blocking_completion();
1) 0.305 us | usb_anchor_resume_wakeups();
1) 0.335 us | usb_free_urb();
1) 6.255 us | }
------------------------------------------
1) ksoftir-21 => kworker-66
------------------------------------------

1) 7.405 us | } /* usb_control_msg */
1) | usb_kill_urb() {
------------------------------------------
1) kworker-66 => ksoftir-21
------------------------------------------

1) | usb_giveback_urb_bh() {
1) | xhci_unmap_urb_for_dma() {
1) 0.320 us | usb_hcd_is_primary_hcd();
1) | usb_hcd_unmap_urb_for_dma() {
1) 0.460 us | usb_hcd_unmap_urb_setup_for_dma();
1) 1.025 us | }
1) 2.335 us | }
1) 0.325 us | usb_anchor_suspend_wakeups();
1) 0.320 us | usb_unanchor_urb();
1) 0.310 us | usb_anchor_resume_wakeups();
1) 0.325 us | usb_free_urb();
1) 6.305 us | }
------------------------------------------
1) ksoftir-21 => kworker-66
------------------------------------------

1) 4.130 us | } /* usb_kill_urb */
1) 4.350 us | usb_generic_driver_suspend();
1) 0.380 us | usb_hcd_flush_endpoint();
1) 0.345 us | usb_hcd_flush_endpoint();
1) 0.335 us | usb_hcd_flush_endpoint();
1) 0.495 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.300 us | usb_hcd_flush_endpoint();
1) 0.300 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.300 us | usb_hcd_flush_endpoint();
1) 0.435 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.320 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.310 us | usb_hcd_flush_endpoint();
1) 0.305 us | usb_hcd_flush_endpoint();
1) 0.315 us | usb_hcd_flush_endpoint();
1) + 38.510 us | } /* usb_suspend_both */
1) + 39.405 us | } /* usb_runtime_suspend */
1) + 41.965 us | } /* usb_runtime_idle */

设备拔出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
cd /sys/kernel/debug/tracing
echo nop > current_tracer
echo > trace
echo > set_ftrace_filter
echo > set_graph_function
echo > set_ftrace_notrace
echo function_graph > current_tracer

cat <<EOF > set_ftrace_filter
xhci_*
usb_*
*dwc3*
hcd_*
scsi_*
sd_*
submit_bio
blk_mq_submit_bio
EOF
cat <<EOF > set_ftrace_notrace
_dev_info
mutex*
_raw_spin*
__pm_runtime*
xhci_dbg_trace
EOF

echo 4 > max_graph_depth
echo 1 > tracing_on && sleep 1 && echo <拔出设备> && sleep 2 && echo 0 > tracing_on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
0) | usb_hcd_irq() {
0) | xhci_irq() {
0) 0.505 us | usb_hcd_is_primary_hcd();
0) 3.165 us | usb_hcd_resume_root_hub();
0) | usb_hcd_poll_rh_status() {
0) 1.235 us | xhci_hub_status_data();
0) 2.610 us | }
0) 1.215 us | xhci_update_erst_dequeue.isra.49();
0) + 14.140 us | }
0) + 18.070 us | }
------------------------------------------
0) <idle>-0 => kworker-68
------------------------------------------

0) | hcd_resume_work() {
0) | usb_remote_wakeup() {
0) | usb_autoresume_device() {
0) | usb_runtime_resume() {
------------------------------------------
0) kworker-68 => <idle>-0
------------------------------------------

0) | usb_hcd_poll_rh_status() {
0) | xhci_hub_status_data() {
0) 0.355 us | usb_hcd_is_primary_hcd();
0) 0.340 us | usb_hcd_is_primary_hcd();
0) 2.100 us | }
0) 3.350 us | }
------------------------------------------
0) <idle>-0 => ksoftir-15
------------------------------------------

0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.340 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.325 us | usb_hcd_unmap_urb_setup_for_dma();
0) 0.960 us | }
0) 2.190 us | }
0) 0.340 us | usb_anchor_suspend_wakeups();
0) 0.325 us | usb_unanchor_urb();
0) 1.585 us | usb_api_blocking_completion();
0) 0.320 us | usb_anchor_resume_wakeups();
0) 0.330 us | usb_free_urb();
0) 7.780 us | }
0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.330 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.345 us | usb_hcd_unmap_urb_setup_for_dma();
0) 0.930 us | }
0) 2.125 us | }
0) 0.325 us | usb_anchor_suspend_wakeups();
0) 0.325 us | usb_unanchor_urb();
0) 0.830 us | usb_api_blocking_completion();
0) 0.310 us | usb_anchor_resume_wakeups();
0) 0.320 us | usb_free_urb();
0) 6.285 us | }
------------------------------------------
0) ksoftir-15 => kworker-68
------------------------------------------

0) + 33.490 us | } /* usb_runtime_resume */
0) + 36.495 us | } /* usb_autoresume_device */
0) | usb_autosuspend_device() {
0) 0.780 us | usb_runtime_suspend();
0) 2.205 us | }
0) + 39.860 us | } /* usb_remote_wakeup */
0) + 40.815 us | } /* hcd_resume_work */
0) 0.760 us | usb_autopm_get_interface();
0) | usb_control_msg() {
0) 0.370 us | usb_alloc_urb();
0) | usb_start_wait_urb() {
0) | usb_submit_urb() {
0) 3.340 us | usb_hcd_submit_urb();
0) 4.005 us | }
------------------------------------------
0) kworker-68 => ksoftir-15
------------------------------------------

0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.315 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.340 us | usb_hcd_unmap_urb_setup_for_dma();
0) 0.940 us | }
0) 2.105 us | }
0) 0.325 us | usb_anchor_suspend_wakeups();
0) 0.335 us | usb_unanchor_urb();
0) 0.850 us | usb_api_blocking_completion();
0) 0.305 us | usb_anchor_resume_wakeups();
0) 0.325 us | usb_free_urb();
0) 6.335 us | }
------------------------------------------
0) ksoftir-15 => kworker-68
------------------------------------------

0) 0.395 us | usb_free_urb();
0) 6.290 us | } /* usb_start_wait_urb */
0) 7.770 us | } /* usb_control_msg */
0) 0.390 us | usb_autopm_put_interface_no_suspend();
0) 1.145 us | usb_autopm_put_interface();
0) | usb_runtime_idle() {
0) | usb_runtime_suspend() {
0) | usb_suspend_both() {
0) | usb_control_msg() {
------------------------------------------
0) kworker-68 => ksoftir-15
------------------------------------------

0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.335 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.325 us | usb_hcd_unmap_urb_setup_for_dma();
0) 1.235 us | }
0) 2.440 us | }
0) 0.330 us | usb_anchor_suspend_wakeups();
0) 0.325 us | usb_unanchor_urb();
0) 0.755 us | usb_api_blocking_completion();
0) 0.305 us | usb_anchor_resume_wakeups();
0) 0.345 us | usb_free_urb();
0) 6.690 us | }
------------------------------------------
0) ksoftir-15 => kworker-68
------------------------------------------

0) 6.230 us | } /* usb_control_msg */
0) | usb_kill_urb() {
------------------------------------------
0) kworker-68 => ksoftir-15
------------------------------------------

0) | usb_giveback_urb_bh() {
0) | xhci_unmap_urb_for_dma() {
0) 0.345 us | usb_hcd_is_primary_hcd();
0) | usb_hcd_unmap_urb_for_dma() {
0) 0.350 us | usb_hcd_unmap_urb_setup_for_dma();
0) 0.940 us | }
0) 2.155 us | }
0) 0.315 us | usb_anchor_suspend_wakeups();
0) 0.310 us | usb_unanchor_urb();
0) 0.325 us | usb_anchor_resume_wakeups();
0) 0.335 us | usb_free_urb();
0) 6.060 us | }
------------------------------------------
0) ksoftir-15 => kworker-68
------------------------------------------

0) 3.435 us | } /* usb_kill_urb */
0) 3.095 us | usb_generic_driver_suspend();
0) 0.355 us | usb_hcd_flush_endpoint();
0) 0.345 us | usb_hcd_flush_endpoint();
0) 0.320 us | usb_hcd_flush_endpoint();
0) 0.345 us | usb_hcd_flush_endpoint();
0) 0.320 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.300 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.300 us | usb_hcd_flush_endpoint();
0) 0.320 us | usb_hcd_flush_endpoint();
0) 0.305 us | usb_hcd_flush_endpoint();
0) 0.330 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.305 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.305 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.945 us | usb_hcd_flush_endpoint();
0) 0.315 us | usb_hcd_flush_endpoint();
0) 0.310 us | usb_hcd_flush_endpoint();
0) 0.360 us | usb_hcd_flush_endpoint();
0) + 35.365 us | } /* usb_suspend_both */
0) + 35.990 us | } /* usb_runtime_suspend */
0) + 37.170 us | } /* usb_runtime_idle */
------------------------------------------
0) kworker-68 => <idle>-0
------------------------------------------

0) | usb_hcd_poll_rh_status() {
0) | xhci_hub_status_data() {
0) 0.335 us | usb_hcd_is_primary_hcd();
0) 0.315 us | usb_hcd_is_primary_hcd();
0) 1.995 us | }
0) 2.610 us | }

异步:suspend机制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
echo device > /sys/class/usb_role/22100000.dwc3-role-switch/role
cd /sys/kernel/debug/tracing
echo 0 > tracing_on
echo > trace
echo function_graph > current_tracer
echo > set_graph_function
echo xhci_* > set_ftrace_filter
echo usb_* >> set_ftrace_filter
echo hub_* >> set_ftrace_filter
echo *dwc3* >> set_ftrace_filter
echo hcd_* >> set_ftrace_filter
echo uas_* >> set_ftrace_filter
echo scsi_* >> set_ftrace_filter
echo sd_* >> set_ftrace_filter
echo _dev_info > set_ftrace_notrace
echo mutex* >> set_ftrace_notrace
echo _raw_spin* >> set_ftrace_notrace
echo __pm_runtime* >> set_ftrace_notrace
echo xhci_dbg_trace >> set_ftrace_notrace
echo nosleep-time > trace_options
echo nograph-time > trace_options
echo noirq-info > trace_options
echo noannotate > trace_options
echo 20 > max_graph_depth
sleep 3 && echo 1 > tracing_on && echo host > /sys/class/usb_role/22100000.dwc3-role-switch/role && sleep 3 && echo 0 > tracing_on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
3)               |  () {
3) 1.050 us | usb_autopm_get_interface();
3) 0.355 us | usb_autopm_put_interface_no_suspend();
3) 1.015 us | usb_autopm_put_interface();
3) 3.665 us | }
3) | usb_runtime_idle() {
3) | usb_runtime_suspend() {
3) | usb_suspend_both() {
3) | hub_suspend() {
3) | hub_quiesce() {
3) | usb_kill_urb() {
3) | usb_kill_urb.part.15() {
3) | usb_hcd_unlink_urb() {
3) 0.360 us | usb_get_dev();
3) 0.340 us | usb_hcd_unlink_urb_from_ep();
3) 0.935 us | usb_hcd_giveback_urb();
3) 0.375 us | usb_put_dev();
3) 4.100 us | }
3) 4.720 us | }
3) 5.300 us | }
3) 6.190 us | }
3) 6.865 us | } /* hub_suspend */
3) | usb_generic_driver_suspend() {
3) | hcd_bus_suspend() {
3) | xhci_bus_suspend() {
3) 0.345 us | usb_hcd_is_primary_hcd();
3) 0.315 us | usb_hcd_is_primary_hcd();
3) 2.150 us | }
3) 0.360 us | usb_set_device_state();
3) | xhci_hub_status_data() {
3) 0.320 us | usb_hcd_is_primary_hcd();
3) 0.320 us | usb_hcd_is_primary_hcd();
3) 2.055 us | }
3) | hcd_bus_resume() {
3) | xhci_bus_resume() {
3) 0.310 us | usb_hcd_is_primary_hcd();
3) 0.325 us | usb_hcd_is_primary_hcd();
3) 7.445 us | }
3) 0.310 us | usb_phy_roothub_calibrate();
3) 0.365 us | usb_set_device_state();
3) 0.325 us | usb_hub_find_child();
3) 0.325 us | usb_hub_find_child();
3) + 10.635 us | }
3) + 17.080 us | }
3) + 17.690 us | }
3) | usb_resume_interface.isra.13() {
3) | hub_resume() {
3) | hub_activate() {
3) | hub_ext_port_status() {
3) | usb_control_msg() {
3) 0.385 us | usb_alloc_urb();
3) | usb_start_wait_urb() {
3) | usb_submit_urb() {
3) | usb_hcd_submit_urb() {
3) | usb_get_urb() {
3) 0.325 us | usb_get_urb.part.12();
3) 0.895 us | }
3) 0.340 us | usb_hcd_link_urb_to_ep();
3) | xhci_hub_control() {
3) 0.310 us | usb_hcd_is_primary_hcd();
3) 0.305 us | usb_hcd_is_primary_hcd();
3) | xhci_get_port_status.isra.17() {
3) 0.310 us | usb_hcd_is_primary_hcd();
3) 0.915 us | }
3) 3.110 us | }
3) 0.320 us | usb_hcd_unlink_urb_from_ep();
3) 1.430 us | usb_hcd_giveback_urb();
3) 8.535 us | }
3) 9.130 us | }
3) 0.395 us | usb_free_urb();
3) + 10.475 us | }
3) + 11.800 us | }
3) + 12.420 us | }
3) 0.310 us | hub_port_warm_reset_required();
3) | usb_submit_urb() {
3) | usb_hcd_submit_urb() {
3) | usb_get_urb() {
3) 0.320 us | usb_get_urb.part.12();
3) 1.035 us | }
3) 0.325 us | usb_hcd_link_urb_to_ep();
3) 2.545 us | }
3) 3.175 us | }
3) 0.415 us | usb_autopm_get_interface_no_resume();
3) + 18.010 us | }
3) | xhci_get_resuming_ports() {
3) 0.315 us | usb_hcd_is_primary_hcd();
3) 0.920 us | }
3) + 19.835 us | }
3) + 20.420 us | } /* usb_resume_interface.isra.13 */
3) + 46.230 us | } /* usb_suspend_both */
3) + 46.910 us | } /* usb_runtime_suspend */
3) + 48.095 us | } /* usb_runtime_idle */

数据结构

1
2
3
4
5
6
7
8
9
10
11
// linux-6.6.64/drivers/usb/host/xhci.h
struct xhci_hcd {
struct usb_hcd *main_hcd;
struct usb_hcd *shared_hcd;
/* glue to PCI and HCD framework */
struct xhci_cap_regs __iomem *cap_regs;
struct xhci_op_regs __iomem *op_regs;
struct xhci_run_regs __iomem *run_regs;
struct xhci_doorbell_array __iomem *dba;
...
};

主控注册

汇总流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// echo host > /sys/class/usb_role/22100000.dwc3-role-switch/role
role_store
usb_role_switch_set_role(sw, ret)
sw->set(sw, role) // dwc3_usb_role_switch_set
dwc3_set_mode(dwc, mode)
// &dwc->drd_work工作队列入队,触发__dwc3_set_mode

// 异步通过&dwc->drd_work触发
__dwc3_set_mode
dwc3_host_init(dwc)
platform_device_add(xhci) // 通过platform框架,触发xhci_generic_plat_probe

// usb_generic_xhci_driver.probe
xhci_generic_plat_probe
xhci_plat_probe(pdev, sysdev, priv_match)
usb_disabled
usb_hcd_is_primary_hcd
usb_hcd_is_primary_hcd
/* 添加第1个控制器,对应u2口,作为primary */
usb_add_hcd(hcd, irq, IRQF_SHARED) // 打印 xHCI Host Controller
usb_register_bus(&hcd->self) // 打印 new USB bus registered, assigned bus number 1
xhci_plat_setup
usb_hcd_is_primary_hcd
xhci_gen_setup
usb_hcd_is_primary_hcd
usb_hcd_is_primary_hcd
xhci_halt // 打印 // Halt the HC
// 打印 Resetting HCD
xhci_reset // 打印 Wait for controller to be ready for doorbell rings
// 打印 Reset complete
// 打印 Enabling 64-bit DMA addresses.
// 打印 Calling HCD init
xhci_init
// 打印 xhci_init
// 打印 xHCI doesn't need link TRB QUIRK
xhci_mem_init
// 打印 Supported page size register = 0x1
// 打印 Supported page size of 8K
// 打印 HCD page size set to 4K
// 打印 // xHC can handle at most 64 device slots.
// 打印 // Setting Max device slots reg = 0x40.
// 打印 // Device context base array address = 0x0x000000081224b000 (DMA), (____ptrval____) (virt)
// 打印 Allocated command ring at (____ptrval____)
// 打印 First segment DMA is 0x0x000000081224d000
// 打印 // Setting command ring address to 0x000000081224d001
// 打印 // Doorbell array is located at offset 0x2000 from cap regs base addr
// 打印 Allocating primary event ring
xhci_ring_alloc
xhci_ring_alloc
xhci_alloc_erst
*xhci_add_interrupter(xhci, xhci->interrupter, 0)
*xhci_set_hc_event_deq(xhci, ir)
xhci_trb_virt_to_dma(ir->event_ring->deq_seg,
// 打印 // Write event ring dequeue pointer, preserving EHB bit
*scratchpad_alloc(xhci, flags) // 打印 Allocating 2 scratchpad buffers
*xhci_setup_port_arrays(xhci, flags)
*xhci_add_in_port(xhci, num_ports, base + offset, cap_count)
// 打印 Ext Cap (____ptrval____), port offset = 1, count = 1, revision = 0x2
// 打印 xHCI 1.0: support USB2 hardware lpm
*xhci_add_in_port(xhci, num_ports, base + offset, cap_count)
// 打印 Ext Cap (____ptrval____), port offset = 2, count = 1, revision = 0x3
// 打印 PSIV:4 PSIE:3 PLT:0 PFD:1 LP:0 PSIM:5
// 打印 PSIV:5 PSIE:3 PLT:0 PFD:1 LP:1 PSIM:10
// 打印 Found 1 USB 2.0 ports and 1 USB 3.0 ports.
xhci_create_rhub_port_array
xhci_create_rhub_port_array
// 打印 Finished xhci_init
// 打印 Called HCD init
// 打印 hcc params 0x0118ffcd hci version 0x120 quirks 0x0000008000000010
// 打印 supports USB remote wakeup
usb_hcd_request_irqs // 打印 irq 18, io mem 0x22100000
usb_phy_roothub_calibrate
xhci_plat_start
usb_hcd_is_primary_hcd
dwc3_xhci_plat_start
usb_hcd_is_primary_hcd
xhci_run
// 打印 xhci_run
// 打印 ERST deq = 64'h812c21000
// 打印 // Set the interrupt modulation register
// 打印 Finished xhci_run for main hcd
usb_hcd_is_primary_hcd
usb_hcd_is_primary_hcd
xhci_create_dbc_dev
xhci_debugfs_init
/* 添加第2个控制器,对应u3口,hcd为primary */
usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED) // 打印 xHCI Host Controller
hcd_buffer_create
usb_notify_add_bus
usb_alloc_dev
usb_register_bus(&hcd->self) // 打印 new USB bus registered, assigned bus number 2
xhci_plat_setup
usb_hcd_is_primary_hcd
xhci_gen_setup
usb_hcd_is_primary_hcd
usb_hcd_is_primary_hcd
xhci_hcd_init_usb3_data // 打印 Host supports USB 3.%x %sSuperSpeed
// 打印 supports USB remote wakeup
usb_phy_roothub_calibrate
xhci_plat_start
usb_hcd_is_primary_hcd
dwc3_xhci_plat_start
xhci_run
usb_hcd_is_primary_hcd
usb_hcd_is_primary_hcd
xhci_run_finished
// 打印 Enable interrupts
// 打印 Enable primary interrupter
xhci_start(xhci) // 打印 // Turn on HC, cmd = 0x%x.
usb_set_device_state(usb_dev, USB_STATE_ADDRESS)
usb_get_device_descriptor
usb_get_descriptor
usb_control_msg
usb_new_device (usb_dev)
usb_disable_autosuspend
usb_get_configuration
usb_get_descriptor
usb_control_msg
usb_get_descriptor
usb_control_msg
usb_cache_string(udev, udev->descriptor.iProduct)
usb_string(udev, index, buf, MAX_USB_STRING_SIZE)
usb_get_langid(dev, tbuf) // 打印 default language 0x0409
usb_cache_string(udev, udev->descriptor.iManufacturer)
usb_string
usb_cache_string(udev, udev->descriptor.iSerialNumber)
usb_string
usb_detect_interface_quirks
usb_detect_static_quirks
// 打印 udev 1, busnum 1, minor = 0
usb_devnode
usb_devnode
usb_probe_device // 打印 usb_probe_device
usb_generic_driver_probe
usb_choose_configuration(udev) // 打印 configuration #1 chosen from 1 choice
usb_set_configuration
usb_hcd_alloc_bandwidth
xhci_add_endpoint // 打印 xHCI xhci_add_endpoint called for root hub
xhci_check_bandwidth // 打印 xHCI xhci_check_bandwidth called for root hub
// 打印 adding 1-0:1.0 (config #1, interface 0)
device_add(&intf->dev) // 通过device框架,会触发drvwrap.driver.probe (usb_probe_interface)
// 打印 usb_probe_interface
// 打印 usb_probe_interface - got id
driver->probe(intf, id) // hub_driver.probe (hub_probe)
// 打印 USB hub found
hub_configure(hub, &desc->endpoint[0].desc)
// 打印 1 port detected
// 打印 standalone hub
// 打印 individual port power switching
// 打印 individual port over-current protection
// 打印 Single TT
// 打印 TT requires at most 8 FS bit times (666 ns)
// 打印 power on to power good time: 20ms
// 打印 local power source is good
hub_activate(hub, HUB_INIT)
hub_power_on(hub, false) // 打印 enabling power on all ports
set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER) // 长调用链,细节见usb_control_msg;打印 set port power 1-1 ON, portsc: 0x2a0
usb_notify_add_device
usb_create_ep_devs
usb_set_device_state(usb_dev, USB_STATE_ADDRESS)
usb_get_device_descriptor
usb_get_descriptor
usb_get_bos_descriptor
usb_get_descriptor
usb_get_descriptor
usb_device_supports_lpm // 打印 We don't know the algorithms for LPM for this host, disabling LPM.
usb_new_device (usb_dev)
usb_disable_autosuspend
usb_get_configuration
usb_get_descriptor
usb_get_descriptor
usb_parse_configuration(dev, cfgno,
usb_parse_interface(ddev, cfgno, config,
usb_parse_endpoint(ddev, cfgno, config, inum, asnum, // 打印 skipped 1 descriptor after endpoint
usb_cache_string(udev, udev->descriptor.iProduct)
usb_string(udev, index, buf, MAX_USB_STRING_SIZE)
usb_get_langid(dev, tbuf) // 打印 default language 0x0409
usb_cache_string(udev, udev->descriptor.iManufacturer)
usb_string
usb_cache_string(udev, udev->descriptor.iSerialNumber)
usb_string
usb_detect_interface_quirks
// 打印 udev 1, busnum 2, minor = 128
usb_probe_device // 打印 usb_probe_device
usb_generic_driver_probe
usb_choose_configuration(udev) // 打印 configuration #1 chosen from 1 choice
usb_set_configuration
usb_hcd_alloc_bandwidth
xhci_add_endpoint // 打印 xHCI xhci_add_endpoint called for root hub
xhci_check_bandwidth // 打印 xHCI xhci_check_bandwidth called for root hub
// 打印 adding 2-0:1.0 (config #1, interface 0)
device_add(&intf->dev) // 通过device框架,会触发drvwrap.driver.probe (usb_probe_interface)
// 打印 usb_probe_interface
// 打印 usb_probe_interface - got id
driver->probe(intf, id) // hub_driver.probe (hub_probe)
// 打印 USB hub found
hub_configure(hub, &desc->endpoint[0].desc)
// 打印 1 port detected
// 打印 standalone hub
// 打印 individual port power switching
// 打印 individual port over-current protection
// 打印 Single TT
// 打印 TT requires at most 8 FS bit times (666 ns)
// 打印 power on to power good time: 100ms
// 打印 local power source is good
hub_activate(hub, HUB_INIT)
hub_power_on(hub, false) // 打印 enabling power on all ports
set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER) // 长调用链,细节见usb_control_msg;打印 set port power 2-1 ON, portsc: 0x2a0
usb_bus_notify
usb_create_ep_devs

usb_set_configuration
usb_autoresume_device
usb_hcd_alloc_bandwidth
usb_enable_interface
usb_get_dev
usb_control_msg_send
usb_control_msg
usb_cache_string
usb_unlocked_enable_lpm
usb_enable_lpm
usb_probe_interface
usb_autoresume_device
usb_enable_autosuspend
usb_control_msg
usb_get_status
usb_control_msg
usb_control_msg
usb_hub_create_port_device
xhci_update_hub_device
usb_hub_adjust_deviceremovable
usb_control_msg
usb_autopm_get_interface_no_resume
usb_create_ep_devs
usb_autosuspend_device

流程细节

写/sys/class/usb_role/xxx-role-switch/role节点

1
2
3
4
5
6
7
8
9
10
11
// linux-6.6.64/drivers/usb/roles/class.c
static ssize_t role_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t size)
usb_role_switch_set_role(sw, ret)
sw->set(sw, role) // 通过dwc3_role_switch.set = dwc3_usb_role_switch_set 关联dwc3_usb_role_switch_set函数

// linux-6.6.64/drivers/usb/dwc3/drd.c
static int dwc3_usb_role_switch_set(struct usb_role_switch *sw,
enum usb_role role)
dwc3_set_mode(dwc, mode)
queue_work(system_freezable_wq, &dwc->drd_work) // 通过INIT_WORK(&dwc->drd_work, __dwc3_set_mode)关联__dwc3_set_mode函数

probe

1
2
3
4
5
6
7
8
9
usb_generic_xhci_driver.probe (xhci_generic_plat_probe)
xhci_plat_probe(pdev, sysdev, priv_match)
usb_add_hcd(hcd, irq, IRQF_SHARED)
usb_register_bus(&hcd->self)
hcd->driver->reset(hcd) // xhci_plat_overrides.reset (xhci_plat_setup)
xhci_gen_setup
xhci_halt
hcd->driver->start(hcd) xhci_hc_driver.start (xhci_plat_start)
xhci_run

usb_add_hcd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// linux-6.6.64/drivers/usb/core/hcd.c
int usb_add_hcd(struct usb_hcd *hcd,
unsigned int irqnum, unsigned long irqflags)
// 打印 xHCI Host Controller
...
usb_register_bus(&hcd->self)
hcd->driver->reset(hcd) // xhci_plat_overrides.reset (xhci_plat_setup)
xhci_gen_setup
xhci_halt // 打印 // Halt the HC
...
// 打印 supports USB remote wakeup
usb_hcd_request_irqs // 打印 irq %d, %s 0x%08llx
hcd->driver->start(hcd) xhci_hc_driver.start (xhci_plat_start)
xhci_run // 打印 xhci_run
/* 此处,非primary hcd会调用register_root_hub */
register_root_hub(hcd)

usb_register_bus

1
2
3
4
5
6
// linux-6.6.64/drivers/usb/core/hcd.c
// 注册控制器到usbcore
static int usb_register_bus(struct usb_bus *bus)
// 分配总线号
usb_notify_add_bus(bus) // usb_notifier_list增加 USB_BUS_ADD
// 打印 new USB bus registered, assigned bus

xhci_plat_setup

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
xhci_plat_overrides.reset (xhci_plat_setup)
static int xhci_plat_setup(struct usb_hcd *hcd)
xhci_gen_setup
/* 此处,非primary hcd会调用xhci_hcd_init_usb3_data函数后,直接返回 */
xhci_hcd_init_usb3_data // 打印 Host supports USB 3.%x %sSuperSpeed
xhci_halt // 打印 // Halt the HC
// 打印 Resetting HCD
xhci_reset // 打印 Wait for controller to be ready for doorbell rings
// 打印 Reset complete
// 打印 Enabling 64-bit DMA addresses.
// 打印 Calling HCD init
xhci_init
// 打印 xhci_init
// 打印 xHCI doesn't need link TRB QUIRK
xhci_mem_init
// 打印 Supported page size register
// 打印 Supported page size of
// 打印 HCD page size set to
// 打印 // xHC can handle at most
// 打印 // Setting Max device slots reg =
// 打印 // Device context base array address
// 打印 Allocated command ring at
// 打印 First segment DMA is
// 打印 // Setting command ring address
// 打印 // Doorbell array is located at offset
// 打印 Allocating primary event ring
xhci_add_interrupter
xhci_set_hc_event_deq // 打印 // Write event ring dequeue pointer, preserving EHB bit
scratchpad_alloc // 打印 Allocating %d scratchpad buffers
xhci_setup_port_arrays
xhci_add_in_port // 循环添加usb输入端口
// 打印 Ext Cap %p, port offset = %u, count = %u, revision =
// 打印 xHCI 1.0: support USB2 hardware lpm
// 打印 PSIV:%d PSIE:%d PLT:%d PFD:%d LP:%d PSIM:%d
// 打印 Found %u USB 2.0 ports and %u USB 3.0 ports.
// 打印 Finished xhci_init
// 打印 Called HCD init
// 打印 hcc params 0x0118ffcd hci version 0x120 quirks 0x0000008000000010

xhci_run

1
2
3
4
5
6
7
8
9
10
11
// linux-6.6.64/drivers/usb/host/xhci.c
int xhci_run(struct usb_hcd *hcd)
/* 此处,非primary hcd会调用xhci_run_finished后,直接返回 */
xhci_run_finished(xhci)
// 打印 Enable interrupts
// 打印 Enable primary interrupter
xhci_start(xhci) // 打印 // Turn on HC, cmd = 0x%x.
// 打印 xhci_run
// 打印 ERST deq = 64'h%0lx
// 打印 // Set the interrupt modulation register
// 打印 Finished %s for main hcd

register_root_hub

1
2
3
4
5
6
7
8
9
10
11
12
// linux-6.6.64/drivers/usb/core/hcd.c
static int register_root_hub(struct usb_hcd *hcd)
/* descriptor.bcdUSB满足条件则调用 */
usb_device_supports_lpm(usb_dev) // 打印 We don't know the algorithms for LPM for this host, disabling LPM.
usb_new_device(usb_dev)
usb_enumerate_device(udev)
usb_cache_string(udev, udev->descriptor.xxx)
usb_string(udev, index, buf, MAX_USB_STRING_SIZE)
usb_get_langid(dev, tbuf)
// 打印 default language 0x%04x
// 打印 udev %d, busnum %d, minor = %d
device_add(&udev->dev) // 通过device框架,会触发drvwrap.driver.probe (usb_probe_device)

usb_probe_device

1
2
3
4
5
6
7
8
9
10
11
12
13
// linux-6.6.64/drivers/usb/core/driver.c
static int usb_probe_device(struct device *dev)
// 打印 usb_probe_device
usb_generic_driver_probe(udev)
usb_choose_configuration(udev) // 打印 configuration #%d chosen from %d choice%s
usb_set_configuration(udev, c)
usb_hcd_alloc_bandwidth(dev, cp, NULL, NULL)
hcd->driver->add_endpoint(hcd, udev, &alt->endpoint[j]) // xhci_hc_driver.add_endpoint (xhci_add_endpoint)
xhci_check_args(hcd, udev, ep, 1, true, __func__) // 打印 xHCI xhci_add_endpoint called for root hub
hcd->driver->check_bandwidth(hcd, udev) // xhci_hc_driver.check_bandwidth (xhci_check_bandwidth)
xhci_check_args(hcd, udev, NULL, 0, true, __func__) // 打印 xHCI xhci_check_bandwidth called for root hub
// 打印 adding %s (config #%d, interface %d)
device_add(&intf->dev) // 通过device框架,会触发drvwrap.driver.probe (usb_probe_interface)

usb_probe_interface

1
2
3
4
5
// linux-6.6.64/drivers/usb/core/driver.c
static int usb_probe_interface(struct device *dev)
// 打印 usb_probe_interface
// 打印 %s - got id
driver->probe(intf, id) // hub_driver.probe (hub_probe)

hub_probe

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// linux-6.6.64/drivers/usb/core/hub.c
static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
// 打印 USB hub found
hub_configure(hub, &desc->endpoint[0].desc)
// 打印 %d port%s detected
// 打印 standalone hub
// 打印 individual port power switching
// 打印 individual port over-current protection
// 打印 Single TT
// 打印 TT requires at most %d
// 打印 power on to power good time: %dms
// 打印 local power source is %s
hub_activate(hub, HUB_INIT)
hub_power_on(hub, false)
// 打印 enabling power on all ports
set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER)
usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, NULL, 0, 1000)
... // 长调用链,细节见usb_control_msg;最终调用 xhci_hc_driver.hub_control (xhci_hub_control)

usb_control_msg

1
2
3
4
5
6
7
8
9
10
11
// linux-6.6.64/drivers/usb/core/message.c
int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
__u8 requesttype, __u16 value, __u16 index, void *data,
__u16 size, int timeout)
usb_internal_control_msg(dev, pipe, dr, data, size, timeout)
usb_start_wait_urb(urb, timeout, &length)
usb_submit_urb(urb, GFP_NOIO)
usb_hcd_submit_urb(urb, mem_flags)
rh_urb_enqueue(hcd, urb)
rh_call_control (hcd, urb)
hcd->driver->hub_control (hcd, typeReq, wValue, wIndex, tbuf, wLength) // xhci_hc_driver.hub_control (xhci_hub_control)

xhci_hub_control

1
2
3
4
5
// linux-6.6.64/drivers/usb/host/xhci-hub.c
int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
xhci_set_port_power(xhci, port, true, &flags)
// 打印 set port power %d-%d %s, portsc: 0x%x

usb_enumerate_device

1
2
3
4
5
6
7
// linux-6.6.64/drivers/usb/core/hub.c
static int usb_enumerate_device(struct usb_device *udev)
usb_get_configuration(udev)
usb_parse_configuration(dev, cfgno,
usb_parse_interface(ddev, cfgno, config,
usb_parse_endpoint(ddev, cfgno, config, inum, asnum,
// 打印 skipped %d descriptor%s after %s

suspend机制

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// linux-6.6.64/drivers/usb/core/hcd.c
usb_generic_driver.suspend (usb_generic_driver_suspend)
int usb_generic_driver_suspend(struct usb_device *udev, pm_message_t msg)
hcd_bus_suspend(udev, msg)
// 打印 bus %ssuspend, wakeup %d
xhci_bus_suspend
usb_set_device_state
xhci_hub_status_data
hcd_bus_resume
xhci_bus_resume
usb_phy_roothub_calibrate
usb_set_device_state

// linux-6.6.64/drivers/usb/host/xhci-hub.c
xhci_hc_driver.hub_status_data (xhci_hub_status_data)
int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
// 打印 %s: stopping usb%d port polling

// linux-6.6.64/drivers/usb/host/xhci-hub.c
int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
// 打印 Get port status %d-%d read: 0x%x, return 0x%x

// linux-6.6.64/drivers/usb/core/hub.c
static void hub_event(struct work_struct *work)
// 打印 state %d ports %d chg %04x evt %04x

static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
// 打印 hub_suspend

int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
// 打印 bus %ssuspend, wakeup %d
// 打印 suspend raced with wakeup event

int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
// 打印 usb %sresume

static void link_peers_report(struct usb_port *left, struct usb_port *right)
// 打印 peered to %s

int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
// 打印 set port remote wake mask, actual port %d-%d status = 0x%x

设备接入

汇总流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
usb_hcd_irq
/* 打印
Port change event, 2-1, id 2, portsc: 0xa021603
resume root hub
handle_port_status: starting usb2 port polling.
*/

// drivers/usb/core/hcd.c
// hcd wakeup工作队列被唤醒
void hcd_resume_work(struct work_struct *work)
usb_remote_wakeup(udev)
// 打印 usb wakeup-resume
usb_autoresume_device(udev)
usb_runtime_resume
usb_resume_both
*usb_resume_device(udev, msg) // usb_generic_driver_resume
hcd_bus_resume(udev, msg) // 打印 usb auto-resume
hcd->driver->bus_resume(hcd) // xhci_bus_resume
usb_resume_interface(udev, intf, msg
driver->resume(intf) // hub_resume
// 打印 hub_resume
hub_activate(hub, HUB_RESUME)
*usb_hub_port_status(hub, port1, &portstatus, &portchange) // hub_ext_port_status(hub, port1, HUB_PORT_STATUS,
*get_port_status(hub->hdev, port1, &hub->status->port, type, len) // usb_control_msg(..USB_REQ_GET_STATUS..)
// 长调用,打印 Get port status 2-1 read: 0x21603, return 0x10203
// 打印 status 0203 change 0001
hub_port_warm_reset_required(hub, port1, portstatus)
usb_clear_port_feature(hdev, port1,
usb_control_msg(..USB_REQ_CLEAR_FEATURE..)
// 长调用,打印 clear port1 connect change, portsc: 0x1603
usb_submit_urb(hub->urb, GFP_NOIO)
kick_hub_wq(hub) // 触发 hub_event

// linux-6.6.64/drivers/usb/core/hub.c
static void hub_event(struct work_struct *work)
// 打印 state 7 ports 1 chg 0002 evt 0000
usb_hcd_poll_rh_status
xhci_hub_status_data
hub_ext_port_status
usb_control_msg
// 长调用,打印 Get port status 2-1 read: 0x1603, return 0x203
*port_event(hub, i) -> hub_port_connect_change
// 打印 status 0203, change 0000, 10.0 Gb/s
hub_port_warm_reset_required
usb_alloc_dev
xhci_alloc_dev
xhci_queue_slot_control
xhci_ring_cmd_db
// 打印 // Ding dong!
usb_hcd_irq
xhci_irq
xhci_alloc_virt_device
// 打印 Slot 1 output ctx = 0x0x0000000812d0e000 (dma)
// 打印 Slot 1 input ctx = 0x0x0000000812d23000 (dma)
// 打印 Set slot id 1 dcbaa entry (____ptrval____) to 0x812d0e000
xhci_debugfs_create_slot
usb_enable_endpoint
usb_set_device_state
hub_port_init
hub_port_reset
hub_ext_port_status
usb_control_msg
// 长调用,打印 Get port status 2-1 read: 0x1603, return 0x203
hub_port_warm_reset_required
usb_control_msg
hub_ext_port_status
hub_port_warm_reset_required
usb_clear_port_feature // 打印 set port reset, actual port 2-1 status = 0x1711
usb_clear_port_feature
usb_clear_port_feature
usb_clear_port_feature
hub_ext_port_status
hub_port_warm_reset_required
xhci_discover_or_reset_device
xhci_check_args
xhci_get_slot_ctx
usb_set_device_state
usb_speed_string
xhci_address_device
xhci_setup_device
xhci_setup_addressable_virt_dev
xhci_queue_address_device
xhci_ring_cmd_db
usb_set_device_state
usb_ep0_reinit
usb_disable_endpoint
usb_hcd_flush_endpoint
usb_hcd_disable_endpoint
usb_disable_endpoint
usb_hcd_flush_endpoint
usb_hcd_disable_endpoint
usb_enable_endpoint
usb_control_msg
usb_set_isoch_delay
usb_control_msg_send
usb_get_device_descriptor
usb_get_descriptor
usb_detect_quirks
usb_detect_static_quirks
usb_get_bos_descriptor
usb_get_descriptor
usb_get_descriptor
usb_device_supports_lpm
xhci_update_device
usb_new_device
usb_get_configuration
usb_get_descriptor
usb_get_descriptor
usb_cache_string
usb_cache_string
usb_cache_string
usb_detect_interface_quirks
usb_bus_notify
usb_probe_device
usb_generic_driver_probe
usb_choose_configuration
usb_set_configuration
usb_hcd_alloc_bandwidth
xhci_add_endpoint
xhci_add_endpoint
xhci_check_bandwidth
usb_enable_interface
usb_enable_endpoint
usb_hcd_reset_endpoint
xhci_endpoint_reset
usb_enable_endpoint
usb_hcd_reset_endpoint
xhci_endpoint_reset
usb_control_msg_send
usb_set_device_state
usb_cache_string
usb_unlocked_enable_lpm
usb_enable_ltm
usb_probe_interface
usb_create_ep_devs
usb_create_ep_devs
usb_create_ep_devs

???
Get port status 2-1 read: 0x201603, return 0x100203
clear port1 reset change, portsc: 0x1603
clear port1 warm(BH) reset change, portsc: 0x1603
clear port1 link state change, portsc: 0x1603
clear port1 connect change, portsc: 0x1603
Get port status 2-1 read: 0x1603, return 0x203
Set root hub portnum to 2
Set fake root hub portnum to 1
udev->tt = 0000000000000000
udev->ttport = 0x0
// Ding dong!
Successful setup address command
???

sd_probe

portsc 值为0xa021603按位解析(详见linux-6.6.64/drivers/usb/host/xhci-port.h):

  • CONNECT (0): 1
  • PE(1): 1
  • PLS(8:5): 0 U0
  • POWER(9): 1
  • SPEED(13:10): 5 SSP
  • CSC(17): 1
  • WKCONN_E(25): 1
  • WKOC_E(27): 1

流程细节

中断

1
2
3
4
5
6
7
8
9
10
11
12
// linux-6.6.64/drivers/usb/core/hcd.c
irqreturn_t usb_hcd_irq (int irq, void *__hcd)
*hcd->driver->irq(hcd) // xhci_irq
*xhci_handle_event(xhci, ir) // 循环调用函数
*handle_port_status(xhci, ir, event) // 打印 Port change event, 2-1, id 2, portsc: 0xa021603
usb_hcd_is_primary_hcd
// 打印 resume root hub
usb_hcd_resume_root_hub
// 打印 handle_port_status: starting usb1 port polling.
usb_hcd_poll_rh_status(hcd)
hcd->driver->hub_status_data(hcd, buffer) // xhci_hub_status_data
// 打印 xhci_hub_status_data: stopping usb2 port polling

usb_control_msg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
usb_control_msg
usb_alloc_urb
usb_start_wait_urb
usb_submit_urb
usb_hcd_submit_urb
usb_get_urb
*rh_urb_enqueue(hcd, urb) -> rh_call_control (hcd, urb)
usb_hcd_link_urb_to_ep
hcd->driver->hub_control (hcd, // xhci_hub_control
xhci_get_port_status
// 打印 Get port status %d-%d read: 0x%x, return 0x%x
usb_hcd_unlink_urb_from_ep
usb_hcd_giveback_urb
usb_free_urb

附录

参考文档

先插播广告

使用Vultr,充值就送美金,便宜还可免费换ip

  1. 最低3.5美金(2.5美金的仅支持ipv6访问),性能足够使用!
  2. 可以保存快照,随时迁移新的IP地址,而且免费!
  3. 可以使用支付宝和微信,相当方便!

服务器端的工作

安装脚本

运行以下脚本即可:

1
curl -Ls https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh | sudo bash

里面可能会有些报错信息,暂时不管,完成之后就是配置了

获取用户ID

之前的脚本,不用手动配置脚本即可使用,现在使用以上脚本,需要自己配置config.json文件,首先获取用户ID:

运用指令:cat /proc/sys/kernel/random/uuid 创建一个用户 id ,并记住这个id号;

1
2
[root@vultr ~]# cat /proc/sys/kernel/random/uuid 
08ef6234-dcc0-45d1-9954-f9490cb2beb2

配置

配置文件路径为/usr/local/etc/v2ray/config.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"inbounds": [{
"port": 12345,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "08ef6234-dcc0-45d1-9954-f9490cb2beb2",
"level": 1,
"alterId": 0
}
]
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
},{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
"routing": {
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "blocked"
}
]
}
}

直接复制我上面的配置即可使用,id就是上面第二步获取的用户id

启动V2Ray

在首次安装完成之后,V2Ray不会自动启动,需要手动运行上述启动命令。而在已经运行V2Ray的VPS上再次执行安装脚本,安装脚本会自动停止V2Ray 进程,升级V2Ray程序,然后自动运行V2Ray。在升级过程中,配置文件不会被修改。

1
2
3
4
5
6
7
8
# 启动
systemctl start v2ray
# 停止
systemctl stop v2ray
# 重启
systemctl restart v2ray
# 使能
systemctl enable v2ray

关于软件更新:更新 V2Ray 的方法是再次执行安装脚本!再次执行安装脚本!再次执行安装脚本!

打开防火墙

centos系统防火墙默认是开启的,上面第三步你用了一个端口,因此你需要打开这个端口,指令如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 添加开放端口
firewall-cmd --zone=public --add-port=12345/tcp --permanent
# 重载防火墙配置,不然查看开放端口都查不到,也不能用,重载配置后即可
firewall-cmd --reload
# 删除端口
firewall-cmd --zone=public --remove-port=123456/tcp --permanent
# 查看已开放端口
firewall-cmd --zone=public --list-ports
# 查看防火墙firewalld状态
systemctl status firewalld
# 开启防火墙
systemctl start firewalld
# 关闭防火墙
systemctl stop firewalld

如果哪一天发现怎么无法使用了,有可能是IP被屏蔽,也有肯能是端口被封,这个时候就需要换个端口,别忘记防火墙开启新端口,那旧端口就可以删除了

客户端下载和使用

Windows客户端下载

工具下载

v2ray-core发布地址

v2rayN发布地址

Android客户端下载

工具下载

v2rayNG发布地址

官方机器翻译版本

官方参考手册:

开发板整体布局AN385 - ARM Cortex-M3 SMM on V2M-MPS2

子系统相关Cortex-M System Design Kit Technical Reference Manual r1p0

代码为官方示例程序:FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC

系统结构

配置文件

FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/FreeRTOSConfig.h工程下的系统配置文件

  • configSUPPORT_DYNAMIC_ALLOCATION 栈内存管理

关键组件

1
2
3
4
5
6
7
8
FreeRTOS
|-Source
|-tasks.c # 必备;提供任务管理
list.c # 必备;提供列表管理
queue.c # 基本必备;提供队列管理
timers.c # 可选;提供定时器管理
event_groups.c # 可选;提供事件组管理
croutine.c # 可选;提供协程管理

FreeRTOS/Source/portable/MemMang提供heap_1~5堆申请实现

头文件路径:

  • FreeRTOS/Source/include系统内核头文件
  • FreeRTOS/Source/portable/[compiler]/[architecture]BSP头文件
  • FreeRTOSConfig.h配置文件

BSP

FreeRTOS/Source/portable/[compiler]/[architecture]特定编译器和架构的文件

M3内核寄存器

r0~r12

sp

lr

pc

xpsr

初始化

重置入口Reset_Handler

初始化pc寄存器指向0x80(应该有默认引导指向这里)

mps2_m3.ld定义了内存分布和关键变量分布,ld是ARM的链接配置文件,在编译时有-T ./scripts/mps2_m3.ld选项指定。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// 文件FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/scripts/mps2_m3.ld

MEMORY
{
FLASH (xr) : ORIGIN = 0x00000000, LENGTH = 4M /* to 0x00003FFF = 0x007FFFFF*/
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 4M /* to 0x21FFFFFF = 0xFFFFFF */
}
ENTRY(Reset_Handler)

_estack = ORIGIN(RAM) + LENGTH(RAM);

_sidata = LOADADDR(.data);

.data : /* AT ( _sidata ) */
{
. = ALIGN(4);
_sdata = .;
*(.data*)
. = ALIGN(4);
_edata = .;
} > RAM AT > FLASH

.bss :
{
. = ALIGN(4);
_sbss = .;
__bss_start__ = _sbss;
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .;
__bss_end__ = _ebss;
} >RAM

ENTRY(Reset_Handler)指定汇编入口

这里_sidata变量为代码的.data起始处数据(地址为0x56e8)。_sdata_edata分别是4字节对齐(ARM处理器没对齐会出现异常)用于存放.data数据的内存起止数据处(地址为0x200001000x20000178)。

_sbss_ebss分别是内存.bss区域起止数据(地址为0x200001800x200064a0)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/init/startup.c
/* Prevent optimization so gcc does not replace code with memcpy */
__attribute__((optimize("O0")))
__attribute__((naked)) void
Reset_Handler(void)
{
/* set stack pointer */
__asm volatile("ldr r0, =_estack");
__asm volatile("mov sp, r0");

/* copy .data section from flash to RAM */
for (uint32_t *src = &_sidata, *dest = &_sdata; dest < &_edata;)
{
*dest++ = *src++;
}

/* zero out .bss section */
for (uint32_t *dest = &_sbss; dest < &_ebss;)
{
*dest++ = 0;
}

/* jump to board initialisation */
void _start(void);
_start();
}

设置栈指针

入口函数__attribute__((optimize("O0"))) __attribute__((naked))定义避免优化,这两个是属于GNU C的编译属性控制编译过程。

__asm volatile("ldr r0, =_estack");__asm封装为asm,标注C内联汇编,volatile直接从Flash上读取_estack的值,这个值在就是0x20400000,即将栈指针指向内存最高处。

拷贝.data区域

将Flash的.data区域拷贝到内存中,内存中数据起止地址4字节对齐。

清空.bss区域

将内存.bss区域数据清零。

跳转启动函数

跳转到C语言入口处函数_start

启动函数_start

首先初始化串口,再进入主函数

1
2
3
4
5
6
7
8
// FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/init/startup.c

void _start(void)
{
uart_init();
main(0, 0);
exit(0);
}

串口初始化uart_init

配置波特率并开启发送

1
2
3
4
5
6
7
// FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/syscall.c

void uart_init()
{
UART0_ADDR->BAUDDIV = 16;
UART0_ADDR->CTRL = UART_CTRL_TX_EN;
}

主函数main

这里也只负责调用不同实现

1
2
3
4
5
6
7
// FreeRTOSv202112.00/FreeRTOS/Demo/CORTEX_M3_MPS2_QEMU_GCC/main_blinky.c

int main()
{
main_blinky();
return 0;
}

示例函数main_blinky

首先创建队列用于两任务进行通信。再创建收发队列任务,启动任务调度器。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
void main_blinky( void )
{
/* Create the queue. */
xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );

if( xQueue != NULL )
{
/* Start the two tasks as described in the comments at the top of this
* file. */
xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */
"Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */
configMINIMAL_STACK_SIZE, /* The size of the stack to allocate to the task. */
NULL, /* The parameter passed to the task - not used in this case. */
mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */
NULL ); /* The task handle is not required, so NULL is passed. */

xTaskCreate( prvQueueSendTask,
"TX",
configMINIMAL_STACK_SIZE,
NULL,
mainQUEUE_SEND_TASK_PRIORITY,
NULL );

/* Start the tasks and timer running. */
vTaskStartScheduler();
}

/* If all is well, the scheduler will now be running, and the following
* line will never be reached. If the following line does execute, then
* there was insufficient FreeRTOS heap memory available for the Idle and/or
* timer tasks to be created. See the memory management section on the
* FreeRTOS web site for more details on the FreeRTOS heap
* http://www.freertos.org/a00111.html. */
for( ; ; )
{
}
}

系统函数

队列-创建

1
2
3
4
5
6
7
8
9
10
11
12
// FreeRTOSv202112.00/FreeRTOS/Source/queue.c
QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength,
const UBaseType_t uxItemSize,
const uint8_t ucQueueType )

// FreeRTOSv202112.00/FreeRTOS-Plus/Source/AWS/ota/test/cbmc/FreeRTOS-Kernel/include/queue.h
#define queueQUEUE_TYPE_BASE ( ( uint8_t ) 0U )
#define queueQUEUE_TYPE_SET ( ( uint8_t ) 0U )
#define queueQUEUE_TYPE_MUTEX ( ( uint8_t ) 1U )
#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( ( uint8_t ) 2U )
#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( ( uint8_t ) 3U )
#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( ( uint8_t ) 4U )

输入参数

  • uxQueueLength队列长度
  • uxItemSize队列元素大小
  • ucQueueType队列类型,参考头文件可以填写queueQUEUE_TYPE_xxx

输出参数

  • QueueHandle_t队列指针

内部调用逻辑

1
2
3
4
5
6
7
8
9
xQueueGenericCreate
|-pvPortMalloc // 申请足够的内存
|-vTaskSuspendAll // 进入关键区域,将调度器挂起uxSchedulerSuspended加1,
|-portSOFTWARE_BARRIER // 等待内部中断xInsideInterrupt处理完
portMEMORY_BARRIER // 内存屏障,M3不需要??
xTaskResumeAll
malloc // C库函数,申请内存
prvInitialiseNewQueue // 初始化队列结构
|-xQueueGenericReset // 队列通用初始化,为结构体赋值

其他

队列内存结构为:Queue_t头部信息数据+元素数据列表

队列-发送数据

队列-接收数据

任务-全部恢复

1
BaseType_t xTaskResumeAll( void )

注意

函数xTaskResumeAll与函数vTaskSuspendAll需要成对出现

内部调用逻辑

1
2
xTaskResumeAll
|-vPortEnterCritical # 宏包装taskENTER_CRITICAL

列表

1
2
// FreeRTOSv202112.00/FreeRTOS/Source/list.c
void vListInitialise( List_t * const pxList )

关键结构

时钟滴答

TickType_t

configUSE_16_BIT_TICKS时钟滴答计数值类型。1–16位uint16_t;0–32位uint32_t

基本数据

BaseType_t

定义为架构中执行效率最高的数据类型。它的典型的是,32位架构上为32位,16位架构上为16位,8位架构上为8位。

布尔型pdTRUE/pdFALSE也被定义为BaseType_t

队列

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
typedef xQUEUE Queue_t;

typedef struct QueueDefinition
{
int8_t *pcHead; /*< 指向存储数据区开始处,即跳过头部区域 */
int8_t *pcWriteTo; /*< 指向存储数据区可使用处,跳过已经入队的元素 */

union
{
QueuePointers_t xQueue; /*< 队列数据,pcTail指向存储数据区结束处;pcReadFrom指向存储数据区最后一元素区域 */
SemaphoreData_t xSemaphore; /*< 信号量使用 */
} u;

List_t xTasksWaitingToSend; /*< 阻塞等待写入数据的任务列表,按优先级排序 */
List_t xTasksWaitingToReceive; /*< 阻塞等待读取数据的任务列表,按优先级排序. */

volatile UBaseType_t uxMessagesWaiting; /*< 当前队列中元素个数 */
UBaseType_t uxLength; /*< 队列元素个数. */
UBaseType_t uxItemSize; /*< 队列元素大小 */

volatile int8_t cRxLock; /*< 上锁时,存储从队列移除元素数;无锁时,值为queueUNLOCKED */
volatile int8_t cTxLock; /*< 上锁时,存储向队列添加元素数;无锁时,值为queueUNLOCKED */

#if ((configSUPPORT_STATIC_ALLOCATION == 1) && (configSUPPORT_DYNAMIC_ALLOCATION == 1))
uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the memory used by the queue was statically allocated to ensure no attempt is made to free the memory. */
#endif

#if (configUSE_QUEUE_SETS == 1)
struct QueueDefinition *pxQueueSetContainer;
#endif

#if (configUSE_TRACE_FACILITY == 1)
UBaseType_t uxQueueNumber;
uint8_t ucQueueType; /*< 队列类型 */
#endif
} xQUEUE;

任务控制块

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
typedef tskTCB TCB_t;

typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
volatile StackType_t * pxTopOfStack; /*< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */

#if ( portUSING_MPU_WRAPPERS == 1 )
xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */
#endif

ListItem_t xStateListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
ListItem_t xEventListItem; /*< Used to reference a task from an event list. */
UBaseType_t uxPriority; /*< The priority of the task. 0 is the lowest priority. */
StackType_t * pxStack; /*< Points to the start of the stack. */
char pcTaskName[ configMAX_TASK_NAME_LEN ]; /*< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */

#if ( ( portSTACK_GROWTH > 0 ) || ( configRECORD_STACK_HIGH_ADDRESS == 1 ) )
StackType_t * pxEndOfStack; /*< Points to the highest valid address for the stack. */
#endif

#if ( portCRITICAL_NESTING_IN_TCB == 1 )
UBaseType_t uxCriticalNesting; /*< Holds the critical section nesting depth for ports that do not maintain their own count in the port layer. */
#endif

#if ( configUSE_TRACE_FACILITY == 1 )
UBaseType_t uxTCBNumber; /*< Stores a number that increments each time a TCB is created. It allows debuggers to determine when a task has been deleted and then recreated. */
UBaseType_t uxTaskNumber; /*< Stores a number specifically for use by third party trace code. */
#endif

#if ( configUSE_MUTEXES == 1 )
UBaseType_t uxBasePriority; /*< The priority last assigned to the task - used by the priority inheritance mechanism. */
UBaseType_t uxMutexesHeld;
#endif

#if ( configUSE_APPLICATION_TASK_TAG == 1 )
TaskHookFunction_t pxTaskTag;
#endif

#if ( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
void * pvThreadLocalStoragePointers[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
#endif

#if ( configGENERATE_RUN_TIME_STATS == 1 )
configRUN_TIME_COUNTER_TYPE ulRunTimeCounter; /*< Stores the amount of time the task has spent in the Running state. */
#endif

#if ( configUSE_NEWLIB_REENTRANT == 1 )

/* Allocate a Newlib reent structure that is specific to this task.
* Note Newlib support has been included by popular demand, but is not
* used by the FreeRTOS maintainers themselves. FreeRTOS is not
* responsible for resulting newlib operation. User must be familiar with
* newlib and must provide system-wide implementations of the necessary
* stubs. Be warned that (at the time of writing) the current newlib design
* implements a system-wide malloc() that must be provided with locks.
*
* See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html
* for additional information. */
struct _reent xNewLib_reent;
#endif

#if ( configUSE_TASK_NOTIFICATIONS == 1 )
volatile uint32_t ulNotifiedValue[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
volatile uint8_t ucNotifyState[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
#endif

/* See the comments in FreeRTOS.h with the definition of
* tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE. */
#if ( tskSTATIC_AND_DYNAMIC_ALLOCATION_POSSIBLE != 0 ) /*lint !e731 !e9029 Macro has been consolidated for readability reasons. */
uint8_t ucStaticallyAllocated; /*< Set to pdTRUE if the task is a statically allocated to ensure no attempt is made to free the memory. */
#endif

#if ( INCLUDE_xTaskAbortDelay == 1 )
uint8_t ucDelayAborted;
#endif

#if ( configUSE_POSIX_ERRNO == 1 )
int iTaskErrno;
#endif
} tskTCB;

目标

移植CORTEX_LM3S811_GCC为QEMU中运行

问题

内联汇编指令寄存器重排

__asm volatile("push {r1,r0,lr}");实际产生的汇编是push {r0,r1,lr},容易造成pop {r3,r4,lr}理解偏差。

官方手册简介

所有变量类型都显示声明为signedunsigned

变量命名规则:c代表chars代表int16_tl代表int32_t(long)x代表BaseType_t;前缀u代表unsignedp代表指针;

函数命名规则:使用前缀标识返回值类型;在变量命名规则上,增加v代表void

宏名称命名规则:使用小写单词开头标明宏定义位置;

堆管理

基本情况

C标准库的内存管理不适合嵌入式的原因:

  • 在小型嵌入式系统中并不是都是可用的;
  • 实现体积比较大,会消耗可贵的代码空间;
  • 很少是线程安全的;
  • 运行不确定性;执行函数所花费的时间在不同调用会有差异;
  • 会遭受内存碎片侵蚀;
  • 会使链接器配置变复杂;
  • 若允许栈空间增长到正在使用的内存中,它们可能称为难以调试错误的来源;

pvPortMalloc

vPortFree

FreeRTOS/Source/portable/MemMang中定义了5中栈管理方式:heap_1~heap_5

configTOTAL_HEAP_SIZE配置栈空间大小

创建每个任务都需要从内存分配任务控制块(Task Control Block, TCB)和栈空间。

申请内存

Heap_1

适合仅仅创建任务和其他内核对象的场景。只实现内存申请,而没有实现内存释放接口。

image-20230219214120657

Heap_2

提前分配内存块,大小由参数决定

configTOTAL_HEAP_SIZE

适合重复创建任务,但任务大小一致的场景

image-20230222092456582

非确定性,当运行速度比标准库块

推荐使用Heap_4代替Heap_2

Heap_3

使用标准库函数管理内存,通过暂停调度来保障线程安全

Heap_4

与Heap_1和Heap_4一样,将内存划分为小块。

拥有合并相邻空闲内存的功能,减少内存碎片的风险。

image-20230222093624554

有时需要确保使用的是内部内存,可以配置configAPPLICATION_ALLOCATED_HEAP为1,内存数据将由应用程序声明的数据替换。数据类型为uint8_tucHeap数组,大小为configTOTAL_HEAP_SIZE。

不同编译器的语法不一样。

使用GCC语法声明heap_4使用的数组,数组将会在.my_heap区域:

1
uint8_t ucHeap[configTOTAL_HEAP_SIZE] __attribute__((section(".my_heap")));

使用IAR语法声明heap_4使用的数组,数组将会在绝对地址0x20000000处:

1
uint8_t ucHeap[configTOTAL_HEAP_SIZE] @ 0x20000000;

Heap_5

分配算法与Heap_4一样,不同的是,Heap_5可以使用非连续的内存区域。

在使用前,必须显示调用vPortDefineHeapRegions()完成内存初始化。函数参数是区域结构体数组,每块区域结构体类型为HeapRegion_t

1
2
3
4
5
typedef struct HeapRegion
{
uint8_t *pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;

显示声明时,内存地址pucStartAddress必须从低到高的顺序声明,并且有结束的区域pucStartAddress=NULL

例如有三块内存区域:

image-20230222102857053

使用Heap_5需要显示初始化这几块内存

1
2
3
4
5
6
7
8
9
10
11
12
const HeapRegion_t xHeapRegion[] = 
{
{(uint8_t *)0x00010000, 65*1024},
{(uint8_t *)0x00020000, 32*1024},
{(uint8_t *)0x00030000, 32*1024},
{NULL, 0},
};

int main(void)
{
vPortDefineHeapRegions(xHeapRegion);
}

若真按上面代码初始化,就没有内存给其他变量使用。在项目中,链接阶段将会分配每个变量内存地址。可以将RAM1划分为两个区域,0x0001nnn以上区域由系统内存管理。优化后的GCC版本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#define RAM1_HEAP_SIZE (30*1024)
static uint8_t ucHeap[RAM1_HEAP_SIZE];

const HeapRegion_t xHeapRegion[] =
{
{ucHeap, RAM1_HEAP_SIZE},
{(uint8_t *)0x00020000, 32*1024},
{(uint8_t *)0x00030000, 32*1024},
{NULL, 0},
};

int main(void)
{
vPortDefineHeapRegions(xHeapRegion);
}

堆相关函数

xPortGetFreeHeapSize

函数原型:

1
size_t xPortGetFreeHeapSize( void );

返回堆中可用字节数。

使用heap_3时,函数不可用。

xPortGetMinimumEverFreeHeapSize

函数原型:

1
size_t xPortGetMinimumEverFreeHeapSize( void );

返回应用开始执行后,历史最小可用字节数。

只有heap_4和heap_5可使用此函数。

内存申请失败钩子函数

当调用pvPortMalloc没有足够内存时,将会返回NULL,即内存申请失败。若应用需要处理这种场景,需要配置configUSE_MALLOC_FAILED_HOOK,然后应用需要实现内存申请失败钩子函数,原型如下:

1
void vApplicationMallocFailedHook( void );

任务管理

3.1 章节介绍和范围

范围

本章旨在让读者很好地理解:

  • FreeRTOS如何为应用程序中的每个任务分配处理时间。

  • FreeRTOS如何在任何给定时间内选择任务执行。

  • 每个任务的相对优先级如何影响系统行为。

  • 任务可以存在的状态。

读者还可以容易理解:

  • 如何实现任务。
  • 如何创建一个或多个任务的实例。
  • 如何使用任务参数。
  • 如何更改已经创建的任务的优先级。
  • 如何删除一个任务。
  • 如何使用任务实现周期性处理(软件计时器将在后面的一章中讨论)。
  • 空闲任务的执行时间以及如何使用它。

本章中介绍的概念是理解FreeRTOS的基础:如何使用系统和系统应用程序的行为。所以,这也是本书中最详细章节。

3.2 任务函数

任务都是由C语言函数实现。它们唯一特殊之处在于函数原型,它必须返回void类型并接受一个void类型指针。Listing 11展示了函数原型:

1
2
// Listing 11
void ATaskFunction( void *pvParameters );

每个任务本身都是一个小程序。它有一个入口,通常会在无限循环中永久运行,并且不会退出。Listing 12展示了典型的任务结构。

1
2
3
4
5
6
7
8
9
10
11
12
13
// Listing 12
void ATaskFunction( void *pvParameters )
{
/* 变量可以像普通函数一样进行声明。使用此示例函数创建的每个任务实例,都有其lVariableExample变量的副本。如果变量声明为静态,这就是错误的。在这种情况下,变量只有一个副本,并且副本将被创建的任务实例共享。(变量名称中的前缀参考章节1.5 数据类型和编码风格指南。) */
int32_t lVariableExample = 0;
/* 任务通常被实现为无限循环。 */
for( ;; )
{
/* 实现任务功能的代码写到这里。 */
}
/* 即使任务跳出循环,那么必须在其实现函数结束之前将任务删除。传递给vTaskDelete() API函数的NULL参数,它表示要删除的是调用(此)任务。API函数命名规范在0章节中已描述。 */
vTaskDelete( NULL );
}

任务不需要,应该调用删除任务

1
2
3
4
5
6
7
8
9
10
11
void ATaskFunction( void *pvParameters )
{
int32_t lVariableExample = 0;
/* 一般就是无限循环 */
for( ;; )
{
/* 任务功能代码逻辑. */
}
/* 一定要返回,需要显示调用删除 */
vTaskDelete( NULL );
}

顶层任务状态

简化模型,假定系统中只有一个核,有许多任务需要运行。当任务为运行状态时,处理器会执行任务代码。当任务为非运行状态时,任务被休眠,运行上下文将会被保存。当任务恢复运行状态时,运行上下文也需要恢复。

由非运行态转为运行态的任务称为被切入或换入,反之,称为被切出或换出。系统中调度器是唯一能切换任务的实体。

image-20230222111533707

创建任务

xTaskCreate

函数原型:

1
2
3
4
5
6
BaseType_t xTaskCreate( TaskFunction_t pvTaskCode, 
const char * const pcName,
uint16_t usStackDepth,
void *pvParameters,
UBaseType_t uxPriority,
TaskHandle_t *pxCreatedTask );

这可能是所有API中最复杂的,但任务也是多任务系统的最基本组件。

参数表

参数名描述
pvTaskCode任务函数入口
pcName任务的描述名称。configMAX_TASK_NAME_LEN配置名称最大长度。超过会被截断
usStackDepth任务使用的栈大小,单位是字(words)。configMINIMAL_STACK_SIZE配置空闲任务和任务最小栈大小。
pvParameters任务使用的void*类型参数指针。
uxPriority指定任务运行优先级,范围0-(configMAX_PRIORITIES – 1),最低优先级为0。
pxCreatedTask创建的任务句柄,可以会被其他接口引用。没有需要可以设置为NULL。

返回值

pdPASS创建成功;pdFAIL创建失败;

Example 1 创建任务

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void vTask1( void *pvParameters )
{
const char *pcTaskName = "Task 1 is running\r\n";
volatile uint32_t ul; /* volatile to ensure ul is not optimized away. */
/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{
/* Print out the name of this task. */
vPrintString( pcTaskName );
/* Delay for a period. */
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
{
/* This loop is just a very crude delay implementation. There is
nothing to do in here. Later examples will replace this crude
loop with a proper delay/sleep function. */
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void vTask2( void *pvParameters )
{
const char *pcTaskName = "Task 2 is running\r\n";
volatile uint32_t ul; /* volatile to ensure ul is not optimized away. */
/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{
/* Print out the name of this task. */
vPrintString( pcTaskName );
/* Delay for a period. */
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
{
/* This loop is just a very crude delay implementation. There is
nothing to do in here. Later examples will replace this crude
loop with a proper delay/sleep function. */
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int main( void )
{
/* Create one of the two tasks. Note that a real application should check
the return value of the xTaskCreate() call to ensure the task was created
successfully. */
xTaskCreate( vTask1, /* Pointer to the function that implements the task. */
"Task 1",/* Text name for the task. This is to facilitate
debugging only. */
1000, /* Stack depth - small microcontrollers will use much
less stack than this. */
NULL, /* This example does not use the task parameter. */
1, /* This task will run at priority 1. */
NULL ); /* This example does not use the task handle. */
/* Create the other task in exactly the same way and at the same priority. */
xTaskCreate( vTask2, "Task 2", 1000, NULL, 1, NULL );
/* Start the scheduler so the tasks start executing. */
vTaskStartScheduler();

/* If all is well then main() will never reach here as the scheduler will
now be running the tasks. If main() does reach here then it is likely that
there was insufficient heap memory available for the idle task to be created.
Chapter 2 provides more information on heap memory management. */
for( ;; );
}
image-20230222175228346

Task2可以被Task1创建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void vTask1( void *pvParameters )
{
const char *pcTaskName = "Task 1 is running\r\n";
volatile uint32_t ul; /* volatile to ensure ul is not optimized away. */
/* If this task code is executing then the scheduler must already have
been started. Create the other task before entering the infinite loop. */
xTaskCreate( vTask2, "Task 2", 1000, NULL, 1, NULL );
for( ;; )
{
/* Print out the name of this task. */
vPrintString( pcTaskName );
/* Delay for a period. */
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
{
/* This loop is just a very crude delay implementation. There is
nothing to do in here. Later examples will replace this crude
loop with a proper delay/sleep function. */
}
}
}

Example 2 使用任务参数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void vTaskFunction( void *pvParameters )
{
char *pcTaskName;
volatile uint32_t ul; /* volatile to ensure ul is not optimized away. */
/* The string to print out is passed in via the parameter. Cast this to a
character pointer. */
pcTaskName = ( char * ) pvParameters;
/* As per most tasks, this task is implemented in an infinite loop. */
for( ;; )
{
/* Print out the name of this task. */
vPrintString( pcTaskName );
/* Delay for a period. */
for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
{
/* This loop is just a very crude delay implementation. There is
nothing to do in here. Later exercises will replace this crude
loop with a proper delay/sleep function. */
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* Define the strings that will be passed in as the task parameters. These are
defined const and not on the stack to ensure they remain valid when the tasks are
executing. */
static const char *pcTextForTask1 = "Task 1 is running\r\n";
static const char *pcTextForTask2 = "Task 2 is running\r\n";
int main( void )
{
/* Create one of the two tasks. */
xTaskCreate( vTaskFunction, /* Pointer to the function that
implements the task. */
"Task 1", /* Text name for the task. This is to
facilitate debugging only. */
1000, /* Stack depth - small microcontrollers
will use much less stack than this. */
(void*)pcTextForTask1, /* Pass the text to be printed into the
task using the task parameter. */
1, /* This task will run at priority 1. */
NULL ); /* The task handle is not used in this
example. */
/* Create the other task in exactly the same way. Note this time that multiple
tasks are being created from the SAME task implementation (vTaskFunction). Only
the value passed in the parameter is different. Two instances of the same
task are being created. */
xTaskCreate( vTaskFunction, "Task 2", 1000, (void*)pcTextForTask2, 1, NULL );
/* Start the scheduler so the tasks start executing. */
vTaskStartScheduler();

/* If all is well then main() will never reach here as the scheduler will
now be running the tasks. If main() does reach here then it is likely that
there was insufficient heap memory available for the idle task to be created.
Chapter 2 provides more information on heap memory management. */
for( ;; );
}

任务优先级

configMAX_PRIORITIES

configUSE_PORT_OPTIMISED_TASK_SELECTION

时间尺度和滴答中断

configTICK_RATE_HZ

100

image-20230223094018410

pdMS_TO_TICKS()

Example 3. Experimenting with priorities

image-20230223094342546

扩展非运行状态

阻塞状态(Blocked)

暂停状态(Suspended)

就绪状态(Ready)

完整的状态切换图

image-20230223094909681

Example 4. Using the Blocked state to create a delay

INCLUDE_vTaskDelay

1
void vTaskDelay( TickType_t xTicksToDelay );
image-20230223095233646

vTaskDelayUntil()函数

1
void vTaskDelayUntil( TickType_t * pxPreviousWakeTime, TickType_t xTimeIncrement );

Example 5. Converting the example tasks to use vTaskDelayUntil()

Example 6. Combining blocking and non-blocking tasks

image-20230223100440966

空闲任务和钩子函数

configIDLE_SHOULD_YIELD

清理内核资源

空闲任务钩子函数

使用场景

空闲任务钩子函数的限制

使用事项

1
void vApplicationIdleHook( void );

configUSE_IDLE_HOOK

改变任务优先级

vTaskPrioritySet()

1
void vTaskPrioritySet( TaskHandle_t pxTask, UBaseType_t uxNewPriority );

uxTaskPriorityGet()

1
UBaseType_t uxTaskPriorityGet( TaskHandle_t pxTask );

Example 8. Changing task priorities

删除任务

vTaskDelete()

INCLUDE_vTaskDelete

1
void vTaskDelete( TaskHandle_t pxTaskToDelete );

Example 9. Deleting tasks

线程本地存储

调度算法

任务状态和事件回顾

Running

Ready

Blocked

Suspended

配置调度算法

configUSE_PREEMPTION

configUSE_TIME_SLICING

configUSE_TICKLESS_IDLE

Round Robin Scheduling

Fixed Priority Pre-emptive Scheduling with Time Slicing

基于时间片优先级抢占调度

image-20230224092259473
image-20230224092550083

configIDLE_SHOULD_YIELD=1

image-20230224093117397

优先级抢占调度(无时间片)

image-20230224094055809

合作调度

image-20230224095111125

队列管理

队列特性

数据存储

First In First Out FIFO

image-20230224095944873

多任务访问

队列读取阻塞

队列写入阻塞

多队列阻塞

使用队列

xQueueCreate

QueueHandle_t

1
QueueHandle_t xQueueCreate( UBaseType_t uxQueueLength, UBaseType_t uxItemSize );

xQueueSendToBack/xQueueSendToFront

xQueueSend

1
2
3
4
5
6
BaseType_t xQueueSendToFront( QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait );
BaseType_t xQueueSendToBack( QueueHandle_t xQueue,
const void * pvItemToQueue,
TickType_t xTicksToWait );

portMAX_DELAY

INCLUDE_vTaskSuspend

pdPASS

errQUEUE_FULL

xQueueReceive

1
2
3
BaseType_t xQueueReceive( QueueHandle_t xQueue,
void * const pvBuffer,
TickType_t xTicksToWait );

pdPASS

errQUEUE_EMPTY

uxQueueMessagesWaiting

1
UBaseType_t uxQueueMessagesWaiting( QueueHandle_t xQueue );

Example 10. Blocking when receiving from a queue

image-20230224140047388

从多个源接收数据

image-20230224140141858

Example 11. Blocking when sending to a queue, and sending structures on a queue

image-20230224140630606

传输大量或可变大小的数据

队列指针

使用队列传输不同类型和长度数据

IPStackEvent_t

从多个队列接收

队列集

xQueueCreateSet

1
QueueSetHandle_t xQueueCreateSet( const UBaseType_t uxEventQueueLength );

uxEventQueueLength 每个队列最大长度和

xQueueAddToSet

1
2
BaseType_t xQueueAddToSet( QueueSetMemberHandle_t xQueueOrSemaphore, 
QueueSetHandle_t xQueueSet );

xQueueSelectFromSet

1
2
QueueSetMemberHandle_t xQueueSelectFromSet( QueueSetHandle_t xQueueSet,
const TickType_t xTicksToWait );

Example 12. Using a Queue Set

More Realistic Queue Set Use Cases

使用队列构建邮箱

xQueueOverwrite

1
BaseType_t xQueueOverwrite( QueueHandle_t xQueue, const void * pvItemToQueue );

xQueuePeek

1
2
3
BaseType_t xQueuePeek( QueueHandle_t xQueue,
void * const pvBuffer,
TickType_t xTicksToWait );

软件计时器管理

FreeRTOS/Source/timers.c

configUSE_TIMERS

软件计时器回调函数

1
void ATimerCallback( TimerHandle_t xTimer );

不能调用可能进入阻塞状态的API

软件计时器的属性和状态

软件计时器的周期

单次和自动重载计时器

image-20230227140145505

软件计时器状态

休眠

运行

image-20230227140355152
image-20230227140419033

软件计时器上下文

RTOS守护任务

configTIMER_TASK_PRIORITY

configTIMER_TASK_STACK_DEPTH

不能调用可能进入阻塞状态的API

计时器命令队列

configTIMER_QUEUE_LENGTH

image-20230227140850116

守护任务调度

image-20230227141013158
image-20230227141229467

创建并启动一个软件计时器

xTimerCreate

1
2
3
4
5
TimerHandle_t xTimerCreate( const char * const pcTimerName,
TickType_t xTimerPeriodInTicks,
UBaseType_t uxAutoReload,
void * pvTimerID,
TimerCallbackFunction_t pxCallbackFunction );

xTimerStart

1
BaseType_t xTimerStart( TimerHandle_t xTimer, TickType_t xTicksToWait );

INCLUDE_vTaskSuspend

portMAX_DELAY

Example 13. Creating one-shot and auto-reload timers

计时器编号

vTimerSetTimerID

1
void vTimerSetTimerID( const TimerHandle_t xTimer, void *pvNewID );

pvTimerGetTimerID

1
void *pvTimerGetTimerID( TimerHandle_t xTimer );

Example 14. Using the callback function parameter and the software timer ID

改变计时器周期

xTimerChangePeriod

1
2
3
BaseType_t xTimerChangePeriod( TimerHandle_t xTimer, 
TickType_t xNewTimerPeriodInTicks,
TickType_t xTicksToWait );

重置软件计时器

image-20230228092540839

xTimerReset

1
BaseType_t xTimerReset( TimerHandle_t xTimer, TickType_t xTicksToWait );

Example 15. Resetting a software timer

中断管理

ISR中使用系统API

中断安全API

FromISR

使用独立的中断安全API的优势

使用独立的中断安全API的劣势

xHigherPriorityTaskWoken参数

一般用pbFALSE

portYIELD_FROM_ISR和portEND_SWITCHING_ISR宏

taskYIELD

1
2
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );

延时中断处理

image-20230228134407138

用于同步的二进制信号量

image-20230228135032388
image-20230228135534394

xSemaphoreCreateBinary

1
SemaphoreHandle_t xSemaphoreCreateBinary( void );

xSemaphoreTake

1
BaseType_t xSemaphoreTake( SemaphoreHandle_t xSemaphore, TickType_t xTicksToWait );

xSemaphoreGiveFromISR

1
2
BaseType_t xSemaphoreGiveFromISR( SemaphoreHandle_t xSemaphore, 
BaseType_t *pxHigherPriorityTaskWoken );

Example 16. Using a binary semaphore to synchronize a task with an interrupt

vPortGenerateSimulatedInterrupt

vPortSetInterruptHandler

image-20230228140557184

Improving the Implementation of the Task Used in Example 16

image-20230228140947975
image-20230228141049239

计数信号量

configUSE_COUNTING_SEMAPHORES

image-20230301092559990

xSemaphoreCreateCounting

1
2
SemaphoreHandle_t xSemaphoreCreateCounting( UBaseType_t uxMaxCount,
UBaseType_t uxInitialCount );

Example 17. Using a counting semaphore to synchronize a task with an interrupt

延时工作到系统守护任务

xTimerPendFunctionCallFromISR

1
2
3
4
5
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend,
void *pvParameter1,
uint32_t ulParameter2,
BaseType_t *pxHigherPriorityTaskWoken );
void vPendableFunction( void *pvParameter1, uint32_t ulParameter2 );

Example 18. Centralized deferred interrupt processing

image-20230301093446475

在中断服务函数(ISR)中使用队列

xQueueSendToFrontFromISR和xQueueSendToBackFromISR

1
2
3
4
5
6
7
8
BaseType_t xQueueSendToFrontFromISR( QueueHandle_t xQueue, 
void *pvItemToQueue
BaseType_t *pxHigherPriorityTaskWoken
);
BaseType_t xQueueSendToBackFromISR( QueueHandle_t xQueue,
void *pvItemToQueue
BaseType_t *pxHigherPriorityTaskWoken
);

考虑合适使用ISR队列

DMA

Example 19. Sending and receiving on a queue from within an interrupt

image-20230301094553407

中断嵌套

configMAX_SYSCALL_INTERRUPT_PRIORITY

configMAX_API_CALL_INTERRUPT_PRIORITY

configKERNEL_INTERRUPT_PRIORITY

数字优先级

逻辑优先级

image-20230301100213478

ARM Cortex-M1和GIC的用户说明

configASSERT

image-20230301101125569

资源管理

互斥现象

临界段和暂停调度器

临界段基础

taskENTER_CRITICAL

taskEXIT_CRITICAL

configMAX_SYSCALL_INTERRUPT_PRIORITY

taskENTER_CRITICAL_FROM_ISR

taskEXIT_CRITICAL_FROM_ISR

暂停调度器

vTaskSuspendAll

1
void vTaskSuspendAll( void );

xTaskResumeAll

1
BaseType_t xTaskResumeAll( void );

互斥体(二进制信号量)

image-20230302134248107

xSemaphoreCreateMutex

1
SemaphoreHandle_t xSemaphoreCreateMutex( void );

Example 20. Rewriting vPrintString() to use a semaphore

image-20230302134426159

优先级反转

image-20230302134556524

优先级继承

image-20230302134936848

死锁

递归互斥锁

xSemaphoreCreateRecursiveMutex

xSemaphoreTakeRecursive

xSemaphoreGiveRecursive

互斥锁和任务调度

image-20230303091409614
image-20230303092336449

守护任务

只有守护任务才能直接访问资源

Example 21. Re-writing vPrintString() to use a gatekeeper task

configUSE_TICK_HOOK

1
void vApplicationTickHook( void );

事件组

事件组特性

EventBits_t

image-20230306093213414
image-20230306093348768

EventBits_t数据类型细节

configUSE_16_BIT_TICKS

多任务访问

使用事件组的一个实际实例

FreeRTOS+TCP TCP/IP

FreeRTOS_Socket_t

使用事件组的事件管理

xEventGroupCreate

1
EventGroupHandle_t xEventGroupCreate( void );

xEventGroupSetBits

1
2
EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet );

xEventGroupSetBitsFromISR

1
2
3
BaseType_t xEventGroupSetBitsFromISR( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet,
BaseType_t *pxHigherPriorityTaskWoken );

xEventGroupWaitBits

1
2
3
4
5
EventBits_t xEventGroupWaitBits( const EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToWaitFor,
const BaseType_t xClearOnExit,
const BaseType_t xWaitForAllBits,
TickType_t xTicksToWait );

Example 22. Experimenting with event groups

使用事件组的任务同步

xEventGroupSync

1
2
3
4
EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
const EventBits_t uxBitsToSet,
const EventBits_t uxBitsToWaitFor,
TickType_t xTicksToWait );

Example 23. Synchronizing tasks

任务通知

通过中间对象通信

image-20230307094905368

任务通知——直接通信方式

image-20230307101348461

configUSE_TASK_NOTIFICATIONS

任务通知:优势和限制

性能优势

内存消耗优势

限制

使用任务通知

任务通知API选项

xTaskNotifyGive

1
BaseType_t xTaskNotifyGive( TaskHandle_t xTaskToNotify );

vTaskNotifyGiveFromISR

1
2
void vTaskNotifyGiveFromISR( TaskHandle_t xTaskToNotify, 
BaseType_t *pxHigherPriorityTaskWoken );

ulTaskNotifyTake

1
uint32_t ulTaskNotifyTake( BaseType_t xClearCountOnExit, TickType_t xTicksToWait );

Example 24. Using a task notification in place of a semaphore, method 1

image-20230307134340180

Example 25. Using a task notification in place of a semaphore, method 2

xTaskNotify和xTaskNotifyFromISR

1
2
3
4
5
6
7
BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, 
uint32_t ulValue,
eNotifyAction eAction );
BaseType_t xTaskNotifyFromISR( TaskHandle_t xTaskToNotify,
uint32_t ulValue,
eNotifyAction eAction,
BaseType_t *pxHigherPriorityTaskWoken );

xTaskNotifyWait

1
2
3
4
BaseType_t xTaskNotifyWait( uint32_t ulBitsToClearOnEntry,
uint32_t ulBitsToClearOnExit,
uint32_t *pulNotificationValue,
TickType_t xTicksToWait );

Task Notifications Used in Peripheral Device Drivers: UART Example

Task Notifications Used in Peripheral Device Drivers: ADC Example

Task Notifications Used Directly Within an Application

image-20230307135357762

低功耗支持

开发者支持

configASSERT

默认无效:

1
assert( pxMyPointer != NULL );

需要改为

configASSERT()

configASSERT定义示例

FreeRTOS+跟踪

image-20230308092623605

调试相关钩子(回调)函数

内存申请失败

栈溢出

查看运行时和任务状态信息

任务运行时统计

运行时统计时钟

10~100倍频率

配置应用以收集运行时统计

configGENERATE_RUN_TIME_STATS

portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()

portGET_RUN_TIME_COUNTER_VALUE()

portALT_GET_RUN_TIME_COUNTER_VALUE(Time)

uxTaskGetSystemState

1
2
3
UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray,
const UBaseType_t uxArraySize,
uint32_t * const pulTotalRunTime );
1
2
3
4
5
6
7
8
9
10
11
typedef struct xTASK_STATUS
{
TaskHandle_t xHandle;
const char *pcTaskName;
UBaseType_t xTaskNumber;
eTaskState eCurrentState;
UBaseType_t uxCurrentPriority;
UBaseType_t uxBasePriority;
uint32_t ulRunTimeCounter;
uint16_t usStackHighWaterMark;
} TaskStatus_t;

vTaskList辅助函数

configUSE_TRACE_FACILITY

configUSE_STATS_FORMATTING_FUNCTIONS

1
void vTaskList( signed char *pcWriteBuffer );
image-20230308094211231

vTaskGetRunTimeStats辅助函数

configGENERATE_RUN_TIME_STATS

configUSE_STATS_FORMATTING_FUNCTIONS

1
void vTaskGetRunTimeStats( signed char *pcWriteBuffer );
image-20230308095815972

产生和显示运行时统计示例

跟踪钩子宏

traceTASK_INCREMENT_TICK(xTickCount)

traceTASK_SWITCHED_OUT()

traceTASK_SWITCHED_IN()

traceBLOCKING_ON_QUEUE_RECEIVE(pxQueue)

traceBLOCKING_ON_QUEUE_SEND(pxQueue)

traceQUEUE_SEND(pxQueue)

traceQUEUE_SEND_FAILED(pxQueue)

traceQUEUE_RECEIVE(pxQueue)

traceQUEUE_RECEIVE_FAILED(pxQueue)

traceQUEUE_SEND_FROM_ISR(pxQueue)

traceQUEUE_SEND_FROM_ISR_FAILED(pxQueue)

traceQUEUE_RECEIVE_FROM_ISR(pxQueue)

traceQUEUE_RECEIVE_FROM_ISR_FAILED(pxQueue)

traceTASK_DELAY_UNTIL()

traceTASK_DELAY()

定义跟踪钩子宏

FreeRTOSConfig.h

FreeRTOS感知调试插件

Eclipse (StateViewer)

Eclipse (ThreadSpy)

IAR

ARM DS-5

Atollic TrueStudio

Microchip MPLAB

iSYSTEM WinIDEA

问题解答

中断优先级

configMAX_SYSCALL_INTERRUPT_PRIORITY

栈溢出

uxTaskGetStackHighWaterMark

1
UBaseType_t uxTaskGetStackHighWaterMark( TaskHandle_t xTask );

运行时栈检查——概述

configCHECK_FOR_STACK_OVERFLOW

1
void vApplicationStackOverflowHook( TaskHandle_t *pxTask, signed char *pcTaskName );

运行时栈检查——方法1

configCHECK_FOR_STACK_OVERFLOW 1

运行时栈检查——方法2

configCHECK_FOR_STACK_OVERFLOW 2

不适当地使用printf()和sprintf()

Printf-stdarg.c

其他常见的错误来源

症状:向演示中添加一个简单的任务会导致演示崩溃

症状:在中断中使用API函数会导致应用程序崩溃

症状:有时应用程序会在中断服务例程中崩溃

症状:尝试启动第一个任务时崩溃

症状:意外禁用中断,或者临界段未正确嵌套

症状:应用程序甚至在调度程序启动之前就崩溃了

症状:当调度程序挂起时,或从关键部分内部调用API函数,会导致应用程序崩溃

系统概览

平台是由一个或多个元件组成的单个集成电路。有些组件可能是RISC-V内核,而其他组件可能具有不同的功能。通常,它们都将连接到单个系统总线。单个RISC-V核心包含一个或多个硬件线程,称为hart。

用户与运行调试器(如gdb)的调试主机(如笔记本电脑)交互。调试器与调试转换器(例如OpenOCD,它可能包括一个硬件驱动程序)通信,以与调试传输硬件(例如Olimex USB-JTAG适配器)通信。调试传输硬件将调试主机连接到平台的调试传输模块(Debug Transport Module, DTM)。DTM使用调试模块接口(DMI)提供对一个或多个调试模块(dm)的访问。

平台中每个hart都由一个DM控制。对hart-DM映射没有进一步的限制,但通常单个核心中的所有hart都由同一个DM控制。在大多数平台中,只有一个DM控制平台中的所有hart。

2024-09-14T09:34:55.png

调试模块DM

调试模块接口DMI

调试模块从属于称为调试模块接口(DMI)的总线。总线的主人是调试传输模块(Debug Transport Module)。调试模块接口可以是一个普通的总线,有一个主总线和一个从总线,也可以使用功能更全面的总线,如TileLink或AMBA高级外围总线。

DMI使用7到32位地址位。如果在这个DMI上有额外的DM,DMI地址空间中下一个DM的基址在nextdm中给出。调试模块自己的状态和寄存器应该只在上电时重置,而dmcontrol中的dmactive为0。如果dmactive为1,即使会引起CSRs被清零,所有hart在系统重置期间也要保持halt状态。

重置控制

调试模块控制一个全局复位信号ndmreset(非调试模块复位),它可以复位或保持复位平台中的每个组件,除了调试模块和调试传输模块。

选择hart

一个单一的DM可以管理高达2^20个hart。

要枚举所有hart,调试器必须首先通过将所有hart写入hartsel(假设最大大小)并回读值来确定HARTSELLEN,以查看实际设置了哪些位。然后,它从0开始选择每个hart,直到在dmstatus中anynonexistent为1,或者达到最高索引(取决于HARTSELLEN)。

抽象命令

DM支持一组抽象命令,其中大部分是可选的。根据实现的不同,调试器可能能够执行一些抽象命令,即使所选的hart没有停止。调试器只能通过尝试特定状态下的特定hart支持哪些抽象命令,然后查看abstractcs中cmderr以确定它们是否成功。

如果命令接受参数,调试器必须在写入命令之前将它们写入数据寄存器。

每个抽象命令都是32位值。前8位包含cmdtype,它决定了命令的类型。

cmdtypeCommand
0Access Register
1Quick Access
2Access Memory

Access Register

3.6.1.1 Access Register

遵循以下操作顺序:

  1. 若write为0且transfer为1,则将regno指定的寄存器的数据拷贝到数据区arg0中,并执行从m模式读取该寄存器时发生的任何副作用。
  2. 若write为1且transfer为1,则将数据区arg0的数据拷贝到regno指定的寄存器中,并执行从m模式写入该寄存器时发生的任何副作用。
  3. 若aarpostincrement为1,则将增加regno。
  4. 若postexec为1,执行Program Buffer.

抽象寄存器号表

地址范围说明
0x0000 - 0x0fffCSRs,可以通过dpc访问PC
0x1000 - 0x101fGPRs
0x1020 - 0x103f浮点寄存器
0xc000 - 0xffff保留给非标扩展和内部使用的

Quick Access

3.6.1.2 Quick Access

遵循以下操作顺序:

  1. 若hart已经暂停,命令将会设置cmderr为”halt/resume”并不会继续执行。
  2. 暂停hart。若hart因某些其他原因(如breakpoint)暂停,命令将会设置cmderr为”halt/resume”并不会继续执行。
  3. 执行Program Buffer。若发生异常,cmderr会被设置为”exception”并且program buffer结束执行,但快速访问命令会继续。
  4. 恢复hart。

Access Memory

3.6.1.3 Access Memory

遵循以下操作顺序:

  1. 若write为0,从arg1指定的内存位置拷贝数据到数据区arg0中。
  2. 若write为1,从数据区arg0拷贝数据到arg1指定的内存位置中。
  3. 若aampostincrement为1,则将增加arg1.

若任何操作失败,设置cmderr并不会执行任何剩余步骤。

程序缓冲区

3.7 Program Buffer

为支持在已停止的hart上执行任意指令,调试模块可以包括程序缓冲区,调试器可以将小程序写入其中。

调试器可以将一个小程序写入程序缓冲区,然后使用Access Register抽象命令执行它一次,命令中postexec位为1。调试器可以编写任何它喜欢的程序(包括跳出程序缓冲区),但是程序必须以ebreak或c.ebreak结束。

若progbufsize为1,则impebreak必须为1. 程序缓冲区可容纳一条32位或16位指令,所以在这种情况下,调试器必须只写一条指令,而不管它的大小。

执行程序缓冲区可能会破坏dpc。如果是这种情况,必须可以使用抽象命令读取/写入dpc,而不设置postexec。调试器必须尝试在停止和执行程序缓冲区之间保存dpc,然后在离开调试模式之前恢复dpc。

状态概览

下图显示了运行/停止调试期间hart经过的状态的概念视图,这些状态受到dmcontrol、abstractcs、abstractauto和command的不同字段的影响。

image-20240914114316238.png

系统总线访问

3.9 System Bus Access

调试器可以使用Program Buffer或Access Memory抽象命令从hart的角度访问内存。一个调试模块也可以包括一个System Bus Access块来提供内存访问而不涉及hart,而不管是否实现了Program Buffer。

System Bus Access块支持8, 16, 32, 64和128位访问。下表显示在sbdata中每个访问大小可以访问的位。

访问大小数据位
8sbdata0位7:0
16sbdata0位15:0
32sbdata0
64sbdata1, sbdata0
128sbdata3, sbdata2, sbdata1, sbdata0

DM寄存器

3.12 Debug Module Registers

本节中描述的寄存器是通过DMI总线访问的。每个DM都有一个基址(第一个DM为0)。下面的寄存器地址是这个基址的偏移量。

调试模块调试总线寄存器表

地址名称
0x04Abstract Data 0 (data0)
0x0fAbstract Data 11 (data11)
0x10Debug Module Control (dmcontrol)
0x11Debug Module Status (dmstatus)
0x12Hart Info (hartinfo)
0x13Halt Summary 1 (haltsum1)
0x14Hart Array Window Select (hawindowsel)
0x15Hart Array Window (hawindow)
0x16Abstract Control and Status (abstractcs)
0x17Abstract Command (command)
0x18Abstract Command Autoexec (abstractauto)
0x19Configuration String Pointer 0 (confstrptr0)
0x1aConfiguration String Pointer 1 (confstrptr1)
0x1bConfiguration String Pointer 2 (confstrptr2)
0x1cConfiguration String Pointer 3 (confstrptr3)
0x1dNext Debug Module (nextdm)
0x20Program Buffer 0 (progbuf0)
0x2fProgram Buffer 15 (progbuf15)
0x30Authentication Data (authdata)
0x34Halt Summary 2 (haltsum2)
0x35Halt Summary 3 (haltsum3)
0x37System Bus Address 127:96 (sbaddress3)
0x38System Bus Access Control and Status (sbcs)
0x39System Bus Address 31:0 (sbaddress0)
0x3aSystem Bus Address 63:32 (sbaddress1)
0x3bSystem Bus Address 95:64 (sbaddress2)
0x3cSystem Bus Data 31:0 (sbdata0)
0x3dSystem Bus Data 63:32 (sbdata1)
0x3eSystem Bus Data 95:64 (sbdata2)
0x3fSystem Bus Data 127:96 (sbdata3)
0x40Halt Summary 0 (haltsum0)

dmstatus, 0x11

3.12.1 Debug Module Status (dmstatus, at 0x11)

这个寄存器报告整个调试模块以及由hasel所选hart的状态。它的地址在将来不会改变,因为它包含了version。

整个寄存器是只读的。

dmcontrol, 0x10

3.12.2 Debug Module Control (dmcontrol, at 0x10)

这个寄存器控制整个调试模块以及由hasel所选的hart。

在本文档中,我们提到hartsel,它是hartselhi和hartsello的组合。虽然规范允许20个hartsel位,但实现可能会选择实现少于这个数。hartsel的实际宽度被称为HARTSELLEN。它最少为0,最多为20。调试器应该通过将所有的1写入HARTSELLEN(假设最大大小)并回读值以查看实际设置了哪些位来发现HARTSELLEN。

在任何给定的写操作中,调试器最多只能将1写入以下位中的一个:resumereq、hartreset、ackhavereset、setresethaltreq和clrresethaltreq。其他的必须写成0。

resethaltreq是每个hart可选内部状态位,不能读取,但可以使用setresethaltreq和clrresethaltreq写入。

hartinfo, 0x12

3.12.3 Hart Info (hartinfo, at 0x12)

这个寄存器能获取hartsel选择的hart的信息。

这个寄存器是可选的。若它不可用它会读到全0。

如果包含这个寄存器,调试器可以通过编写显式访问data或dscratch寄存器的程序来对程序缓冲区做更多的工作。

hawindowsel, 0x14

3.12.4 Hart Array Window Select (hawindowsel, at 0x14)

hawindowsel有效可写位取决于具体实现,最多为15位。比如单个DM支持48个hart,则此寄存器只有bit0可以写入,其余位均为0.

hawindow, 0x15

3.12.5 Hart Array Window (hawindow, at 0x15)

hart数组掩码寄存器,与hawindowsel一起选择hart数组。比如bit0代表hawindowsel * 32索引的hart,bit31代表hawindowsel * 32 + 31索引的hart。

abstractcs, 0x16

3.12.6 Abstract Control and Status (abstractcs, at 0x16)

当一个抽象命令正在执行时,写这个寄存器会造成cderr被设置为1(忙),如果它是0.

支持RV32,datacount至少为1;支持RV64,至少为2;支持RV128,至少为4.

command, 0x17

3.12.7 Abstract Command (command, at 0x17)

写这个寄存器会造成相关抽象命令被执行。

当一个抽象命令正在执行时,写这个寄存器会造成cderr被设置为1(忙),如果它是0.

如果cmderr为非0,写这个寄存器会被忽略。

abstractauto, 0x18

3.12.8 Abstract Command Autoexec (abstractauto, at 0x18)

这个寄存器是可选的。包含它允许更有效的突发访问。调试器可以通过设置位并读取它们来检测它是否被支持。

当一个抽象命令正在执行时,写这个寄存器会造成cderr被设置为1(忙),如果它是0.

confstrptr0, 0x19

3.12.9 Configuration String Pointer 0 (confstrptr0, at 0x19)

当设置confstrptrvalid时,读取该寄存器将返回配置字符串指针的第31:0位。读取其他的confstrptr寄存器返回地址的上位。

当实现系统总线主控时,这必须是一个可以与系统总线访问模块一起使用的地址。否则,这必须是一个可以用来访问ID0的hart的配置字符串的地址。

如果confstrptrvalid为0,则confstrptr寄存器保存标识符信息,该信息在本文档中没有进一步指定。

nextdm, 0x1d

3.12.10 Next Debug Module (nextdm, at 0x1d)

如果在DMI上有超过一个DM,这个寄存器包含链中下一个DM的基地址,如果是链中最后一个则为0.

data0, 0x04

3.12.11 Abstract Data 0 (data0, at 0x04)

data0到data11是基本的读/写寄存器,可以通过抽象命令读取或更改。dataccount表示实现了多少个,从data0开始,依次递增。

progbuf0, 0x20

3.12.12 Program Buffer 0 (progbuf0, at 0x20)

progbuf0到progbuf15提供对可选程序缓冲区的读/写访问。progbufsize表示从progbuf0开始实现的数目,依次递增。

authdata, 0x30

3.12.13 Authentication Data (authdata, at 0x30)

这个寄存器作为一个32位的串行端口进出认证模块。

当authbusy为0时,调试器可以通过读取或写入该寄存器与身份验证模块通信。没有单独的机制来指示溢出/下溢。

haltsum0, 0x40

3.12.14 Halt Summary 0 (haltsum0, at 0x40)

这个只读寄存器中的每个位表示一个特定的hart是否停止。不可用/不存在的hart不被认为是停止的。

LSB代表hart hartsel[19:5],5'h0的暂停状态,MSB代表harthartsel[19:5],5'h1f的暂停状态。

haltsum1, 0x13

3.12.15 Halt Summary 1 (haltsum1, at 0x13)

这个只读寄存器中的每个位表示一组(32个)hart是否停止。不可用/不存在的hart不被认为是停止的。

这个寄存器不能出现在少于33个hart的系统中。

LSB代表一组harthartsel[19:10],10'h0到harthartsel[19:10],10'h1f的暂停状态。MSB代表一组harthartsel[19:10],10'h3e0到harthartsel[19:10],10'h3ff的暂停状态。

haltsum2, 0x34

3.12.16 Halt Summary 2 (haltsum2, at 0x34)

这个只读寄存器中的每个位表示一组(1024个)hart是否停止。不可用/不存在的hart不被认为是停止的。

这个寄存器不能出现在少于1025个hart的系统中。

LSB代表一组harthartsel[19:15],15'h0到harthartsel[19:15],15'h3ff的暂停状态。MSB代表一组harthartsel[19:15],15'h7c00到harthartsel[19:15],15'h7fff的暂停状态。

haltsum3, 0x35

3.12.17 Halt Summary 3 (haltsum3, at 0x35)

这个只读寄存器中的每个位表示一组(32768个)hart是否停止。不可用/不存在的hart不被认为是停止的。

这个寄存器不能出现在少于32769个hart的系统中。

LSB代表一组hart20'h0到hart20'h7fff的暂停状态。MSB代表一组hart20'hf8000到hart20'hfffff的暂停状态。

sbcs, 0x38

3.12.18 System Bus Access Control and Status (sbcs, at 0x38)

sbaddress0, 0x39

3.12.19 System Bus Address 31:0 (sbaddress0, at 0x39)

如果sbasize为0,则这个寄存器不存在。

如果sberror为0,sbbusyerror为0,sbreadonaddr为1,然后开始向该寄存器写入以下内容:

  1. sbbusy置位。
  2. 从sbaddress的新值执行一次总线读取。
  3. 如果读成功且sbautoincrement为1,增加sbaddress。
  4. sbbusy清零。

sbaddress1, 0x3a

3.12.20 System Bus Address 63:32 (sbaddress1, at 0x3a)

如果sbasize少于33,则这个寄存器不存在。

sbaddress2, 0x3b

3.12.21 System Bus Address 95:64 (sbaddress2, at 0x3b)

如果sbasize少于65,则这个寄存器不存在。

sbaddress3, 0x37

3.12.22 System Bus Address 127:96 (sbaddress3, at 0x37)

如果sbasize少于97,则这个寄存器不存在。

sbdata0, 0x3c

3.12.23 System Bus Data 31:0 (sbdata0, at 0x3c)

如果sbc中的所有saccess位都是0,那么这个寄存器不存在。

对这个寄存器写入开始如下:

  1. sbbusy置位。
  2. 对sbdata的新值执行总线写入到sbaddress。
  3. 如果写成功且设置了sbautoincrement,增加sbaddress。
  4. sbbusy清零。

从这个寄存器读取开始如下:

  1. 返回数据。
  2. sbbusy置位。
  3. 如果设置了sbreadondata,则从saddress中包含的地址执行一次系统总线读取,将结果放入sbdata中。
  4. 如果设置了sbautoincrement,增加sbaddress。
  5. sbbusy清零。

sbdata1, 0x3d

3.12.24 System Bus Data 63:32 (sbdata1, at 0x3d)

如果sbaccess64和sbaccess128为0,那么这个寄存器不存在。

sbdata2, 0x3e

3.12.25 System Bus Data 95:64 (sbdata2, at 0x3e)

只有当sbaccess128为1时,这个寄存器才存在。

sbdata3, 0x3f

3.12.26 System Bus Data 127:96 (sbdata3, at 0x3f)

只有当sbaccess128为1时,这个寄存器才存在。

RISC-V调试

调试模式

调试模式是一种特殊的处理器模式,仅在hart暂停用于外部调试时使用。

当从可选的程序缓冲区执行代码时,hart保持在调试模式,并适用以下内容:

  1. 所有操作都在机器模式特权级别执行,除了根据mprven可以忽略处于状态的MPRV。
  2. 所有中断(包括NMI)被屏蔽。
  3. 异常不更新任何寄存器。包括cause, epc, tval, dpc和mstatus。它们终止程序缓冲区的执行。
  4. 如果一个触发器匹配上,则不采取任何操作。
  5. 计数器可能会停止,这取决于dcsr中的stopcount。
  6. 计时器可能会停止,这取决于dcsr中的stoptime。
  7. wfi指令起着nop的作用。
  8. 几乎所有改变特权级别的指令都有未定义的行为。这包括ecall、mret、sret和uret。(要更改特权级别,调试器可以在dcsr中写入prv)。唯一的例外是ebreak。当在调试模式下执行该命令时,它会再次停止hart,但不会更新dpc或dcsr。
  9. 完成Program Buffer的执行被认为是fence指令的输出。
  10. 如果所有的控制转移指令的目的地在程序缓冲区中,它们都可能被视为非法指令。如果其中一条指令是非法指令,那么所有这些指令都必须是非法指令。
  11. 如果控制转移指令的目的地在程序缓冲区之外,则所有控制转移指令都可能被视为非法指令。如果其中一条指令是非法指令,那么所有这些指令都必须是非法指令。
  12. 依赖于PC值的指令(例如auipc)可能作为非法指令。
  13. 有效的XLEN是DXLEN。

等待中断指令

如果在wfi执行时请求暂停,则hart必须离开已停止状态,完成该指令的执行,然后进入调试模式。

单步调试

调试器可以使暂停的hart执行一条指令,然后在设置resumereq之前通过设置step重新进入调试模式。

如果执行或获取该指令导致异常,则在PC更改为异常处理程序并更新相应的tval和cause寄存器后立即重新进入调试模式。

如果执行或获取指令导致触发器触发,则在触发器触发后立即重新进入调试模式。在这种情况下,cause被设置为2(trigger)而不是4(single step)。指令是否执行取决于触发器的具体配置。

如果被执行的指令导致PC改变到一个地址,在这个地址中指令获取会导致异常,那么这个异常直到下一次hart被恢复时才会发生。

类似地,新地址的触发器在hart实际尝试执行该指令之前不会触发。

如果正在跳过的指令是wfi并且通常会使hart停止,那么该指令将被视为nop。

重置

如果在hart从复位状态出来时断言了暂停信号(由hart的调试模块中的暂停请求位驱动)或resethaltreq, hart必须在执行任何指令之前进入调试模式,但在执行任何初始化之后,通常会在执行第一个指令之前发生

dret指令

为了从调试模式返回,定义了一条新指令:dret。编码为0x7b200073。在支持此指令的硬件上,在调试模式下执行dret会将pc更改为存储在dpc中的值。将当前权限级别更改为dcsr中prv指定的权限级别。hart不再处于调试模式。

核调试寄存器

地址名称
0x7b0Debug Control and Status (dcsr)
0x7b1Debug PC (dpc)
0x7b2Debug Scratch Register 0 (dscratch0)
0x7b3Debug Scratch Register 1 (dscratch1)

dcsr, 0x7b0

4.8.1 Debug Control and Status (dcsr, at 0x7b0)

dpc, 0x7b1

4.8.2 Debug PC (dpc, at 0x7b1)

dscratch0, 0x7b2

4.8.3 Debug Scratch Register 0 (dscratch0, at 0x7b2)

dscratch1, 0x7b3

4.8.4 Debug Scratch Register 1 (dscratch1, at 0x7b3)

虚拟调试寄存器

虚拟寄存器是一种不直接存在于硬件中的寄存器,但调试器将其显示为存在的寄存器。调试软件应该实现它们,但是硬件可以跳过这一节。虚拟寄存器的存在是为了让用户访问不属于标准调试器的功能,而不需要他们在调试器访问这些寄存器时仔细修改调试寄存器。

priv

4.9.1 Privilege Level (priv, at virtual)

用户可以读取此寄存器以检查hart停止时运行的特权级别。用户可以写这个寄存器来更改hart恢复时运行的特权级别。

编码特权等级
0User/Application
1Supervisor
3Machine

触发器模块

触发器可以导致断点异常、进入调试模式或跟踪操作,而无需执行特殊指令。这使得它们在从ROM中调试代码时非常宝贵。

触发器在调试模式下不会触发。

调试器可以构建所有触发器及其特性的列表,如下所示:

  1. 将0写入tselect。
  2. 回读tselect并检查它是否包含写入的值。如果不是,则退出循环。
  3. 读tinfo。
  4. 如果导致异常,调试器必须读取tdata1以发现类型。(如果type为0,则此触发器不存在。退出循环。)
  5. 如果info为1,则此触发器不存在。退出循环。
  6. 否则,所选触发器支持info中发现的类型。
  7. 重复,增加tselect中的值。

本地M-Mode触发器

触发器可用于本机调试。在一个功能齐全的系统上,触发器将使用u或s来设置,当触发它们时,可能会导致一个断点异常被捕获到一个更特权的模式。也可以将触发器本地设置为在M模式下触发。在这种情况下,没有更高的特权模式可以捕获。当这样的触发器在陷阱处理程序中导致断点异常时,这将使系统无法恢复正常执行。

简单的解决方案是在“M模式”和MIE在mstatus为0的状态下,让硬件防止触发器触发action=0。它的限制是,当用户想要触发触发器时,可能会在其他时间禁用中断。

触发器寄存器

这些寄存器是CSR,可以使用RISC-V csr操作码访问,也可以选择使用抽象调试命令。

action编码表

描述
0引发断点异常。(当软件想要在没有外部调试器的情况下使用触发模块时使用。)
1进入调试模式。(仅当触发器的dmode为1时支持。)
2 - 5保留供trace规范使用。
other保留以备将来使用。

触发器寄存器表

地址名称
0x7a0Trigger Select (tselect)
0x7a1Trigger Data 1 (tdata1)
0x7a1Match Control (mcontrol)
0x7a1Instruction Count (icount)
0x7a1Interrupt Trigger (itrigger)
0x7a1Exception Trigger (etrigger)
0x7a2Trigger Data 2 (tdata2)
0x7a3Trigger Data 3 (tdata3)
0x7a3Trigger Extra (RV32) (textra32)
0x7a3Trigger Extra (RV64) (textra64)
0x7a4Trigger Info (tinfo)
0x7a5Trigger Control (tcontrol)
0x7a8Machine Context (mcontext)
0x7aaSupervisor Context (scontext)

tselect, 0x7a0

5.2.1 Trigger Select (tselect, at 0x7a0)

这个寄存器确定哪个触发器可以通过其他触发器寄存器访问。可访问触发器集必须从0开始,并且是连续的。

tdata1, 0x7a1

5.2.2 Trigger Data 1 (tdata1, at 0x7a1)

tdata2, 0x7a2

5.2.3 Trigger Data 2 (tdata2, at 0x7a2)

tdata3, 0x7a3

5.2.4 Trigger Data 3 (tdata3, at 0x7a3)

tinfo, 0x7a4

5.2.5 Trigger Info (tinfo, at 0x7a4)

tcontrol, 0x7a5

5.2.6 Trigger Control (tcontrol, at 0x7a5)

mcontext, 0x7a8

5.2.7 Machine Context (mcontext, at 0x7a8)

scontext, 0x7aa

5.2.8 Supervisor Context (scontext, at 0x7aa)

mcontrol, 0x7a1

5.2.9 Match Control (mcontrol, at 0x7a1)

当type为2时,这个寄存器可以作为tdata1访问。

icount, 0x7a1

5.2.10 Instruction Count (icount, at 0x7a1)

当type为3时,这个寄存器可以作为tdata1访问。

itrigger, 0x7a1

5.2.11 Interrupt Trigger (itrigger, at 0x7a1)

当type为4时,这个寄存器可以作为tdata1访问。

etrigger, 0x7a1

5.2.12 Exception Trigger (etrigger, at 0x7a1)

当type为5时,这个寄存器可以作为tdata1访问。

textra32, 0x7a3

5.2.13 Trigger Extra (RV32) (textra32, at 0x7a3)

textra64, 0x7a3

5.2.14 Trigger Extra (RV64) (textra64, at 0x7a3)

调试传输模块DTM

调试传输模块通过一个或多个传输(例如JTAG或USB)提供对DM的访问。

单个平台中可能有多个dtm。理想情况下,与外部世界通信的每个组件都包含DTM,允许通过平台支持的每种传输对平台进行调试。例如,USB组件可以包含DTM。这样就可以轻松地通过USB调试任何平台。所需要的就是已经在使用的USB模块也可以访问调试模块接口。

JTAG调试传输模块

这个调试传输模块是基于一个正常的JTAG测试访问端口(TAP)。通过首先使用JTAG指令寄存器(IR)选择一个JTAG寄存器,然后通过JTAG数据寄存器(DR)访问它,JTAG TAP允许访问任意JTAG寄存器。

JTAG DTM寄存器

用作DTM的JTAG抽头必须具有至少5位的IR。当TAP复位时,IR必须默认为00001,选择IDCODE指令。调试器可能使用的唯一常规JTAG寄存器是BYPASS和IDCODE,但是该规范为许多其他标准JTAG指令留下了IR空间。未实现指令必须选择BYPASS寄存器。

JTAG DTM TAP寄存器表

地址名称描述
0x00BYPASSJTAG recommends this encoding
0x01IDCODEJTAG recommends this encoding
0x10DTM Control and Status (dtmcs)For Debugging
0x11Debug Module Interface Access (dmi)For Debugging
0x12Reserved (BYPASS)Reserved for future RISC-V debugging
0x13Reserved (BYPASS)Reserved for future RISC-V debugging
0x14Reserved (BYPASS)Reserved for future RISC-V debugging
0x15Reserved (BYPASS)Reserved for future RISC-V standards
0x16Reserved (BYPASS)Reserved for future RISC-V standards
0x17Reserved (BYPASS)Reserved for future RISC-V standards
0x1fBYPASSJTAG requires this encoding

IDCODE, 0x01

6.1.3 IDCODE (at 0x01)

当TAP状态机复位时,选择这个寄存器(在IR中)。其定义与IEEE标准1149.1-2013中的定义完全一致。

dtmcs, 0x10

6.1.4 DTM Control and Status (dtmcs, at 0x10)

在以后的版本中,这个寄存器的大小将保持不变,以便调试器始终可以确定DTM的版本。

dmi, 0x11

6.1.5 Debug Module Interface Access (dmi, at 0x11)

这个寄存器允许访问调试模块接口(DMI)。

在Update-DR中,DTM将启动op中指定的操作,除非op中报告的当前状态为sticky。 在Capture-DR中,DTM使用该操作的结果更新数据,如果当前操作不是sticky,则更新op。

BYPASS 0x1f

6.1.6 BYPASS (at 0x1f)

无效的1位寄存器。当调试器不想与此TAP通信时使用它。

FreeRTOS源码解析

基本配置

1
#define portSTACK_GROWTH			( -1 )

任务管理

任务控制块TCB

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* Task control block. A task control block (TCB) is allocated for each task,
* and stores task state information, including a pointer to the task's context
* (the task's run time environment, including register values)
*/
typedef struct tskTaskControlBlock /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{
volatile StackType_t * pxTopOfStack; /**< Points to the location of the last item placed on the tasks stack. THIS MUST BE THE FIRST MEMBER OF THE TCB STRUCT. */

ListItem_t xStateListItem; /**< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */
ListItem_t xEventListItem; /**< Used to reference a task from an event list. */
UBaseType_t uxPriority; /**< The priority of the task. 0 is the lowest priority. */
StackType_t * pxStack; /**< Points to the start of the stack. */
char pcTaskName[ configMAX_TASK_NAME_LEN ]; /**< Descriptive name given to the task when created. Facilitates debugging only. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */

UBaseType_t uxBasePriority; /**< The priority last assigned to the task - used by the priority inheritance mechanism. */
UBaseType_t uxMutexesHeld;

volatile uint32_t ulNotifiedValue[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];
volatile uint8_t ucNotifyState[ configTASK_NOTIFICATION_ARRAY_ENTRIES ];

uint8_t ucDelayAborted;
} tskTCB;

/* The old tskTCB name is maintained above then typedefed to the new TCB_t name
* below to enable the use of older kernel aware debuggers. */
typedef tskTCB TCB_t;

动态创建任务

1
2
3
4
5
6
7
// tasks.c
BaseType_t xTaskCreate( TaskFunction_t pxTaskCode,
const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const configSTACK_DEPTH_TYPE usStackDepth,
void * const pvParameters,
UBaseType_t uxPriority,
TaskHandle_t * const pxCreatedTask )

portSTACK_GROWTH < 0,栈向下增长;为避免栈增长到TCB中,需要先申请栈再申请TCB结构。

pxNewTCB->pxStack = pxStack;将栈赋值到TCB中。

prvInitialiseNewTask初始化TCB结构。

prvAddNewTaskToReadyList将任务添加到就绪列表中。

1
static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB )

taskENTER_CRITICAL进入临界区,关闭中断。

prvAddTaskToReadyList将任务按优先级加入就绪队列中。

taskEXIT_CRITICAL退出临界区,开中断。

开始任务调度

1
2
// tasks.c
void vTaskStartScheduler( void )

xTaskCreate创建idle任务。

xTimerCreateTimerTask创建计时器任务。

portDISABLE_INTERRUPTS禁用中断。

xPortStartScheduler调用开启硬件调度接口,一般是启动tick计时器。

1
2
// port.c
BaseType_t xPortStartScheduler( void )

portDISABLE_INTERRUPTS禁用中断。

configSETUP_TICK_INTERRUPT配置tick计时器。

vPortRestoreTaskContext开始执行第一个任务。

汇编程序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// portASM.S
/******************************************************************************
* vPortRestoreTaskContext is used to start the scheduler.
*****************************************************************************/
.align 8
.type vPortRestoreTaskContext, %function
vPortRestoreTaskContext:
.set freertos_vector_base, _freertos_vector_table

/* Install the FreeRTOS interrupt handlers. */
LDR X1, =freertos_vector_base
#if defined( GUEST )
MSR VBAR_EL1, X1
#else
MSR VBAR_EL3, X1
#endif
DSB SY
ISB SY

/* Start the first task. */
portRESTORE_CONTEXT

任务切换

MPS2_QEMU会调用汇编处理程序xPortPendSVHandler

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void xPortPendSVHandler( void )
{
/* This is a naked function. */

__asm volatile
(
" mrs r0, psp \n"
" isb \n"
" \n"
" ldr r3, pxCurrentTCBConst \n"/* Get the location of the current TCB. */
" ldr r2, [r3] \n"
" \n"
" stmdb r0!, {r4-r11} \n"/* Save the remaining registers. */
" str r0, [r2] \n"/* Save the new top of stack into the first member of the TCB. */
" \n"
" stmdb sp!, {r3, r14} \n"
" mov r0, %0 \n"
" msr basepri, r0 \n"
" bl vTaskSwitchContext \n"
" mov r0, #0 \n"
" msr basepri, r0 \n"
" ldmia sp!, {r3, r14} \n"
" \n"/* Restore the context, including the critical nesting count. */
" ldr r1, [r3] \n"
" ldr r0, [r1] \n"/* The first item in pxCurrentTCB is the task top of stack. */
" ldmia r0!, {r4-r11} \n"/* Pop the registers. */
" msr psp, r0 \n"
" isb \n"
" bx r14 \n"
" \n"
" .align 4 \n"
"pxCurrentTCBConst: .word pxCurrentTCB \n"
::"i" ( configMAX_SYSCALL_INTERRUPT_PRIORITY )
);
}

OpenAI辅助理解

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void PendSV_Handler(void) {
/* 保存当前任务的上下文 */
__asm volatile (
"MRS R0, PSP \n" /* 获取进程堆栈指针 */
"STMDB R0!, {R4-R11} \n" /* 保存R4-R11寄存器到堆栈 */
"LDR R1, =pxCurrentTCB \n" /* 加载当前TCB指针地址 */
"LDR R2, [R1] \n" /* 加载当前TCB指针 */
"STR R0, [R2] \n" /* 保存堆栈指针到当前TCB */
);

/* 切换到下一个任务 */
vTaskSwitchContext();

/* 恢复下一个任务的上下文 */
__asm volatile (
"LDR R1, =pxCurrentTCB \n" /* 加载当前TCB指针地址 */
"LDR R2, [R1] \n" /* 加载当前TCB指针 */
"LDR R0, [R2] \n" /* 加载堆栈指针 */
"LDMIA R0!, {R4-R11} \n" /* 恢复R4-R11寄存器 */
"MSR PSP, R0 \n" /* 恢复进程堆栈指针 */
"BX LR \n" /* 返回任务 */
);
}

然后调用切换上下文函数

1
2
// task.c
void vTaskSwitchContext( void )

taskSELECT_HIGHEST_PRIORITY_TASK选择最高优先级任务

时钟管理

时钟节拍

MPS2_QEMU会调用处理程序xPortSysTickHandler

1
2
// port.c
void xPortSysTickHandler( void )

portDISABLE_INTERRUPTS关闭中断。

xTaskIncrementTick尝试增加tick值,成功后触发PendSV中断,强行进行一次调度。

portENABLE_INTERRUPTS打开中断。

1
2
// tasks.c
BaseType_t xTaskIncrementTick( void )

taskSWITCH_DELAYED_LISTS系统tick值反转时,将延时任务队列与反转反转队列互换。

判断是否有超时的任务,并将其移入就绪队列中。

任务延时

1
void vTaskDelay( const TickType_t xTicksToDelay )

vTaskSuspendAll关闭调度器。

prvAddCurrentTaskToDelayedList将当前任务加到延时列表中。

xTaskResumeAll恢复调度器。

portYIELD_WITHIN_API当恢复调度时未进行再次调度,则强制进行调度并让任务进入睡眠状态。

1
2
3
static void prvAddCurrentTaskToDelayedList( TickType_t xTicksToWait,
const BaseType_t xCanBlockIndefinitely )

uxListRemove将当前任务移除队列中。

xTimeToWake = xConstTickCount + xTicksToWait计算下次唤醒的时刻。需要考虑时间反转的场景。

0%