From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S939289AbdAFGgJ (ORCPT ); Fri, 6 Jan 2017 01:36:09 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:56000 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752307AbdAFGgE (ORCPT ); Fri, 6 Jan 2017 01:36:04 -0500 DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org AB7ED61151 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=sboyd@codeaurora.org Date: Thu, 5 Jan 2017 22:36:02 -0800 From: Stephen Boyd To: Chris Packham Cc: linux-arm-kernel@lists.infradead.org, Rob Herring , Mark Rutland , Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Russell King , Chris Brand , Florian Fainelli , Geert Uytterhoeven , Lorenzo Pieralisi , Jayachandran C , Juri Lelli , Magnus Damm , Thierry Reding , Sudeep Holla , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv3 2/5] arm: mvebu: support for SMP on 98DX3336 SoC Message-ID: <20170106063602.GM17126@codeaurora.org> References: <20170105033641.6212-1-chris.packham@alliedtelesis.co.nz> <20170106041517.9589-1-chris.packham@alliedtelesis.co.nz> <20170106041517.9589-3-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170106041517.9589-3-chris.packham@alliedtelesis.co.nz> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/06, Chris Packham wrote: > diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c > index 46c742d3bd41..3c9ab9a008ad 100644 > --- a/arch/arm/mach-mvebu/platsmp.c > +++ b/arch/arm/mach-mvebu/platsmp.c > @@ -182,5 +182,48 @@ const struct smp_operations armada_xp_smp_ops __initconst = { > #endif > }; > > +static int mv98dx3236_boot_secondary(unsigned int cpu, struct task_struct *idle) > +{ > + int ret, hw_cpu; > + > + pr_info("Booting CPU %d\n", cpu); Doesn't the core already print something when bringing up CPUs? This message seems redundant. > + > + hw_cpu = cpu_logical_map(cpu); > + set_secondary_cpu_clock(hw_cpu); > + mv98dx3236_resume_set_cpu_boot_addr(hw_cpu, > + armada_xp_secondary_startup); > + > + /* > + * This is needed to wake up CPUs in the offline state after > + * using CPU hotplug. > + */ > + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > + > + /* > + * This is needed to take secondary CPUs out of reset on the > + * initial boot. > + */ > + ret = mvebu_cpu_reset_deassert(hw_cpu); > + if (ret) { > + pr_warn("unable to boot CPU: %d\n", ret); > + return ret; > + } > + > + return 0; > +} > + > +struct smp_operations mv98dx3236_smp_ops __initdata = { static const __initconst? > + .smp_init_cpus = armada_xp_smp_init_cpus, > + .smp_prepare_cpus = armada_xp_smp_prepare_cpus, > + .smp_boot_secondary = mv98dx3236_boot_secondary, > + .smp_secondary_init = armada_xp_secondary_init, > +#ifdef CONFIG_HOTPLUG_CPU > + .cpu_die = armada_xp_cpu_die, > + .cpu_kill = armada_xp_cpu_kill, > +#endif > +}; > + > CPU_METHOD_OF_DECLARE(armada_xp_smp, "marvell,armada-xp-smp", > &armada_xp_smp_ops); > +CPU_METHOD_OF_DECLARE(mv98dx3236_smp, "marvell,98dx3236-smp", > + &mv98dx3236_smp_ops); > diff --git a/arch/arm/mach-mvebu/pmsu-98dx3236.c b/arch/arm/mach-mvebu/pmsu-98dx3236.c > new file mode 100644 > index 000000000000..1052674dd439 > --- /dev/null > +++ b/arch/arm/mach-mvebu/pmsu-98dx3236.c > @@ -0,0 +1,52 @@ > +/** > + * CPU resume support for 98DX3236 internal CPU (a.k.a. MSYS). > + */ > + > +#define pr_fmt(fmt) "mv98dx3236-resume: " fmt > + > +#include > +#include > +#include > +#include > +#include "common.h" > + > +static void __iomem *mv98dx3236_resume_base; > +#define MV98DX3236_CPU_RESUME_CTRL_OFFSET 0x08 > +#define MV98DX3236_CPU_RESUME_ADDR_OFFSET 0x04 > + > +static const struct of_device_id of_mv98dx3236_resume_table[] = { > + {.compatible = "marvell,98dx3336-resume-ctrl",}, > + { /* end of list */ }, > +}; > + > +void mv98dx3236_resume_set_cpu_boot_addr(int hw_cpu, void *boot_addr) > +{ > + WARN_ON(hw_cpu != 1); > + > + writel(0, mv98dx3236_resume_base + MV98DX3236_CPU_RESUME_CTRL_OFFSET); > + writel(virt_to_phys(boot_addr), mv98dx3236_resume_base + > + MV98DX3236_CPU_RESUME_ADDR_OFFSET); > +} > + > +static int __init mv98dx3236_resume_init(void) > +{ > + struct device_node *np; > + void __iomem *base; > + > + np = of_find_matching_node(NULL, of_mv98dx3236_resume_table); > + if (!np) > + return 0; Is there any reason we can't just look for this node from the smp_ops and map it if it isn't mapped yet? Seems simpler than a whole new file and initcall. > + > + base = of_io_request_and_map(np, 0, of_node_full_name(np)); > + if (IS_ERR(base)) { > + pr_err("unable to map registers\n"); Doesn't of_io_request_and_map() spit out an error on failure already? > + of_node_put(np); This could be done before the if statement and then the duplicate statement deleted. > + return PTR_ERR(mv98dx3236_resume_base); Should be PTR_ERR(base)? > + } > + > + mv98dx3236_resume_base = base; > + of_node_put(np); > + return 0; > +} -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Boyd Subject: Re: [PATCHv3 2/5] arm: mvebu: support for SMP on 98DX3336 SoC Date: Thu, 5 Jan 2017 22:36:02 -0800 Message-ID: <20170106063602.GM17126@codeaurora.org> References: <20170105033641.6212-1-chris.packham@alliedtelesis.co.nz> <20170106041517.9589-1-chris.packham@alliedtelesis.co.nz> <20170106041517.9589-3-chris.packham@alliedtelesis.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20170106041517.9589-3-chris.packham-6g8wRflRTwXFdCa3tKVlE6U/zSkkHjvu@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Chris Packham Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Rob Herring , Mark Rutland , Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Russell King , Chris Brand , Florian Fainelli , Geert Uytterhoeven , Lorenzo Pieralisi , Jayachandran C , Juri Lelli , Magnus Damm , Thierry Reding , Sudeep Holla , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: devicetree@vger.kernel.org On 01/06, Chris Packham wrote: > diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c > index 46c742d3bd41..3c9ab9a008ad 100644 > --- a/arch/arm/mach-mvebu/platsmp.c > +++ b/arch/arm/mach-mvebu/platsmp.c > @@ -182,5 +182,48 @@ const struct smp_operations armada_xp_smp_ops __initconst = { > #endif > }; > > +static int mv98dx3236_boot_secondary(unsigned int cpu, struct task_struct *idle) > +{ > + int ret, hw_cpu; > + > + pr_info("Booting CPU %d\n", cpu); Doesn't the core already print something when bringing up CPUs? This message seems redundant. > + > + hw_cpu = cpu_logical_map(cpu); > + set_secondary_cpu_clock(hw_cpu); > + mv98dx3236_resume_set_cpu_boot_addr(hw_cpu, > + armada_xp_secondary_startup); > + > + /* > + * This is needed to wake up CPUs in the offline state after > + * using CPU hotplug. > + */ > + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > + > + /* > + * This is needed to take secondary CPUs out of reset on the > + * initial boot. > + */ > + ret = mvebu_cpu_reset_deassert(hw_cpu); > + if (ret) { > + pr_warn("unable to boot CPU: %d\n", ret); > + return ret; > + } > + > + return 0; > +} > + > +struct smp_operations mv98dx3236_smp_ops __initdata = { static const __initconst? > + .smp_init_cpus = armada_xp_smp_init_cpus, > + .smp_prepare_cpus = armada_xp_smp_prepare_cpus, > + .smp_boot_secondary = mv98dx3236_boot_secondary, > + .smp_secondary_init = armada_xp_secondary_init, > +#ifdef CONFIG_HOTPLUG_CPU > + .cpu_die = armada_xp_cpu_die, > + .cpu_kill = armada_xp_cpu_kill, > +#endif > +}; > + > CPU_METHOD_OF_DECLARE(armada_xp_smp, "marvell,armada-xp-smp", > &armada_xp_smp_ops); > +CPU_METHOD_OF_DECLARE(mv98dx3236_smp, "marvell,98dx3236-smp", > + &mv98dx3236_smp_ops); > diff --git a/arch/arm/mach-mvebu/pmsu-98dx3236.c b/arch/arm/mach-mvebu/pmsu-98dx3236.c > new file mode 100644 > index 000000000000..1052674dd439 > --- /dev/null > +++ b/arch/arm/mach-mvebu/pmsu-98dx3236.c > @@ -0,0 +1,52 @@ > +/** > + * CPU resume support for 98DX3236 internal CPU (a.k.a. MSYS). > + */ > + > +#define pr_fmt(fmt) "mv98dx3236-resume: " fmt > + > +#include > +#include > +#include > +#include > +#include "common.h" > + > +static void __iomem *mv98dx3236_resume_base; > +#define MV98DX3236_CPU_RESUME_CTRL_OFFSET 0x08 > +#define MV98DX3236_CPU_RESUME_ADDR_OFFSET 0x04 > + > +static const struct of_device_id of_mv98dx3236_resume_table[] = { > + {.compatible = "marvell,98dx3336-resume-ctrl",}, > + { /* end of list */ }, > +}; > + > +void mv98dx3236_resume_set_cpu_boot_addr(int hw_cpu, void *boot_addr) > +{ > + WARN_ON(hw_cpu != 1); > + > + writel(0, mv98dx3236_resume_base + MV98DX3236_CPU_RESUME_CTRL_OFFSET); > + writel(virt_to_phys(boot_addr), mv98dx3236_resume_base + > + MV98DX3236_CPU_RESUME_ADDR_OFFSET); > +} > + > +static int __init mv98dx3236_resume_init(void) > +{ > + struct device_node *np; > + void __iomem *base; > + > + np = of_find_matching_node(NULL, of_mv98dx3236_resume_table); > + if (!np) > + return 0; Is there any reason we can't just look for this node from the smp_ops and map it if it isn't mapped yet? Seems simpler than a whole new file and initcall. > + > + base = of_io_request_and_map(np, 0, of_node_full_name(np)); > + if (IS_ERR(base)) { > + pr_err("unable to map registers\n"); Doesn't of_io_request_and_map() spit out an error on failure already? > + of_node_put(np); This could be done before the if statement and then the duplicate statement deleted. > + return PTR_ERR(mv98dx3236_resume_base); Should be PTR_ERR(base)? > + } > + > + mv98dx3236_resume_base = base; > + of_node_put(np); > + return 0; > +} -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 From: sboyd@codeaurora.org (Stephen Boyd) Date: Thu, 5 Jan 2017 22:36:02 -0800 Subject: [PATCHv3 2/5] arm: mvebu: support for SMP on 98DX3336 SoC In-Reply-To: <20170106041517.9589-3-chris.packham@alliedtelesis.co.nz> References: <20170105033641.6212-1-chris.packham@alliedtelesis.co.nz> <20170106041517.9589-1-chris.packham@alliedtelesis.co.nz> <20170106041517.9589-3-chris.packham@alliedtelesis.co.nz> Message-ID: <20170106063602.GM17126@codeaurora.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 01/06, Chris Packham wrote: > diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c > index 46c742d3bd41..3c9ab9a008ad 100644 > --- a/arch/arm/mach-mvebu/platsmp.c > +++ b/arch/arm/mach-mvebu/platsmp.c > @@ -182,5 +182,48 @@ const struct smp_operations armada_xp_smp_ops __initconst = { > #endif > }; > > +static int mv98dx3236_boot_secondary(unsigned int cpu, struct task_struct *idle) > +{ > + int ret, hw_cpu; > + > + pr_info("Booting CPU %d\n", cpu); Doesn't the core already print something when bringing up CPUs? This message seems redundant. > + > + hw_cpu = cpu_logical_map(cpu); > + set_secondary_cpu_clock(hw_cpu); > + mv98dx3236_resume_set_cpu_boot_addr(hw_cpu, > + armada_xp_secondary_startup); > + > + /* > + * This is needed to wake up CPUs in the offline state after > + * using CPU hotplug. > + */ > + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > + > + /* > + * This is needed to take secondary CPUs out of reset on the > + * initial boot. > + */ > + ret = mvebu_cpu_reset_deassert(hw_cpu); > + if (ret) { > + pr_warn("unable to boot CPU: %d\n", ret); > + return ret; > + } > + > + return 0; > +} > + > +struct smp_operations mv98dx3236_smp_ops __initdata = { static const __initconst? > + .smp_init_cpus = armada_xp_smp_init_cpus, > + .smp_prepare_cpus = armada_xp_smp_prepare_cpus, > + .smp_boot_secondary = mv98dx3236_boot_secondary, > + .smp_secondary_init = armada_xp_secondary_init, > +#ifdef CONFIG_HOTPLUG_CPU > + .cpu_die = armada_xp_cpu_die, > + .cpu_kill = armada_xp_cpu_kill, > +#endif > +}; > + > CPU_METHOD_OF_DECLARE(armada_xp_smp, "marvell,armada-xp-smp", > &armada_xp_smp_ops); > +CPU_METHOD_OF_DECLARE(mv98dx3236_smp, "marvell,98dx3236-smp", > + &mv98dx3236_smp_ops); > diff --git a/arch/arm/mach-mvebu/pmsu-98dx3236.c b/arch/arm/mach-mvebu/pmsu-98dx3236.c > new file mode 100644 > index 000000000000..1052674dd439 > --- /dev/null > +++ b/arch/arm/mach-mvebu/pmsu-98dx3236.c > @@ -0,0 +1,52 @@ > +/** > + * CPU resume support for 98DX3236 internal CPU (a.k.a. MSYS). > + */ > + > +#define pr_fmt(fmt) "mv98dx3236-resume: " fmt > + > +#include > +#include > +#include > +#include > +#include "common.h" > + > +static void __iomem *mv98dx3236_resume_base; > +#define MV98DX3236_CPU_RESUME_CTRL_OFFSET 0x08 > +#define MV98DX3236_CPU_RESUME_ADDR_OFFSET 0x04 > + > +static const struct of_device_id of_mv98dx3236_resume_table[] = { > + {.compatible = "marvell,98dx3336-resume-ctrl",}, > + { /* end of list */ }, > +}; > + > +void mv98dx3236_resume_set_cpu_boot_addr(int hw_cpu, void *boot_addr) > +{ > + WARN_ON(hw_cpu != 1); > + > + writel(0, mv98dx3236_resume_base + MV98DX3236_CPU_RESUME_CTRL_OFFSET); > + writel(virt_to_phys(boot_addr), mv98dx3236_resume_base + > + MV98DX3236_CPU_RESUME_ADDR_OFFSET); > +} > + > +static int __init mv98dx3236_resume_init(void) > +{ > + struct device_node *np; > + void __iomem *base; > + > + np = of_find_matching_node(NULL, of_mv98dx3236_resume_table); > + if (!np) > + return 0; Is there any reason we can't just look for this node from the smp_ops and map it if it isn't mapped yet? Seems simpler than a whole new file and initcall. > + > + base = of_io_request_and_map(np, 0, of_node_full_name(np)); > + if (IS_ERR(base)) { > + pr_err("unable to map registers\n"); Doesn't of_io_request_and_map() spit out an error on failure already? > + of_node_put(np); This could be done before the if statement and then the duplicate statement deleted. > + return PTR_ERR(mv98dx3236_resume_base); Should be PTR_ERR(base)? > + } > + > + mv98dx3236_resume_base = base; > + of_node_put(np); > + return 0; > +} -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project