From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752776AbeDPVqb (ORCPT ); Mon, 16 Apr 2018 17:46:31 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:34808 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751110AbeDPVq2 (ORCPT ); Mon, 16 Apr 2018 17:46:28 -0400 X-Google-Smtp-Source: AIpwx497iBfAXZIxXjq41aU7THd9yXv2Ky1Hd3S1nuQ10yHJYbU7wP6MV3lW2adD4K5kx2hm8inCJA== Subject: Re: [RFC 3/3] arm: shmobile: Add the RZ/N1D SMP enabler driver. To: Michel Pollet , linux-renesas-soc@vger.kernel.org, Simon Horman Cc: phil.edworthy@renesas.com, buserror+upstream@gmail.com, Rob Herring , Mark Rutland , Magnus Damm , Russell King , Chen-Yu Tsai , Martin Blumenstingl , =?UTF-8?Q?Andreas_F=c3=a4rber?= , Andy Gross , Carlo Caione , Rajendra Nayak , Frank Rowand , Juri Lelli , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <1523871304-48517-1-git-send-email-michel.pollet@bp.renesas.com> <1523871304-48517-5-git-send-email-michel.pollet@bp.renesas.com> From: Florian Fainelli Openpgp: preference=signencrypt Autocrypt: addr=f.fainelli@gmail.com; prefer-encrypt=mutual; keydata= xsDiBEjPuBIRBACW9MxSJU9fvEOCTnRNqG/13rAGsj+vJqontvoDSNxRgmafP8d3nesnqPyR xGlkaOSDuu09rxuW+69Y2f1TzjFuGpBk4ysWOR85O2Nx8AJ6fYGCoeTbovrNlGT1M9obSFGQ X3IzRnWoqlfudjTO5TKoqkbOgpYqIo5n1QbEjCCwCwCg3DOH/4ug2AUUlcIT9/l3pGvoRJ0E AICDzi3l7pmC5IWn2n1mvP5247urtHFs/uusE827DDj3K8Upn2vYiOFMBhGsxAk6YKV6IP0d ZdWX6fqkJJlu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UfCcZwmLrU +eOTPzaF6drw6ayewEi5yzPg3TAT6FV3oBsNg3xlwU0gPK3v6gYPX5w9+ovPZ1/qqNfOrbsE FRuiSVsZQ5s3AAMFD/9XjlnnVDh9GX/r/6hjmr4U9tEsM+VQXaVXqZuHKaSmojOLUCP/YVQo 7IiYaNssCS4FCPe4yrL4FJJfJAsbeyDykMN7wAnBcOkbZ9BPJPNCbqU6dowLOiy8AuTYQ48m vIyQ4Ijnb6GTrtxIUDQeOBNuQC/gyyx3nbL/lVlHbxr4tb6YkhkO6shjXhQh7nQb33FjGO4P WU11Nr9i/qoV8QCo12MQEo244RRA6VMud06y/E449rWZFSTwGqb0FS0seTcYNvxt8PB2izX+ HZA8SL54j479ubxhfuoTu5nXdtFYFj5Lj5x34LKPx7MpgAmj0H7SDhpFWF2FzcC1bjiW9mjW HaKaX23Awt97AqQZXegbfkJwX2Y53ufq8Np3e1542lh3/mpiGSilCsaTahEGrHK+lIusl6mz Joil+u3k01ofvJMK0ZdzGUZ/aPMZ16LofjFA+MNxWrZFrkYmiGdv+LG45zSlZyIvzSiG2lKy kuVag+IijCIom78P9jRtB1q1Q5lwZp2TLAJlz92DmFwBg1hyFzwDADjZ2nrDxKUiybXIgZp9 aU2d++ptEGCVJOfEW4qpWCCLPbOT7XBr+g/4H3qWbs3j/cDDq7LuVYIe+wchy/iXEJaQVeTC y5arMQorqTFWlEOgRA8OP47L9knl9i4xuR0euV6DChDrguup2aJVU8JPBBgRAgAPAhsMBQJU X9LxBQkeXB3fAAoJEGFXmRW1Y3YOj4UAn3nrFLPZekMeqX5aD/aq/dsbXSfyAKC45Go0YyxV HGuUuzv+GKZ6nsysJw== Message-ID: <9f33a1d2-3c55-2485-a1f2-909def69e5b0@gmail.com> Date: Mon, 16 Apr 2018 14:46:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1523871304-48517-5-git-send-email-michel.pollet@bp.renesas.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michel, On 04/16/2018 02:34 AM, Michel Pollet wrote: > The Renesas RZ/N1D second CA7 is parked in a ROM pen at boot time, it > requires a special enable method to get it started at boot time. > > Signed-off-by: Michel Pollet Some few comments below. This patch should probably be re-ordered in your patch series, I would expect you to have this become patch 2 and have patch 2 be patch 3 (first you add infrastructure for using something, then you make use of it). > +static int rzn1_smp_boot_secondary(unsigned int cpu, struct task_struct *idle) > +{ > + if (!cpu_bootaddr) > + return -ENODEV; > + > + spin_lock(&cpu_lock); > + > + writel(virt_to_phys(secondary_startup), cpu_bootaddr); Consider using __pa_symbol() instead of virt_to_phys() since secondary_startup is part of the kernel's linear memory map. > + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > + > + spin_unlock(&cpu_lock); > + > + return 0; > +} > + > +static void __init rzn1_smp_prepare_cpus(unsigned int max_cpus) > +{ > + struct device_node *dn; > + int ret; > + u32 bootaddr; > + > + dn = of_get_cpu_node(1, NULL); > + if (!dn) { > + pr_err("CPU#1: missing device tree node\n"); > + return; > + } > + /* > + * Determine the address from which the CPU is polling. > + */ > + ret = of_property_read_u32(dn, "cpu-release-addr", &bootaddr); > + if (ret) > + pr_err("CPU#1: invalid cpu-release-addr property\n"); > + > + of_node_put(dn); > + /* The bootloader *does* change this property */ This comment should probably be moved above the function that fetches "cpu-release-addr" > + pr_info("CPU#1: cpu-release-addr %08x\n", (u32)bootaddr); > + > + if (!bootaddr) > + return; Would not you want to show a message here to help catch such conditions > + > + cpu_bootaddr = ioremap(bootaddr, sizeof(bootaddr)); Relying on ioremap() to reject values that might be outside of the allowed range may be a little fragile, but I can't suggest any better alternative. > + if (!cpu_bootaddr) > + pr_err("CPU#1: cpu-release-addr map failed\n"); > +} > + > +static const struct smp_operations rzn1_smp_ops __initconst = { > + .smp_prepare_cpus = rzn1_smp_prepare_cpus, > + .smp_boot_secondary = rzn1_smp_boot_secondary, > +}; > +CPU_METHOD_OF_DECLARE(rzn1_smp, "renesas,r9a06g032-smp", &rzn1_smp_ops); > -- Florian From mboxrd@z Thu Jan 1 00:00:00 1970 From: f.fainelli@gmail.com (Florian Fainelli) Date: Mon, 16 Apr 2018 14:46:16 -0700 Subject: [RFC 3/3] arm: shmobile: Add the RZ/N1D SMP enabler driver. In-Reply-To: <1523871304-48517-5-git-send-email-michel.pollet@bp.renesas.com> References: <1523871304-48517-1-git-send-email-michel.pollet@bp.renesas.com> <1523871304-48517-5-git-send-email-michel.pollet@bp.renesas.com> Message-ID: <9f33a1d2-3c55-2485-a1f2-909def69e5b0@gmail.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Michel, On 04/16/2018 02:34 AM, Michel Pollet wrote: > The Renesas RZ/N1D second CA7 is parked in a ROM pen at boot time, it > requires a special enable method to get it started at boot time. > > Signed-off-by: Michel Pollet Some few comments below. This patch should probably be re-ordered in your patch series, I would expect you to have this become patch 2 and have patch 2 be patch 3 (first you add infrastructure for using something, then you make use of it). > +static int rzn1_smp_boot_secondary(unsigned int cpu, struct task_struct *idle) > +{ > + if (!cpu_bootaddr) > + return -ENODEV; > + > + spin_lock(&cpu_lock); > + > + writel(virt_to_phys(secondary_startup), cpu_bootaddr); Consider using __pa_symbol() instead of virt_to_phys() since secondary_startup is part of the kernel's linear memory map. > + arch_send_wakeup_ipi_mask(cpumask_of(cpu)); > + > + spin_unlock(&cpu_lock); > + > + return 0; > +} > + > +static void __init rzn1_smp_prepare_cpus(unsigned int max_cpus) > +{ > + struct device_node *dn; > + int ret; > + u32 bootaddr; > + > + dn = of_get_cpu_node(1, NULL); > + if (!dn) { > + pr_err("CPU#1: missing device tree node\n"); > + return; > + } > + /* > + * Determine the address from which the CPU is polling. > + */ > + ret = of_property_read_u32(dn, "cpu-release-addr", &bootaddr); > + if (ret) > + pr_err("CPU#1: invalid cpu-release-addr property\n"); > + > + of_node_put(dn); > + /* The bootloader *does* change this property */ This comment should probably be moved above the function that fetches "cpu-release-addr" > + pr_info("CPU#1: cpu-release-addr %08x\n", (u32)bootaddr); > + > + if (!bootaddr) > + return; Would not you want to show a message here to help catch such conditions > + > + cpu_bootaddr = ioremap(bootaddr, sizeof(bootaddr)); Relying on ioremap() to reject values that might be outside of the allowed range may be a little fragile, but I can't suggest any better alternative. > + if (!cpu_bootaddr) > + pr_err("CPU#1: cpu-release-addr map failed\n"); > +} > + > +static const struct smp_operations rzn1_smp_ops __initconst = { > + .smp_prepare_cpus = rzn1_smp_prepare_cpus, > + .smp_boot_secondary = rzn1_smp_boot_secondary, > +}; > +CPU_METHOD_OF_DECLARE(rzn1_smp, "renesas,r9a06g032-smp", &rzn1_smp_ops); > -- Florian