lkml.org 
[lkml]   [2022]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next 3/3] genirq/affinity: Add __irq_do_set_affinity_lock function.
Date
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@huawei.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
\
 
 \ /
  Last update: 2022-08-27 03:18    [W:0.050 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site