From patchwork Sun Sep 17 16:45:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9954921 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 602396039A for ; Sun, 17 Sep 2017 16:46:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 504A7289AE for ; Sun, 17 Sep 2017 16:46:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44B09289B7; Sun, 17 Sep 2017 16:46:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E13EC289B5 for ; Sun, 17 Sep 2017 16:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rvMFEftkAzGQG6W/Xoki9MifaK4fj1SGYARH5D2lLrw=; b=k/lxn0EM0T3Bb2ZsEWSlo6/4im bLz4f2DoAMI7X66rRfc3bTVZyQPE0hOJFyIpWIxThn0XaErvzStVwp2BExdgf8JQwDnL/V2MzfWjg W+MeuSVn7LslTCbNZfvO9EtzTS6nnLFoVDAxhlQFKMarfxJuh77npJTFIMeg6x6H2mYEjsD9ZjTYB V3kezEmGtMDk+0JkKgx0wsAVVqzpoZY/bQ3PYF7v2jKCkUdu0aT7/uNS9pj2F1ctXYqmvlwDsAr85 Xbs15DchFCwKKGwgP3oO0svZDeQIBWzzURyc7TScKL6cn4iEYPf3tneGrftNdDFwmeI191NopQPAO /5E+MBfA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dtciH-0005r5-6P; Sun, 17 Sep 2017 16:46:33 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dtchx-0005Vh-Hk; Sun, 17 Sep 2017 16:46:22 +0000 Received: by mail-wm0-x241.google.com with SMTP id i131so6780052wma.1; Sun, 17 Sep 2017 09:45:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0T7cJnf7c6CR6t89XI4z1LEJbpqDk5e4PTNtwvJpDJE=; b=XbKAVIR5EiixtAqtl3momK6/fZF6a+cIUg0UFdhr8Xk+XRfWTtEPSW/WX3NRmtV2Tz hS1sNjuuDWtKLgf5/X407IYk6NzjPHG9wigWOOT0ETH5j5j7G3rRGzUoy8hthfRjZ4Ja wSIqdYUmiHrXbSw74P+SivLMa1o9/DBHXC8O4DlK4hZuMfPgtDobWLA2lg5SMiUUicGN EGHJSSL89PvEe84m3rqETC6oQBgK6xp/0kPUhfObdk49SpjjXLS54UlQ/qsdVLH/tmwK zndbSVcwV7NzgniCLPw0Nw6YY6d3/msoKiUbqXsoZ8mqZLoWC/BgygCuoWpMZH0S0ZHx UOng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0T7cJnf7c6CR6t89XI4z1LEJbpqDk5e4PTNtwvJpDJE=; b=GuhbR+aB5BJaRWrMbAWf1xYmz29bZFbtoUX0wZ1UGneQUVnfJm209OO5/ooCFomC+l IxJY2/AV1eqxKahABaWfl141MaDnANXg4mDlVsC7JnFJRrtgEMIpdIGVP6kj4S1YAhdz NbJImcc3/gGeJDEcsZYILeZxygDfdMfZO2AiA5p1CIQ10UoYKLp5zDDB25SJm3MKrUHO M9Gybd0LE9KkrUO472Q9ZzU2ARJiLFuEVJ2IRCt5YfBN5LvIIlqVsOsziClq0N9fZLcb Nky5E9I3CsmRnyEc32sD0AI66EEYWAMpL0NFvQatVM0Yc9tSVxIThhf+nUsQzYCCZ335 hJcw== X-Gm-Message-State: AHPjjUh9+as8fxaSddNsWgjiEreeSmfec2/HGE3CUstZ2o0qQbHgKSp/ mHsW/+YbdzOzS5CeB7f4Op4i9nVi X-Google-Smtp-Source: AOwi7QA5FEV7eb3O86qw65zmm8lAPo4uthOCAbsVMclWNC51TVQlkev2SO15fhauqCgaPw9AnJvR/A== X-Received: by 10.28.109.77 with SMTP id i74mr7490268wmc.67.1505666753606; Sun, 17 Sep 2017 09:45:53 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3D04A042D42E2FA95194724.dip0.t-ipconnect.de. [2003:dc:d3d0:4a04:2d42:e2fa:9519:4724]) by smtp.googlemail.com with ESMTPSA id p59sm6323799wrc.75.2017.09.17.09.45.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Sep 2017 09:45:53 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, khilman@baylibre.com, carlo@caione.org, linux@armlinux.org.uk Subject: [PATCH v7 3/6] ARM: smp_scu: allow the platform code to read the SCU CPU status Date: Sun, 17 Sep 2017 18:45:20 +0200 Message-Id: <20170917164523.6970-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170917164523.6970-1-martin.blumenstingl@googlemail.com> References: <20170917164523.6970-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170917_094614_882284_C73988BE X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, f.fainelli@gmail.com, arnd@arndb.de, Martin Blumenstingl , robh+dt@kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Amlogic Meson8 / Meson8m2 (both Cortex-A9) and Meson8b (Cortex-A5) the CPU hotplug code needs to wait until the SCU status of the CPU that is being taken offline is SCU_PM_POWEROFF. Provide a utility function (which can be invoked for example from .cpu_kill()) which allows reading the SCU status of a CPU. While here, replace the magic number 0x3 with a preprocessor macro (SCU_CPU_STATUS_MASK) so we don't have to duplicate this magic number in the new function. Signed-off-by: Martin Blumenstingl Acked-by: Russell King --- arch/arm/include/asm/smp_scu.h | 6 ++++++ arch/arm/kernel/smp_scu.c | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/smp_scu.h b/arch/arm/include/asm/smp_scu.h index 4c47bdfd4f61..1529d1ae2f8d 100644 --- a/arch/arm/include/asm/smp_scu.h +++ b/arch/arm/include/asm/smp_scu.h @@ -28,6 +28,7 @@ static inline unsigned long scu_a9_get_base(void) unsigned int scu_get_core_count(void __iomem *); int scu_power_mode(void __iomem *, unsigned int); int scu_cpu_power_enable(void __iomem *, unsigned int); +int scu_get_cpu_power_mode(void __iomem *scu_base, unsigned int logical_cpu); #else static inline unsigned int scu_get_core_count(void __iomem *scu_base) { @@ -42,6 +43,11 @@ static inline int scu_cpu_power_enable(void __iomem *scu_base, { return -EINVAL; } +static inline int scu_get_cpu_power_mode(void __iomem *scu_base, + unsigned int logical_cpu) +{ + return -EINVAL; +} #endif #if defined(CONFIG_SMP) && defined(CONFIG_HAVE_ARM_SCU) diff --git a/arch/arm/kernel/smp_scu.c b/arch/arm/kernel/smp_scu.c index 1d549c16b5fc..c6b33074c393 100644 --- a/arch/arm/kernel/smp_scu.c +++ b/arch/arm/kernel/smp_scu.c @@ -21,6 +21,7 @@ #define SCU_STANDBY_ENABLE (1 << 5) #define SCU_CONFIG 0x04 #define SCU_CPU_STATUS 0x08 +#define SCU_CPU_STATUS_MASK GENMASK(1, 0) #define SCU_INVALIDATE 0x0c #define SCU_FPGA_REVISION 0x10 @@ -82,7 +83,8 @@ static int scu_set_power_mode_internal(void __iomem *scu_base, if (mode > 3 || mode == 1 || cpu > 3) return -EINVAL; - val = readb_relaxed(scu_base + SCU_CPU_STATUS + cpu) & ~0x03; + val = readb_relaxed(scu_base + SCU_CPU_STATUS + cpu); + val &= ~SCU_CPU_STATUS_MASK; val |= mode; writeb_relaxed(val, scu_base + SCU_CPU_STATUS + cpu); @@ -109,3 +111,17 @@ int scu_cpu_power_enable(void __iomem *scu_base, unsigned int cpu) { return scu_set_power_mode_internal(scu_base, cpu, SCU_PM_NORMAL); } + +int scu_get_cpu_power_mode(void __iomem *scu_base, unsigned int logical_cpu) +{ + unsigned int val; + int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(logical_cpu), 0); + + if (cpu > 3) + return -EINVAL; + + val = readb_relaxed(scu_base + SCU_CPU_STATUS + cpu); + val &= SCU_CPU_STATUS_MASK; + + return val; +}