From patchwork Wed May 7 14:27:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Chaugule X-Patchwork-Id: 29770 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 410CF20534 for ; Wed, 7 May 2014 14:28:00 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf4725422pab.3 for ; Wed, 07 May 2014 07:28:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=CpHz16d2Rgsklz4XnVeshQPaGqr44ZL7Pa8dTsw6FYc=; b=VmoL2CF0HkEd4UYvHWCYRc5tPpGiOPZmbRoZ+nSfZob1oTmI6OsvrVf84Eg+zIaB0t wHAT1gi4u0Ca55ZpSiZ4ZLJRkixI9hLzkjMp76m1SeKAu/yX97EY1P9fVF6nbbsqTKcM Di5+F16R6yfo5gU+aBeHG7hkj3NnHa6t4b8CB0inNUZi4C/Iejl8cUH0/8Ki9nrg8Wfc jA5bjq5XyXJfzvs5F5+6Y5vZj25NEKeG6GlXbENLlfasW5FsHnk7QUxVgcVi8DMnV0UY KwSQSlVGSDChkWAnAK7hKQUydA8aehnWfhVlZvF5+wPi9x6HIsc7kvVIYUKw3Dvgcxf8 2/vw== X-Gm-Message-State: ALoCoQkNLAp979f1U+P5lRKeQXqTBefTyiSiUGLSaQAPrv4duYRknfAgGrNhAC00ZoGrKpRSNjbx X-Received: by 10.66.163.33 with SMTP id yf1mr4695779pab.19.1399472880137; Wed, 07 May 2014 07:28:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.239 with SMTP id l102ls3457879qgd.81.gmail; Wed, 07 May 2014 07:28:00 -0700 (PDT) X-Received: by 10.52.93.201 with SMTP id cw9mr660323vdb.80.1399472880009; Wed, 07 May 2014 07:28:00 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id is3si2936432vec.99.2014.05.07.07.27.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 May 2014 07:28:00 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ij19so1366532vcb.14 for ; Wed, 07 May 2014 07:27:59 -0700 (PDT) X-Received: by 10.221.69.68 with SMTP id yb4mr969354vcb.49.1399472879939; Wed, 07 May 2014 07:27:59 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp313961vcb; Wed, 7 May 2014 07:27:58 -0700 (PDT) X-Received: by 10.224.112.74 with SMTP id v10mr66000936qap.28.1399472878078; Wed, 07 May 2014 07:27:58 -0700 (PDT) Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com [209.85.216.43]) by mx.google.com with ESMTPS id x1si6794283qal.142.2014.05.07.07.27.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 May 2014 07:27:58 -0700 (PDT) Received-SPF: none (google.com: ashwin.chaugule@linaro.org does not designate permitted sender hosts) client-ip=209.85.216.43; Received: by mail-qa0-f43.google.com with SMTP id m5so1053119qaj.2 for ; Wed, 07 May 2014 07:27:57 -0700 (PDT) X-Received: by 10.224.20.196 with SMTP id g4mr65927536qab.66.1399472877898; Wed, 07 May 2014 07:27:57 -0700 (PDT) Received: from linaro5.qualcomm.com (rrcs-67-52-130-30.west.biz.rr.com. [67.52.130.30]) by mx.google.com with ESMTPSA id x5sm29455150qaj.9.2014.05.07.07.27.56 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 May 2014 07:27:56 -0700 (PDT) From: Ashwin Chaugule To: mark.rutland@arm.com Cc: Catalin.Marinas@arm.com, linaro-acpi@lists.linaro.org, linux-arm-kernel@lists.infradead.org, rob.herring@linaro.org, christoffer.dall@linaro.org, Marc.Zyngier@arm.com, anup.patel@linaro.org, patches@linaro.org, Ashwin Chaugule Subject: [PATCH v9 3/3] ARM: Check if a CPU has gone offline Date: Wed, 7 May 2014 10:27:27 -0400 Message-Id: <1399472847-14377-4-git-send-email-ashwin.chaugule@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399472847-14377-1-git-send-email-ashwin.chaugule@linaro.org> References: <1399472847-14377-1-git-send-email-ashwin.chaugule@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ashwin.chaugule@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , PSCIv0.2 adds a new function called AFFINITY_INFO, which can be used to query if a specified CPU has actually gone offline. Calling this function via cpu_kill ensures that a CPU has quiesced after a call to cpu_die. Signed-off-by: Ashwin Chaugule Reviewed-by: Rob Herring --- arch/arm/kernel/psci_smp.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c index 570a48c..502e6cf 100644 --- a/arch/arm/kernel/psci_smp.c +++ b/arch/arm/kernel/psci_smp.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include @@ -66,6 +68,34 @@ void __ref psci_cpu_die(unsigned int cpu) /* We should never return */ panic("psci: cpu %d failed to shutdown\n", cpu); } + +int __ref psci_cpu_kill(unsigned int cpu) +{ + int err, i; + + if (!psci_ops.affinity_info) + return 1; + /* + * cpu_kill could race with cpu_die and we can + * potentially end up declaring this cpu undead + * while it is dying. So, try again a few times. + */ + + for (i=0; i<10; i++) { + err = psci_ops.affinity_info(cpu_logical_map(cpu), 0); + if (err == PSCI_0_2_AFFINITY_LEVEL_OFF) + return 1; + + msleep(10); + pr_info("Retrying again to check for CPU kill\n"); + } + + pr_err("psci: Cannot kill CPU:%d, psci ret val: %d\n", + cpu, err); + /* Make platform_cpu_kill() fail. */ + return 0; +} + #endif bool __init psci_smp_available(void) @@ -78,5 +108,6 @@ struct smp_operations __initdata psci_smp_ops = { .smp_boot_secondary = psci_boot_secondary, #ifdef CONFIG_HOTPLUG_CPU .cpu_die = psci_cpu_die, + .cpu_kill = psci_cpu_kill, #endif };