|
23 | 23 | #include "vfio_pci_priv.h"
|
24 | 24 |
|
25 | 25 | struct vfio_pci_irq_ctx {
|
26 |
| - struct eventfd_ctx *trigger; |
27 |
| - struct virqfd *unmask; |
28 |
| - struct virqfd *mask; |
29 |
| - char *name; |
30 |
| - bool masked; |
| 26 | + struct vfio_pci_core_device *vdev; |
| 27 | + struct eventfd_ctx *trigger; |
| 28 | + struct virqfd *unmask; |
| 29 | + struct virqfd *mask; |
| 30 | + char *name; |
| 31 | + bool masked; |
31 | 32 | struct irq_bypass_producer producer;
|
32 | 33 | };
|
33 | 34 |
|
@@ -228,15 +229,11 @@ void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev)
|
228 | 229 |
|
229 | 230 | static irqreturn_t vfio_intx_handler(int irq, void *dev_id)
|
230 | 231 | {
|
231 |
| - struct vfio_pci_core_device *vdev = dev_id; |
232 |
| - struct vfio_pci_irq_ctx *ctx; |
| 232 | + struct vfio_pci_irq_ctx *ctx = dev_id; |
| 233 | + struct vfio_pci_core_device *vdev = ctx->vdev; |
233 | 234 | unsigned long flags;
|
234 | 235 | int ret = IRQ_NONE;
|
235 | 236 |
|
236 |
| - ctx = vfio_irq_ctx_get(vdev, 0); |
237 |
| - if (WARN_ON_ONCE(!ctx)) |
238 |
| - return ret; |
239 |
| - |
240 | 237 | spin_lock_irqsave(&vdev->irqlock, flags);
|
241 | 238 |
|
242 | 239 | if (!vdev->pci_2_3) {
|
@@ -282,6 +279,7 @@ static int vfio_intx_enable(struct vfio_pci_core_device *vdev,
|
282 | 279 |
|
283 | 280 | ctx->name = name;
|
284 | 281 | ctx->trigger = trigger;
|
| 282 | + ctx->vdev = vdev; |
285 | 283 |
|
286 | 284 | /*
|
287 | 285 | * Fill the initial masked state based on virq_disabled. After
|
@@ -312,7 +310,7 @@ static int vfio_intx_enable(struct vfio_pci_core_device *vdev,
|
312 | 310 | vdev->irq_type = VFIO_PCI_INTX_IRQ_INDEX;
|
313 | 311 |
|
314 | 312 | ret = request_irq(pdev->irq, vfio_intx_handler,
|
315 |
| - irqflags, ctx->name, vdev); |
| 313 | + irqflags, ctx->name, ctx); |
316 | 314 | if (ret) {
|
317 | 315 | vdev->irq_type = VFIO_PCI_NUM_IRQS;
|
318 | 316 | kfree(name);
|
@@ -358,7 +356,7 @@ static void vfio_intx_disable(struct vfio_pci_core_device *vdev)
|
358 | 356 | if (ctx) {
|
359 | 357 | vfio_virqfd_disable(&ctx->unmask);
|
360 | 358 | vfio_virqfd_disable(&ctx->mask);
|
361 |
| - free_irq(pdev->irq, vdev); |
| 359 | + free_irq(pdev->irq, ctx); |
362 | 360 | if (ctx->trigger)
|
363 | 361 | eventfd_ctx_put(ctx->trigger);
|
364 | 362 | kfree(ctx->name);
|
|
0 commit comments