Skip to content

Commit 3e8cd71

Browse files
dwmw2jgross1
authored andcommitted
xen: Allow platform PCI interrupt to be shared
When we don't use the per-CPU vector callback, we ask Xen to deliver event channel interrupts as INTx on the PCI platform device. As such, it can be shared with INTx on other PCI devices. Set IRQF_SHARED, and make it return IRQ_HANDLED or IRQ_NONE according to whether the evtchn_upcall_pending flag was actually set. Now I can share the interrupt: 11: 82 0 IO-APIC 11-fasteoi xen-platform-pci, ens4 Drop the IRQF_TRIGGER_RISING. It has no effect when the IRQ is shared, and besides, the only effect it was having even beforehand was to trigger a debug message in both I/OAPIC and legacy PIC cases: [ 0.915441] genirq: No set_type function for IRQ 11 (IO-APIC) [ 0.951939] genirq: No set_type function for IRQ 11 (XT-PIC) Signed-off-by: David Woodhouse <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent caea091 commit 3e8cd71

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

drivers/xen/events/events_base.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,9 +1710,10 @@ void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl)
17101710
generic_handle_irq(irq);
17111711
}
17121712

1713-
static void __xen_evtchn_do_upcall(void)
1713+
static int __xen_evtchn_do_upcall(void)
17141714
{
17151715
struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu);
1716+
int ret = vcpu_info->evtchn_upcall_pending ? IRQ_HANDLED : IRQ_NONE;
17161717
int cpu = smp_processor_id();
17171718
struct evtchn_loop_ctrl ctrl = { 0 };
17181719

@@ -1737,6 +1738,8 @@ static void __xen_evtchn_do_upcall(void)
17371738
* above.
17381739
*/
17391740
__this_cpu_inc(irq_epoch);
1741+
1742+
return ret;
17401743
}
17411744

17421745
void xen_evtchn_do_upcall(struct pt_regs *regs)
@@ -1751,9 +1754,9 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
17511754
set_irq_regs(old_regs);
17521755
}
17531756

1754-
void xen_hvm_evtchn_do_upcall(void)
1757+
int xen_hvm_evtchn_do_upcall(void)
17551758
{
1756-
__xen_evtchn_do_upcall();
1759+
return __xen_evtchn_do_upcall();
17571760
}
17581761
EXPORT_SYMBOL_GPL(xen_hvm_evtchn_do_upcall);
17591762

drivers/xen/platform-pci.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,13 @@ static uint64_t get_callback_via(struct pci_dev *pdev)
6464

6565
static irqreturn_t do_hvm_evtchn_intr(int irq, void *dev_id)
6666
{
67-
xen_hvm_evtchn_do_upcall();
68-
return IRQ_HANDLED;
67+
return xen_hvm_evtchn_do_upcall();
6968
}
7069

7170
static int xen_allocate_irq(struct pci_dev *pdev)
7271
{
7372
return request_irq(pdev->irq, do_hvm_evtchn_intr,
74-
IRQF_NOBALANCING | IRQF_TRIGGER_RISING,
73+
IRQF_NOBALANCING | IRQF_SHARED,
7574
"xen-platform-pci", pdev);
7675
}
7776

include/xen/events.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ evtchn_port_t evtchn_from_irq(unsigned irq);
107107

108108
int xen_set_callback_via(uint64_t via);
109109
void xen_evtchn_do_upcall(struct pt_regs *regs);
110-
void xen_hvm_evtchn_do_upcall(void);
110+
int xen_hvm_evtchn_do_upcall(void);
111111

112112
/* Bind a pirq for a physical interrupt to an irq. */
113113
int xen_bind_pirq_gsi_to_irq(unsigned gsi,

0 commit comments

Comments
 (0)