From: Hanjun Guo <hanjun.guo@linaro.org>
To: Marc Zyngier <marc.zyngier@arm.com>,
Jason Cooper <jason@lakedaemon.net>,
Will Deacon <will.deacon@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Jiang Liu <jiang.liu@linux.intel.com>,
Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
Arnd Bergmann <arnd@arndb.de>,
Tomasz Nowicki <tomasz.nowicki@linaro.org>,
Grant Likely <grant.likely@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Olof Johansson <olof@lixom.net>,
linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, linaro-acpi@lists.linaro.org,
Hanjun Guo <hanjun.guo@linaro.org>
Subject: [RFC PATCH 6/9] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi()
Date: Tue, 5 May 2015 21:50:54 +0800 [thread overview]
Message-ID: <1430833857-30736-7-git-send-email-hanjun.guo@linaro.org> (raw)
In-Reply-To: <1430833857-30736-1-git-send-email-hanjun.guo@linaro.org>
Add a mutex for acpi_register_gsi()/acpi_unregister_gsi() to avoid
concurrency issues.
Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org>
---
drivers/acpi/gsi.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/acpi/gsi.c b/drivers/acpi/gsi.c
index f4110d8..f0f219c 100644
--- a/drivers/acpi/gsi.c
+++ b/drivers/acpi/gsi.c
@@ -14,6 +14,7 @@
enum acpi_irq_model_id acpi_irq_model;
struct irq_domain *acpi_irq_domain;
+static DEFINE_MUTEX(gsi_mutex);
static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
{
@@ -71,20 +72,24 @@ int acpi_register_gsi(struct device *dev, u32 gsi, int trigger,
int irq;
unsigned int irq_type = acpi_gsi_get_irq_type(trigger, polarity);
+ mutex_lock(&gsi_mutex);
irq = irq_find_mapping(acpi_irq_domain, gsi);
if (irq > 0)
- return irq;
+ goto out;
irq = irq_domain_alloc_irqs(acpi_irq_domain, 1, dev_to_node(dev),
&gsi);
if (irq <= 0)
- return -EINVAL;
+ goto out;
/* Set irq type if specified and different than the current one */
if (irq_type != IRQ_TYPE_NONE &&
irq_type != irq_get_trigger_type(irq))
irq_set_irq_type(irq, irq_type);
- return irq;
+
+out:
+ mutex_unlock(&gsi_mutex);
+ return irq > 0 ? irq : -EINVAL;
}
EXPORT_SYMBOL_GPL(acpi_register_gsi);
@@ -94,8 +99,12 @@ EXPORT_SYMBOL_GPL(acpi_register_gsi);
*/
void acpi_unregister_gsi(u32 gsi)
{
- int irq = irq_find_mapping(acpi_irq_domain, gsi);
+ int irq;
+
+ mutex_lock(&gsi_mutex);
+ irq = irq_find_mapping(acpi_irq_domain, gsi);
irq_dispose_mapping(irq);
+ mutex_unlock(&gsi_mutex);
}
EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
--
1.9.1
next prev parent reply other threads:[~2015-05-05 13:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-05 13:50 [RFC PATCH 0/9] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 1/9] ACPICA: Introduce GIC version for arm based system Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 2/9] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 3/9] irqchip / gic: Add GIC version support in ACPI MADT Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 4/9] irqchip: gic: ACPI: Use IRQCHIP_ACPI_DECLARE to simplify GICv2 init code Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 5/9] irqchip / gic: Add stacked irqdomain support for ACPI based GICv2 init Hanjun Guo
2015-05-05 13:50 ` Hanjun Guo [this message]
2015-05-05 13:50 ` [RFC PATCH 7/9] irqchip / GICv3: Refactor gic_of_init() for GICv3 driver Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 8/9] irqchip / GICv3: Add ACPI support for GICv3+ initialization Hanjun Guo
2015-05-05 13:50 ` [RFC PATCH 9/9] irqchip / GICv3: Add stacked irqdomain support for ACPI based init Hanjun Guo
2015-05-05 20:28 ` [RFC PATCH 0/9] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Rafael J. Wysocki
2015-05-06 3:00 ` Hanjun Guo
2015-05-06 14:25 ` Lorenzo Pieralisi
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=1430833857-30736-7-git-send-email-hanjun.guo@linaro.org \
--to=hanjun.guo@linaro.org \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=grant.likely@linaro.org \
--cc=jason@lakedaemon.net \
--cc=jiang.liu@linux.intel.com \
--cc=linaro-acpi@lists.linaro.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=olof@lixom.net \
--cc=rjw@rjwysocki.net \
--cc=tglx@linutronix.de \
--cc=tomasz.nowicki@linaro.org \
--cc=will.deacon@arm.com \
/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