-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathblock-comment-for-block-and-drivers-for-linux-5.2-rc4.patch
More file actions
3337 lines (3183 loc) · 135 KB
/
Copy pathblock-comment-for-block-and-drivers-for-linux-5.2-rc4.patch
File metadata and controls
3337 lines (3183 loc) · 135 KB
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
From 5b62a4b189dddce5c00b392d33593f7dd0754d6b Mon Sep 17 00:00:00 2001
From: Dongli Zhang <dongli.zhang0129@gmail.com>
Date: Mon, 8 Jul 2019 13:55:45 +0800
Subject: [PATCH 1/1] block comment for block and drivers for linux-5.2-rc4
Signed-off-by: Dongli Zhang <dongli.zhang0129@gmail.com>
---
arch/x86/kernel/apic/vector.c | 69 ++++++++++
arch/x86/pci/common.c | 25 ++++
arch/x86/pci/legacy.c | 9 ++
block/blk-core.c | 42 ++++++
block/blk-mq-sysfs.c | 3 +
block/blk-mq-tag.c | 9 ++
block/blk-mq-tag.h | 7 +
block/blk-mq.c | 161 ++++++++++++++++++++++
block/blk-mq.h | 9 ++
block/blk-timeout.c | 18 +++
drivers/acpi/pci_root.c | 4 +
drivers/acpi/scan.c | 6 +
drivers/nvme/host/pci.c | 4 +
drivers/pci/msi.c | 7 +
drivers/pci/probe.c | 254 +++++++++++++++++++++++++++++++++++
drivers/pci/search.c | 20 +++
drivers/scsi/hosts.c | 47 +++++++
drivers/scsi/iscsi_tcp.c | 10 ++
drivers/scsi/scsi_lib.c | 211 +++++++++++++++++++++++++++++
drivers/scsi/scsi_scan.c | 254 +++++++++++++++++++++++++++++++++++
drivers/scsi/scsi_sysfs.c | 68 ++++++++++
drivers/scsi/scsi_transport_iscsi.c | 9 ++
drivers/scsi/sd.c | 56 ++++++++
drivers/scsi/virtio_scsi.c | 259 ++++++++++++++++++++++++++++++++++++
drivers/virtio/virtio_pci_common.c | 15 +++
include/linux/blk-mq.h | 63 +++++++++
include/linux/blkdev.h | 20 +++
include/linux/dma-mapping.h | 13 ++
include/linux/interrupt.h | 33 +++++
include/linux/irq.h | 7 +
include/linux/virtio_config.h | 3 +
include/scsi/scsi_cmnd.h | 24 ++++
include/scsi/scsi_device.h | 46 +++++++
include/scsi/scsi_host.h | 22 +++
kernel/irq/affinity.c | 75 +++++++++++
kernel/irq/matrix.c | 4 +
36 files changed, 1886 insertions(+)
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 3173e07..04aa2bd 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -26,6 +26,37 @@
#include <asm/trace/irq_vectors.h>
+/*
+ * struct irq_affinity_desc
+ * unsigned int is_managed:1; 默认是1
+ *
+ * - kernel/irq/affinity.c|318| <<irq_create_affinity_masks>> masks[i].is_managed = 1;
+ * - kernel/irq/irqdesc.c|473| <<alloc_descs>> if (affinity->is_managed) {
+ *
+ *
+ * struct pci_dev
+ * unsigned int is_managed:1; 默认是1
+ *
+ * - drivers/pci/pci.c|1808| <<pcim_enable_device>> pdev->is_managed = 1;
+ * - include/linux/pci.h|1107| <<pci_is_managed>> return pdev->is_managed;
+ *
+ *
+ * struct apic_chip_data
+ * unsigned int is_managed:1; 默认是1
+ *
+ * - arch/x86/kernel/apic/vector.c|194| <<reserve_managed_vector>> apicd->is_managed = true;
+ * - arch/x86/kernel/apic/vector.c|367| <<x86_vector_deactivate>> trace_vector_deactivate(irqd->irq, apicd->is_managed,
+ * - arch/x86/kernel/apic/vector.c|371| <<x86_vector_deactivate>> if (!apicd->is_managed && !apicd->can_reserve)
+ * - arch/x86/kernel/apic/vector.c|438| <<x86_vector_activate>> trace_vector_activate(irqd->irq, apicd->is_managed,
+ * - arch/x86/kernel/apic/vector.c|442| <<x86_vector_activate>> if (!apicd->can_reserve && !apicd->is_managed)
+ * - arch/x86/kernel/apic/vector.c|448| <<x86_vector_activate>> else if (apicd->is_managed)
+ * - arch/x86/kernel/apic/vector.c|461| <<vector_free_reserved_and_managed>> trace_vector_teardown(irqd->irq, apicd->is_managed,
+ * - arch/x86/kernel/apic/vector.c|466| <<vector_free_reserved_and_managed>> if (apicd->is_managed)
+ * - arch/x86/kernel/apic/vector.c|615| <<x86_vector_debug_show>> seq_printf(m, "%*sis_managed: %u\n", ind, "", apicd.is_managed ? 1 : 0);
+ * - arch/x86/kernel/apic/vector.c|776| <<apic_set_affinity>> (apicd->is_managed || apicd->can_reserve))
+ * - arch/x86/kernel/apic/vector.c|830| <<free_moved_vector>> bool managed = apicd->is_managed;
+ */
+
struct apic_chip_data {
struct irq_cfg hw_irq_cfg;
unsigned int vector;
@@ -43,6 +74,25 @@ struct apic_chip_data {
struct irq_domain *x86_vector_domain;
EXPORT_SYMBOL_GPL(x86_vector_domain);
static DEFINE_RAW_SPINLOCK(vector_lock);
+/*
+ * used by:
+ * - arch/x86/kernel/apic/vector.c|297| <<assign_irq_vector>> cpumask_and(vector_searchmask, dest, cpu_online_mask);
+ * - arch/x86/kernel/apic/vector.c|298| <<assign_irq_vector>> ret = assign_vector_locked(irqd, vector_searchmask);
+ * - arch/x86/kernel/apic/vector.c|312| <<assign_irq_vector_any_locked>> cpumask_and(vector_searchmask, cpumask_of_node(node), affmsk);
+ * - arch/x86/kernel/apic/vector.c|313| <<assign_irq_vector_any_locked>> if (!assign_vector_locked(irqd, vector_searchmask))
+ * - arch/x86/kernel/apic/vector.c|320| <<assign_irq_vector_any_locked>> cpumask_and(vector_searchmask, affmsk, cpu_online_mask);
+ * - arch/x86/kernel/apic/vector.c|321| <<assign_irq_vector_any_locked>> if (!assign_vector_locked(irqd, vector_searchmask))
+ * - arch/x86/kernel/apic/vector.c|352| <<assign_managed_vector>> cpumask_and(vector_searchmask, dest, affmsk);
+ * - arch/x86/kernel/apic/vector.c|355| <<assign_managed_vector>> if (apicd->vector && cpumask_test_cpu(apicd->cpu, vector_searchmask))
+ * - arch/x86/kernel/apic/vector.c|357| <<assign_managed_vector>> vector = irq_matrix_alloc_managed(vector_matrix, vector_searchmask,
+ * - arch/x86/kernel/apic/vector.c|447| <<activate_managed>> cpumask_and(vector_searchmask, dest, cpu_online_mask);
+ * - arch/x86/kernel/apic/vector.c|448| <<activate_managed>> if (WARN_ON_ONCE(cpumask_empty(vector_searchmask))) {
+ * - arch/x86/kernel/apic/vector.c|454| <<activate_managed>> ret = assign_managed_vector(irqd, vector_searchmask);
+ * - arch/x86/kernel/apic/vector.c|738| <<arch_early_irq_init>> BUG_ON(!alloc_cpumask_var(&vector_searchmask, GFP_KERNEL));
+ * - arch/x86/kernel/apic/vector.c|815| <<apic_set_affinity>> cpumask_and(vector_searchmask, dest, cpu_online_mask);
+ * - arch/x86/kernel/apic/vector.c|817| <<apic_set_affinity>> err = assign_managed_vector(irqd, vector_searchmask);
+ * - arch/x86/kernel/apic/vector.c|819| <<apic_set_affinity>> err = assign_vector_locked(irqd, vector_searchmask);
+ */
static cpumask_var_t vector_searchmask;
static struct irq_chip lapic_controller;
static struct irq_matrix *vector_matrix;
@@ -183,6 +233,10 @@ static void vector_assign_managed_shutdown(struct irq_data *irqd)
apic_update_irq_cfg(irqd, MANAGED_IRQ_SHUTDOWN_VECTOR, cpu);
}
+/*
+ * called only by:
+ * - arch/x86/kernel/apic/vector.c|358| <<assign_irq_vector_policy>> return reserve_managed_vector(irqd);
+ */
static int reserve_managed_vector(struct irq_data *irqd)
{
const struct cpumask *affmsk = irq_data_get_affinity_mask(irqd);
@@ -257,6 +311,10 @@ assign_vector_locked(struct irq_data *irqd, const struct cpumask *dest)
return 0;
}
+/*
+ * called only by:
+ * - arch/x86/kernel/apic/vector.c|337| <<assign_irq_vector_policy>> return assign_irq_vector(irqd, info->mask);
+ */
static int assign_irq_vector(struct irq_data *irqd, const struct cpumask *dest)
{
unsigned long flags;
@@ -293,9 +351,17 @@ static int assign_irq_vector_any_locked(struct irq_data *irqd)
return assign_vector_locked(irqd, cpu_online_mask);
}
+/*
+ * called by:
+ * - arch/x86/kernel/apic/vector.c|621| <<x86_vector_alloc_irqs>> err = assign_irq_vector_policy(irqd, info);
+ */
static int
assign_irq_vector_policy(struct irq_data *irqd, struct irq_alloc_info *info)
{
+ /*
+ * IRQD_AFFINITY_MANAGED在以下设置:
+ * - kernel/irq/irqdesc.c|474| <<alloc_descs>> flags = IRQD_AFFINITY_MANAGED |
+ */
if (irqd_affinity_is_managed(irqd))
return reserve_managed_vector(irqd);
if (info->mask)
@@ -517,6 +583,9 @@ static bool vector_configure_legacy(unsigned int virq, struct irq_data *irqd,
return realloc;
}
+/*
+ * struct irq_domain_ops x86_vector_domain_ops.alloc = x86_vector_alloc_irqs()
+ */
static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq,
unsigned int nr_irqs, void *arg)
{
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 9acab6a..7a0b806 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -31,6 +31,17 @@ int noioapicreroute = 0;
#else
int noioapicreroute = 1;
#endif
+/*
+ * 在以下修改pcibios_last_bus:
+ * - arch/x86/pci/common.c|34| <<global>> int pcibios_last_bus = -1;
+ * - arch/x86/kernel/jailhouse.c|126| <<jailhouse_pci_arch_init>> pcibios_last_bus = 0xff;
+ * - arch/x86/pci/common.c|591| <<pcibios_setup>> pcibios_last_bus = simple_strtol(str+8, NULL, 0);
+ * - arch/x86/pci/fixup.c|34| <<pci_fixup_i450nx>> pcibios_last_bus = -1;
+ * - arch/x86/pci/fixup.c|48| <<pci_fixup_i450gx>> pcibios_last_bus = -1;
+ * - arch/x86/pci/irq.c|145| <<pirq_peer_trick>> pcibios_last_bus = -1;
+ * - arch/x86/pci/mmconfig-shared.c|647| <<__pci_mmcfg_init>> pcibios_last_bus = cfg->end_bus;
+ * - arch/x86/pci/pcbios.c|162| <<check_pcibios>> pcibios_last_bus = ecx & 0xff;
+ */
int pcibios_last_bus = -1;
unsigned long pirq_table_addr;
const struct pci_raw_ops *__read_mostly raw_pci_ops;
@@ -169,6 +180,11 @@ void pcibios_fixup_bus(struct pci_bus *b)
pcibios_fixup_device_resources(dev);
}
+/*
+ * called by:
+ * - drivers/pci/probe.c|900| <<pci_register_host_bridge>> pcibios_add_bus(bus);
+ * - drivers/pci/probe.c|1053| <<pci_alloc_child_bus>> pcibios_add_bus(child);
+ */
void pcibios_add_bus(struct pci_bus *bus)
{
acpi_pci_add_bus(bus);
@@ -454,6 +470,15 @@ void __init dmi_check_pciprobe(void)
dmi_check_system(pciprobe_dmi_table);
}
+/*
+ * called by:
+ * - arch/x86/pci/fixup.c|30| <<pci_fixup_i450nx>> pcibios_scan_root(busno);
+ * - arch/x86/pci/fixup.c|32| <<pci_fixup_i450nx>> pcibios_scan_root(suba+1);
+ * - arch/x86/pci/fixup.c|47| <<pci_fixup_i450gx>> pcibios_scan_root(busno);
+ * - arch/x86/pci/irq.c|143| <<pirq_peer_trick>> pcibios_scan_root(i);
+ * - arch/x86/pci/legacy.c|33| <<pci_legacy_init>> pcibios_scan_root(0);
+ * - arch/x86/pci/legacy.c|51| <<pcibios_scan_specific_bus>> pcibios_scan_root(busn);
+ */
void pcibios_scan_root(int busnum)
{
struct pci_bus *bus;
diff --git a/arch/x86/pci/legacy.c b/arch/x86/pci/legacy.c
index 467311b..67b2b62 100644
--- a/arch/x86/pci/legacy.c
+++ b/arch/x86/pci/legacy.c
@@ -12,6 +12,10 @@
* Discover remaining PCI buses in case there are peer host bridges.
* We use the number of last PCI bus provided by the PCI BIOS.
*/
+/*
+ * called by only:
+ * - arch/x86/pci/legacy.c|71| <<pci_subsys_init>> pcibios_fixup_peer_bridges();
+ */
static void pcibios_fixup_peer_bridges(void)
{
int n;
@@ -34,6 +38,11 @@ int __init pci_legacy_init(void)
return 0;
}
+/*
+ * called by:
+ * - arch/x86/pci/legacy.c|24| <<pcibios_fixup_peer_bridges>> pcibios_scan_specific_bus(n);
+ * - drivers/edac/i7core_edac.c|1275| <<i7core_xeon_pci_fixup>> pcibios_scan_specific_bus(255-i);
+ */
void pcibios_scan_specific_bus(int busn)
{
int stride = jailhouse_paravirt() ? 1 : 8;
diff --git a/block/blk-core.c b/block/blk-core.c
index 8340f69..9ffd259 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -411,10 +411,23 @@ static void blk_queue_usage_counter_release(struct percpu_ref *ref)
wake_up_all(&q->mq_freeze_wq);
}
+/*
+ * used by:
+ * - block/blk-core.c|466| <<blk_alloc_queue_node>> timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
+ */
static void blk_rq_timed_out_timer(struct timer_list *t)
{
struct request_queue *q = from_timer(q, t, timeout);
+ /*
+ * timeout_work在以下使用:
+ * - block/blk-core.c|235| <<blk_sync_queue>> cancel_work_sync(&q->timeout_work);
+ * - block/blk-core.c|418| <<blk_rq_timed_out_timer>> kblockd_schedule_work(&q->timeout_work);
+ * - block/blk-core.c|467| <<blk_alloc_queue_node>> INIT_WORK(&q->timeout_work, blk_timeout_work);
+ * - block/blk-mq.c|923| <<blk_mq_timeout_work>> container_of(work, struct request_queue, timeout_work);
+ * - block/blk-mq.c|2942| <<blk_mq_init_allocated_queue>> INIT_WORK(&q->timeout_work, blk_mq_timeout_work);
+ * - block/blk-timeout.c|89| <<blk_abort_request>> kblockd_schedule_work(&req->q->timeout_work);
+ */
kblockd_schedule_work(&q->timeout_work);
}
@@ -427,6 +440,18 @@ static void blk_timeout_work(struct work_struct *work)
* @gfp_mask: memory allocation flags
* @node_id: NUMA node to allocate memory from
*/
+/*
+ * called by:
+ * - block/blk-mq.c|2777| <<blk_mq_init_queue>> uninit_q = blk_alloc_queue_node(GFP_KERNEL, set->numa_node);
+ * - block/blk-core.c|345| <<blk_alloc_queue>> return blk_alloc_queue_node(gfp_mask, NUMA_NO_NODE);
+ * - drivers/block/drbd/drbd_main.c|2803| <<drbd_create_device>> q = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE);
+ * - drivers/block/null_blk_main.c|1663| <<null_add_dev>> nullb->q = blk_alloc_queue_node(GFP_KERNEL, dev->home_node);
+ * - drivers/block/umem.c|888| <<mm_pci_probe>> card->queue = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE);
+ * - drivers/lightnvm/core.c|381| <<nvm_create_tgt>> tqueue = blk_alloc_queue_node(GFP_KERNEL, dev->q->node);
+ * - drivers/md/dm.c|1971| <<alloc_dev>> md->queue = blk_alloc_queue_node(GFP_KERNEL, numa_node_id);
+ * - drivers/nvdimm/pmem.c|398| <<pmem_attach_disk>> q = blk_alloc_queue_node(GFP_KERNEL, dev_to_node(dev));
+ * - drivers/nvme/host/multipath.c|310| <<nvme_mpath_alloc_disk>> q = blk_alloc_queue_node(GFP_KERNEL, ctrl->numa_node);
+ */
struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
{
struct request_queue *q;
@@ -463,6 +488,17 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id)
timer_setup(&q->backing_dev_info->laptop_mode_wb_timer,
laptop_mode_timer_fn, 0);
+ /*
+ * q->timeout在以下使用:
+ * - block/blk-core.c|234| <<blk_sync_queue>> del_timer_sync(&q->timeout);
+ * - block/blk-core.c|491| <<blk_alloc_queue_node>> timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
+ * - block/blk-mq.c|967| <<blk_mq_timeout_work>> mod_timer(&q->timeout, next);
+ * - block/blk-timeout.c|154| <<blk_add_timer>> if (!timer_pending(&q->timeout) ||
+ * - block/blk-timeout.c|155| <<blk_add_timer>> time_before(expiry, q->timeout.expires)) {
+ * - block/blk-timeout.c|156| <<blk_add_timer>> unsigned long diff = q->timeout.expires - expiry;
+ * - block/blk-timeout.c|165| <<blk_add_timer>> if (!timer_pending(&q->timeout) || (diff >= HZ / 2))
+ * - block/blk-timeout.c|166| <<blk_add_timer>> mod_timer(&q->timeout, expiry);
+ */
timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
INIT_WORK(&q->timeout_work, blk_timeout_work);
INIT_LIST_HEAD(&q->icq_list);
@@ -1606,6 +1642,12 @@ int kblockd_schedule_work_on(int cpu, struct work_struct *work)
}
EXPORT_SYMBOL(kblockd_schedule_work_on);
+/*
+ * called by:
+ * - block/blk-mq.c|798| <<blk_mq_kick_requeue_list>> kblockd_mod_delayed_work_on(WORK_CPU_UNBOUND, &q->requeue_work, 0);
+ * - block/blk-mq.c|805| <<blk_mq_delay_kick_requeue_list>> kblockd_mod_delayed_work_on(WORK_CPU_UNBOUND, &q->requeue_work,
+ * - block/blk-mq.c|1494| <<__blk_mq_delay_run_hw_queue>> kblockd_mod_delayed_work_on(blk_mq_hctx_next_cpu(hctx), &hctx->run_work,
+ */
int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork,
unsigned long delay)
{
diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index d6e1a9b..801e593 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -164,6 +164,9 @@ static ssize_t blk_mq_hw_sysfs_nr_reserved_tags_show(struct blk_mq_hw_ctx *hctx,
return sprintf(page, "%u\n", hctx->tags->nr_reserved_tags);
}
+/*
+ * 打印cpu_list
+ */
static ssize_t blk_mq_hw_sysfs_cpus_show(struct blk_mq_hw_ctx *hctx, char *page)
{
unsigned int i, first = 1;
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 7513c8e..63f1900 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -529,6 +529,15 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
* Note: When called for a request that is queued on a non-multiqueue request
* queue, the hardware context index is set to zero.
*/
+/*
+ * 调用的例子:
+ * - drivers/nvme/host/nvme.h|129| <<nvme_req_qid>> return blk_mq_unique_tag_to_hwq(blk_mq_unique_tag(req)) + 1;
+ * - drivers/scsi/lpfc/lpfc_scsi.c|693| <<lpfc_get_scsi_buf_s4>> tag = blk_mq_unique_tag(cmnd->request);
+ * - drivers/scsi/qla2xxx/qla_os.c|859| <<qla2xxx_queuecommand>> tag = blk_mq_unique_tag(cmd->request);
+ * - drivers/scsi/scsi_debug.c|3698| <<get_queue>> u32 tag = blk_mq_unique_tag(cmnd->request);
+ * - drivers/scsi/scsi_debug.c|5620| <<scsi_debug_queuecommand>> blk_mq_unique_tag(scp->request), b);
+ * - drivers/scsi/virtio_scsi.c|649| <<virtscsi_pick_vq_mq>> u32 tag = blk_mq_unique_tag(sc->request);
+ */
u32 blk_mq_unique_tag(struct request *rq)
{
return (rq->mq_hctx->queue_num << BLK_MQ_UNIQUE_TAG_BITS) |
diff --git a/block/blk-mq-tag.h b/block/blk-mq-tag.h
index 61deab0..a9f4d7f 100644
--- a/block/blk-mq-tag.h
+++ b/block/blk-mq-tag.h
@@ -18,6 +18,13 @@ struct blk_mq_tags {
struct request **rqs;
struct request **static_rqs;
+ /*
+ * 在以下使用:
+ * - block/blk-mq.c|2072| <<blk_mq_free_rqs>> while (!list_empty(&tags->page_list)) {
+ * - block/blk-mq.c|2073| <<blk_mq_free_rqs>> page = list_first_entry(&tags->page_list, struct page, lru);
+ * - block/blk-mq.c|2162| <<blk_mq_alloc_rqs>> INIT_LIST_HEAD(&tags->page_list);
+ * - block/blk-mq.c|2197| <<blk_mq_alloc_rqs>> list_add_tail(&page->lru, &tags->page_list);
+ */
struct list_head page_list;
};
diff --git a/block/blk-mq.c b/block/blk-mq.c
index ce0f5f4..4ae7444 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -844,6 +844,10 @@ bool blk_mq_queue_inflight(struct request_queue *q)
}
EXPORT_SYMBOL_GPL(blk_mq_queue_inflight);
+/*
+ * called by:
+ * - block/blk-mq.c|913| <<blk_mq_check_expired>> blk_mq_rq_timed_out(rq, reserved);
+ */
static void blk_mq_rq_timed_out(struct request *req, bool reserved)
{
req->rq_flags |= RQF_TIMED_OUT;
@@ -879,6 +883,10 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)
return false;
}
+/*
+ * used by:
+ * - block/blk-mq.c|944| <<blk_mq_timeout_work>> blk_mq_queue_tag_busy_iter(q, blk_mq_check_expired, &next);
+ */
static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
struct request *rq, void *priv, bool reserved)
{
@@ -917,6 +925,18 @@ static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
return true;
}
+/*
+ * q->timeout_work在以下使用:
+ * - lock/blk-core.c|235| <<blk_sync_queue>> cancel_work_sync(&q->timeout_work);
+ * - block/blk-core.c|418| <<blk_rq_timed_out_timer>> kblockd_schedule_work(&q->timeout_work);
+ * - block/blk-core.c|467| <<blk_alloc_queue_node>> INIT_WORK(&q->timeout_work, blk_timeout_work);
+ * - block/blk-mq.c|923| <<blk_mq_timeout_work>> container_of(work, struct request_queue, timeout_work);
+ * - block/blk-mq.c|2942| <<blk_mq_init_allocated_queue>> INIT_WORK(&q->timeout_work, blk_mq_timeout_work);
+ * - block/blk-timeout.c|89| <<blk_abort_request>> kblockd_schedule_work(&req->q->timeout_work);
+ *
+ * used by:
+ * - block/blk-mq.c|2942| <<blk_mq_init_allocated_queue>> INIT_WORK(&q->timeout_work, blk_mq_timeout_work);
+ */
static void blk_mq_timeout_work(struct work_struct *work)
{
struct request_queue *q =
@@ -1352,6 +1372,11 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
return (queued + errors) != 0;
}
+/*
+ * called by:
+ * - block/blk-mq.c|1486| <<__blk_mq_delay_run_hw_queue>> __blk_mq_run_hw_queue(hctx);
+ * - block/blk-mq.c|1661| <<blk_mq_run_work_fn>> __blk_mq_run_hw_queue(hctx);
+ */
static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
{
int srcu_idx;
@@ -1373,6 +1398,11 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
* triggered, and we depend on blk-mq timeout handler to
* handle dispatched requests to this hctx
*/
+ /*
+ * 在以下修改hctx的cpumask:
+ * - block/blk-mq.c|2562| <<blk_mq_map_swqueue>> cpumask_set_cpu(i, hctx->cpumask);
+ * - block/blk-mq.c|2520| <<blk_mq_map_swqueue>> cpumask_clear(hctx->cpumask);
+ */
if (!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask) &&
cpu_online(hctx->next_cpu)) {
printk(KERN_WARNING "run queue from wrong CPU %d, hctx %s\n",
@@ -1457,6 +1487,11 @@ static void __blk_mq_delay_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async,
if (!async && !(hctx->flags & BLK_MQ_F_BLOCKING)) {
int cpu = get_cpu();
+ /*
+ * 在以下修改hctx的cpumask:
+ * - block/blk-mq.c|2562| <<blk_mq_map_swqueue>> cpumask_set_cpu(i, hctx->cpumask);
+ * - block/blk-mq.c|2520| <<blk_mq_map_swqueue>> cpumask_clear(hctx->cpumask);
+ */
if (cpumask_test_cpu(cpu, hctx->cpumask)) {
__blk_mq_run_hw_queue(hctx);
put_cpu();
@@ -1611,6 +1646,16 @@ void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async)
}
EXPORT_SYMBOL(blk_mq_start_stopped_hw_queues);
+/*
+ * 在以下使用:
+ * - block/blk-mq.c|2353| <<blk_mq_alloc_hctx>> INIT_DELAYED_WORK(&hctx->run_work, blk_mq_run_work_fn);
+ *
+ * 在以下调用:
+ * - block/blk-mq-sysfs.c|39| <<blk_mq_hw_sysfs_release>> cancel_delayed_work_sync(&hctx->run_work);
+ * - block/blk-mq.c|1469| <<__blk_mq_delay_run_hw_queue>> kblockd_mod_delayed_work_on(blk_mq_hctx_next_cpu(hctx), &hctx->run_work,
+ * - block/blk-mq.c|1551| <<blk_mq_stop_hw_queue>> cancel_delayed_work(&hctx->run_work);
+ * - block/blk-mq.c|1618| <<blk_mq_run_work_fn>> hctx = container_of(work, struct blk_mq_hw_ctx, run_work.work);
+ */
static void blk_mq_run_work_fn(struct work_struct *work)
{
struct blk_mq_hw_ctx *hctx;
@@ -2041,6 +2086,14 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio)
return cookie;
}
+/*
+ * called by:
+ * - block/blk-mq-sched.c|453| <<blk_mq_sched_free_tags>> blk_mq_free_rqs(set, hctx->sched_tags, hctx_idx);
+ * - block/blk-mq-sched.c|562| <<blk_mq_sched_free_requests>> blk_mq_free_rqs(q->tag_set, hctx->sched_tags, i);
+ * - block/blk-mq-tag.c|505| <<blk_mq_tag_update_depth>> blk_mq_free_rqs(set, *tagsptr, hctx->queue_num);
+ * - block/blk-mq.c|2224| <<blk_mq_alloc_rqs>> blk_mq_free_rqs(set, tags, hctx_idx);
+ * - block/blk-mq.c|2473| <<blk_mq_free_map_and_requests>> blk_mq_free_rqs(set, set->tags[hctx_idx], hctx_idx);
+ */
void blk_mq_free_rqs(struct blk_mq_tag_set *set, struct blk_mq_tags *tags,
unsigned int hctx_idx)
{
@@ -2249,6 +2302,11 @@ static int blk_mq_hctx_notify_dead(unsigned int cpu, struct hlist_node *node)
return 0;
}
+/*
+ * called by:
+ * - block/blk-mq.c|2315| <<blk_mq_exit_hctx>> blk_mq_remove_cpuhp(hctx);
+ * - block/blk-mq.c|2373| <<blk_mq_init_hctx>> blk_mq_remove_cpuhp(hctx);
+ */
static void blk_mq_remove_cpuhp(struct blk_mq_hw_ctx *hctx)
{
cpuhp_state_remove_instance_nocalls(CPUHP_BLK_MQ_DEAD,
@@ -2304,6 +2362,10 @@ static int blk_mq_hw_ctx_size(struct blk_mq_tag_set *tag_set)
return hw_ctx_size;
}
+/*
+ * called by:
+ * - block/blk-mq.c|2895| <<blk_mq_alloc_and_init_hctx>> if (blk_mq_init_hctx(q, set, hctx, hctx_idx))
+ */
static int blk_mq_init_hctx(struct request_queue *q,
struct blk_mq_tag_set *set,
struct blk_mq_hw_ctx *hctx, unsigned hctx_idx)
@@ -2429,10 +2491,18 @@ static void blk_mq_init_cpu_queues(struct request_queue *q,
}
}
+/*
+ * called by:
+ * - block/blk-mq.c|2488| <<blk_mq_map_swqueue>> !__blk_mq_alloc_rq_map(set, hctx_idx)) {
+ * - block/blk-mq.c|2955| <<__blk_mq_alloc_rq_maps>> if (!__blk_mq_alloc_rq_map(set, i))
+ */
static bool __blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, int hctx_idx)
{
int ret = 0;
+ /*
+ * struct blk_mq_tags **tags;
+ */
set->tags[hctx_idx] = blk_mq_alloc_rq_map(set, hctx_idx,
set->queue_depth, set->reserved_tags);
if (!set->tags[hctx_idx])
@@ -2584,6 +2654,11 @@ static void queue_set_hctx_shared(struct request_queue *q, bool shared)
}
}
+/*
+ * called by:
+ * - block/blk-mq.c|2657| <<blk_mq_del_queue_tag_set>> blk_mq_update_tag_set_depth(set, false);
+ * - block/blk-mq.c|2705| <<blk_mq_add_queue_tag_set>> blk_mq_update_tag_set_depth(set, true);
+ */
static void blk_mq_update_tag_set_depth(struct blk_mq_tag_set *set,
bool shared)
{
@@ -2598,6 +2673,34 @@ static void blk_mq_update_tag_set_depth(struct blk_mq_tag_set *set,
}
}
+/*
+ * [0] blk_mq_del_queue_tag_set
+ * [0] blk_mq_exit_queue
+ * [0] blk_cleanup_queue
+ * [0] __scsi_remove_device
+ * [0] scsi_probe_and_add_lun
+ * [0] __scsi_scan_target
+ * [0] scsi_scan_channel
+ * [0] scsi_scan_host_selected
+ * [0] scsi_scan_host
+ * [0] virtscsi_probe
+ * [0] virtio_dev_probe
+ * [0] really_probe
+ * [0] driver_probe_device
+ * [0] device_driver_attach
+ * [0] __driver_attach
+ * [0] bus_for_each_dev
+ * [0] bus_add_driver
+ * [0] driver_register
+ * [0] init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * called only by:
+ * - block/blk-mq.c|3041| <<blk_mq_exit_queue>> blk_mq_del_queue_tag_set(q);
+ */
static void blk_mq_del_queue_tag_set(struct request_queue *q)
{
struct blk_mq_tag_set *set = q->tag_set;
@@ -2614,6 +2717,36 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q)
INIT_LIST_HEAD(&q->tag_set_list);
}
+/*
+ * virtio_scsi的例子, 调用了好多好多遍, 似乎为每一个target都调用了
+ * [0] blk_mq_add_queue_tag_set
+ * [0] blk_mq_init_allocated_queue
+ * [0] blk_mq_init_queue
+ * [0] scsi_mq_alloc_queue
+ * [0] scsi_alloc_sdev
+ * [0] scsi_probe_and_add_lun
+ * [0] __scsi_scan_target
+ * [0] scsi_scan_channel
+ * [0] scsi_scan_host_selected
+ * [0] scsi_scan_host
+ * [0] virtscsi_probe
+ * [0] virtio_dev_probe
+ * [0] really_probe
+ * [0] driver_probe_device
+ * [0] device_driver_attach
+ * [0] __driver_attach
+ * [0] bus_for_each_dev
+ * [0] bus_add_driver
+ * [0] driver_register
+ * [0] init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * called by:
+ * - block/blk-mq.c|2941| <<blk_mq_init_allocated_queue>> blk_mq_add_queue_tag_set(set, q);
+ */
static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set,
struct request_queue *q)
{
@@ -2694,6 +2827,17 @@ void blk_mq_release(struct request_queue *q)
blk_mq_sysfs_deinit(q);
}
+/*
+ * 调用的几个例子:
+ * - drivers/scsi/scsi_lib.c|1832| <<scsi_mq_alloc_queue>> sdev->request_queue = blk_mq_init_queue(&sdev->host->tag_set);
+ * - drivers/nvme/host/core.c|3253| <<nvme_alloc_ns>> ns->queue = blk_mq_init_queue(ctrl->tagset);
+ * - drivers/nvme/host/pci.c|1636| <<nvme_alloc_admin_tags>> dev->ctrl.admin_q = blk_mq_init_queue(&dev->admin_tagset);
+ * - drivers/block/virtio_blk.c|802| <<virtblk_probe>> q = blk_mq_init_queue(&vblk->tag_set);
+ * - drivers/block/xen-blkfront.c|986| <<xlvbd_init_blk_queue>> rq = blk_mq_init_queue(&info->tag_set);
+ * - block/blk-mq.c|2813| <<blk_mq_init_sq_queue>> q = blk_mq_init_queue(set);
+ * - drivers/block/loop.c|2004| <<loop_add>> lo->lo_queue = blk_mq_init_queue(&lo->tag_set);
+ * - drivers/block/null_blk_main.c|1656| <<null_add_dev>> nullb->q = blk_mq_init_queue(nullb->tag_set);
+ */
struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
{
struct request_queue *uninit_q, *q;
@@ -3034,6 +3178,19 @@ static int blk_mq_update_queue_map(struct blk_mq_tag_set *set)
* requested depth down, if it's too large. In that case, the set
* value will be stored in set->queue_depth.
*/
+/*
+ * 被很多调用, 这里是部分调用的例子:
+ * - block/blk-mq.c|2820| <<blk_mq_init_sq_queue>> ret = blk_mq_alloc_tag_set(set);
+ * - block/bsg-lib.c|382| <<bsg_setup_queue>> if (blk_mq_alloc_tag_set(set))
+ * - drivers/block/loop.c|2000| <<loop_add>> err = blk_mq_alloc_tag_set(&lo->tag_set);
+ * - drivers/block/null_blk_main.c|1562| <<null_init_tag_set>> return blk_mq_alloc_tag_set(set);
+ * - drivers/block/virtio_blk.c|798| <<virtblk_probe>> err = blk_mq_alloc_tag_set(&vblk->tag_set);
+ * - drivers/block/xen-blkfront.c|984| <<xlvbd_init_blk_queue>> if (blk_mq_alloc_tag_set(&info->tag_set))
+ * - drivers/md/dm-rq.c|561| <<dm_mq_init_request_queue>> err = blk_mq_alloc_tag_set(md->tag_set);
+ * - drivers/nvme/host/pci.c|1632| <<nvme_alloc_admin_tags>> if (blk_mq_alloc_tag_set(&dev->admin_tagset))
+ * - drivers/nvme/host/pci.c|2277| <<nvme_dev_add>> ret = blk_mq_alloc_tag_set(&dev->tagset);
+ * - drivers/scsi/scsi_lib.c|2050| <<scsi_mq_setup_tags>> return blk_mq_alloc_tag_set(&shost->tag_set);
+ */
int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
{
int i, ret;
@@ -3252,6 +3409,10 @@ static void blk_mq_elv_switch_back(struct list_head *head,
mutex_unlock(&q->sysfs_lock);
}
+/*
+ * called by only:
+ * - block/blk-mq.c|3408| <<blk_mq_update_nr_hw_queues>> __blk_mq_update_nr_hw_queues(set, nr_hw_queues);
+ */
static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
int nr_hw_queues)
{
diff --git a/block/blk-mq.h b/block/blk-mq.h
index 633a5a7..850fd7d 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -149,6 +149,15 @@ static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q,
* care about preemption, since we know the ctx's are persistent. This does
* mean that we can't rely on ctx always matching the currently running CPU.
*/
+/*
+ * called by:
+ * - block/blk-mq-sched.c|324| <<__blk_mq_sched_bio_merge>> struct blk_mq_ctx *ctx = blk_mq_get_ctx(q);
+ * - block/blk-mq-tag.c|172| <<blk_mq_get_tag>> data->ctx = blk_mq_get_ctx(data->q);
+ * - block/blk-mq.c|363| <<blk_mq_get_request>> data->ctx = blk_mq_get_ctx(q);
+ * - block/kyber-iosched.c|568| <<kyber_bio_merge>> struct blk_mq_ctx *ctx = blk_mq_get_ctx(hctx->queue);
+ *
+ * 这个函数会通过get_cpu()来disable preemption
+ */
static inline struct blk_mq_ctx *blk_mq_get_ctx(struct request_queue *q)
{
return __blk_mq_get_ctx(q, get_cpu());
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 8aa68fa..f13f6f5 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -78,6 +78,15 @@ ssize_t part_timeout_store(struct device *dev, struct device_attribute *attr,
* LLDDs who implement their own error recovery MAY ignore the timeout
* event if they generated blk_abort_request.
*/
+/*
+ * called by:
+ * - drivers/ata/libata-eh.c|916| <<ata_qc_schedule_eh>> blk_abort_request(qc->scsicmd->request);
+ * - drivers/block/mtip32xx/mtip32xx.c|2618| <<mtip_queue_cmd>> blk_abort_request(req);
+ * - drivers/s390/block/dasd_ioctl.c|168| <<dasd_ioctl_abortio>> blk_abort_request(cqr->callback_data);
+ * - drivers/scsi/libsas/sas_ata.c|588| <<sas_ata_task_abort>> blk_abort_request(qc->scsicmd->request);
+ * - drivers/scsi/libsas/sas_scsi_host.c|912| <<sas_task_abort>> blk_abort_request(sc->request);
+ * - drivers/scsi/scsi_debug.c|4390| <<schedule_resp>> blk_abort_request(cmnd->request);
+ */
void blk_abort_request(struct request *req)
{
/*
@@ -90,6 +99,10 @@ void blk_abort_request(struct request *req)
}
EXPORT_SYMBOL_GPL(blk_abort_request);
+/*
+ * called by:
+ * - block/blk-timeout.c|134| <<blk_add_timer>> expiry = blk_rq_timeout(round_jiffies_up(expiry));
+ */
unsigned long blk_rq_timeout(unsigned long timeout)
{
unsigned long maxt;
@@ -109,6 +122,11 @@ unsigned long blk_rq_timeout(unsigned long timeout)
* Each request has its own timer, and as it is added to the queue, we
* set up the timer. When the request completes, we cancel the timer.
*/
+/*
+ * called by:
+ * - block/blk-mq.c|691| <<blk_mq_start_request>> blk_add_timer(rq);
+ * - block/blk-mq.c|863| <<blk_mq_rq_timed_out>> blk_add_timer(req);
+ */
void blk_add_timer(struct request *req)
{
struct request_queue *q = req->q;
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 39f5d17..a8f75cd 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -871,6 +871,10 @@ static void acpi_pci_root_release_info(struct pci_host_bridge *bridge)
__acpi_pci_root_release_info(bridge->release_data);
}
+/*
+ * called by:
+ * - arch/x86/pci/acpi.c|368| <<pci_acpi_scan_root>> bus = acpi_pci_root_create(root, &acpi_pci_root_ops,
+ */
struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root,
struct acpi_pci_root_ops *ops,
struct acpi_pci_root_info *info,
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 0e28270..965b12f 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1951,6 +1951,12 @@ static int acpi_scan_attach_handler(struct acpi_device *device)
return ret;
}
+/*
+ * called by:
+ * - drivers/acpi/scan.c|2006| <<acpi_bus_attach>> acpi_bus_attach(child);
+ * - drivers/acpi/scan.c|2026| <<acpi_walk_dep_device_list>> acpi_bus_attach(adev);
+ * - drivers/acpi/scan.c|2058| <<acpi_bus_scan>> acpi_bus_attach(device);
+ */
static void acpi_bus_attach(struct acpi_device *device)
{
struct acpi_device *child;
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 524d6bd..db63737 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2464,6 +2464,10 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
kfree(dev);
}
+/*
+ * called by only:
+ * - drivers/nvme/host/pci.c|2600| <<nvme_reset_work>> nvme_remove_dead_ctrl(dev, result);
+ */
static void nvme_remove_dead_ctrl(struct nvme_dev *dev, int status)
{
dev_warn(dev->ctrl.device, "Removing after probe failure status: %d\n", status);
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index e039b74..034610f 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -1149,6 +1149,13 @@ EXPORT_SYMBOL(pci_enable_msix_range);
* To get the Linux IRQ number used for a vector that can be passed to
* request_irq() use the pci_irq_vector() helper.
*/
+/*
+ * called by:
+ * - drivers/nvme/host/pci.c|2089| <<nvme_setup_irqs>> return pci_alloc_irq_vectors_affinity(pdev, 1, irq_queues,
+ * - drivers/scsi/qla2xxx/qla_isr.c|3463| <<qla24xx_enable_msix>> ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs,
+ * - drivers/virtio/virtio_pci_common.c|133| <<vp_request_msix_vectors>> err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors,
+ * - include/linux/pci.h|1466| <<pci_alloc_irq_vectors>> return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags,
+ */
int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs,
unsigned int max_vecs, unsigned int flags,
struct irq_affinity *affd)
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 0e8e2c1..36a943c 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -31,6 +31,17 @@ static struct resource busn_resource = {
};
/* Ugh. Need to stop exporting this to modules. */
+/*
+ * used by:
+ * - arch/x86/pci/i386.c|360| <<pcibios_assign_resources>> list_for_each_entry(bus, &pci_root_buses, node)
+ * - arch/x86/pci/i386.c|394| <<pcibios_resource_survey>> list_for_each_entry(bus, &pci_root_buses, node)
+ * - arch/x86/pci/i386.c|397| <<pcibios_resource_survey>> list_for_each_entry(bus, &pci_root_buses, node)
+ * - arch/x86/pci/i386.c|399| <<pcibios_resource_survey>> list_for_each_entry(bus, &pci_root_buses, node)
+ * - drivers/pci/probe.c|937| <<pci_register_host_bridge>> list_add_tail(&bus->node, &pci_root_buses);
+ * - drivers/pci/search.c|168| <<pci_find_next_bus>> n = from ? from->node.next : pci_root_buses.next;
+ * - drivers/pci/search.c|169| <<pci_find_next_bus>> if (n != &pci_root_buses)
+ * - drivers/pci/setup-bus.c|1803| <<pci_assign_unassigned_resources>> list_for_each_entry(root_bus, &pci_root_buses, node) {
+ */
LIST_HEAD(pci_root_buses);
EXPORT_SYMBOL(pci_root_buses);
@@ -603,6 +614,12 @@ static void pci_init_host_bridge(struct pci_host_bridge *bridge)
bridge->native_ltr = 1;
}
+/*
+ * called by:
+ * - drivers/pci/controller/pci-v3-semi.c|746| <<v3_pci_probe>> host = pci_alloc_host_bridge(sizeof(*v3));
+ * - drivers/pci/controller/pcie-rcar.c|1132| <<rcar_pcie_probe>> bridge = pci_alloc_host_bridge(sizeof(*pcie));
+ * - drivers/pci/probe.c|3278| <<pci_create_root_bus>> bridge = pci_alloc_host_bridge(0);
+ */
struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
{
struct pci_host_bridge *bridge;
@@ -827,6 +844,11 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus)
dev_set_msi_domain(&bus->dev, d);
}
+/*
+ * called by:
+ * - drivers/pci/probe.c|3187| <<pci_create_root_bus>> error = pci_register_host_bridge(bridge);
+ * - drivers/pci/probe.c|3309| <<pci_scan_root_bus_bridge>> ret = pci_register_host_bridge(bridge);
+ */
static int pci_register_host_bridge(struct pci_host_bridge *bridge)
{
struct device *parent = bridge->dev.parent;
@@ -863,6 +885,11 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
goto free;
}
+ /*
+ * i440fx上pci的name例子:
+ * pci0000:00
+ * pci0000:03
+ */
dev_set_name(&bridge->dev, "pci%04x:%02x", pci_domain_nr(bus),
bridge->busnr);
@@ -897,6 +924,13 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
/* Create legacy_io and legacy_mem files for this bus */
pci_create_legacy_files(bus);
+ /*
+ * 例子:
+ * [ 0.324037] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-02])
+ * [ 0.325050] PCI host bridge to bus 0000:00
+ * [ 0.371036] ACPI: PCI Root Bridge [PC03] (domain 0000 [bus 03-04])
+ * [ 0.372048] PCI host bridge to bus 0000:03
+ */
if (parent)
dev_info(parent, "PCI host bridge to bus %s\n", name);
else
@@ -1141,6 +1175,13 @@ static bool pci_ea_fixed_busnrs(struct pci_dev *dev, u8 *sec, u8 *sub)
*
* Return: New subordinate number covering all buses behind this bridge.
*/
+/*
+ * called by:
+ * - drivers/pci/probe.c|1396| <<pci_scan_bridge>> return pci_scan_bridge_extend(bus, dev, max, 0, pass);
+ * - drivers/pci/probe.c|3070| <<pci_scan_child_bus_extend>> max = pci_scan_bridge_extend(bus, dev, max, 0, 0);
+ * - drivers/pci/probe.c|3105| <<pci_scan_child_bus_extend>> max = pci_scan_bridge_extend(bus, dev, cmax, buses, 1);
+ * - drivers/pci/probe.c|3530| <<pci_hp_add_bridge>> pci_scan_bridge_extend(parent, dev, busnr, available_buses, 1);
+ */
static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,
int max, unsigned int available_buses,
int pass)
@@ -1706,6 +1747,72 @@ static void early_dump_pci_device(struct pci_dev *pdev)
* Returns 0 on success and negative if unknown type of device (not normal,
* bridge or CardBus).
*/
+/*
+ * [0] pci_setup_device
+ * [0] pci_scan_single_device
+ * [0] pci_scan_slot
+ * [0] pci_scan_child_bus_extend
+ * [0] acpi_pci_root_create
+ * [0] pci_acpi_scan_root
+ * [0] acpi_pci_root_add
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_scan
+ * [0] acpi_scan_init
+ * [0] acpi_init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * [0] pci_setup_device
+ * [0] pci_scan_single_device
+ * [0] pci_scan_slot
+ * [0] pci_scan_child_bus_extend
+ * [0] pci_scan_bridge_extend
+ * [0] pci_scan_child_bus_extend
+ * [0] acpi_pci_root_create
+ * [0] pci_acpi_scan_root
+ * [0] acpi_pci_root_add
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_scan
+ * [0] acpi_scan_init
+ * [0] acpi_init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * 设置了pci=noacpi
+ * [0] pci_setup_device
+ * [0] pci_scan_single_device
+ * [0] pci_scan_slot
+ * [0] pci_scan_child_bus_extend
+ * [0] pci_scan_root_bus
+ * [0] pcibios_scan_root
+ * [0] pci_legacy_init
+ * [0] pci_subsys_init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * [0] pci_setup_device
+ * [0] pci_scan_single_device
+ * [0] pci_scan_slot
+ * [0] pci_scan_child_bus_extend
+ * [0] pci_scan_root_bus
+ * [0] pcibios_scan_root
+ * [0] pcibios_scan_specific_bus
+ * [0] pci_subsys_init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ */
int pci_setup_device(struct pci_dev *dev)
{
u32 class;
@@ -2788,6 +2895,19 @@ static int only_one_child(struct pci_bus *bus)
*
* Returns the number of new devices found.
*/
+/*
+ * called by:
+ * - drivers/pci/hotplug/acpiphp_glue.c|431| <<acpiphp_rescan_slot>> return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
+ * - drivers/pci/hotplug/cpci_hotplug_pci.c|262| <<cpci_configure_slot>> n = pci_scan_slot(slot->bus, slot->devfn);
+ * - drivers/pci/hotplug/cpqphp_pci.c|86| <<cpqhp_configure_device>> num = pci_scan_slot(ctrl->pci_dev->bus, PCI_DEVFN(func->device, func->function));
+ * - drivers/pci/hotplug/ibmphp_core.c|751| <<ibm_configure_device>> num = pci_scan_slot(bus,
+ * - drivers/pci/hotplug/pciehp_pci.c|54| <<pciehp_configure_device>> num = pci_scan_slot(parent, PCI_DEVFN(0, 0));
+ * - drivers/pci/hotplug/s390_pci_hpc.c|82| <<enable_slot>> pci_scan_slot(slot->zdev->bus, ZPCI_DEVFN);
+ * - drivers/pci/hotplug/sgi_hotplug.c|366| <<enable_slot>> num_funcs = pci_scan_slot(slot->pci_bus,
+ * - drivers/pci/hotplug/shpchp_pci.c|43| <<shpchp_configure_device>> num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
+ * - drivers/pci/probe.c|3074| <<pci_scan_child_bus_extend>> nr_devs = pci_scan_slot(bus, devfn);
+ * - drivers/pcmcia/cardbus.c|75| <<cb_alloc>> s->functions = pci_scan_slot(bus, PCI_DEVFN(0, 0));
+ */
int pci_scan_slot(struct pci_bus *bus, int devfn)
{
unsigned fn, nr = 0;
@@ -3000,6 +3120,69 @@ void __weak pcibios_fixup_bus(struct pci_bus *bus)
* equally between hotplug-capable bridges to allow future extension of the
* hierarchy.
*/
+/*
+ * qemu在i440fx上加了一个pxb, 一个bus是0, 一个bus是0x3
+ * [0] pci_scan_child_bus_extend
+ * [0] acpi_pci_root_create
+ * [0] pci_acpi_scan_root
+ * [0] acpi_pci_root_add
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_scan
+ * [0] acpi_scan_init
+ * [0] acpi_init
+ * [0] do_one_initcall
+ * [0] kernel_init_freeable
+ * [0] kernel_init
+ * [0] ret_from_fork
+ *
+ * 0x3的bus上挂了nvme, 是bus=0x4
+ * [0] pci_scan_child_bus_extend
+ * [0] pci_scan_bridge_extend
+ * [0] pci_scan_child_bus_extend
+ * [0] acpi_pci_root_create
+ * [0] pci_acpi_scan_root
+ * [0] acpi_pci_root_add
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_attach
+ * [0] acpi_bus_scan
+ * [0] acpi_scan_init
+ * [0] acpi_init