Skip to content

Commit 943af0e

Browse files
committed
Merge tag 'x86-apic-2023-10-29-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 APIC updates from Thomas Gleixner: - Make the quirk for non-maskable MSI interrupts in the affinity setter functional again. It was broken by a MSI core code update, which restructured the code in a way that the quirk flag was not longer set correctly. Trying to restore the core logic caused a deeper inspection and it turned out that the extra quirk flag is not required at all because it's the inverse of the reservation mode bit, which only can be set when the MSI interrupt is maskable. So the trivial fix is to use the reservation mode check in the affinity setter function and remove almost 40 lines of code related to the no-mask quirk flag. - Cure a Kconfig dependency issue which causes compile failures by correcting the conditionals in the affected header files. - Clean up coding style in the UV APIC driver. * tag 'x86-apic-2023-10-29-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/apic/msi: Fix misconfigured non-maskable MSI quirk x86/msi: Fix compile error caused by CONFIG_GENERIC_MSI_IRQ=y && !CONFIG_X86_LOCAL_APIC x86/platform/uv/apic: Clean up inconsistent indenting
2 parents 63a3f11 + b56ebe7 commit 943af0e

File tree

8 files changed

+14
-51
lines changed

8 files changed

+14
-51
lines changed

arch/x86/include/asm/hw_irq.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <asm/irq.h>
2929
#include <asm/sections.h>
3030

31-
#ifdef CONFIG_X86_LOCAL_APIC
31+
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
3232
struct irq_data;
3333
struct pci_dev;
3434
struct msi_desc;
@@ -105,10 +105,10 @@ static inline void irq_complete_move(struct irq_cfg *c) { }
105105
#endif
106106

107107
extern void apic_ack_edge(struct irq_data *data);
108-
#else /* CONFIG_X86_LOCAL_APIC */
108+
#else /* CONFIG_IRQ_DOMAIN_HIERARCHY */
109109
static inline void lock_vector_lock(void) {}
110110
static inline void unlock_vector_lock(void) {}
111-
#endif /* CONFIG_X86_LOCAL_APIC */
111+
#endif /* CONFIG_IRQ_DOMAIN_HIERARCHY */
112112

113113
/* Statistics */
114114
extern atomic_t irq_err_count;

