linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <marc.zyngier@arm.com>
To: Oleksij Rempel <linux@rempel-privat.de>
Cc: <linux-kernel@vger.kernel.org>, <jason@lakedaemon.net>,
	<tglx@linutronix.de>,
	Oleksij Rempel <external.Oleksij.Rempel@de.bosch.com>
Subject: Re: Possible Spam [PATCH v2 2/2] ARM: irqchip: mxs: add Alpascale ASM9260 support
Date: Fri, 18 Sep 2015 11:42:56 +0100	[thread overview]
Message-ID: <20150918114256.74ab823a@arm.com> (raw)
In-Reply-To: <1442567922-14538-3-git-send-email-linux@rempel-privat.de>

On Fri, 18 Sep 2015 11:18:42 +0200
Oleksij Rempel <linux@rempel-privat.de> wrote:

> From: Oleksij Rempel <external.Oleksij.Rempel@de.bosch.com>
> 
> Freescale iMX23/iMX28 and Alphascale ASM9260 have similar

Is it Alphascale or Alpascale? You may need to fix the patch title.

> interrupt collectors. It makes easy to reuse irq-mxs code for ASM9260.
> Differences between this devices are fallowing:
> - different register offsets
> - different count of intterupt lines per register
> - ASM9260 don't provide reset bit
> - ASM9260 don't support FIQ.
> 
> Signed-off-by: Oleksij Rempel <external.Oleksij.Rempel@de.bosch.com>
> ---
>  drivers/irqchip/Kconfig                    |   5 ++
>  drivers/irqchip/Makefile                   |   2 +-
>  drivers/irqchip/alphascale_asm9260-icoll.h | 109 +++++++++++++++++++++++++++++
>  drivers/irqchip/irq-mxs.c                  | 106 +++++++++++++++++++++++++++-
>  4 files changed, 220 insertions(+), 2 deletions(-)
>  create mode 100644 drivers/irqchip/alphascale_asm9260-icoll.h
> 

[...]

> diff --git a/drivers/irqchip/irq-mxs.c b/drivers/irqchip/irq-mxs.c
> index 14374de..1470087 100644
> --- a/drivers/irqchip/irq-mxs.c
> +++ b/drivers/irqchip/irq-mxs.c
> @@ -1,5 +1,7 @@
>  /*
>   * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
> + * Copyright (C) 2014 Oleksij Rempel <linux@rempel-privat.de>
> + *	Add Alphascale ASM9260 support.
>   *
>   * This program is free software; you can redistribute it and/or modify
>   * it under the terms of the GNU General Public License as published by
> @@ -28,6 +30,8 @@
>  #include <linux/stmp_device.h>
>  #include <asm/exception.h>
>  
> +#include "alphascale_asm9260-icoll.h"
> +
>  /*
>   * this device provide 4 offsets for each register:
>   * 0x0 - plain read write mode
> @@ -49,6 +53,11 @@
>  
>  #define ICOLL_NUM_IRQS		128
>  
> +enum icoll_type {
> +	ICOLL,
> +	ASM9260_ICOLL,
> +};
> +
>  struct icoll_priv {
>  	void __iomem *vector;
>  	void __iomem *levelack;
> @@ -58,10 +67,38 @@ struct icoll_priv {
>  	/* number of interrupts per register */
>  	int ;
>  	void __iomem *clear;
> +	enum icoll_type type;
>  };
>  
>  static struct icoll_priv icoll_priv;
>  static struct irq_domain *icoll_domain;
> +static DEFINE_RAW_SPINLOCK(icoll_lock);
> +
> +/* calculate bit offset depending on number of intterupt per register */
> +static u32 icoll_intr_bitshift(struct irq_data *d, u32 bit)
> +{
> +	/*
> +	 * We expect intr_per_reg to be 4 or 1, it means
> +	 * "n" will be 3 or 0.
> +	 */
> +	int n = icoll_priv.intr_per_reg - 1;
> +
> +	/*
> +	 * If n = 0, "bit" is never shifted.
> +	 * If n = 3, mask lower part of hwirq to convert it
> +	 * in 0, 1, 2 or 3 and then multiply it by 8 (or shift by 3)
> +	 */
> +	return bit << ((d->hwirq & n) << n);
> +}
> +
> +/* calculate mem offset depending on number of intterupt per register */
> +static void __iomem *icoll_intr_reg(struct irq_data *d)
> +{
> +	int n = icoll_priv.intr_per_reg >> 1;
> +
> +	/* offset = hwirq / intr_per_reg * 0x10 */
> +	return icoll_priv.intr + ((d->hwirq >> n) * 0x10);
> +}

Please correct me if I'm wrong, but it looks like these function are
only useful when used on ams9260. So why do we need intr_per_reg at
all? MXS doesn't need it (always 1), and ams9260 always need it (always
4). Save yourself some previous cycles and simplify the whole thing.

