From patchwork Sat Jul 22 19:19:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9858179 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 C3912600F5 for ; Sat, 22 Jul 2017 19:34:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C848928469 for ; Sat, 22 Jul 2017 19:34:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD5422846D; Sat, 22 Jul 2017 19:34:21 +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=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=unavailable 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 4D6FE28469 for ; Sat, 22 Jul 2017 19:34:21 +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=m/nv4yCpLXdQ9X4u3yqL03DQYueeZukxQoanhXPCV+o=; b=soGETHC4NUj3zYk2orXKITpQQ5 lx0/P6Nf/CVNZFjvOduZTUePiBETxO9I4ueXpYCmtrJUUVExfraDmTneYHfnaywtKrMZGu2NcYzJu 0YS6lzscl6nPGyOfY3Y4l2+rOjCMjQJpoFPwl/0GPfHR+qUZ5QYxd+VkxOpw807mHHJoIpgmrh7rE TAMI8ZMIsZrzvFyLkst2ZezzY2vYWgjQbM8ItJMn5+nrBdywy+9ILGNA3QXsV3otPVWi5bcRPtxbb v1GAL2SKwwxL+3TTiZstLfu8QVpyKIvqtzrThH1Y9u27Ino8DAAQia8GHPKhZYCuni1qWkKrUMymj TrnIqOZQ==; 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 1dZ0AD-0005Ki-Bq; Sat, 22 Jul 2017 19:34:09 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dYzwt-0007N2-Tr; Sat, 22 Jul 2017 19:20:28 +0000 Received: by mail-wr0-x243.google.com with SMTP id o33so6945433wrb.1; Sat, 22 Jul 2017 12:20:03 -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=AsnOkEJkhlc308eFnV1S/2QCmwj2665LKQJZi5hmjqA=; b=kjlm8Te5SiAS4+0Eyvo9qohO11Q6HST73r5Dl+SWyq/KdVQCyIm1R4zCYTlQtgQ+un Fs0ZHEAwDfoo+VKSEyEgQuCnfRuHtjCfYgWc2XKnh3qWMBjBaJUqGr7BHVQtuDhMfv6X KpEP3yN4d0KObM7uzfyFebX/ePNNHmbJroO2p5/Izw7HZ72EJQ6a8MTV/aMyT6EBX7lZ kGS0VA6iSgJ+gBUUjE1h0bNQnicRj3yH0R2vMFfuGHDgBfW4lpwFMJV9TndarZYE8/we 6Za3RPceffg9IV34HYHzzBrYwLv4rIm4kX0lD2Y7NJk2WHySulcekQURcVGp+rrhWt/p H3+Q== 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=AsnOkEJkhlc308eFnV1S/2QCmwj2665LKQJZi5hmjqA=; b=LDc1TrUVhJudbDXJtL/39jln2vaqeAaXpEEW6hDoK6aCs/Xq/5Deti8OEAfa9ikn/Z k1WGK5zZ08L9UqIbRuskKfaxqkSYqcb9aYu4vtu783FrRNJ3RHqGi2sabfbIcBZN6b58 xJZnUE1W0g6JOw2u1KbZAkFQMtfN7mh97gJTN9u1YyV98/JgY3ReGVoBth0C9bRZz1ub N5NGRQ5eotqk/V1hDRCXXd3a3RVYlaZRw3VAq6I4TuXWcFoZxfyybPyHlEjXNqUTMmNS afqtJtdIpKORN2eW9K/oyVTKURG7rijjsQDZHNUEQjge1SlucT0mB4qA5sCBwPPbnCgZ 60Rw== X-Gm-Message-State: AIVw11100Ziraepmtub8bsX0OGZrba1QVMmohT6QZeMVxjn76UYx433J 9taZN3YydPX3Fzh+cZc= X-Received: by 10.223.163.158 with SMTP id l30mr1286377wrb.203.1500751201929; Sat, 22 Jul 2017 12:20:01 -0700 (PDT) Received: from blackbox.darklights.net (p5B056101.dip0.t-ipconnect.de. [91.5.97.1]) by smtp.googlemail.com with ESMTPSA id l143sm2043472wmg.46.2017.07.22.12.20.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Jul 2017 12:20:01 -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 v4 3/7] ARM: smp_scu: allow the platform code to read the SCU CPU status Date: Sat, 22 Jul 2017 21:19:42 +0200 Message-Id: <20170722191946.22938-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170722191946.22938-1-martin.blumenstingl@googlemail.com> References: <20170722191946.22938-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170722_122024_133650_9B1653EE X-CRM114-Status: GOOD ( 10.51 ) 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, robh+dt@kernel.org, Martin Blumenstingl , arnd@arndb.de 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. Signed-off-by: Martin Blumenstingl --- 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 11e636f33ed9..992b34c4267f 100644 --- a/arch/arm/include/asm/smp_scu.h +++ b/arch/arm/include/asm/smp_scu.h @@ -27,6 +27,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) { @@ -41,6 +42,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 ef09121b18eb..942f8acb82c1 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); @@ -113,3 +115,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; +}