Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753800AbcKQCTH (ORCPT ); Wed, 16 Nov 2016 21:19:07 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:58336 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752375AbcKQCTE (ORCPT ); Wed, 16 Nov 2016 21:19:04 -0500 X-AuditID: b6c32a23-f79b16d0000019cb-e1-582d139279d6 Subject: Re: [PATCH 01/16] ARM: scu: Provide support for parsing SCU device node to enable SCU To: Russell King - ARM Linux Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, horms@verge.net.au, magnus.damm@gmail.com, geert+renesas@glider.be, vireshk@kernel.org, shiraz.linux.kernel@gmail.com, krzk@kernel.org, thomas.ab@samsung.com, Jisheng Zhang , Dinh Nguyen , Patrice Chotard , Linus Walleij , Liviu Dudau , Ray Jui , Stephen Warren , Heiko Stuebner , Shawn Guo , Michal Simek , Wei Xu , Andrew Lunn , Jun Nie , "cpgs ." From: "pankaj.dubey" Message-id: <8b3f2f77-d883-519e-db65-a0bfca254c22@samsung.com> Date: Thu, 17 Nov 2016 07:52:03 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-version: 1.0 In-reply-to: <20161114134813.GK1041@n2100.armlinux.org.uk> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Ta0xbZRjH8/acnrbbqsdye61R63F+GLMdp7bwsow5IzHHTB2Jt6ox3bGc USZtsaclbgkTIcEJRqGwC11hsICbHcug3IY4pXUDiUFkdDUzY6NrFy5aXFanhm1q27MlfPs9 z///5LkkjxRT1EmU0lKrg7Nb2TKKWIMPfr/hCbUrTW3I8QWz0dRsAEN3XWMStBjYgLw3uzHU esQF0H/XfhOjmoFbAC2Pj+CoMxqWoKmpHglqvnNchHyRkBjN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d5064e95 X-Msg-Generator: CA X-Sender-IP: 182.195.34.25 X-Local-Sender: =?UTF-8?B?7YyQ7Lm07KaIG1NTSVItVHVybiBLZXkgU29sdXRpb25zGw==?= =?UTF-8?B?7IK87ISx7KCE7J6QGy4vQ2hpZWYgRW5naW5lZXI=?= X-Global-Sender: =?UTF-8?B?UEFOS0FKIEtVTUFSIERVQkVZG1NTSVItVHVybiBLZXkgU29s?= =?UTF-8?B?dXRpb25zG1NhbXN1bmcgRWxlY3Ryb25pY3MbLi9DaGllZiBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG1NXQUhRG0MxMElEMDdJRDAxMDk5Nw==?= CMS-TYPE: 104P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20161114134843epcas2p2d52a44bae703d52a9e9646e73ed5b41d X-RootMTR: 20161114134843epcas2p2d52a44bae703d52a9e9646e73ed5b41d References: <1479099731-28108-1-git-send-email-pankaj.dubey@samsung.com> <1479099731-28108-2-git-send-email-pankaj.dubey@samsung.com> <20161114134813.GK1041@n2100.armlinux.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4301 Lines: 133 Hi Russell, On Monday 14 November 2016 07:18 PM, Russell King - ARM Linux wrote: > This should be sent _to_ me because it's touching generic ARM code. > Thanks. > Sorry for this. I had included your email in CC for this patch, but looks like my email client had some issue and this patch could not reach to your mailbox. I will take care in future. > On Mon, Nov 14, 2016 at 10:31:56AM +0530, Pankaj Dubey wrote: >> Many platforms are duplicating code for enabling SCU, lets add >> common code to enable SCU by parsing SCU device node so the duplication >> in each platform can be avoided. >> >> CC: Krzysztof Kozlowski >> CC: Jisheng Zhang >> CC: Russell King >> CC: Dinh Nguyen >> CC: Patrice Chotard >> CC: Linus Walleij >> CC: Liviu Dudau >> CC: Ray Jui >> CC: Stephen Warren >> CC: Heiko Stuebner >> CC: Shawn Guo >> CC: Michal Simek >> CC: Wei Xu >> CC: Andrew Lunn >> CC: Jun Nie >> Suggested-by: Arnd Bergmann >> Signed-off-by: Pankaj Dubey >> --- >> arch/arm/include/asm/smp_scu.h | 4 +++ >> arch/arm/kernel/smp_scu.c | 56 ++++++++++++++++++++++++++++++++++++++++++ >> 2 files changed, 60 insertions(+) >> >> diff --git a/arch/arm/include/asm/smp_scu.h b/arch/arm/include/asm/smp_scu.h >> index bfe163c..fdeec07 100644 >> --- a/arch/arm/include/asm/smp_scu.h >> +++ b/arch/arm/include/asm/smp_scu.h >> @@ -39,8 +39,12 @@ static inline int scu_power_mode(void __iomem *scu_base, unsigned int mode) >> >> #if defined(CONFIG_SMP) && defined(CONFIG_HAVE_ARM_SCU) >> void scu_enable(void __iomem *scu_base); >> +void __iomem *of_scu_get_base(void); >> +int of_scu_enable(void); >> #else >> static inline void scu_enable(void __iomem *scu_base) {} >> +static inline void __iomem *of_scu_get_base(void) {return NULL; } >> +static inline int of_scu_enable(void) {return 0; } >> #endif >> >> #endif >> diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c >> index 72f9241..d0ac3ed 100644 >> --- a/arch/arm/kernel/smp_scu.c >> +++ b/arch/arm/kernel/smp_scu.c >> @@ -10,6 +10,7 @@ >> */ >> #include >> #include >> +#include >> >> #include >> #include >> @@ -70,6 +71,61 @@ void scu_enable(void __iomem *scu_base) >> */ >> flush_cache_all(); >> } >> + >> +static const struct of_device_id scu_match[] = { >> + { .compatible = "arm,cortex-a9-scu", }, >> + { .compatible = "arm,cortex-a5-scu", }, >> + { } >> +}; >> + >> +/* >> + * Helper API to get SCU base address >> + * In case platform DT do not have SCU node, or iomap fails >> + * this call will fallback and will try to map via call to >> + * scu_a9_get_base. >> + * This will return ownership of scu_base to the caller >> + */ >> +void __iomem *of_scu_get_base(void) >> +{ >> + unsigned long base = 0; >> + struct device_node *np; >> + void __iomem *scu_base; >> + >> + np = of_find_matching_node(NULL, scu_match); >> + scu_base = of_iomap(np, 0); >> + of_node_put(np); >> + if (!scu_base) { >> + pr_err("%s failed to map scu_base via DT\n", __func__); >> + if (scu_a9_has_base()) { >> + base = scu_a9_get_base(); >> + scu_base = ioremap(base, SZ_4K); >> + } >> + if (!scu_base) { >> + pr_err("%s failed to map scu_base\n", __func__); >> + return IOMEM_ERR_PTR(-ENOMEM); > > I can't see the point of using error-pointers here - it's not like we > really know why we're failing, so just return NULL. > >> + } >> + } >> + return scu_base; >> +} >> + >> +/* >> + * Enable SCU via mapping scu_base DT >> + * If scu_base mapped successfully scu will be enabled and in case of >> + * failure if will return non-zero error code >> + */ >> +int of_scu_enable(void) >> +{ >> + void __iomem *scu_base; >> + >> + scu_base = of_scu_get_base(); >> + if (!IS_ERR(scu_base)) { >> + scu_enable(scu_base); >> + iounmap(scu_base); >> + return 0; >> + } >> + return PTR_ERR(scu_base); > > and just return your -ENOMEM here. >