-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlinux-v5.12.patch
407 lines (385 loc) · 15.5 KB
/
linux-v5.12.patch
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
From 59c550f0a25507e9880824949726ebf7146f61cf Mon Sep 17 00:00:00 2001
From: Dongli Zhang <[email protected]>
Date: Tue, 29 Jun 2021 21:27:58 -0700
Subject: [PATCH 1/1] linux v5.12
Signed-off-by: Dongli Zhang <[email protected]>
---
arch/x86/kvm/irq_comm.c | 35 ++++++++++++++++++++++++++
arch/x86/kvm/lapic.c | 5 ++++
drivers/scsi/virtio_scsi.c | 12 +++++++++
drivers/vhost/vringh.c | 9 +++++++
drivers/virtio/virtio.c | 30 ++++++++++++++++++++++
drivers/virtio/virtio_dma_buf.c | 17 +++++++++++++
drivers/virtio/virtio_pci_common.c | 12 +++++++++
drivers/virtio/virtio_pci_modern_dev.c | 23 +++++++++++++++++
drivers/virtio/virtio_ring.c | 11 ++++++++
9 files changed, 154 insertions(+)
diff --git a/arch/x86/kvm/irq_comm.c b/arch/x86/kvm/irq_comm.c
index 8a4de3f12820..fc0d631a0876 100644
--- a/arch/x86/kvm/irq_comm.c
+++ b/arch/x86/kvm/irq_comm.c
@@ -99,6 +99,41 @@ int kvm_irq_delivery_to_apic(struct kvm *kvm, struct kvm_lapic *src,
return r;
}
+/*
+ * # sudo /usr/share/bcc/tools/trace -t -C 'kvm_set_msi_irq'
+ * TIME CPU PID TID COMM FUNC
+ * 1.409018 4 23372 23372 vhost-23357 kvm_set_msi_irq
+ * 1.430408 4 23372 23372 vhost-23357 kvm_set_msi_irq
+ * 1.557921 1 23372 23372 vhost-23357 kvm_set_msi_irq
+ * 1.594878 5 23372 23372 vhost-23357 kvm_set_msi_irq
+ * 1.624964 4 23372 23372 vhost-23357 kvm_set_msi_irq
+ *
+ * 9.586209 17 23357 23357 qemu-system-x86 kvm_set_msi_irq
+ * 9.586283 17 23357 23357 qemu-system-x86 kvm_set_msi_irq
+ * 9.586399 5 23372 23372 vhost-23357 kvm_set_msi_irq
+ * 9.586470 17 23357 23357 qemu-system-x86 kvm_set_msi_irq
+ * 9.586482 17 23357 23357 qemu-system-x86 kvm_set_msi_irq
+ *
+ * kvm_set_msi_irq
+ * irqfd_wakeup
+ * __wake_up_common
+ * __wake_up_locked_key
+ * eventfd_signal
+ * vhost_signal
+ * vhost_add_used_and_signal_n
+ * handle_rx
+ * handle_rx_net
+ * vhost_worker
+ * kthread
+ * ret_from_fork
+ *
+ * called by:
+ * - arch/x86/kvm/irq_comm.c|140| <<kvm_set_msi>> kvm_set_msi_irq(kvm, e, &irq);
+ * - arch/x86/kvm/irq_comm.c|172| <<kvm_arch_set_irq_inatomic>> kvm_set_msi_irq(kvm, e, &irq);
+ * - arch/x86/kvm/irq_comm.c|413| <<kvm_scan_ioapic_routes>> kvm_set_msi_irq(vcpu->kvm, entry, &irq);
+ * - arch/x86/kvm/svm/avic.c|785| <<get_pi_vcpu_info>> kvm_set_msi_irq(kvm, e, &irq);
+ * - arch/x86/kvm/vmx/posted_intr.c|292| <<pi_update_irte>> kvm_set_msi_irq(kvm, e, &irq);
+ */
void kvm_set_msi_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e,
struct kvm_lapic_irq *irq)
{
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index cc369b9ad8f1..abba6196e958 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -116,6 +116,11 @@ static bool kvm_can_post_timer_interrupt(struct kvm_vcpu *vcpu)
return pi_inject_timer && kvm_vcpu_apicv_active(vcpu);
}
+/*
+ * called by:
+ * - arch/x86/kvm/lapic.c|1838| <<start_hv_timer>> if (!kvm_can_use_hv_timer(vcpu))
+ * - arch/x86/kvm/x86.c|1831| <<handle_fastpath_set_tscdeadline>> if (!kvm_can_use_hv_timer(vcpu))
+ */
bool kvm_can_use_hv_timer(struct kvm_vcpu *vcpu)
{
return kvm_x86_ops.set_hv_timer
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index b9c86a7e3b97..4c5925883598 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -600,6 +600,11 @@ static int virtscsi_queuecommand(struct Scsi_Host *shost,
return 0;
}
+/*
+ * called by:
+ * - drivers/scsi/virtio_scsi.c|655| <<virtscsi_device_reset>> return virtscsi_tmf(vscsi, cmd);
+ * - drivers/scsi/virtio_scsi.c|713| <<virtscsi_abort>> return virtscsi_tmf(vscsi, cmd);
+ */
static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd)
{
DECLARE_COMPLETION_ONSTACK(comp);
@@ -632,6 +637,9 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd)
return ret;
}
+/*
+ * struct scsi_host_template virtscsi_host_template.eh_device_reset_handler = virtscsi_device_reset()
+ */
static int virtscsi_device_reset(struct scsi_cmnd *sc)
{
struct virtio_scsi *vscsi = shost_priv(sc->device->host);
@@ -690,6 +698,10 @@ static int virtscsi_change_queue_depth(struct scsi_device *sdev, int qdepth)
return scsi_change_queue_depth(sdev, min(max_depth, qdepth));
}
+/*
+ * called by:
+ * - struct scsi_host_template virtscsi_host_template.eh_abort_handler = virtscsi_abort()
+ */
static int virtscsi_abort(struct scsi_cmnd *sc)
{
struct virtio_scsi *vscsi = shost_priv(sc->device->host);
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 85d85faba058..8ce073e903db 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -1404,6 +1404,10 @@ EXPORT_SYMBOL(vringh_notify_enable_iotlb);
* This is our normal running state: we disable and then only enable when
* we're going to sleep.
*/
+/*
+ * called by:
+ * - drivers/vhost/vringh.c|1407| <<vringh_notify_disable_iotlb>> void vringh_notify_disable_iotlb(struct vringh *vrh)
+ */
void vringh_notify_disable_iotlb(struct vringh *vrh)
{
__vringh_notify_disable(vrh, putu16_iotlb);
@@ -1416,6 +1420,11 @@ EXPORT_SYMBOL(vringh_notify_disable_iotlb);
*
* Returns -errno or 0 if we don't need to tell the other side, 1 if we do.
*/
+/*
+ * called by:
+ * - drivers/vdpa/vdpa_sim/vdpa_sim_net.c|95| <<vdpasim_net_work>> if (vringh_need_notify_iotlb(&txq->vring) > 0)
+ * - drivers/vdpa/vdpa_sim/vdpa_sim_net.c|97| <<vdpasim_net_work>> if (vringh_need_notify_iotlb(&rxq->vring) > 0)
+ */
int vringh_need_notify_iotlb(struct vringh *vrh)
{
return __vringh_need_notify(vrh, getu16_iotlb);
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 4b15c00c0a0a..80ce2e9a95a2 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -69,6 +69,10 @@ static struct attribute *virtio_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(virtio_dev);
+/*
+ * called by:
+ * - drivers/virtio/virtio.c|91| <<virtio_dev_match>> if (virtio_id_match(dev, &ids[i]))
+ */
static inline int virtio_id_match(const struct virtio_device *dev,
const struct virtio_device_id *id)
{
@@ -80,6 +84,9 @@ static inline int virtio_id_match(const struct virtio_device *dev,
/* This looks through all the IDs a driver claims to support. If any of them
* match, we return 1 and the kernel will call virtio_dev_probe(). */
+/*
+ * struct bus_type virtio_bus.match = virtio_dev_match()
+ */
static int virtio_dev_match(struct device *_dv, struct device_driver *_dr)
{
unsigned int i;
@@ -93,6 +100,9 @@ static int virtio_dev_match(struct device *_dv, struct device_driver *_dr)
return 0;
}
+/*
+ * struct bus_type virtio_bus.uevent = virtio_uevent()
+ */
static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env)
{
struct virtio_device *dev = dev_to_virtio(_dv);
@@ -101,6 +111,10 @@ static int virtio_uevent(struct device *_dv, struct kobj_uevent_env *env)
dev->id.device, dev->id.vendor);
}
+/*
+ * called by:
+ * - include/linux/virtio_config.h|168| <<virtio_has_feature>> virtio_check_driver_offered_feature(vdev, fbit);
+ */
void virtio_check_driver_offered_feature(const struct virtio_device *vdev,
unsigned int fbit)
{
@@ -203,6 +217,9 @@ int virtio_finalize_features(struct virtio_device *dev)
}
EXPORT_SYMBOL_GPL(virtio_finalize_features);
+/*
+ * struct bus_type virtio_bus.probe = virtio_dev_probe()
+ */
static int virtio_dev_probe(struct device *_d)
{
int err, i;
@@ -278,6 +295,9 @@ static int virtio_dev_probe(struct device *_d)
}
+/*
+ * struct bus_type virtio_bus.remove = virtio_dev_remove()
+ */
static int virtio_dev_remove(struct device *_d)
{
struct virtio_device *dev = dev_to_virtio(_d);
@@ -328,6 +348,16 @@ EXPORT_SYMBOL_GPL(unregister_virtio_driver);
*
* Returns: 0 on suceess, -error on failure
*/
+/*
+ * called by:
+ * - arch/um/drivers/virtio_uml.c|1141| <<virtio_uml_probe>> rc = register_virtio_device(&vu_dev->vdev);
+ * - drivers/platform/mellanox/mlxbf-tmfifo.c|1086| <<mlxbf_tmfifo_create_vdev>> ret = register_virtio_device(&tm_vdev->vdev);
+ * - drivers/remoteproc/remoteproc_virtio.c|416| <<rproc_add_virtio_dev>> ret = register_virtio_device(vdev);
+ * - drivers/s390/virtio/virtio_ccw.c|1321| <<virtio_ccw_online>> ret = register_virtio_device(&vcdev->vdev);
+ * - drivers/virtio/virtio_mmio.c|626| <<virtio_mmio_probe>> rc = register_virtio_device(&vm_dev->vdev);
+ * - drivers/virtio/virtio_pci_common.c|552| <<virtio_pci_probe>> rc = register_virtio_device(&vp_dev->vdev);
+ * - drivers/virtio/virtio_vdpa.c|355| <<virtio_vdpa_probe>> ret = register_virtio_device(&vd_dev->vdev);
+ */
int register_virtio_device(struct virtio_device *dev)
{
int err;
diff --git a/drivers/virtio/virtio_dma_buf.c b/drivers/virtio/virtio_dma_buf.c
index 5127a2f0c986..12ee0ddf80af 100644
--- a/drivers/virtio/virtio_dma_buf.c
+++ b/drivers/virtio/virtio_dma_buf.c
@@ -17,6 +17,10 @@
* for an virtio exported object that can be queried by other virtio drivers
* for the object's UUID.
*/
+/*
+ * called by:
+ * - drivers/gpu/drm/virtio/virtgpu_prime.c|109| <<virtgpu_gem_prime_export>> buf = virtio_dma_buf_export(&exp_info);
+ */
struct dma_buf *virtio_dma_buf_export
(const struct dma_buf_export_info *exp_info)
{
@@ -37,6 +41,12 @@ EXPORT_SYMBOL(virtio_dma_buf_export);
/**
* virtio_dma_buf_attach - mandatory attach callback for virtio dma-bufs
*/
+/*
+ * 在以下使用virtio_dma_buf_attach():
+ * - drivers/gpu/drm/virtio/virtgpu_prime.c|49| <<global>> .attach = virtio_dma_buf_attach,
+ * - drivers/virtio/virtio_dma_buf.c|28| <<global>> exp_info->ops->attach != &virtio_dma_buf_attach ||
+ * - drivers/virtio/virtio_dma_buf.c|63| <<is_virtio_dma_buf>> return dma_buf->ops->attach == &virtio_dma_buf_attach;
+ */
int virtio_dma_buf_attach(struct dma_buf *dma_buf,
struct dma_buf_attachment *attach)
{
@@ -58,6 +68,10 @@ EXPORT_SYMBOL(virtio_dma_buf_attach);
* is_virtio_dma_buf - returns true if the given dma-buf is a virtio dma-buf
* @dma_buf: buffer to query
*/
+/*
+ * called by:
+ * - drivers/virtio/virtio_dma_buf.c|81| <<virtio_dma_buf_get_uuid>> if (!is_virtio_dma_buf(dma_buf))
+ */
bool is_virtio_dma_buf(struct dma_buf *dma_buf)
{
return dma_buf->ops->attach == &virtio_dma_buf_attach;
@@ -71,6 +85,9 @@ EXPORT_SYMBOL(is_virtio_dma_buf);
*
* Returns: 0 on success, negative on failure.
*/
+/*
+ * 没人调用
+ */
int virtio_dma_buf_get_uuid(struct dma_buf *dma_buf,
uuid_t *uuid)
{
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
index 222d630c41fc..3be1f8b9a48b 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -491,6 +491,9 @@ static const struct dev_pm_ops virtio_pci_pm_ops = {
/* Qumranet donated their vendor ID for devices 0x1000 thru 0x10FF. */
+/*
+ * struct pci_driver virtio_pci_driver.id_table = virtio_pci_id_table
+ */
static const struct pci_device_id virtio_pci_id_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_ANY_ID) },
{ 0 }
@@ -509,6 +512,9 @@ static void virtio_pci_release_dev(struct device *_d)
kfree(vp_dev);
}
+/*
+ * struct pci_driver virtio_pci_driver.probe = virtio_pci_probe()
+ */
static int virtio_pci_probe(struct pci_dev *pci_dev,
const struct pci_device_id *id)
{
@@ -571,6 +577,9 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
return rc;
}
+/*
+ * struct pci_driver virtio_pci_driver.remove = virtio_pci_remove()
+ */
static void virtio_pci_remove(struct pci_dev *pci_dev)
{
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
@@ -589,6 +598,9 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
put_device(dev);
}
+/*
+ * struct pci_driver virtio_pci_driver.sriov_configure = virtio_pci_sriov_configure()
+ */
static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs)
{
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c
index cbd667496bb1..5320088d5fa0 100644
--- a/drivers/virtio/virtio_pci_modern_dev.c
+++ b/drivers/virtio/virtio_pci_modern_dev.c
@@ -16,6 +16,14 @@
*
* Returns the io address of for the part of the capability
*/
+/*
+ * called by:
+ * - drivers/virtio/virtio_pci_modern.c|245| <<setup_vq>> vq->priv = (void __force *)vp_modern_map_capability(mdev,
+ * - drivers/virtio/virtio_pci_modern_dev.c|275| <<vp_modern_probe>> mdev->common = vp_modern_map_capability(mdev, common,
+ * - drivers/virtio/virtio_pci_modern_dev.c|281| <<vp_modern_probe>> mdev->isr = vp_modern_map_capability(mdev, isr, sizeof(u8), 1,
+ * - drivers/virtio/virtio_pci_modern_dev.c|308| <<vp_modern_probe>> mdev->notify_base = vp_modern_map_capability(mdev, notify,
+ * - drivers/virtio/virtio_pci_modern_dev.c|322| <<vp_modern_probe>> mdev->device = vp_modern_map_capability(mdev, device, 0, 4,
+ */
void __iomem *vp_modern_map_capability(struct virtio_pci_modern_device *mdev, int off,
size_t minlen,
u32 align,
@@ -101,6 +109,13 @@ EXPORT_SYMBOL_GPL(vp_modern_map_capability);
*
* Returns offset of the capability, or 0.
*/
+/*
+ * called by:
+ * - drivers/virtio/virtio_pci_modern_dev.c|232| <<vp_modern_probe>> common = virtio_pci_find_capability(pci_dev, VIRTIO_PCI_CAP_COMMON_CFG,
+ * - drivers/virtio/virtio_pci_modern_dev.c|242| <<vp_modern_probe>> isr = virtio_pci_find_capability(pci_dev, VIRTIO_PCI_CAP_ISR_CFG,
+ * - drivers/virtio/virtio_pci_modern_dev.c|245| <<vp_modern_probe>> notify = virtio_pci_find_capability(pci_dev, VIRTIO_PCI_CAP_NOTIFY_CFG,
+ * - drivers/virtio/virtio_pci_modern_dev.c|265| <<vp_modern_probe>> device = virtio_pci_find_capability(pci_dev, VIRTIO_PCI_CAP_DEVICE_CFG,
+ */
static inline int virtio_pci_find_capability(struct pci_dev *dev, u8 cfg_type,
u32 ioresource_types, int *bars)
{
@@ -202,6 +217,10 @@ static inline void check_offsets(void)
*
* Return 0 on succeed otherwise fail
*/
+/*
+ * called by:
+ * - drivers/virtio/virtio_pci_modern.c|448| <<virtio_pci_modern_probe>> err = vp_modern_probe(mdev);
+ */
int vp_modern_probe(struct virtio_pci_modern_device *mdev)
{
struct pci_dev *pci_dev = mdev->pci_dev;
@@ -344,6 +363,10 @@ EXPORT_SYMBOL_GPL(vp_modern_probe);
* vp_modern_probe: remove and cleanup the modern virtio pci device
* @mdev: the modern virtio-pci device
*/
+/*
+ * called by:
+ * - drivers/virtio/virtio_pci_modern.c|470| <<virtio_pci_modern_remove>> vp_modern_remove(mdev);
+ */
void vp_modern_remove(struct virtio_pci_modern_device *mdev)
{
struct pci_dev *pci_dev = mdev->pci_dev;
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 71e16b53e9c1..a2daa2590524 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -1122,6 +1122,12 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
return virtqueue_add_indirect_packed(vq, sgs, total_sg,
out_sgs, in_sgs, data, gfp);
+ /*
+ * struct vring_virtqueue *vq:
+ * -> struct {
+ * -> u16 next_avail_idx;
+ * } packed;
+ */
head = vq->packed.next_avail_idx;
avail_used_flags = vq->packed.avail_used_flags;
@@ -1956,6 +1962,11 @@ EXPORT_SYMBOL_GPL(virtqueue_enable_cb_prepare);
*
* This does not need to be serialized.
*/
+/*
+ * called by:
+ * - drivers/net/virtio_net.c|335| <<virtqueue_napi_complete>> if (unlikely(virtqueue_poll(vq, opaque)))
+ * - drivers/virtio/virtio_ring.c|1993| <<virtqueue_enable_cb>> return !virtqueue_poll(_vq, last_used_idx);
+ */
bool virtqueue_poll(struct virtqueue *_vq, unsigned last_used_idx)
{
struct vring_virtqueue *vq = to_vvq(_vq);
--
2.17.1