From: Markos Chandras <markos.chandras@imgtec.com> To: <linux-mips@linux-mips.org> Cc: <alex@alex-smith.me.uk>, Alex Smith <alex.smith@imgtec.com>, "Thomas Gleixner" <tglx@linutronix.de>, Jason Cooper <jason@lakedaemon.net>, "Marc Zyngier" <marc.zyngier@arm.com>, <linux-kernel@vger.kernel.org>, "Markos Chandras" <markos.chandras@imgtec.com> Subject: [PATCH 2/3] irqchip: irq-mips-gic: Provide function to map GIC user section Date: Mon, 28 Sep 2015 11:11:57 +0100 [thread overview] Message-ID: <1443435117-17144-1-git-send-email-markos.chandras@imgtec.com> (raw) In-Reply-To: <1443434629-14325-1-git-send-email-markos.chandras@imgtec.com> From: Alex Smith <alex.smith@imgtec.com> The GIC provides a "user-mode visible" section containing a mirror of the counter registers which can be mapped into user memory. This will be used by the VDSO time function implementations, so provide a function to map it in. When the GIC is not enabled in Kconfig a dummy inline version of this function is provided, along with "#define gic_present 0", so that we don't have to litter the VDSO code with ifdefs. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Cooper <jason@lakedaemon.net> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: linux-kernel@vger.kernel.org Signed-off-by: Alex Smith <alex.smith@imgtec.com> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> --- drivers/irqchip/irq-mips-gic.c | 27 +++++++++++++++++++++------ include/linux/irqchip/mips-gic.h | 24 ++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index af2f16bb8a94..c995b199ca32 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -13,6 +13,7 @@ #include <linux/irq.h> #include <linux/irqchip.h> #include <linux/irqchip/mips-gic.h> +#include <linux/mm.h> #include <linux/of_address.h> #include <linux/sched.h> #include <linux/smp.h> @@ -29,6 +30,7 @@ struct gic_pcpu_mask { DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); }; +static unsigned long gic_base_addr; static void __iomem *gic_base; static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; static DEFINE_SPINLOCK(gic_lock); @@ -301,6 +303,19 @@ int gic_get_c0_fdc_int(void) GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC)); } +int gic_map_user_section(struct vm_area_struct *vma, unsigned long base, + unsigned long size) +{ + unsigned long pfn; + + BUG_ON(!gic_present); + BUG_ON(size > USM_VISIBLE_SECTION_SIZE); + + pfn = (gic_base_addr + USM_VISIBLE_SECTION_OFS) >> PAGE_SHIFT; + return io_remap_pfn_range(vma, base, pfn, size, + pgprot_noncached(PAGE_READONLY)); +} + static void gic_handle_shared_int(bool chained) { unsigned int i, intr, virq, gic_reg_step = mips_cm_is64 ? 8 : 4; @@ -783,14 +798,15 @@ static const struct irq_domain_ops gic_irq_domain_ops = { .xlate = gic_irq_domain_xlate, }; -static void __init __gic_init(unsigned long gic_base_addr, - unsigned long gic_addrspace_size, +static void __init __gic_init(unsigned long base_addr, + unsigned long addrspace_size, unsigned int cpu_vec, unsigned int irqbase, struct device_node *node) { unsigned int gicconfig; - gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size); + gic_base_addr = base_addr; + gic_base = ioremap_nocache(base_addr, addrspace_size); gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> @@ -847,11 +863,10 @@ static void __init __gic_init(unsigned long gic_base_addr, gic_ipi_init(); } -void __init gic_init(unsigned long gic_base_addr, - unsigned long gic_addrspace_size, +void __init gic_init(unsigned long base_addr, unsigned long addrspace_size, unsigned int cpu_vec, unsigned int irqbase) { - __gic_init(gic_base_addr, gic_addrspace_size, cpu_vec, irqbase, NULL); + __gic_init(base_addr, addrspace_size, cpu_vec, irqbase, NULL); } static int __init gic_of_init(struct device_node *node, diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h index 4e6861605050..68f2e9539204 100644 --- a/include/linux/irqchip/mips-gic.h +++ b/include/linux/irqchip/mips-gic.h @@ -245,10 +245,14 @@ #define GIC_SHARED_TO_HWIRQ(x) (GIC_SHARED_HWIRQ_BASE + (x)) #define GIC_HWIRQ_TO_SHARED(x) ((x) - GIC_SHARED_HWIRQ_BASE) +struct vm_area_struct; + +#ifdef CONFIG_MIPS_GIC + extern unsigned int gic_present; -extern void gic_init(unsigned long gic_base_addr, - unsigned long gic_addrspace_size, unsigned int cpu_vec, +extern void gic_init(unsigned long base_addr, + unsigned long addrspace_size, unsigned int cpu_vec, unsigned int irqbase); extern void gic_clocksource_init(unsigned int); extern cycle_t gic_read_count(void); @@ -264,4 +268,20 @@ extern unsigned int plat_ipi_resched_int_xlate(unsigned int); extern int gic_get_c0_compare_int(void); extern int gic_get_c0_perfcount_int(void); extern int gic_get_c0_fdc_int(void); +extern int gic_map_user_section(struct vm_area_struct *vma, unsigned long base, + unsigned long size); + +#else /* CONFIG_MIPS_GIC */ + +#define gic_present 0 + +static inline int gic_map_user_section(struct vm_area_struct *vma, + unsigned long base, unsigned long size) +{ + /* Shouldn't be called. */ + return -1; +} + +#endif /* CONFIG_MIPS_GIC */ + #endif /* __LINUX_IRQCHIP_MIPS_GIC_H */ -- 2.5.3
WARNING: multiple messages have this Message-ID (diff)
From: Markos Chandras <markos.chandras@imgtec.com> To: linux-mips@linux-mips.org Cc: alex@alex-smith.me.uk, Alex Smith <alex.smith@imgtec.com>, Thomas Gleixner <tglx@linutronix.de>, Jason Cooper <jason@lakedaemon.net>, Marc Zyngier <marc.zyngier@arm.com>, linux-kernel@vger.kernel.org, Markos Chandras <markos.chandras@imgtec.com> Subject: [PATCH 2/3] irqchip: irq-mips-gic: Provide function to map GIC user section Date: Mon, 28 Sep 2015 11:11:57 +0100 [thread overview] Message-ID: <1443435117-17144-1-git-send-email-markos.chandras@imgtec.com> (raw) Message-ID: <20150928101157.xQvaZ1bI0IJ2yXkf5fnEZJ4s-pOcCsS_12E_KsEu3Qc@z> (raw) In-Reply-To: <1443434629-14325-1-git-send-email-markos.chandras@imgtec.com> From: Alex Smith <alex.smith@imgtec.com> The GIC provides a "user-mode visible" section containing a mirror of the counter registers which can be mapped into user memory. This will be used by the VDSO time function implementations, so provide a function to map it in. When the GIC is not enabled in Kconfig a dummy inline version of this function is provided, along with "#define gic_present 0", so that we don't have to litter the VDSO code with ifdefs. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jason Cooper <jason@lakedaemon.net> Cc: Marc Zyngier <marc.zyngier@arm.com> Cc: linux-kernel@vger.kernel.org Signed-off-by: Alex Smith <alex.smith@imgtec.com> Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> --- drivers/irqchip/irq-mips-gic.c | 27 +++++++++++++++++++++------ include/linux/irqchip/mips-gic.h | 24 ++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index af2f16bb8a94..c995b199ca32 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c @@ -13,6 +13,7 @@ #include <linux/irq.h> #include <linux/irqchip.h> #include <linux/irqchip/mips-gic.h> +#include <linux/mm.h> #include <linux/of_address.h> #include <linux/sched.h> #include <linux/smp.h> @@ -29,6 +30,7 @@ struct gic_pcpu_mask { DECLARE_BITMAP(pcpu_mask, GIC_MAX_INTRS); }; +static unsigned long gic_base_addr; static void __iomem *gic_base; static struct gic_pcpu_mask pcpu_masks[NR_CPUS]; static DEFINE_SPINLOCK(gic_lock); @@ -301,6 +303,19 @@ int gic_get_c0_fdc_int(void) GIC_LOCAL_TO_HWIRQ(GIC_LOCAL_INT_FDC)); } +int gic_map_user_section(struct vm_area_struct *vma, unsigned long base, + unsigned long size) +{ + unsigned long pfn; + + BUG_ON(!gic_present); + BUG_ON(size > USM_VISIBLE_SECTION_SIZE); + + pfn = (gic_base_addr + USM_VISIBLE_SECTION_OFS) >> PAGE_SHIFT; + return io_remap_pfn_range(vma, base, pfn, size, + pgprot_noncached(PAGE_READONLY)); +} + static void gic_handle_shared_int(bool chained) { unsigned int i, intr, virq, gic_reg_step = mips_cm_is64 ? 8 : 4; @@ -783,14 +798,15 @@ static const struct irq_domain_ops gic_irq_domain_ops = { .xlate = gic_irq_domain_xlate, }; -static void __init __gic_init(unsigned long gic_base_addr, - unsigned long gic_addrspace_size, +static void __init __gic_init(unsigned long base_addr, + unsigned long addrspace_size, unsigned int cpu_vec, unsigned int irqbase, struct device_node *node) { unsigned int gicconfig; - gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size); + gic_base_addr = base_addr; + gic_base = ioremap_nocache(base_addr, addrspace_size); gicconfig = gic_read(GIC_REG(SHARED, GIC_SH_CONFIG)); gic_shared_intrs = (gicconfig & GIC_SH_CONFIG_NUMINTRS_MSK) >> @@ -847,11 +863,10 @@ static void __init __gic_init(unsigned long gic_base_addr, gic_ipi_init(); } -void __init gic_init(unsigned long gic_base_addr, - unsigned long gic_addrspace_size, +void __init gic_init(unsigned long base_addr, unsigned long addrspace_size, unsigned int cpu_vec, unsigned int irqbase) { - __gic_init(gic_base_addr, gic_addrspace_size, cpu_vec, irqbase, NULL); + __gic_init(base_addr, addrspace_size, cpu_vec, irqbase, NULL); } static int __init gic_of_init(struct device_node *node, diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h index 4e6861605050..68f2e9539204 100644 --- a/include/linux/irqchip/mips-gic.h +++ b/include/linux/irqchip/mips-gic.h @@ -245,10 +245,14 @@ #define GIC_SHARED_TO_HWIRQ(x) (GIC_SHARED_HWIRQ_BASE + (x)) #define GIC_HWIRQ_TO_SHARED(x) ((x) - GIC_SHARED_HWIRQ_BASE) +struct vm_area_struct; + +#ifdef CONFIG_MIPS_GIC + extern unsigned int gic_present; -extern void gic_init(unsigned long gic_base_addr, - unsigned long gic_addrspace_size, unsigned int cpu_vec, +extern void gic_init(unsigned long base_addr, + unsigned long addrspace_size, unsigned int cpu_vec, unsigned int irqbase); extern void gic_clocksource_init(unsigned int); extern cycle_t gic_read_count(void); @@ -264,4 +268,20 @@ extern unsigned int plat_ipi_resched_int_xlate(unsigned int); extern int gic_get_c0_compare_int(void); extern int gic_get_c0_perfcount_int(void); extern int gic_get_c0_fdc_int(void); +extern int gic_map_user_section(struct vm_area_struct *vma, unsigned long base, + unsigned long size); + +#else /* CONFIG_MIPS_GIC */ + +#define gic_present 0 + +static inline int gic_map_user_section(struct vm_area_struct *vma, + unsigned long base, unsigned long size) +{ + /* Shouldn't be called. */ + return -1; +} + +#endif /* CONFIG_MIPS_GIC */ + #endif /* __LINUX_IRQCHIP_MIPS_GIC_H */ -- 2.5.3
next prev parent reply other threads:[~2015-09-28 10:12 UTC|newest] Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-09-28 10:03 [PATCH 0/3] MIPS VDSO support Markos Chandras 2015-09-28 10:03 ` Markos Chandras 2015-09-28 10:10 ` [PATCH 1/3] MIPS: Initial implementation of a VDSO Markos Chandras 2015-09-28 10:10 ` Markos Chandras 2015-09-28 10:54 ` Alex Smith 2015-09-28 13:07 ` Matthew Fortune 2015-09-28 13:07 ` Matthew Fortune 2015-11-20 18:15 ` Maciej W. Rozycki 2015-10-09 8:05 ` [PATCH v2 " Markos Chandras 2015-10-09 8:05 ` Markos Chandras 2015-10-21 8:54 ` [PATCH v3 " Markos Chandras 2015-10-21 8:54 ` Markos Chandras 2015-09-28 10:11 ` Markos Chandras [this message] 2015-09-28 10:11 ` [PATCH 2/3] irqchip: irq-mips-gic: Provide function to map GIC user section Markos Chandras 2015-09-28 10:55 ` Marc Zyngier 2015-09-28 14:16 ` Qais Yousef 2015-09-28 14:16 ` Qais Yousef 2015-09-28 15:03 ` Marc Zyngier 2015-10-05 8:22 ` Markos Chandras 2015-10-05 8:22 ` Markos Chandras 2015-10-12 9:40 ` [PATCH v2 " Markos Chandras 2015-10-12 9:40 ` Markos Chandras 2015-10-12 9:51 ` Marc Zyngier 2015-10-12 10:16 ` Thomas Gleixner 2015-10-15 9:37 ` Qais Yousef 2015-10-15 9:37 ` Qais Yousef 2015-10-15 10:18 ` Thomas Gleixner 2015-09-28 10:12 ` [PATCH 3/3] MIPS: VDSO: Add implementations of gettimeofday() and clock_gettime() Markos Chandras 2015-09-28 10:12 ` Markos Chandras 2015-09-28 13:15 ` kbuild test robot 2015-09-28 13:15 ` kbuild test robot 2015-10-12 10:24 ` [PATCH v2 " Markos Chandras 2015-10-12 10:24 ` Markos Chandras 2015-10-21 8:57 ` [PATCH v3 " Markos Chandras 2015-10-21 8:57 ` Markos Chandras 2015-10-23 1:41 ` [v3, " Leonid Yegoshin 2015-10-23 1:41 ` Leonid Yegoshin 2015-10-27 14:47 ` Ralf Baechle 2015-10-27 20:46 ` Leonid Yegoshin 2015-10-27 20:46 ` Leonid Yegoshin 2015-10-27 21:02 ` David Daney 2015-10-27 21:15 ` Leonid Yegoshin 2015-10-27 21:15 ` Leonid Yegoshin 2015-10-27 21:44 ` David Daney 2015-10-27 21:49 ` Leonid Yegoshin 2015-10-27 21:49 ` Leonid Yegoshin 2015-10-28 10:20 ` Alex Smith 2015-10-28 18:21 ` Leonid Yegoshin 2015-10-28 18:21 ` Leonid Yegoshin 2015-10-28 18:30 ` Alex Smith 2015-10-28 18:57 ` Leonid Yegoshin 2015-10-28 18:57 ` Leonid Yegoshin 2015-10-28 19:04 ` Alex Smith 2015-10-28 19:28 ` Leonid Yegoshin 2015-10-28 19:28 ` Leonid Yegoshin 2015-10-28 19:55 ` Alex Smith 2015-10-28 20:15 ` Leonid Yegoshin 2015-10-28 20:15 ` Leonid Yegoshin 2016-01-25 22:36 ` [PATCH v3 " Hauke Mehrtens
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=1443435117-17144-1-git-send-email-markos.chandras@imgtec.com \ --to=markos.chandras@imgtec.com \ --cc=alex.smith@imgtec.com \ --cc=alex@alex-smith.me.uk \ --cc=jason@lakedaemon.net \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mips@linux-mips.org \ --cc=marc.zyngier@arm.com \ --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: linkBe 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.