linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: gregory.clement@free-electrons.com (Gregory CLEMENT)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/7] irqchip: armada-370-xp: Simplify interrupt map, mask and unmask
Date: Fri, 31 Oct 2014 17:36:55 +0100	[thread overview]
Message-ID: <5453BAA7.1040804@free-electrons.com> (raw)
In-Reply-To: <1413985427-20918-2-git-send-email-ezequiel.garcia@free-electrons.com>

Hi Ezequiel,

On 22/10/2014 15:43, Ezequiel Garcia wrote:
> The map, mask and unmask is unnecessarily complicated, with a different
> implementation for shared and per CPU interrupts. The current code does
> the following:
> 
> At probe time, all interrupts are disabled and masked on all CPUs.
> 
> Shared interrupts:
> 
>  * When the interrupt is mapped(), it gets disabled and unmasked on the
>    calling CPU.
> 
>  * When the interrupt is unmasked(), masked(), it gets enabled and
>    disabled.
> 
> Per CPU interrupts:
> 
>  * When the interrupt is mapped, it gets masked on the calling CPU and
>    enabled.
> 
>  * When the interrupt is unmasked(), masked(), it gets unmasked and masked,
>    on the calling CPU.
> 
> This commit simplifies this code, with a much simpler implementation, common
> to shared and per CPU interrupts.
> 
>  * When the interrupt is mapped, it's enabled.
> 
>  * When the interrupt is unmasked(), masked(), it gets unmasked and masked,
>    on the calling CPU.

By doing this you change the behavior of the irqchip. Before this patch, masking
a shared interrupt was masking it on all the CPUs in the same time whereas with this
change it will mask the interrupt only on the calling CPU. It worth checking it is
the expected behavior.

Moreover I wonder how it is supposed to work with the irq affinity. Let say that the
irq was enabled on the CPU0, then there is irq_unmask call on CPU1, then the irq would
be enabled on both CPUs. It will modify the irq affinity and moreover it will also lead
to an invalidate state with the MPIC because we can't manage an interrupt on more than
one CPU.

>From the point of the view of the armada_370_xp_irq driver there are potential bug, but
maybe the use case I described can't happen. Could you check it?


Thanks,

Gregory


