@@ -85,19 +85,14 @@ vfio_irq_ctx_alloc(struct vfio_pci_core_device *vdev, unsigned long index)
85
85
/*
86
86
* INTx
87
87
*/
88
- static void vfio_send_intx_eventfd (void * opaque , void * unused )
88
+ static void vfio_send_intx_eventfd (void * opaque , void * data )
89
89
{
90
90
struct vfio_pci_core_device * vdev = opaque ;
91
91
92
92
if (likely (is_intx (vdev ) && !vdev -> virq_disabled )) {
93
- struct vfio_pci_irq_ctx * ctx ;
94
- struct eventfd_ctx * trigger ;
93
+ struct vfio_pci_irq_ctx * ctx = data ;
94
+ struct eventfd_ctx * trigger = READ_ONCE ( ctx -> trigger ) ;
95
95
96
- ctx = vfio_irq_ctx_get (vdev , 0 );
97
- if (WARN_ON_ONCE (!ctx ))
98
- return ;
99
-
100
- trigger = READ_ONCE (ctx -> trigger );
101
96
if (likely (trigger ))
102
97
eventfd_signal (trigger );
103
98
}
@@ -167,11 +162,11 @@ bool vfio_pci_intx_mask(struct vfio_pci_core_device *vdev)
167
162
* a signal is necessary, which can then be handled via a work queue
168
163
* or directly depending on the caller.
169
164
*/
170
- static int vfio_pci_intx_unmask_handler (void * opaque , void * unused )
165
+ static int vfio_pci_intx_unmask_handler (void * opaque , void * data )
171
166
{
172
167
struct vfio_pci_core_device * vdev = opaque ;
173
168
struct pci_dev * pdev = vdev -> pdev ;
174
- struct vfio_pci_irq_ctx * ctx ;
169
+ struct vfio_pci_irq_ctx * ctx = data ;
175
170
unsigned long flags ;
176
171
int ret = 0 ;
177
172
@@ -187,10 +182,6 @@ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused)
187
182
goto out_unlock ;
188
183
}
189
184
190
- ctx = vfio_irq_ctx_get (vdev , 0 );
191
- if (WARN_ON_ONCE (!ctx ))
192
- goto out_unlock ;
193
-
194
185
if (ctx -> masked && !vdev -> virq_disabled ) {
195
186
/*
196
187
* A pending interrupt here would immediately trigger,
@@ -214,10 +205,12 @@ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused)
214
205
215
206
static void __vfio_pci_intx_unmask (struct vfio_pci_core_device * vdev )
216
207
{
208
+ struct vfio_pci_irq_ctx * ctx = vfio_irq_ctx_get (vdev , 0 );
209
+
217
210
lockdep_assert_held (& vdev -> igate );
218
211
219
- if (vfio_pci_intx_unmask_handler (vdev , NULL ) > 0 )
220
- vfio_send_intx_eventfd (vdev , NULL );
212
+ if (vfio_pci_intx_unmask_handler (vdev , ctx ) > 0 )
213
+ vfio_send_intx_eventfd (vdev , ctx );
221
214
}
222
215
223
216
void vfio_pci_intx_unmask (struct vfio_pci_core_device * vdev )
@@ -249,7 +242,7 @@ static irqreturn_t vfio_intx_handler(int irq, void *dev_id)
249
242
spin_unlock_irqrestore (& vdev -> irqlock , flags );
250
243
251
244
if (ret == IRQ_HANDLED )
252
- vfio_send_intx_eventfd (vdev , NULL );
245
+ vfio_send_intx_eventfd (vdev , ctx );
253
246
254
247
return ret ;
255
248
}
@@ -604,7 +597,7 @@ static int vfio_pci_set_intx_unmask(struct vfio_pci_core_device *vdev,
604
597
if (fd >= 0 )
605
598
return vfio_virqfd_enable ((void * ) vdev ,
606
599
vfio_pci_intx_unmask_handler ,
607
- vfio_send_intx_eventfd , NULL ,
600
+ vfio_send_intx_eventfd , ctx ,
608
601
& ctx -> unmask , fd );
609
602
610
603
vfio_virqfd_disable (& ctx -> unmask );
@@ -671,11 +664,11 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,
671
664
return - EINVAL ;
672
665
673
666
if (flags & VFIO_IRQ_SET_DATA_NONE ) {
674
- vfio_send_intx_eventfd (vdev , NULL );
667
+ vfio_send_intx_eventfd (vdev , vfio_irq_ctx_get ( vdev , 0 ) );
675
668
} else if (flags & VFIO_IRQ_SET_DATA_BOOL ) {
676
669
uint8_t trigger = * (uint8_t * )data ;
677
670
if (trigger )
678
- vfio_send_intx_eventfd (vdev , NULL );
671
+ vfio_send_intx_eventfd (vdev , vfio_irq_ctx_get ( vdev , 0 ) );
679
672
}
680
673
return 0 ;
681
674
}
0 commit comments