153 lines
4.7 KiB
Diff
153 lines
4.7 KiB
Diff
From 60e95a9fdc9b5283e0a076ba9b3b8ef3ee7abf81 Mon Sep 17 00:00:00 2001
|
|
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
Date: Wed, 21 Aug 2013 17:48:46 +0200
|
|
Subject: [PATCH 195/365] genirq: Do not invoke the affinity callback via a
|
|
workqueue on RT
|
|
|
|
Joe Korty reported, that __irq_set_affinity_locked() schedules a
|
|
workqueue while holding a rawlock which results in a might_sleep()
|
|
warning.
|
|
This patch uses swork_queue() instead.
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
---
|
|
drivers/scsi/qla2xxx/qla_isr.c | 4 +++
|
|
include/linux/interrupt.h | 6 +++++
|
|
kernel/irq/manage.c | 49 ++++++++++++++++++++++++++++------
|
|
3 files changed, 51 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
|
|
index 17b1525d492b..6249c4b6f4be 100644
|
|
--- a/drivers/scsi/qla2xxx/qla_isr.c
|
|
+++ b/drivers/scsi/qla2xxx/qla_isr.c
|
|
@@ -3127,7 +3127,11 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
|
|
* kref_put().
|
|
*/
|
|
kref_get(&qentry->irq_notify.kref);
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
+ swork_queue(&qentry->irq_notify.swork);
|
|
+#else
|
|
schedule_work(&qentry->irq_notify.work);
|
|
+#endif
|
|
}
|
|
|
|
/*
|
|
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
|
|
index 807d3f6af646..4917b6273f33 100644
|
|
--- a/include/linux/interrupt.h
|
|
+++ b/include/linux/interrupt.h
|
|
@@ -14,6 +14,7 @@
|
|
#include <linux/hrtimer.h>
|
|
#include <linux/kref.h>
|
|
#include <linux/workqueue.h>
|
|
+#include <linux/swork.h>
|
|
|
|
#include <linux/atomic.h>
|
|
#include <asm/ptrace.h>
|
|
@@ -219,6 +220,7 @@ extern void resume_device_irqs(void);
|
|
* struct irq_affinity_notify - context for notification of IRQ affinity changes
|
|
* @irq: Interrupt to which notification applies
|
|
* @kref: Reference count, for internal use
|
|
+ * @swork: Swork item, for internal use
|
|
* @work: Work item, for internal use
|
|
* @notify: Function to be called on change. This will be
|
|
* called in process context.
|
|
@@ -230,7 +232,11 @@ extern void resume_device_irqs(void);
|
|
struct irq_affinity_notify {
|
|
unsigned int irq;
|
|
struct kref kref;
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
+ struct swork_event swork;
|
|
+#else
|
|
struct work_struct work;
|
|
+#endif
|
|
void (*notify)(struct irq_affinity_notify *, const cpumask_t *mask);
|
|
void (*release)(struct kref *ref);
|
|
};
|
|
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
|
|
index 996b5fb0efc4..8f459282b034 100644
|
|
--- a/kernel/irq/manage.c
|
|
+++ b/kernel/irq/manage.c
|
|
@@ -235,11 +235,12 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
|
|
|
|
if (desc->affinity_notify) {
|
|
kref_get(&desc->affinity_notify->kref);
|
|
- if (!schedule_work(&desc->affinity_notify->work)) {
|
|
- /* Work was already scheduled, drop our extra ref */
|
|
- kref_put(&desc->affinity_notify->kref,
|
|
- desc->affinity_notify->release);
|
|
- }
|
|
+
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
+ swork_queue(&desc->affinity_notify->swork);
|
|
+#else
|
|
+ schedule_work(&desc->affinity_notify->work);
|
|
+#endif
|
|
}
|
|
irqd_set(data, IRQD_AFFINITY_SET);
|
|
|
|
@@ -277,10 +278,8 @@ int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m)
|
|
}
|
|
EXPORT_SYMBOL_GPL(irq_set_affinity_hint);
|
|
|
|
-static void irq_affinity_notify(struct work_struct *work)
|
|
+static void _irq_affinity_notify(struct irq_affinity_notify *notify)
|
|
{
|
|
- struct irq_affinity_notify *notify =
|
|
- container_of(work, struct irq_affinity_notify, work);
|
|
struct irq_desc *desc = irq_to_desc(notify->irq);
|
|
cpumask_var_t cpumask;
|
|
unsigned long flags;
|
|
@@ -302,6 +301,35 @@ static void irq_affinity_notify(struct work_struct *work)
|
|
kref_put(¬ify->kref, notify->release);
|
|
}
|
|
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
+static void init_helper_thread(void)
|
|
+{
|
|
+ static int init_sworker_once;
|
|
+
|
|
+ if (init_sworker_once)
|
|
+ return;
|
|
+ if (WARN_ON(swork_get()))
|
|
+ return;
|
|
+ init_sworker_once = 1;
|
|
+}
|
|
+
|
|
+static void irq_affinity_notify(struct swork_event *swork)
|
|
+{
|
|
+ struct irq_affinity_notify *notify =
|
|
+ container_of(swork, struct irq_affinity_notify, swork);
|
|
+ _irq_affinity_notify(notify);
|
|
+}
|
|
+
|
|
+#else
|
|
+
|
|
+static void irq_affinity_notify(struct work_struct *work)
|
|
+{
|
|
+ struct irq_affinity_notify *notify =
|
|
+ container_of(work, struct irq_affinity_notify, work);
|
|
+ _irq_affinity_notify(notify);
|
|
+}
|
|
+#endif
|
|
+
|
|
/**
|
|
* irq_set_affinity_notifier - control notification of IRQ affinity changes
|
|
* @irq: Interrupt for which to enable/disable notification
|
|
@@ -330,7 +358,12 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
|
|
if (notify) {
|
|
notify->irq = irq;
|
|
kref_init(¬ify->kref);
|
|
+#ifdef CONFIG_PREEMPT_RT_BASE
|
|
+ INIT_SWORK(¬ify->swork, irq_affinity_notify);
|
|
+ init_helper_thread();
|
|
+#else
|
|
INIT_WORK(¬ify->work, irq_affinity_notify);
|
|
+#endif
|
|
}
|
|
|
|
raw_spin_lock_irqsave(&desc->lock, flags);
|
|
--
|
|
2.28.0
|
|
|