All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Hanjun Guo <hanjun.guo@linaro.org>,
	Jason Cooper <jason@lakedaemon.net>,
	Will Deacon <Will.Deacon@arm.com>,
	Catalin Marinas <Catalin.Marinas@arm.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linaro-acpi@lists.linaro.org" <linaro-acpi@lists.linaro.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Tomasz Nowicki <tomasz.nowicki@linaro.org>,
	Olof Johansson <olof@lixom.net>,
	"grant.likely@linaro.org" <grant.likely@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Jiang Liu <jiang.liu@linux.intel.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 06/11] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi()
Date: Wed, 10 Jun 2015 16:58:05 +0100	[thread overview]
Message-ID: <55785E8D.1000909@arm.com> (raw)
In-Reply-To: <1431953961-22706-7-git-send-email-hanjun.guo@linaro.org>

On 18/05/15 13:59, Hanjun Guo wrote:
> 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 55b5f31..ab0dcb4 100644
> --- a/drivers/acpi/gsi.c
> +++ b/drivers/acpi/gsi.c
> @@ -16,6 +16,7 @@
>  enum acpi_irq_model_id acpi_irq_model;
>  /* ACPI core domian pointing to GICv2/3 core domain */
>  struct irq_domain *acpi_irq_domain __read_mostly;
> +static DEFINE_MUTEX(gsi_mutex);
>  
>  static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
>  {
> @@ -73,20 +74,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);
>  
> @@ -96,8 +101,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);
> 

Can you point out why we need this locking? The rest of the kernel seems
to live without it pretty well. And if we really have an issue, I'd
prefer seeing it fixed in the core code rather than in something that is
very much firmware-specific.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com>
To: Hanjun Guo <hanjun.guo@linaro.org>,
	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@linaro.org" <grant.likely@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Olof Johansson <olof@lixom.net>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linaro-acpi@lists.linaro.org" <linaro-acpi@lists.linaro.org>
Subject: Re: [PATCH 06/11] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi()
Date: Wed, 10 Jun 2015 16:58:05 +0100	[thread overview]
Message-ID: <55785E8D.1000909@arm.com> (raw)
In-Reply-To: <1431953961-22706-7-git-send-email-hanjun.guo@linaro.org>

On 18/05/15 13:59, Hanjun Guo wrote:
> 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 55b5f31..ab0dcb4 100644
> --- a/drivers/acpi/gsi.c
> +++ b/drivers/acpi/gsi.c
> @@ -16,6 +16,7 @@
>  enum acpi_irq_model_id acpi_irq_model;
>  /* ACPI core domian pointing to GICv2/3 core domain */
>  struct irq_domain *acpi_irq_domain __read_mostly;
> +static DEFINE_MUTEX(gsi_mutex);
>  
>  static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
>  {
> @@ -73,20 +74,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);
>  
> @@ -96,8 +101,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);
> 

Can you point out why we need this locking? The rest of the kernel seems
to live without it pretty well. And if we really have an issue, I'd
prefer seeing it fixed in the core code rather than in something that is
very much firmware-specific.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

WARNING: multiple messages have this Message-ID (diff)
From: marc.zyngier@arm.com (Marc Zyngier)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/11] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi()
Date: Wed, 10 Jun 2015 16:58:05 +0100	[thread overview]
Message-ID: <55785E8D.1000909@arm.com> (raw)
In-Reply-To: <1431953961-22706-7-git-send-email-hanjun.guo@linaro.org>

On 18/05/15 13:59, Hanjun Guo wrote:
> 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 55b5f31..ab0dcb4 100644
> --- a/drivers/acpi/gsi.c
> +++ b/drivers/acpi/gsi.c
> @@ -16,6 +16,7 @@
>  enum acpi_irq_model_id acpi_irq_model;
>  /* ACPI core domian pointing to GICv2/3 core domain */
>  struct irq_domain *acpi_irq_domain __read_mostly;
> +static DEFINE_MUTEX(gsi_mutex);
>  
>  static unsigned int acpi_gsi_get_irq_type(int trigger, int polarity)
>  {
> @@ -73,20 +74,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);
>  
> @@ -96,8 +101,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);
> 

Can you point out why we need this locking? The rest of the kernel seems
to live without it pretty well. And if we really have an issue, I'd
prefer seeing it fixed in the core code rather than in something that is
very much firmware-specific.

Thanks,

	M.