> 
> Tested on a Armada XP SoC with SMP and UP configurations, with chained and
> regular interrupts.
> 
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
> ---
>  drivers/irqchip/irq-armada-370-xp.c | 27 ++++-----------------------
>  1 file changed, 4 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
> index 3e238cd..af4e307 100644
> --- a/drivers/irqchip/irq-armada-370-xp.c
> +++ b/drivers/irqchip/irq-armada-370-xp.c
> @@ -73,33 +73,18 @@ static DEFINE_MUTEX(msi_used_lock);
>  static phys_addr_t msi_doorbell_addr;
>  #endif
>  
> -/*
> - * In SMP mode:
> - * For shared global interrupts, mask/unmask global enable bit
> - * For CPU interrupts, mask/unmask the calling CPU's bit
> - */
>  static void armada_370_xp_irq_mask(struct irq_data *d)
>  {
>  	irq_hw_number_t hwirq = irqd_to_hwirq(d);
>  
> -	if (hwirq != ARMADA_370_XP_TIMER0_PER_CPU_IRQ)
> -		writel(hwirq, main_int_base +
> -				ARMADA_370_XP_INT_CLEAR_ENABLE_OFFS);
> -	else
> -		writel(hwirq, per_cpu_int_base +
> -				ARMADA_370_XP_INT_SET_MASK_OFFS);
> +	writel(hwirq, per_cpu_int_base + ARMADA_370_XP_INT_SET_MASK_OFFS);
>  }
>  
>  static void armada_370_xp_irq_unmask(struct irq_data *d)
>  {
>  	irq_hw_number_t hwirq = irqd_to_hwirq(d);
>  
> -	if (hwirq != ARMADA_370_XP_TIMER0_PER_CPU_IRQ)
> -		writel(hwirq, main_int_base +
> -				ARMADA_370_XP_INT_SET_ENABLE_OFFS);
> -	else
> -		writel(hwirq, per_cpu_int_base +
> -				ARMADA_370_XP_INT_CLEAR_MASK_OFFS);
> +	writel(hwirq, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS);
>  }
>  
>  #ifdef CONFIG_PCI_MSI
> @@ -282,12 +267,8 @@ static struct irq_chip armada_370_xp_irq_chip = {
>  static int armada_370_xp_mpic_irq_map(struct irq_domain *h,
>  				      unsigned int virq, irq_hw_number_t hw)
>  {
> -	armada_370_xp_irq_mask(irq_get_irq_data(virq));
> -	if (hw != ARMADA_370_XP_TIMER0_PER_CPU_IRQ)
> -		writel(hw, per_cpu_int_base +
> -			ARMADA_370_XP_INT_CLEAR_MASK_OFFS);
> -	else
> -		writel(hw, main_int_base + ARMADA_370_XP_INT_SET_ENABLE_OFFS);
> +	writel(hw, main_int_base + ARMADA_370_XP_INT_SET_ENABLE_OFFS);
> +
>  	irq_set_status_flags(virq, IRQ_LEVEL);
>  
>  	if (hw == ARMADA_370_XP_TIMER0_PER_CPU_IRQ) {
> 


-- 
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

  reply	other threads:[~2014-10-31 16:36 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-22 13:43 [PATCH 0/7] Armada 375/38x perf support, and a bonus irqchip driver simplification Ezequiel Garcia
2014-10-22 13:43 ` [PATCH 1/7] irqchip: armada-370-xp: Simplify interrupt map, mask and unmask Ezequiel Garcia
2014-10-31 16:36   ` Gregory CLEMENT [this message]
2014-11-04 15:11     ` Ezequiel Garcia
2014-11-10 17:09       ` Gregory CLEMENT
2014-10-22 13:43 ` [PATCH 2/7] irqchip: armada-370-xp: Initialize per cpu registers when CONFIG_SMP=N Ezequiel Garcia
2014-11-12 10:30   ` Gregory CLEMENT
2014-10-22 13:43 ` [PATCH 3/7] irqchip: armada-370-xp: Introduce a is_percpu_irq() helper for readability Ezequiel Garcia
2014-10-22 13:58   ` Mark Rutland
2014-10-22 15:14     ` Ezequiel Garcia
2014-10-22 13:43 ` [PATCH 4/7] irqchip: armada-370-xp: Enable Performance Counter interrupts Ezequiel Garcia
2014-10-22 13:43 ` [PATCH 5/7] ARM: mvebu: Enable Performance Monitor Unit on Armada 375 SoC Ezequiel Garcia
2014-10-22 14:04   ` Mark Rutland
2014-10-22 22:16     ` Ezequiel Garcia
2014-10-23  9:14       ` Thomas Petazzoni
2014-10-23 11:51         ` Ezequiel Garcia
2014-10-23 12:07           ` Thomas Petazzoni
2014-10-23 12:19             ` Ezequiel Garcia
2014-10-23 13:18             ` Mark Rutland
2014-10-31 16:23               ` Ezequiel Garcia
2014-10-23  9:41       ` Mark Rutland
2014-10-22 13:43 ` [PATCH 6/7] ARM: mvebu: Enable Performance Monitor Unit on Armada 380/385 SoC Ezequiel Garcia
2014-10-22 14:06   ` Mark Rutland
2014-10-22 22:18     ` Ezequiel Garcia
2014-10-22 13:43 ` [PATCH 7/7] ARM: mvebu: Enable perf support in mvebu_v7_defconfig Ezequiel Garcia
2014-10-22 14:11   ` Mark Rutland
2014-10-22 15:33     ` Ezequiel Garcia
2014-10-22 15:38       ` Mark Rutland
2014-11-09  5:23 ` [PATCH 0/7] Armada 375/38x perf support, and a bonus irqchip driver simplification Jason Cooper
2014-11-09  9:41   ` Thomas Petazzoni
2014-11-09 12:18     ` Ezequiel Garcia
2014-11-09 22:50       ` Jason Cooper
2014-11-23  0:45         ` Ezequiel Garcia

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=5453BAA7.1040804@free-electrons.com \
    --to=gregory.clement@free-electrons.com \
    --cc=linux-arm-kernel@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).