From patchwork Fri Sep 5 11:22:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 36812 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id ED690202E4 for ; Fri, 5 Sep 2014 11:26:05 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf66445851pdb.9 for ; Fri, 05 Sep 2014 04:26:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=cEZTIChQF/tzRVaAGMccb9jxjwSTOYUZmusfyXC2RCk=; b=X0O3P/m10a/lgWW0i1KeGg4Fh+oQyhcS/0l9WFD6ZYe4YjkapYemuiBfFXdNdHTrXl sD0zvhC5R1Md98fwAVJgeRo8xjyXsJF80IMfrQwzIOniFDcN1zbvG4fcf4PzdMQ8U2Wd 43BRr0YB4aQDqawTmyrKboWYGoLrc1gSOlOzI915p3CBrzZU1YG/1kyyEHeR1f6rCXna xTuA8XVOe5bTk/GdRh1wtKZj/speLiYPdj+d40+3talRr0ixMAya7HMdnREzEvX9qHAa IfGUE8Z5Jm6ljiX/gvY1qOrv6kl+BkwlhGRiOdfqXTJuI8FkQvq5BtQCV9tpHuvJ3D/6 2xLg== X-Gm-Message-State: ALoCoQnB/78Twlmq/IbjRKEJ2AdktR1CL2CIF0c/zAjMyQ2xgfZEHUXfTwNhpmbL8RurPUX0CnrA X-Received: by 10.66.227.37 with SMTP id rx5mr5946449pac.25.1409916359678; Fri, 05 Sep 2014 04:25:59 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.247 with SMTP id c110ls67734qga.32.gmail; Fri, 05 Sep 2014 04:25:59 -0700 (PDT) X-Received: by 10.220.86.193 with SMTP id t1mr9673452vcl.22.1409916359569; Fri, 05 Sep 2014 04:25:59 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id u19si336095vcr.36.2014.09.05.04.25.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 04:25:59 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hq11so11950200vcb.22 for ; Fri, 05 Sep 2014 04:25:59 -0700 (PDT) X-Received: by 10.52.137.2 with SMTP id qe2mr8099047vdb.11.1409916359456; Fri, 05 Sep 2014 04:25:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp67443vcb; Fri, 5 Sep 2014 04:25:58 -0700 (PDT) X-Received: by 10.70.123.74 with SMTP id ly10mr20169392pdb.113.1409916358586; Fri, 05 Sep 2014 04:25:58 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [198.137.202.9]) by mx.google.com with ESMTPS id u7si3499540pdn.82.2014.09.05.04.25.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Sep 2014 04:25:56 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=198.137.202.9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPrcL-0004G1-At; Fri, 05 Sep 2014 11:23:49 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPrcH-00043O-QL for linux-arm-kernel@lists.infradead.org; Fri, 05 Sep 2014 11:23:46 +0000 Received: from leverpostej.cambridge.arm.com (leverpostej.cambridge.arm.com [10.1.205.151]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s85BMPwq016013; Fri, 5 Sep 2014 12:22:28 +0100 (BST) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] arm: psci: don't call CPU_OFF blindly Date: Fri, 5 Sep 2014 12:22:19 +0100 Message-Id: <1409916139-20127-3-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409916139-20127-1-git-send-email-mark.rutland@arm.com> References: <1409916139-20127-1-git-send-email-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140905_042346_230412_A3A5BD2E X-CRM114-Status: GOOD ( 16.73 ) X-Spam-Score: -6.7 (------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-6.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Mark Rutland , robh@kernel.org, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, catalin.marinas@arm.com, will.deacon@arm.com, ashwin.chaugule@linaro.org, christoffer.dall@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mark.rutland@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 The generic PSCI operations for arm check the presence of a CPU_OFF ID far too late, and in the absence of an ID will panic(), rather than producing a warning. This patch adds a psci_cpu_disable callback which tests the presence of a CPU_OFF id. As this is called earlier than psci_cpu_die, the failure can be handled gracefully without brining down the system. Additionally a check is added for a UP trusted OS in the presence of PSCI 0.2+. Full support will require the use of MIGRATE, but for now rejecting hotplug will prevent psci_cpu_die from brining down the system. The now redundant check for scpi_ops.cpu_off is removed from psci_cpu_die. At the same time, the whitespace is corrected from seven spaces to tabs. Signed-off-by: Mark Rutland Cc: Ashwin Chaugule Cc: Rob Herring Cc: Stefano Stabellini Cc: Ian Campbell Cc: Christoffer Dall Cc: Will Deacon Cc: Catalin Marinas --- arch/arm/kernel/psci_smp.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) Stefano, I've followed your lead with the __ref annotation here, but I couldn't figure out why they exist on cpu_die and cpu_kill; it feels rather dodgy. Do you know why they were added, or if they are superfluous? There are some other cleanups that should happen here (static, CPU_METHOD_OF_DECLARE), but those will come as a later cleanups series. diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c index 28a1db4..2b00d3c 100644 --- a/arch/arm/kernel/psci_smp.c +++ b/arch/arm/kernel/psci_smp.c @@ -56,17 +56,38 @@ static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle) } #ifdef CONFIG_HOTPLUG_CPU +int __ref psci_cpu_disable(unsigned int cpu) +{ + /* Fail early if we don't have CPU_OFF support */ + if (!psci_ops.cpu_off) + return -EOPNOTSUPP; + + /* + * In the presence of a UP trusted OS, it might not be possible to + * hotplug certain CPUs, and CPU_OFF may return (which would be bad). + * Supporting a UP trusted OS requires careful use of + * MIGRATE_INFO_UP_CPU and MIGRATE, so for now fail in the presence of + * a UP Trusted OS. + */ + if (psci_ops.migrate_info_type && + psci_ops.migrate_info_type() != PSCI_0_2_TOS_MP) { + pr_warn("Unable to handle UP trusted OS\n"); + return -EPERM; + } + + return 0; +} + void __ref psci_cpu_die(unsigned int cpu) { - const struct psci_power_state ps = { - .type = PSCI_POWER_STATE_TYPE_POWER_DOWN, - }; + const struct psci_power_state ps = { + .type = PSCI_POWER_STATE_TYPE_POWER_DOWN, + }; - if (psci_ops.cpu_off) - psci_ops.cpu_off(ps); + psci_ops.cpu_off(ps); - /* We should never return */ - panic("psci: cpu %d failed to shutdown\n", cpu); + /* We should never return */ + panic("psci: cpu %d failed to shutdown\n", cpu); } int __ref psci_cpu_kill(unsigned int cpu) @@ -109,6 +130,7 @@ bool __init psci_smp_available(void) struct smp_operations __initdata psci_smp_ops = { .smp_boot_secondary = psci_boot_secondary, #ifdef CONFIG_HOTPLUG_CPU + .cpu_disable = psci_cpu_disable, .cpu_die = psci_cpu_die, .cpu_kill = psci_cpu_kill, #endif