[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220827011351.9185-3-xuqiang36@huawei.com>
Date: Sat, 27 Aug 2022 01:13:51 +0000
From: Xu Qiang <xuqiang36@...wei.com>
To: <tglx@...utronix.de>, <frederic@...nel.org>,
<peterz@...radead.org>, <nitesh@...hat.com>,
<bigeasy@...utronix.de>, <douliyangs@...il.com>, <maz@...nel.org>
CC: <linux-kernel@...r.kernel.org>, <guohanjun@...wei.com>,
<weiyongjun1@...wei.com>, <xuqiang36@...wei.com>
Subject: [PATCH -next 3/3] genirq/affinity: Add __irq_do_set_affinity_lock function.
To make irq_do_set_affinity more concise and clear, force argument
is handled first, and then non-force scenarios are handled in
the __irq_do_set_affinity_lock function.
Signed-off-by: Xu Qiang <xuqiang36@...wei.com>
---
kernel/irq/manage.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index ae1c7eebdfa6..1fa8ef781736 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -209,21 +209,14 @@ static void irq_validate_effective_affinity(struct irq_data *data)
static inline void irq_validate_effective_affinity(struct irq_data *data) { }
#endif
-int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
- bool force)
+static int __irq_do_set_affinity_lock(struct irq_data *data, const struct cpumask *mask)
{
- struct irq_desc *desc = irq_data_to_desc(data);
struct irq_chip *chip = irq_data_get_irq_chip(data);
const struct cpumask *prog_mask;
int ret;
- static DEFINE_RAW_SPINLOCK(tmp_mask_lock);
struct cpumask tmp_mask;
- if (!chip || !chip->irq_set_affinity)
- return -EINVAL;
-
- raw_spin_lock(&tmp_mask_lock);
/*
* If this is a managed interrupt and housekeeping is enabled on
* it check whether the requested affinity mask intersects with
@@ -264,13 +257,31 @@ int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
* case we do as we are told).
*/
cpumask_and(&tmp_mask, prog_mask, cpu_online_mask);
- if (!force && !cpumask_empty(&tmp_mask))
- ret = chip->irq_set_affinity(data, &tmp_mask, force);
- else if (force)
- ret = chip->irq_set_affinity(data, mask, force);
+ if (!cpumask_empty(&tmp_mask))
+ ret = chip->irq_set_affinity(data, &tmp_mask, false);
else
ret = -EINVAL;
+ return ret;
+}
+
+int irq_do_set_affinity(struct irq_data *data, const struct cpumask *mask,
+ bool force)
+{
+ struct irq_desc *desc = irq_data_to_desc(data);
+ struct irq_chip *chip = irq_data_get_irq_chip(data);
+ int ret;
+
+ static DEFINE_RAW_SPINLOCK(tmp_mask_lock);
+
+ if (!chip || !chip->irq_set_affinity)
+ return -EINVAL;
+
+ raw_spin_lock(&tmp_mask_lock);
+ if (force)
+ ret = chip->irq_set_affinity(data, mask, force);
+ else
+ ret = __irq_do_set_affinity_lock(data, mask);
raw_spin_unlock(&tmp_mask_lock);
switch (ret) {
--
2.17.1
Powered by blists - more mailing lists