arch/x86/kernel/apic/msi.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ msi_set_affinity(struct irq_data *irqd, const struct cpumask *mask, bool force)
5555
* caused by the non-atomic update of the address/data pair.
5656
*
5757
* Direct update is possible when:
58-
* - The MSI is maskable (remapped MSI does not use this code path)).
59-
* The quirk bit is not set in this case.
58+
* - The MSI is maskable (remapped MSI does not use this code path).
59+
* The reservation mode bit is set in this case.
6060
* - The new vector is the same as the old vector
6161
* - The old vector is MANAGED_IRQ_SHUTDOWN_VECTOR (interrupt starts up)
6262
* - The interrupt is not yet started up
6363
* - The new destination CPU is the same as the old destination CPU
6464
*/
65-
if (!irqd_msi_nomask_quirk(irqd) ||
65+
if (!irqd_can_reserve(irqd) ||
6666
cfg->vector == old_cfg.vector ||
6767
old_cfg.vector == MANAGED_IRQ_SHUTDOWN_VECTOR ||
6868
!irqd_is_started(irqd) ||
@@ -215,8 +215,6 @@ static bool x86_init_dev_msi_info(struct device *dev, struct irq_domain *domain,
215215
if (WARN_ON_ONCE(domain != real_parent))
216216
return false;
217217
info->chip->irq_set_affinity = msi_set_affinity;
218-
/* See msi_set_affinity() for the gory details */
219-
info->flags |= MSI_FLAG_NOMASK_QUIRK;
220218
break;
221219
case DOMAIN_BUS_DMAR:
222220
case DOMAIN_BUS_AMDVI:

arch/x86/kernel/apic/x2apic_uv_x.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static void __init early_get_pnodeid(void)
110110
} else if (UVH_RH_GAM_ADDR_MAP_CONFIG) {
111111
union uvh_rh_gam_addr_map_config_u m_n_config;
112112

113-
m_n_config.v = uv_early_read_mmr(UVH_RH_GAM_ADDR_MAP_CONFIG);
113+
m_n_config.v = uv_early_read_mmr(UVH_RH_GAM_ADDR_MAP_CONFIG);
114114
uv_cpuid.n_skt = m_n_config.s.n_skt;
115115
if (is_uv(UV3))
116116
uv_cpuid.m_skt = m_n_config.s3.m_skt;

arch/x86/kernel/hpet.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ unsigned long hpet_address;
5252
u8 hpet_blockid; /* OS timer block num */
5353
bool hpet_msi_disable;
5454

55-
#ifdef CONFIG_GENERIC_MSI_IRQ
55+
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_GENERIC_MSI_IRQ)
5656
static DEFINE_PER_CPU(struct hpet_channel *, cpu_hpet_channel);
5757
static struct irq_domain *hpet_domain;
5858
#endif
@@ -469,7 +469,7 @@ static void __init hpet_legacy_clockevent_register(struct hpet_channel *hc)
469469
/*
470470
* HPET MSI Support
471471
*/
472-
#ifdef CONFIG_GENERIC_MSI_IRQ
472+
#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_GENERIC_MSI_IRQ)
473473
static void hpet_msi_unmask(struct irq_data *data)
474474
{
475475
struct hpet_channel *hc = irq_data_get_irq_handler_data(data);

include/linux/irq.h

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ struct irq_data {
215215
* IRQD_SINGLE_TARGET - IRQ allows only a single affinity target
216216
* IRQD_DEFAULT_TRIGGER_SET - Expected trigger already been set
217217
* IRQD_CAN_RESERVE - Can use reservation mode
218-
* IRQD_MSI_NOMASK_QUIRK - Non-maskable MSI quirk for affinity change
219-
* required
220218
* IRQD_HANDLE_ENFORCE_IRQCTX - Enforce that handle_irq_*() is only invoked
221219
* from actual interrupt context.
222220
* IRQD_AFFINITY_ON_ACTIVATE - Affinity is set on activation. Don't call
@@ -247,11 +245,10 @@ enum {
247245
IRQD_SINGLE_TARGET = BIT(24),
248246
IRQD_DEFAULT_TRIGGER_SET = BIT(25),
249247
IRQD_CAN_RESERVE = BIT(26),
250-
IRQD_MSI_NOMASK_QUIRK = BIT(27),
251-
IRQD_HANDLE_ENFORCE_IRQCTX = BIT(28),
252-
IRQD_AFFINITY_ON_ACTIVATE = BIT(29),
253-
IRQD_IRQ_ENABLED_ON_SUSPEND = BIT(30),
254-
IRQD_RESEND_WHEN_IN_PROGRESS = BIT(31),
248+
IRQD_HANDLE_ENFORCE_IRQCTX = BIT(27),
249+
IRQD_AFFINITY_ON_ACTIVATE = BIT(28),
250+
IRQD_IRQ_ENABLED_ON_SUSPEND = BIT(29),
251+
IRQD_RESEND_WHEN_IN_PROGRESS = BIT(30),
255252
};
256253

257254
#define __irqd_to_state(d) ACCESS_PRIVATE((d)->common, state_use_accessors)
@@ -426,21 +423,6 @@ static inline bool irqd_can_reserve(struct irq_data *d)
426423
return __irqd_to_state(d) & IRQD_CAN_RESERVE;
427424
}
428425

429-
static inline void irqd_set_msi_nomask_quirk(struct irq_data *d)
430-
{
431-
__irqd_to_state(d) |= IRQD_MSI_NOMASK_QUIRK;
432-
}
433-
434-
static inline void irqd_clr_msi_nomask_quirk(struct irq_data *d)
435-
{
436-
__irqd_to_state(d) &= ~IRQD_MSI_NOMASK_QUIRK;
437-
}
438-
439-
static inline bool irqd_msi_nomask_quirk(struct irq_data *d)
440-
{
441-
return __irqd_to_state(d) & IRQD_MSI_NOMASK_QUIRK;
442-
}
443-
444426
static inline void irqd_set_affinity_on_activate(struct irq_data *d)
445427
{
446428
__irqd_to_state(d) |= IRQD_AFFINITY_ON_ACTIVATE;

include/linux/msi.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -547,12 +547,6 @@ enum {
547547
MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS = (1 << 5),
548548
/* Free MSI descriptors */
549549
MSI_FLAG_FREE_MSI_DESCS = (1 << 6),
550-
/*
551-
* Quirk to handle MSI implementations which do not provide
552-
* masking. Currently known to affect x86, but has to be partially
553-
* handled in the core MSI code.
554-
*/
555-
MSI_FLAG_NOMASK_QUIRK = (1 << 7),
556550

557551
/* Mask for the generic functionality */
558552
MSI_GENERIC_FLAGS_MASK = GENMASK(15, 0),

kernel/irq/debugfs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ static const struct irq_bit_descr irqdata_states[] = {
121121
BIT_MASK_DESCR(IRQD_AFFINITY_ON_ACTIVATE),
122122
BIT_MASK_DESCR(IRQD_MANAGED_SHUTDOWN),
123123
BIT_MASK_DESCR(IRQD_CAN_RESERVE),
124-
BIT_MASK_DESCR(IRQD_MSI_NOMASK_QUIRK),
125124

126125
BIT_MASK_DESCR(IRQD_FORWARDED_TO_VCPU),
127126

kernel/irq/msi.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,6 @@ static int msi_handle_pci_fail(struct irq_domain *domain, struct msi_desc *desc,
12041204

12051205
#define VIRQ_CAN_RESERVE 0x01
12061206
#define VIRQ_ACTIVATE 0x02
1207-
#define VIRQ_NOMASK_QUIRK 0x04
12081207

12091208
static int msi_init_virq(struct irq_domain *domain, int virq, unsigned int vflags)
12101209
{
@@ -1213,8 +1212,6 @@ static int msi_init_virq(struct irq_domain *domain, int virq, unsigned int vflag
12131212

12141213
if (!(vflags & VIRQ_CAN_RESERVE)) {
12151214
irqd_clr_can_reserve(irqd);
1216-
if (vflags & VIRQ_NOMASK_QUIRK)
1217-
irqd_set_msi_nomask_quirk(irqd);
12181215

12191216
/*
12201217
* If the interrupt is managed but no CPU is available to
@@ -1275,15 +1272,8 @@ static int __msi_domain_alloc_irqs(struct device *dev, struct irq_domain *domain
12751272
* Interrupt can use a reserved vector and will not occupy
12761273
* a real device vector until the interrupt is requested.
12771274
*/
1278-
if (msi_check_reservation_mode(domain, info, dev)) {
1275+
if (msi_check_reservation_mode(domain, info, dev))
12791276
vflags |= VIRQ_CAN_RESERVE;
1280-
/*
1281-
* MSI affinity setting requires a special quirk (X86) when
1282-
* reservation mode is active.
1283-
*/
1284-
if (info->flags & MSI_FLAG_NOMASK_QUIRK)
1285-
vflags |= VIRQ_NOMASK_QUIRK;
1286-
}
12871277

12881278
xa_for_each_range(xa, idx, desc, ctrl->first, ctrl->last) {
12891279
if (!msi_desc_match(desc, MSI_DESC_NOTASSOCIATED))

0 commit comments

Comments
 (0)