From patchwork Thu Jul 13 10:31:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9838151 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 3D33E60393 for ; Thu, 13 Jul 2017 10:33:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D82C28692 for ; Thu, 13 Jul 2017 10:33:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21AAC286B7; Thu, 13 Jul 2017 10:33:04 +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 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 AA7A128692 for ; Thu, 13 Jul 2017 10:33:03 +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=qw2H3po4xiOP98fwzoEDPqFTg1JYAKQwgRKXmhV6Qbw=; b=F35MrCaoGNk7pYpy+JVhj+1a/o r0w3sBXw4ZWFCePXM9lh/bcKvJqzYkRHl4U9nKG8gJ6rjTQ+0BHdIDZCtrRoApIstl4G3CcNxXMHE KW3how7i6L/d22zu+H4FBlWobrw0s0Q4W8juGCVMioXfZcUbQeHYO2ioaDaulyhLOTvQdczlXv7YC UTlhgcR0UL7JWGv1bSxSrkSDOCJlc98cXzGoWCZVHL/UA0s0aPQDK3ivcsjcrVsx+H4Mc4wLInBfn HGPAEJ6N9uy5JVuiOIhnYfq+DeByD9v5Dwecg/wZzJeyezBUQ4O86gVqOqrlZe/5hDHwwNuEzVxgN 5kAt7I8Q==; 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 1dVbQc-00020z-V6; Thu, 13 Jul 2017 10:33:02 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dVbPc-00011T-G7; Thu, 13 Jul 2017 10:32:02 +0000 Received: by mail-wr0-x241.google.com with SMTP id n18so888308wrb.0; Thu, 13 Jul 2017 03:31:40 -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=VZ6y4N557jftBHvfl+dAXcCNlb6/q9QWtDj15s6OLAE=; b=V1Ny+DFl6vGLfg2rAWkDYW6e9CNX1PSUEGfk3GpoY8HYLSB9T1t8muO7TBQKSosw9V jrnEBObzvU6fJ4zn9YRO783ZYyNJLkc62swfiluMuvxjormHwK3wIO7bJxU/y6w619Pd bPY0BacPrpd5U1U1ZAiZ5q6YYPyRPNY8ls3VwqwHYmlcugkUoqNwaMTxRrOdKkuBAd3M 9FnIkL8hYTnKx3ovVX6r8Q+J2/ZVuPKMRzWFbvSClkVh2B6w2o2xAVv5xZTeLunDj/Zk XFCG3/dpWVUcs/leWoCfDcUwPcF1kBV6/Io95LJkFvRyZSStKKvIYtoGoc3dSmfxG5bp PPTQ== 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=VZ6y4N557jftBHvfl+dAXcCNlb6/q9QWtDj15s6OLAE=; b=tI2WeNjZNso6mos51U7d7NKtWe2X3FpGnlDlvUe9sJ4pkd+KbTEY44pp7dLbkdNrAE 1vmYBcFAkdoHueiVLf5iZzzHfDjfahcOk63jd3RGfqO2Iu0Kk8uf7e/jzq9RvTg0MZdA gR4D0inRpEbHbFd076s/SAjUjyaQ624j1N+QCvuqU6GOhedcC/SK+vdDqHu6+OkFjoiz B5Vnq5TV0Ao+eqLbuQ8fjqutaweJ4Zy2Xy12lAVHUy2zQHhUNZVQubOVdKwO80ifXf/Q RD1+tgjP2nDtvHNtvUDihJGo9xkg1YUJbHvyr9sYmVC4U9jaMtB5lYe8ACK2B9jY4gHK CBpQ== X-Gm-Message-State: AIVw110RiCfQe8t5/0KQvJNLPON3bjam/50vCAxM7/rvX79X0mJP9/de hdcaalTvPSe/F6cJQzc= X-Received: by 10.223.131.66 with SMTP id 60mr1415939wrd.54.1499941898503; Thu, 13 Jul 2017 03:31:38 -0700 (PDT) Received: from blackbox.darklights.net (p5B056DF5.dip0.t-ipconnect.de. [91.5.109.245]) by smtp.googlemail.com with ESMTPSA id n189sm5775136wmd.0.2017.07.13.03.31.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 03:31:37 -0700 (PDT) From: Martin Blumenstingl To: linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, khilman@baylibre.com, carlo@caione.org, linux@armlinux.org.uk Subject: [PATCH v3 3/6] ARM: smp_scu: allow the platform code to read the SCU CPU status Date: Thu, 13 Jul 2017 12:31:10 +0200 Message-Id: <20170713103113.21560-4-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170713103113.21560-1-martin.blumenstingl@googlemail.com> References: <20170713103113.21560-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170713_033200_690523_7B07A3F7 X-CRM114-Status: GOOD ( 10.98 ) X-BeenThere: linux-amlogic@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, Martin Blumenstingl , robh+dt@kernel.org, arnd@arndb.de MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=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; +}