From: tip-bot for Jiang Liu <liuj97@gmail.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
chenkeping@huawei.com, jiang.liu@huawei.com, liuj97@gmail.com,
tglx@linutronix.de
Subject: [tip:irq/core] genirq: Introduce irq_do_set_affinity() to reduce duplicated code
Date: Thu, 24 May 2012 13:53:26 -0700 [thread overview]
Message-ID: <tip-818b0f3bfb236ae66cac3ff38e86b9e47f24b7aa@git.kernel.org> (raw)
In-Reply-To: <1333120296-13563-3-git-send-email-jiang.liu@huawei.com>
Commit-ID: 818b0f3bfb236ae66cac3ff38e86b9e47f24b7aa
Gitweb: http://git.kernel.org/tip/818b0f3bfb236ae66cac3ff38e86b9e47f24b7aa
Author: Jiang Liu <liuj97@gmail.com>
AuthorDate: Fri, 30 Mar 2012 23:11:34 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 24 May 2012 22:36:40 +0200
genirq: Introduce irq_do_set_affinity() to reduce duplicated code
All invocations of chip->irq_set_affinity() are doing the same return
value checks. Let them all use a common function.
[ tglx: removed the silly likely while at it ]
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: Jiang Liu <liuj97@gmail.com>
Cc: Keping Chen <chenkeping@huawei.com>
Link: http://lkml.kernel.org/r/1333120296-13563-3-git-send-email-jiang.liu@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/irq/internals.h | 3 +++
kernel/irq/manage.c | 39 ++++++++++++++++++++++-----------------
kernel/irq/migration.c | 13 ++-----------
3 files changed, 27 insertions(+), 28 deletions(-)
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 8e5c56b..001fa5b 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -101,6 +101,9 @@ extern int irq_select_affinity_usr(unsigned int irq, struct cpumask *mask);
extern void irq_set_thread_affinity(struct irq_desc *desc);
+extern int irq_do_set_affinity(struct irq_data *data,
+ const struct cpumask *dest, bool force);
+
/* Inline functions for support of irq chips on slow busses */
static inline void chip_bus_lock(struct irq_desc *desc)
{
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index bb32326..a1b9033 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -139,6 +139,25 @@ static inline void
irq_get_pending(struct cpumask *mask, struct irq_desc *desc) { }
#endif
+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;
+
+ ret = chip->irq_set_affinity(data, mask, false);
+ switch (ret) {
+ case IRQ_SET_MASK_OK:
+ cpumask_copy(data->affinity, mask);
+ case IRQ_SET_MASK_OK_NOCOPY:
+ irq_set_thread_affinity(desc);
+ ret = 0;
+ }
+
+ return ret;
+}
+
int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
{
struct irq_chip *chip = irq_data_get_irq_chip(data);
@@ -149,14 +168,7 @@ int __irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask)
return -EINVAL;
if (irq_can_move_pcntxt(data)) {
- ret = chip->irq_set_affinity(data, mask, false);
- switch (ret) {
- case IRQ_SET_MASK_OK:
- cpumask_copy(data->affinity, mask);
- case IRQ_SET_MASK_OK_NOCOPY:
- irq_set_thread_affinity(desc);
- ret = 0;
- }
+ ret = irq_do_set_affinity(data, mask, false);
} else {
irqd_set_move_pending(data);
irq_copy_pending(desc, mask);
@@ -280,9 +292,8 @@ EXPORT_SYMBOL_GPL(irq_set_affinity_notifier);
static int
setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
{
- struct irq_chip *chip = irq_desc_get_chip(desc);
struct cpumask *set = irq_default_affinity;
- int ret, node = desc->irq_data.node;
+ int node = desc->irq_data.node;
/* Excludes PER_CPU and NO_BALANCE interrupts */
if (!irq_can_set_affinity(irq))
@@ -308,13 +319,7 @@ setup_affinity(unsigned int irq, struct irq_desc *desc, struct cpumask *mask)
if (cpumask_intersects(mask, nodemask))
cpumask_and(mask, mask, nodemask);
}
- ret = chip->irq_set_affinity(&desc->irq_data, mask, false);
- switch (ret) {
- case IRQ_SET_MASK_OK:
- cpumask_copy(desc->irq_data.affinity, mask);
- case IRQ_SET_MASK_OK_NOCOPY:
- irq_set_thread_affinity(desc);
- }
+ irq_do_set_affinity(&desc->irq_data, mask, false);
return 0;
}
#else
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
index c3c8975..ca3f4aa 100644
--- a/kernel/irq/migration.c
+++ b/kernel/irq/migration.c
@@ -42,17 +42,8 @@ void irq_move_masked_irq(struct irq_data *idata)
* For correct operation this depends on the caller
* masking the irqs.
*/
- if (likely(cpumask_any_and(desc->pending_mask, cpu_online_mask)
- < nr_cpu_ids)) {
- int ret = chip->irq_set_affinity(&desc->irq_data,
- desc->pending_mask, false);
- switch (ret) {
- case IRQ_SET_MASK_OK:
- cpumask_copy(desc->irq_data.affinity, desc->pending_mask);
- case IRQ_SET_MASK_OK_NOCOPY:
- irq_set_thread_affinity(desc);
- }
- }
+ if (cpumask_any_and(desc->pending_mask, cpu_online_mask) < nr_cpu_ids)
+ irq_do_set_affinity(&desc->irq_data, desc->pending_mask, false);
cpumask_clear(desc->pending_mask);
}
next prev parent reply other threads:[~2012-05-24 20:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 15:11 [PATCH v3 0/4] normalize return value of chip->irq_set_affinity() Jiang Liu
2012-03-30 15:11 ` [PATCH v3 1/4] IRQ: correctly handle return value from chip->irq_set_affinity() in irq_move_masked_irq() Jiang Liu
2012-03-30 21:31 ` [tip:irq/core] genirq: Adjust irq thread affinity on IRQ_SET_MASK_OK_NOCOPY return value tip-bot for Jiang Liu
2012-03-30 15:11 ` [PATCH v3 2/4] IRQ: introduce irq_do_set_affinity() to reduce duplicated code Jiang Liu
2012-05-24 20:53 ` tip-bot for Jiang Liu [this message]
2012-03-30 15:11 ` [PATCH v3 3/4] IRQ,x86: normalize return value of chip->irq_set_affinity() method Jiang Liu
2012-03-30 21:23 ` Thomas Gleixner
2012-03-31 16:22 ` Jiang Liu
2012-04-01 16:33 ` [PATCH 1/4] IRQ,x86: remove redundant memory copy operations in chip->irq_set_affinity() Jiang Liu
2012-04-01 16:33 ` [PATCH 2/4] IRQ,x86: normalize return value of chip->irq_set_affinity() method Jiang Liu
2012-04-01 16:33 ` [PATCH 3/4] IRQ,IA64: remove redundant memory copy operations in chip->irq_set_affinity() Jiang Liu
2012-04-01 16:33 ` [PATCH 4/4] IRQ,IA64: normalize return value of chip->irq_set_affinity() method Jiang Liu
2012-05-24 21:23 ` [tip:x86/cleanups] x86: Return IRQ_SET_MASK_OK_NOCOPY from irq affinity functions tip-bot for Jiang Liu
2012-03-30 15:11 ` [PATCH v3 4/4] IRQ,IA64: normalize return value of chip->irq_set_affinity() method Jiang Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-818b0f3bfb236ae66cac3ff38e86b9e47f24b7aa@git.kernel.org \
--to=liuj97@gmail.com \
--cc=chenkeping@huawei.com \
--cc=hpa@zytor.com \
--cc=jiang.liu@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome