From 7e970c18f85f99acc678d90128b6e01dce1bf273 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 01 Nov 2024 02:40:12 +0000
Subject: [PATCH] gmac get mac form eeprom
---
kernel/arch/x86/kernel/apic/vector.c | 72 ++++++++++++++++++++++++++++++------
1 files changed, 60 insertions(+), 12 deletions(-)
diff --git a/kernel/arch/x86/kernel/apic/vector.c b/kernel/arch/x86/kernel/apic/vector.c
index bd557e9..1cb7ab4 100644
--- a/kernel/arch/x86/kernel/apic/vector.c
+++ b/kernel/arch/x86/kernel/apic/vector.c
@@ -39,7 +39,7 @@
struct irq_domain *x86_vector_domain;
EXPORT_SYMBOL_GPL(x86_vector_domain);
-static DEFINE_RAW_SPINLOCK(vector_lock);
+static DEFINE_HARD_SPINLOCK(vector_lock);
static cpumask_var_t vector_searchmask;
static struct irq_chip lapic_controller;
static struct irq_matrix *vector_matrix;
@@ -757,6 +757,10 @@
{
int isairq = vector - ISA_IRQ_VECTOR(0);
+ /* Copy the cleanup vector if irqs are pipelined. */
+ if (IS_ENABLED(CONFIG_IRQ_PIPELINE) &&
+ vector == IRQ_MOVE_CLEANUP_VECTOR)
+ return irq_to_desc(IRQ_MOVE_CLEANUP_VECTOR); /* 1:1 mapping */
/* Check whether the irq is in the legacy space */
if (isairq < 0 || isairq >= nr_legacy_irqs())
return VECTOR_UNUSED;
@@ -791,15 +795,19 @@
void lapic_offline(void)
{
- lock_vector_lock();
+ unsigned long flags;
+
+ raw_spin_lock_irqsave(&vector_lock, flags);
irq_matrix_offline(vector_matrix);
- unlock_vector_lock();
+ raw_spin_unlock_irqrestore(&vector_lock, flags);
}
static int apic_set_affinity(struct irq_data *irqd,
const struct cpumask *dest, bool force)
{
int err;
+
+ WARN_ON_ONCE(irqs_pipelined() && !hard_irqs_disabled());
if (WARN_ON_ONCE(!irqd_is_activated(irqd)))
return -EIO;
@@ -830,10 +838,44 @@
return 1;
}
-void apic_ack_irq(struct irq_data *irqd)
+#if defined(CONFIG_IRQ_PIPELINE) && \
+ defined(CONFIG_GENERIC_PENDING_IRQ)
+
+static void apic_deferred_irq_move(struct irq_work *work)
+{
+ struct irq_data *irqd;
+ struct irq_desc *desc;
+ unsigned long flags;
+
+ irqd = container_of(work, struct irq_data, move_work);
+ desc = irq_data_to_desc(irqd);
+ raw_spin_lock_irqsave(&desc->lock, flags);
+ __irq_move_irq(irqd);
+ raw_spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+static inline void apic_move_irq(struct irq_data *irqd)
+{
+ if (irqd_is_setaffinity_pending(irqd) &&
+ !irqd_is_setaffinity_blocked(irqd)) {
+ init_irq_work(&irqd->move_work, apic_deferred_irq_move);
+ irq_work_queue(&irqd->move_work);
+ }
+}
+
+#else
+
+static inline void apic_move_irq(struct irq_data *irqd)
{
irq_move_irq(irqd);
- ack_APIC_irq();
+}
+
+#endif
+
+void apic_ack_irq(struct irq_data *irqd)
+{
+ apic_move_irq(irqd);
+ __ack_APIC_irq();
}
void apic_ack_edge(struct irq_data *irqd)
@@ -876,15 +918,17 @@
apicd->move_in_progress = 0;
}
-DEFINE_IDTENTRY_SYSVEC(sysvec_irq_move_cleanup)
+DEFINE_IDTENTRY_SYSVEC_PIPELINED(IRQ_MOVE_CLEANUP_VECTOR,
+ sysvec_irq_move_cleanup)
{
struct hlist_head *clhead = this_cpu_ptr(&cleanup_list);
struct apic_chip_data *apicd;
struct hlist_node *tmp;
+ unsigned long flags;
ack_APIC_irq();
/* Prevent vectors vanishing under us */
- raw_spin_lock(&vector_lock);
+ raw_spin_lock_irqsave(&vector_lock, flags);
hlist_for_each_entry_safe(apicd, tmp, clhead, clist) {
unsigned int irr, vector = apicd->prev_vector;
@@ -906,14 +950,15 @@
free_moved_vector(apicd);
}
- raw_spin_unlock(&vector_lock);
+ raw_spin_unlock_irqrestore(&vector_lock, flags);
}
static void __send_cleanup_vector(struct apic_chip_data *apicd)
{
+ unsigned long flags;
unsigned int cpu;
- raw_spin_lock(&vector_lock);
+ raw_spin_lock_irqsave(&vector_lock, flags);
apicd->move_in_progress = 0;
cpu = apicd->prev_cpu;
if (cpu_online(cpu)) {
@@ -922,7 +967,7 @@
} else {
apicd->prev_vector = 0;
}
- raw_spin_unlock(&vector_lock);
+ raw_spin_unlock_irqrestore(&vector_lock, flags);
}
void send_cleanup_vector(struct irq_cfg *cfg)
@@ -960,6 +1005,8 @@
struct apic_chip_data *apicd;
struct irq_data *irqd;
unsigned int vector;
+
+ WARN_ON_ONCE(irqs_pipelined() && !hard_irqs_disabled());
/*
* The function is called for all descriptors regardless of which
@@ -1051,9 +1098,10 @@
int lapic_can_unplug_cpu(void)
{
unsigned int rsvd, avl, tomove, cpu = smp_processor_id();
+ unsigned long flags;
int ret = 0;
- raw_spin_lock(&vector_lock);
+ raw_spin_lock_irqsave(&vector_lock, flags);
tomove = irq_matrix_allocated(vector_matrix);
avl = irq_matrix_available(vector_matrix, true);
if (avl < tomove) {
@@ -1068,7 +1116,7 @@
rsvd, avl);
}
out:
- raw_spin_unlock(&vector_lock);
+ raw_spin_unlock_irqrestore(&vector_lock, flags);
return ret;
}
#endif /* HOTPLUG_CPU */
--
Gitblit v1.6.2