>  
>  static void icoll_ack_irq(struct irq_data *d)
>  {
> @@ -86,12 +123,38 @@ static void icoll_unmask_irq(struct irq_data *d)
>  			icoll_priv.intr + SET_REG + HW_ICOLL_INTERRUPTn(d->hwirq));
>  }
>  
> +static void asm9260_mask_irq(struct irq_data *d)
> +{
> +	raw_spin_lock(&icoll_lock);
> +	__raw_writel(icoll_intr_bitshift(d, BM_ICOLL_INTR_ENABLE),
> +			icoll_intr_reg(d) + CLR_REG);
> +	raw_spin_unlock(&icoll_lock);
> +}
> +
> +static void asm9260_unmask_irq(struct irq_data *d)
> +{
> +	raw_spin_lock(&icoll_lock);
> +	__raw_writel(ASM9260_BM_CLEAR_BIT(d->hwirq),
> +		     icoll_priv.clear +
> +		     ASM9260_HW_ICOLL_CLEARn(d->hwirq));
> +
> +	__raw_writel(icoll_intr_bitshift(d, BM_ICOLL_INTR_ENABLE),
> +			icoll_intr_reg(d) + SET_REG);
> +	raw_spin_unlock(&icoll_lock);
> +}

Can you please explain the rational for this lock? mask/unmask use
different registers, and it is not obvious to me what race you are
trying to avoid here.

Thanks,

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

  reply	other threads:[~2015-09-18 10:43 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18  9:18 [PATCH v2 0/2] changelog Oleksij Rempel
2015-09-18  9:18 ` [PATCH v2 1/2] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-09-18 10:21   ` Thomas Gleixner
2015-09-18  9:18 ` [PATCH v2 2/2] ARM: irqchip: mxs: add Alpascale ASM9260 support Oleksij Rempel
2015-09-18 10:42   ` Marc Zyngier [this message]
2015-09-19  5:53     ` Possible Spam " Oleksij Rempel
2015-09-20 11:28       ` Marc Zyngier
2015-09-20 13:47         ` Oleksij Rempel
2015-09-21  9:06         ` Thomas Gleixner
2015-09-21 11:53         ` [PATCH v3 0/2] Add support for ASM9260 interrupt controller Oleksij Rempel
2015-09-21 11:53           ` [PATCH v3 1/2] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-09-21 11:53           ` [PATCH v3 2/2] ARM: irqchip: mxs: add Alphascale ASM9260 support Oleksij Rempel
2015-09-22 10:34             ` Thomas Gleixner
2015-09-23 16:20               ` [PATCH v4 0/2] Add support for ASM9260 interrupt controller Oleksij Rempel
2015-09-23 16:20                 ` [PATCH v4 1/2] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-09-29 16:06                   ` Thomas Gleixner
2015-10-05 19:00                     ` [PATCH v5 0/2] Add support for ASM9260 interrupt controller Oleksij Rempel
2015-10-05 19:00                       ` [PATCH v5 1/2] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-10-05 19:00                       ` [PATCH v5 2/2] ARM: irqchip: mxs: add Alphascale ASM9260 support Oleksij Rempel
2015-10-09 14:11                         ` Thomas Gleixner
2015-10-10 13:08                           ` [PATCH v6 0/2] Add support for ASM9260 interrupt controller Oleksij Rempel
2015-10-10 13:08                             ` [PATCH v6 1/2] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-10-11 17:58                               ` Thomas Gleixner
2015-10-12  9:29                                 ` Oleksij Rempel
2015-10-12  9:32                                   ` Thomas Gleixner
2015-10-12 19:15                                     ` [PATCH v7 0/3] Add support for ASM9260 interrupt controller Oleksij Rempel
2015-10-12 19:15                                       ` [PATCH v7 1/3] ARM: irqchip: mxs: do panic if icoll_base == NULL Oleksij Rempel
2015-10-14  7:42                                         ` [tip:irq/core] irqchip/mxs: Panic if ioremap or domain creation fails tip-bot for Oleksij Rempel
2015-10-12 19:15                                       ` [PATCH v6 1/2] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-10-12 19:15                                       ` [PATCH v6 2/2] ARM: irqchip: mxs: add Alphascale ASM9260 support Oleksij Rempel
2015-10-12 19:15                                       ` [PATCH v7 2/3] ARM: irqchip: mxs: prepare driver for HW with different offsets Oleksij Rempel
2015-10-14  7:42                                         ` [tip:irq/core] irqchip/mxs: Prepare driver for hardware " tip-bot for Oleksij Rempel
2015-10-12 19:15                                       ` [PATCH v7 3/3] ARM: irqchip: mxs: add Alphascale ASM9260 support Oleksij Rempel
2015-10-14  7:43                                         ` [tip:irq/core] irqchip/mxs: Add " tip-bot for Oleksij Rempel
2015-10-10 13:08                             ` [PATCH v6 2/2] ARM: irqchip: mxs: add " Oleksij Rempel
2015-09-23 16:20                 ` [PATCH v4 " Oleksij Rempel
2015-09-18  9:48 ` [PATCH v2 2/2] ARM: irqchip: mxs: add Alpascale " Oleksij Rempel
2015-09-18 10:16 ` [PATCH v2 0/2] changelog Marc Zyngier
2015-09-18 10:19 ` Thomas Gleixner

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=20150918114256.74ab823a@arm.com \
    --to=marc.zyngier@arm.com \
    --cc=external.Oleksij.Rempel@de.bosch.com \
    --cc=jason@lakedaemon.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --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;
as well as URLs for NNTP newsgroup(s).