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: 4128951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0E67ABFF02 for ; Wed, 7 May 2014 14:30:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBC4620259 for ; Wed, 7 May 2014 14:30:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B7C420170 for ; Wed, 7 May 2014 14:30:30 +0000 (UTC) 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 1Wi2py-0001P1-K5; Wed, 07 May 2014 14:28:46 +0000 Received: from mail-qg0-f47.google.com ([209.85.192.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wi2pX-00017i-W5 for linux-arm-kernel@lists.infradead.org; Wed, 07 May 2014 14:28:21 +0000 Received: by mail-qg0-f47.google.com with SMTP id j107so1132575qga.20 for ; Wed, 07 May 2014 07:27:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CpHz16d2Rgsklz4XnVeshQPaGqr44ZL7Pa8dTsw6FYc=; b=gZ4x/tJpGkBxZO5p6jPUhKorCrdmv0fXFab01dLvb9X4g3/ifBUeQd+Tx78XIJAWji Sq0dy2Z99F4X4lrTNbllbn8Y8yuSMaJq08xN6XtVoYkQ0XUJQFSWEsrjTHQdfmdKLxqR aLRoFfy3Mnt9+skCV5ONlLHj2hTafCoxTmtgK7hN7Pm8a9h4qJZzswCP1fYSL9p7sXP5 mq2tUmbNJpGHLEBq2auyfVpuukgWCrRfGlwxUy+ZSIxPjuG0ucydRHSB14UXinSxsY7w 17BWPBVnTZsIx9UXyeQt36sPIPv433vBTB1jj5Hg10MKgR5gaRmpFOsoAKdO0nNiZGDl Y+hQ== X-Gm-Message-State: ALoCoQnckEHzBUwqk4yj/bIcHBwHm6R3m87LpVoIEJ1LJ16YaWAkE691Gd9XYVKTwRz6qneDzb/7 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140507_072820_141980_D99B8C06 X-CRM114-Status: GOOD ( 13.01 ) X-Spam-Score: 0.0 (/) Cc: rob.herring@linaro.org, anup.patel@linaro.org, linaro-acpi@lists.linaro.org, Marc.Zyngier@arm.com, Catalin.Marinas@arm.com, patches@linaro.org, Ashwin Chaugule , linux-arm-kernel@lists.infradead.org, christoffer.dall@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 };