@@ -85,19 +85,14 @@ vfio_irq_ctx_alloc(struct vfio_pci_core_device *vdev, unsigned long index)
8585/*
8686 * INTx
8787 */
88- static void vfio_send_intx_eventfd (void * opaque , void * unused )
88+ static void vfio_send_intx_eventfd (void * opaque , void * data )
8989{
9090 struct vfio_pci_core_device * vdev = opaque ;
9191
9292 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 ) ;
9595
96- ctx = vfio_irq_ctx_get (vdev , 0 );
97- if (WARN_ON_ONCE (!ctx ))
98- return ;
99-
100- trigger = READ_ONCE (ctx -> trigger );
10196 if (likely (trigger ))
10297 eventfd_signal (trigger );
10398 }
@@ -167,11 +162,11 @@ bool vfio_pci_intx_mask(struct vfio_pci_core_device *vdev)
167162 * a signal is necessary, which can then be handled via a work queue
168163 * or directly depending on the caller.
169164 */
170- static int vfio_pci_intx_unmask_handler (void * opaque , void * unused )
165+ static int vfio_pci_intx_unmask_handler (void * opaque , void * data )
171166{
172167 struct vfio_pci_core_device * vdev = opaque ;
173168 struct pci_dev * pdev = vdev -> pdev ;
174- struct vfio_pci_irq_ctx * ctx ;
169+ struct vfio_pci_irq_ctx * ctx = data ;
175170 unsigned long flags ;
176171 int ret = 0 ;
177172
@@ -187,10 +182,6 @@ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused)
187182 goto out_unlock ;
188183 }
189184
190- ctx = vfio_irq_ctx_get (vdev , 0 );
191- if (WARN_ON_ONCE (!ctx ))
192- goto out_unlock ;
193-
194185 if (ctx -> masked && !vdev -> virq_disabled ) {
195186 /*
196187 * A pending interrupt here would immediately trigger,
@@ -214,10 +205,12 @@ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused)
214205
215206static void __vfio_pci_intx_unmask (struct vfio_pci_core_device * vdev )
216207{
208+ struct vfio_pci_irq_ctx * ctx = vfio_irq_ctx_get (vdev , 0 );
209+
217210 lockdep_assert_held (& vdev -> igate );
218211
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 );
221214}
222215
223216void 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)
249242 spin_unlock_irqrestore (& vdev -> irqlock , flags );
250243
251244 if (ret == IRQ_HANDLED )
252- vfio_send_intx_eventfd (vdev , NULL );
245+ vfio_send_intx_eventfd (vdev , ctx );
253246
254247 return ret ;
255248}
@@ -604,7 +597,7 @@ static int vfio_pci_set_intx_unmask(struct vfio_pci_core_device *vdev,
604597 if (fd >= 0 )
605598 return vfio_virqfd_enable ((void * ) vdev ,
606599 vfio_pci_intx_unmask_handler ,
607- vfio_send_intx_eventfd , NULL ,
600+ vfio_send_intx_eventfd , ctx ,
608601 & ctx -> unmask , fd );
609602
610603 vfio_virqfd_disable (& ctx -> unmask );
@@ -671,11 +664,11 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,
671664 return - EINVAL ;
672665
673666 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 ) );
675668 } else if (flags & VFIO_IRQ_SET_DATA_BOOL ) {
676669 uint8_t trigger = * (uint8_t * )data ;
677670 if (trigger )
678- vfio_send_intx_eventfd (vdev , NULL );
671+ vfio_send_intx_eventfd (vdev , vfio_irq_ctx_get ( vdev , 0 ) );
679672 }
680673 return 0 ;
681674}
0 commit comments