Backported patches for stable 5.10
Subsystems (2)
Jürgen Groß
maintainerI've attached backports of 2 patches for 5.10.
Juergen
From eeb0c941de41ab74ef8163ffc3e32733ff7c4357 Mon Sep 17 00:00:00 2001
From: Juergen Gross <[email protected]>
Date: Mon, 15 Mar 2021 08:11:29 +0100
Subject: [PATCH 1/2] xen/events: don't unmask an event channel when an eoi is
pending
commit 25da4618af240fbec6112401498301a6f2bc9702 upstream.
An event channel should be kept masked when an eoi is pending for it. When being migrated to another cpu it might be unmasked, though.
In order to avoid this keep three different flags for each event channel to be able to distinguish "normal" masking/unmasking from eoi related masking/unmasking and temporary masking. The event channel should only be able to generate an interrupt if all flags are cleared.
[boris -- corrected Fixed tag format]
--- drivers/xen/events/events_2l.c | 7 -- drivers/xen/events/events_base.c | 117 ++++++++++++++++++++------- drivers/xen/events/events_fifo.c | 7 -- drivers/xen/events/events_internal.h | 6 -- 4 files changed, 88 insertions(+), 49 deletions(-)
drivers/xen/events/events_2l.c +0 -7
@@ -77,12 +77,6 @@ static bool evtchn_2l_is_pending(evtchn_port_t port)return sync_test_bit (port,BM (&s->evtchn_pending[0 ])); } -static bool evtchn_2l_test_and_set_mask (evtchn_port_t port) -{ -struct shared_info *s = HYPERVISOR_shared_info; -return sync_test_and_set_bit (port,BM (&s->evtchn_mask[0 ])); -} -static void evtchn_2l_mask (evtchn_port_t port) {struct shared_info *s = HYPERVISOR_shared_info;
@@ -376,7 +370,6 @@ static const struct evtchn_ops evtchn_ops_2l = { .clear_pending = evtchn_2l_clear_pending, .set_pending = evtchn_2l_set_pending, .is_pending = evtchn_2l_is_pending, - .test_and_set_mask = evtchn_2l_test_and_set_mask, .mask = evtchn_2l_mask, .unmask = evtchn_2l_unmask, .handle_events = evtchn_2l_handle_events,
drivers/xen/events/events_base.c +88 -29
256 lines not on this page · raw message
drivers/xen/events/events_fifo.c +0 -7
@@ -209,12 +209,6 @@ static bool evtchn_fifo_is_pending(evtchn_port_t port)return sync_test_bit (EVTCHN_FIFO_BIT (PENDING , word),BM (word)); } -static bool evtchn_fifo_test_and_set_mask (evtchn_port_t port) -{ -event_word_t *word =event_word_from_port (port); -return sync_test_and_set_bit (EVTCHN_FIFO_BIT (MASKED , word),BM (word)); -} -static void evtchn_fifo_mask (evtchn_port_t port) {event_word_t *word =event_word_from_port (port);
@@ -423,7 +417,6 @@ static const struct evtchn_ops evtchn_ops_fifo = { .clear_pending = evtchn_fifo_clear_pending, .set_pending = evtchn_fifo_set_pending, .is_pending = evtchn_fifo_is_pending, - .test_and_set_mask = evtchn_fifo_test_and_set_mask, .mask = evtchn_fifo_mask, .unmask = evtchn_fifo_unmask, .handle_events = evtchn_fifo_handle_events,
drivers/xen/events/events_internal.h +0 -6
@@ -21,7 +21,6 @@ struct evtchn_ops {void (*clear_pending)(evtchn_port_t port);void (*set_pending)(evtchn_port_t port);bool (*is_pending)(evtchn_port_t port); -bool (*test_and_set_mask)(evtchn_port_t port);void (*mask)(evtchn_port_t port);void (*unmask)(evtchn_port_t port);
@@ -84,11 +83,6 @@ static inline bool test_evtchn(evtchn_port_t port)return evtchn_ops->is_pending (port); } -static inline bool test_and_set_mask (evtchn_port_t port) -{ -return evtchn_ops->test_and_set_mask (port); -} -static inline void mask_evtchn (evtchn_port_t port) {return evtchn_ops->mask (port);
Signature · 1 line
2.26.2
From 0d7eb384c8de17adbf7deedcd50c50805926b7b4 Mon Sep 17 00:00:00 2001
From: Juergen Gross <[email protected]>
Date: Mon, 15 Mar 2021 08:23:51 +0100
Subject: [PATCH 2/2] xen/events: avoid handling the same event on two cpus at
the same time
commit b6622798bc50b625a1e62f82c7190df40c1f5b21 upstream.
When changing the cpu affinity of an event it can happen today that (with some unlucky timing) the same event will be handled on the old and the new cpu at the same time.
Avoid that by adding an "event active" flag to the per-event data and call the handler only if this flag isn't set.
--- drivers/xen/events/events_base.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/xen/events/events_base.c +18 -8
@@ -101,6 +101,7 @@ struct irq_info {#define EVT_MASK_REASON_EXPLICIT 0x01#define EVT_MASK_REASON_TEMPORARY 0x02#define EVT_MASK_REASON_EOI_PENDING 0x04 +u8 is_active;/* Is event just being handled? */ unsigned irq;evtchn_port_t evtchn;/* event channel */ unsigned short cpu;/* cpu bound */
@@ -751,6 +752,12 @@ static void xen_evtchn_close(evtchn_port_t port)BUG (); } +static void event_handler_exit (struct irq_info *info) +{ +smp_store_release (&info->is_active,0 ); +clear_evtchn (info->evtchn); +} +static void pirq_query_unmask (int irq) {struct physdev_irq_status_query irq_status;
@@ -781,13 +788,13 @@ static void eoi_pirq(struct irq_data *data) likely(!irqd_irq_disabled(data))) {do_mask (info,EVT_MASK_REASON_TEMPORARY ); -clear_evtchn (evtchn); +event_handler_exit (info);irq_move_masked_irq (data);do_unmask (info,EVT_MASK_REASON_TEMPORARY ); } else -clear_evtchn (evtchn ); +event_handler_exit (info );if (pirq_needs_eoi (data->irq)) { rc =HYPERVISOR_physdev_op (PHYSDEVOP_eoi, &eoi);
@@ -1603,6 +1610,8 @@ void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl) } info =info_for_irq (irq); +if (xchg_acquire (&info->is_active,1 )) +return ;if (ctrl->defer_eoi) { info->eoi_cpu =smp_processor_id ();
@@ -1778,13 +1787,13 @@ static void ack_dynirq(struct irq_data *data) likely(!irqd_irq_disabled(data))) {do_mask (info,EVT_MASK_REASON_TEMPORARY ); -clear_evtchn (evtchn); +event_handler_exit (info);irq_move_masked_irq (data);do_unmask (info,EVT_MASK_REASON_TEMPORARY ); } else -clear_evtchn (evtchn ); +event_handler_exit (info ); }static void mask_ack_dynirq (struct irq_data *data)
@@ -1800,7 +1809,7 @@ static void lateeoi_ack_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {do_mask (info,EVT_MASK_REASON_EOI_PENDING ); -clear_evtchn (evtchn); +event_handler_exit (info); } }
@@ -1811,7 +1820,7 @@ static void lateeoi_mask_ack_dynirq(struct irq_data *data)if (VALID_EVTCHN (evtchn)) {do_mask (info,EVT_MASK_REASON_EXPLICIT ); -clear_evtchn (evtchn); +event_handler_exit (info); } }
@@ -1922,10 +1931,11 @@ static void restore_cpu_ipis(unsigned int cpu)/* Clear an irq's pending state, in preparation for polling on it */ void xen_clear_irq_pending (int irq) { -evtchn_port_t evtchn =evtchn_from_irq (irq); +struct irq_info *info =info_for_irq (irq); +evtchn_port_t evtchn = info ? info->evtchn :0 ;if (VALID_EVTCHN (evtchn)) -clear_evtchn (evtchn); +event_handler_exit (info); }EXPORT_SYMBOL (xen_clear_irq_pending);void xen_set_irq_pending (int irq)
Signature · 1 line
2.26.2
Quoted 1 line · Jürgen Groß
I've attached backports of 2 patches for 5.10.
All backported patches now queued up, thanks for doing them!
greg k-h