From: Marc Zyngier <marc.zyngier@arm.com>
To: Paul Burton <paul.burton@imgtec.com>,
linux-mips@linux-mips.org, Jason Cooper <jason@lakedaemon.net>,
Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/38] MIPS: GIC: Introduce asm/mips-gic.h with accessor functions
Date: Fri, 18 Aug 2017 12:10:20 +0100 [thread overview]
Message-ID: <b331ff4a-cdc6-49d1-96a5-f7536b3324f1@arm.com> (raw)
In-Reply-To: <20170813043646.25821-3-paul.burton@imgtec.com>
On 13/08/17 05:36, Paul Burton wrote:
> This patch introduces a new header providing accessor functions for the
> MIPS Global Interrupt Controller (GIC) mirroring those provided for the
> other 2 components of the MIPS Coherent Processing System (CPS) - the
> Coherence Manager (CM) & Cluster Power Controller (CPC).
>
> This header makes use of the new standardised CPS accessor macros where
> possible, but does require some custom accessors for cases where we have
> either a bit or a register per interrupt.
>
> A major advantage of this over the existing
> include/linux/irqchip/mips-gic.h definitions is that code performing
> accesses can become much simpler, for example this:
>
> gic_update_bits(GIC_REG(SHARED, GIC_SH_SET_TRIGGER) +
> GIC_INTR_OFS(intr), 1ul << GIC_INTR_BIT(intr),
> (unsigned long)trig << GIC_INTR_BIT(intr));
>
> ...can become simply:
>
> change_gic_trig(intr, trig);
>
> The accessors handle 32 vs 64 bit in the same way as for CM & CPC code,
> which means that GIC code will also not need to worry about the access
> size in most cases. They are also accessible outside of
> drivers/irqchip/irq-mips-gic.c which will allow for simplification in
> the use of the non-interrupt portions of the GIC (eg. counters) which
> currently require the interrupt controller driver to expose helper
> functions for access.
>
> This patch doesn't change any existing code over to use the new
> accessors yet, since a wholesale change would be invasive & difficult to
> review. Instead follow-on patches will convert code piecemeal to use
> this new header. The one change to existing code is to rename gic_base
> to mips_gic_base & make it global, in order to fit in with the naming
> expected by the standardised CPS accessor macros.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Cc: Marc Zyngier <marc.zyngier@arm.com>
> Cc: Ralf Baechle <ralf@linux-mips.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mips@linux-mips.org
> ---
>
> arch/mips/include/asm/mips-cps.h | 1 +
> arch/mips/include/asm/mips-gic.h | 293 +++++++++++++++++++++++++++++++++++++++
> drivers/irqchip/irq-mips-gic.c | 13 +-
> 3 files changed, 300 insertions(+), 7 deletions(-)
> create mode 100644 arch/mips/include/asm/mips-gic.h
>
> diff --git a/arch/mips/include/asm/mips-cps.h b/arch/mips/include/asm/mips-cps.h
> index 2dd737d803e1..bf02b5070a98 100644
> --- a/arch/mips/include/asm/mips-cps.h
> +++ b/arch/mips/include/asm/mips-cps.h
> @@ -107,6 +107,7 @@ static inline void clear_##unit##_##name(uint##sz##_t val) \
>
> #include <asm/mips-cm.h>
> #include <asm/mips-cpc.h>
> +#include <asm/mips-gic.h>
>
> /**
> * mips_cps_numclusters - return the number of clusters present in the system
> diff --git a/arch/mips/include/asm/mips-gic.h b/arch/mips/include/asm/mips-gic.h
> new file mode 100644
> index 000000000000..8cf4bdc1a059
> --- /dev/null
> +++ b/arch/mips/include/asm/mips-gic.h
> @@ -0,0 +1,293 @@
> +/*
> + * Copyright (C) 2017 Imagination Technologies
> + * Author: Paul Burton <paul.burton@imgtec.com>
> + *
> + * 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 the
> + * Free Software Foundation; either version 2 of the License, or (at your
> + * option) any later version.
> + */
> +
> +#ifndef __MIPS_ASM_MIPS_CPS_H__
> +# error Please include asm/mips-cps.h rather than asm/mips-gic.h
> +#endif
> +
> +#ifndef __MIPS_ASM_MIPS_GIC_H__
> +#define __MIPS_ASM_MIPS_GIC_H__
> +
> +#include <linux/bitops.h>
> +
> +/* The base address of the GIC registers */
> +extern void __iomem *mips_gic_base;
> +
> +/* Offsets from the GIC base address to various control blocks */
> +#define MIPS_GIC_SHARED_OFS 0x00000
> +#define MIPS_GIC_SHARED_SZ 0x08000
> +#define MIPS_GIC_LOCAL_OFS 0x08000
> +#define MIPS_GIC_LOCAL_SZ 0x04000
> +#define MIPS_GIC_REDIR_OFS 0x0c000
> +#define MIPS_GIC_REDIR_SZ 0x04000
> +#define MIPS_GIC_USER_OFS 0x10000
> +#define MIPS_GIC_USER_SZ 0x10000
> +
> +/* For read-only shared registers */
> +#define GIC_ACCESSOR_RO(sz, off, name) \
> + CPS_ACCESSOR_RO(gic, sz, MIPS_GIC_SHARED_OFS + off, name)
> +
> +/* For read-write shared registers */
> +#define GIC_ACCESSOR_RW(sz, off, name) \
> + CPS_ACCESSOR_RW(gic, sz, MIPS_GIC_SHARED_OFS + off, name)
> +
> +/* For read-only local registers */
> +#define GIC_VX_ACCESSOR_RO(sz, off, name) \
> + CPS_ACCESSOR_RO(gic, sz, MIPS_GIC_LOCAL_OFS + off, vl_##name) \
> + CPS_ACCESSOR_RO(gic, sz, MIPS_GIC_REDIR_OFS + off, vo_##name)
> +
> +/* For read-write local registers */
> +#define GIC_VX_ACCESSOR_RW(sz, off, name) \
> + CPS_ACCESSOR_RW(gic, sz, MIPS_GIC_LOCAL_OFS + off, vl_##name) \
> + CPS_ACCESSOR_RW(gic, sz, MIPS_GIC_REDIR_OFS + off, vo_##name)
> +
> +/* For read-only shared per-interrupt registers */
> +#define GIC_ACCESSOR_RO_INTR_REG(sz, off, stride, name) \
> +static inline void __iomem *addr_gic_##name(unsigned int intr) \
> +{ \
> + return mips_gic_base + (off) + (intr * (stride)); \
> +} \
> + \
> +static inline unsigned int read_gic_##name(unsigned int intr) \
> +{ \
> + BUILD_BUG_ON(sz != 32); \
> + return __raw_readl(addr_gic_##name(intr)); \
> +}
> +
> +/* For read-write shared per-interrupt registers */
> +#define GIC_ACCESSOR_RW_INTR_REG(sz, off, stride, name) \
> + GIC_ACCESSOR_RO_INTR_REG(sz, off, stride, name) \
> + \
> +static inline void write_gic_##name(unsigned int intr, \
> + unsigned int val) \
> +{ \
> + BUILD_BUG_ON(sz != 32); \
> + __raw_writel(val, addr_gic_##name(intr)); \
> +}
> +
> +/* For read-only local per-interrupt registers */
> +#define GIC_VX_ACCESSOR_RO_INTR_REG(sz, off, stride, name) \
> + GIC_ACCESSOR_RO_INTR_REG(sz, MIPS_GIC_LOCAL_OFS + off, \
> + stride, vl_##name) \
> + GIC_ACCESSOR_RO_INTR_REG(sz, MIPS_GIC_REDIR_OFS + off, \
> + stride, vo_##name)
> +
> +/* For read-write local per-interrupt registers */
> +#define GIC_VX_ACCESSOR_RW_INTR_REG(sz, off, stride, name) \
> + GIC_ACCESSOR_RW_INTR_REG(sz, MIPS_GIC_LOCAL_OFS + off, \
> + stride, vl_##name) \
> + GIC_ACCESSOR_RW_INTR_REG(sz, MIPS_GIC_REDIR_OFS + off, \
> + stride, vo_##name)
> +
> +/* For read-only shared bit-per-interrupt registers */
> +#define GIC_ACCESSOR_RO_INTR_BIT(off, name) \
> +static inline void __iomem *addr_gic_##name(void) \
> +{ \
> + return mips_gic_base + (off); \
> +} \
> + \
> +static inline unsigned int read_gic_##name(unsigned int intr) \
> +{ \
> + void __iomem *addr = addr_gic_##name(); \
> + unsigned int val; \
> + \
> + if (mips_cm_is64) { \
> + addr += (intr / 64) * sizeof(uint64_t); \
> + val = __raw_readq(addr) >> intr % 64; \
> + } else { \
> + addr += (intr / 32) * sizeof(uint32_t); \
> + val = __raw_readl(addr) >> intr % 32; \
> + } \
> + \
> + return val & 0x1; \
> +}
> +
> +/* For read-write shared bit-per-interrupt registers */
> +#define GIC_ACCESSOR_RW_INTR_BIT(off, name) \
> + GIC_ACCESSOR_RO_INTR_BIT(off, name) \
> + \
> +static inline void write_gic_##name(unsigned int intr) \
> +{ \
> + void __iomem *addr = addr_gic_##name(); \
> + \
> + if (mips_cm_is64) { \
Given that you now refer to this symbol, wouldn't it be best to include
asm/mips-cm.h here? It is probably included via some other path, but
it'd make this file standalone.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2017-08-18 11:10 UTC|newest]
Thread overview: 111+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-13 4:36 [PATCH 00/38] irqchip: mips-gic: Cleanup & optimisation Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 01/38] irqchip: mips-gic: SYNC after enabling GIC region Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 02/38] MIPS: GIC: Introduce asm/mips-gic.h with accessor functions Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-18 11:10 ` Marc Zyngier [this message]
2017-08-18 16:43 ` Paul Burton
2017-08-18 16:43 ` Paul Burton
2017-08-13 4:36 ` [PATCH 03/38] clocksource: mips-gic-timer: Use new GIC " Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 04/38] irqchip: mips-gic: Remove counter access functions Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 05/38] MIPS: CPS: Read GIC_VL_IDENT directly, not via irqchip driver Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 06/38] irqchip: mips-gic: Remove gic_read_local_vp_id() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 07/38] lib/iomap_copy.c: Add __ioread64_copy Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 08/38] irqchip: mips-gic: Simplify shared interrupt pending/mask reads Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 09/38] irqchip: mips-gic: Simplify gic_local_irq_domain_map() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 10/38] irqchip: mips-gic: Drop gic_(re)set_mask() functions Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 11/38] irqchip: mips-gic: Remove gic_set_polarity() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 12/38] irqchip: mips-gic: Remove gic_set_trigger() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 13/38] irqchip: mips-gic: Remove gic_set_dual_edge() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 14/38] irqchip: mips-gic: Remove gic_map_to_pin() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 15/38] irqchip: mips-gic: Remove gic_map_to_vpe() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 16/38] irqchip: mips-gic: Convert remaining shared reg access to new accessors Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 17/38] irqchip: mips-gic: Convert local int mask " Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 18/38] irqchip: mips-gic: Convert remaining local reg " Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 19/38] MIPS: GIC: Move GIC_LOCAL_INT_* to asm/mips-gic.h Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 20/38] irqchip: mips-gic: Remove GIC_CPU_INT* macros Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 21/38] irqchip: mips-gic: Move various definitions to the driver Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 22/38] MIPS: VDSO: Drop gic_get_usm_range() usage Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-18 11:38 ` Marc Zyngier
2017-08-18 16:47 ` Paul Burton
2017-08-18 16:47 ` Paul Burton
2017-08-18 16:52 ` Marc Zyngier
2017-08-13 4:36 ` [PATCH 23/38] irqchip: mips-gic: Remove gic_get_usm_range() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 24/38] irqchip: mips-gic: Remove __gic_irq_dispatch() forward declaration Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 25/38] irqchip: mips-gic: Remove gic_init() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 26/38] MIPS: Use mips_gic_present() in place of gic_present Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 27/38] irqchip: mips-gic: Remove gic_present Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 28/38] irqchip: mips-gic: Move gic_get_c0_*_int() to asm/mips-gic.h Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 29/38] MIPS: VDSO: Avoid use of linux/irqchip/mips-gic.h Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 30/38] MIPS: Remove unnecessary inclusions " Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 31/38] irqchip: mips-gic: Remove linux/irqchip/mips-gic.h Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 32/38] irqchip: mips-gic: Inline __gic_init() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 33/38] irqchip: mips-gic: Inline gic_basic_init() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 34/38] irqchip: mips-gic: Make pcpu_masks a per-cpu variable Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-18 15:37 ` Marc Zyngier
2017-08-18 17:02 ` Paul Burton
2017-08-18 17:02 ` Paul Burton
2017-08-18 17:18 ` Marc Zyngier
2017-08-13 4:36 ` [PATCH 35/38] irqchip: mips-gic: Use pcpu_masks to avoid reading GIC_SH_MASK* Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-18 15:44 ` Marc Zyngier
2017-08-18 17:11 ` Paul Burton
2017-08-18 17:11 ` Paul Burton
2017-08-18 17:25 ` Marc Zyngier
2017-08-18 21:02 ` [PATCH v2 " Paul Burton
2017-08-18 21:02 ` Paul Burton
2017-08-13 4:36 ` [PATCH 36/38] irqchip: mips-gic: Clean up mti,reserved-cpu-vectors handling Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 4:36 ` [PATCH 37/38] irqchip: mips-gic: Use cpumask_first_and() in gic_set_affinity() Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-13 9:08 ` Sergei Shtylyov
2017-08-14 16:18 ` Paul Burton
2017-08-14 16:18 ` Paul Burton
2017-08-14 16:48 ` Sergei Shtylyov
2017-08-18 21:04 ` [PATCH v2 " Paul Burton
2017-08-18 21:04 ` Paul Burton
2017-08-13 4:36 ` [PATCH 38/38] irqchip: mips-gic: Let the core set struct irq_common_data affinity Paul Burton
2017-08-13 4:36 ` Paul Burton
2017-08-15 10:13 ` [PATCH 00/38] irqchip: mips-gic: Cleanup & optimisation Marc Zyngier
2017-08-15 16:16 ` Paul Burton
2017-08-15 16:16 ` Paul Burton
2017-08-15 16:49 ` Marc Zyngier
2017-08-18 17:28 ` Marc Zyngier
2017-08-18 17:44 ` Paul Burton
2017-08-18 17:44 ` Paul Burton
2017-08-18 17:49 ` Marc Zyngier
2017-08-18 21:09 ` Paul Burton
2017-08-18 21:09 ` Paul Burton
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=b331ff4a-cdc6-49d1-96a5-f7536b3324f1@arm.com \
--to=marc.zyngier@arm.com \
--cc=jason@lakedaemon.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=paul.burton@imgtec.com \
--cc=ralf@linux-mips.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