Skip to content

Commit

Permalink
xen: evtchn: Allow shared registration of IRQ handers
Browse files Browse the repository at this point in the history
[ Upstream commit 9e90e58 ]

Currently the handling of events is supported either in the kernel or
userspace, but not both.

In order to support fast delivery of interrupts from the guest to the
backend, we need to handle the Queue notify part of Virtio protocol in
kernel and the rest in userspace.

Update the interrupt handler registration flag to IRQF_SHARED for event
channels, which would allow multiple entities to bind their interrupt
handler for the same event channel port.

Also increment the reference count of irq_info when multiple entities
try to bind event channel to irqchip, so the unbinding happens only
after all the users are gone.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Juergen Gross <jgross@suse.com>
Link: https://lore.kernel.org/r/99b1edfd3147c6b5d22a5139dab5861e767dc34a.1697439990.git.viresh.kumar@linaro.org
Signed-off-by: Juergen Gross <jgross@suse.com>
Stable-dep-of: fa765c4 ("xen/events: close evtchn after mapping cleanup")
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
vireshk authored and gregkh committed Mar 1, 2024
1 parent 71783d1 commit 3c8f596
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/xen/events/events_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,8 @@ static int bind_evtchn_to_irq_chip(evtchn_port_t evtchn, struct irq_chip *chip,
bind_evtchn_to_cpu(evtchn, 0, false);
} else {
struct irq_info *info = info_for_irq(irq);
WARN_ON(info == NULL || info->type != IRQT_EVTCHN);
if (!WARN_ON(!info || info->type != IRQT_EVTCHN))
info->refcnt++;
}

out:
Expand Down
2 changes: 1 addition & 1 deletion drivers/xen/evtchn.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static int evtchn_bind_to_user(struct per_user_data *u, evtchn_port_t port,
if (rc < 0)
goto err;

rc = bind_evtchn_to_irqhandler_lateeoi(port, evtchn_interrupt, 0,
rc = bind_evtchn_to_irqhandler_lateeoi(port, evtchn_interrupt, IRQF_SHARED,
u->name, evtchn);
if (rc < 0)
goto err;
Expand Down

0 comments on commit 3c8f596

Please sign in to comment.