-- 
Jazz is not dead. It just smells funny...

  reply	other threads:[~2015-06-10 15:58 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 12:59 [PATCH 00/11] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Hanjun Guo
2015-05-18 12:59 ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 01/11] ACPICA: Introduce GIC version for arm based system Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 02/11] ACPI / irqchip: Add self-probe infrastructure to initialize IRQ controller Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-06-10 15:33   ` Marc Zyngier
2015-06-10 15:33     ` Marc Zyngier
2015-06-10 15:33     ` Marc Zyngier
2015-06-11 12:55     ` Hanjun Guo
2015-06-11 12:55       ` Hanjun Guo
2015-06-11 12:55       ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 03/11] irqchip / GIC: Add GIC version support in ACPI MADT Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-20 20:02   ` Thomas Gleixner
2015-05-20 20:02     ` Thomas Gleixner
2015-05-21 14:19     ` Hanjun Guo
2015-05-21 14:19       ` Hanjun Guo
2015-05-21 14:19       ` Hanjun Guo
2015-05-21 14:39       ` Thomas Gleixner
2015-05-21 14:39         ` Thomas Gleixner
2015-05-21 15:04         ` Hanjun Guo
2015-05-21 15:04           ` Hanjun Guo
2015-05-21 15:04           ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 04/11] irqchip / GIC / ACPI: Use IRQCHIP_ACPI_DECLARE to simplify GICv2 init code Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 05/11] irqchip / gic: Add stacked irqdomain support for ACPI based GICv2 init Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-06-10 16:27   ` Marc Zyngier
2015-06-10 16:27     ` Marc Zyngier
2015-06-10 16:27     ` Marc Zyngier
2015-06-11 13:22     ` Hanjun Guo
2015-06-11 13:22       ` Hanjun Guo
2015-06-11 13:22       ` Hanjun Guo
2015-06-18 23:25       ` Hanjun Guo
2015-06-18 23:25         ` Hanjun Guo
2015-06-18 23:25         ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 06/11] ACPI / gsi: Add gsi_mutex to synchronize acpi_register_gsi()/acpi_unregister_gsi() Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-06-10 15:58   ` Marc Zyngier [this message]
2015-06-10 15:58     ` Marc Zyngier
2015-06-10 15:58     ` Marc Zyngier
2015-06-11 13:16     ` Hanjun Guo
2015-06-11 13:16       ` Hanjun Guo
2015-06-11 13:16       ` Hanjun Guo
2015-06-19  7:31       ` Hanjun Guo
2015-06-19  7:31         ` Hanjun Guo
2015-06-19  7:31         ` Hanjun Guo
2015-06-19  9:49         ` Marc Zyngier
2015-06-19  9:49           ` Marc Zyngier
2015-06-19  9:49           ` Marc Zyngier
2015-05-18 12:59 ` [PATCH 07/11] irqchip / GICv3: Refactor gic_of_init() for GICv3 driver Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 08/11] irqchip / GICv3: Add ACPI support for GICv3+ initialization Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 09/11] irqchip / GICv3: Add stacked irqdomain support for ACPI based init Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 10/11] irqchip / GICv2 / ACPI: Consolidate GICv2 ACPI related init code Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-05-20 20:44   ` Tomasz Nowicki
2015-05-20 20:44     ` Tomasz Nowicki
2015-05-21 14:27     ` Hanjun Guo
2015-05-21 14:27       ` Hanjun Guo
2015-05-21 14:27       ` Hanjun Guo
2015-06-10 16:29       ` Marc Zyngier
2015-06-10 16:29         ` Marc Zyngier
2015-06-10 16:29         ` Marc Zyngier
2015-06-11 13:25         ` Hanjun Guo
2015-06-11 13:25           ` Hanjun Guo
2015-06-11 13:25           ` Hanjun Guo
2015-05-18 12:59 ` [PATCH 11/11] irqchip / GICv3 / ACPI: Consolidate GICv3 " Hanjun Guo
2015-05-18 12:59   ` Hanjun Guo
2015-06-02 12:24 ` [PATCH 00/11] Add self-probe infrastructure and stacked irqdomain support for ACPI based GICv2/3 init Hanjun Guo
2015-06-02 12:24   ` Hanjun Guo
2015-06-02 12:24   ` Hanjun Guo

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=55785E8D.1000909@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=Catalin.Marinas@arm.com \
    --cc=Lorenzo.Pieralisi@arm.com \
    --cc=Will.Deacon@arm.com \
    --cc=arnd@arndb.de \
    --cc=grant.likely@linaro.org \
    --cc=hanjun.guo@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=olof@lixom.net \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=tomasz.nowicki@linaro.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.