From patchwork Fri Apr 25 19:48:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Chaugule X-Patchwork-Id: 29129 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3D57203AC for ; Fri, 25 Apr 2014 19:50:22 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rd18sf24301675iec.0 for ; Fri, 25 Apr 2014 12:50:22 -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=X10UF2BQr/f//i0LdsNpYlsjAtFJqYSjdWpBVCBLGo0=; b=Kx08DM57tdfglWfTJC7WD0SBzOYOIHMLIpmBizrHu0azyvJ+m4J+M3FrSWPEX07p7Q goTvB1UDZPj2XJrgqkkvngPz/uZHqlD2wxdizFvMgBiu8xt/FdytIdni42w3MUKXvxMp fpLv78EPwo2XPTR80Ccx8yKastsQDC+ArfXCpB8cYFzjVmDQZ659TvskJuWsGH0nE8hw 5o6PSQP2qS0znEqxGjKb65HYI3vMg2btiEUszYotbdNdscWuICmj+bhHLZs6+5lgczlx y2hqDFeTzHID1FIzbS8t7Y2sWIrodAdwjIilypmLDR+q3bmzKZLXTesO0t3olrzKisDX o0RA== X-Gm-Message-State: ALoCoQm889SLNYwrClPynwS4LgurPPjcVSSP5c2/swxIpyDmiws7WqzJXRlZCUcL1gkzFLGxURqq X-Received: by 10.43.79.196 with SMTP id zr4mr5118091icb.3.1398455422192; Fri, 25 Apr 2014 12:50:22 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.81 with SMTP id e75ls822013qgd.29.gmail; Fri, 25 Apr 2014 12:50:22 -0700 (PDT) X-Received: by 10.52.183.228 with SMTP id ep4mr6822020vdc.30.1398455422076; Fri, 25 Apr 2014 12:50:22 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id tv3si1946282vdc.144.2014.04.25.12.50.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 12:50:22 -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.181; Received: by mail-vc0-f181.google.com with SMTP id id10so5421963vcb.12 for ; Fri, 25 Apr 2014 12:50:22 -0700 (PDT) X-Received: by 10.58.31.136 with SMTP id a8mr8418540vei.20.1398455421998; Fri, 25 Apr 2014 12:50:21 -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 ib8csp123457vcb; Fri, 25 Apr 2014 12:50:21 -0700 (PDT) X-Received: by 10.229.54.201 with SMTP id r9mr14657996qcg.6.1398455421558; Fri, 25 Apr 2014 12:50:21 -0700 (PDT) Received: from mail-qc0-f175.google.com (mail-qc0-f175.google.com [209.85.216.175]) by mx.google.com with ESMTPS id x5si4391778qcs.49.2014.04.25.12.50.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 12:50:21 -0700 (PDT) Received-SPF: none (google.com: ashwin.chaugule@linaro.org does not designate permitted sender hosts) client-ip=209.85.216.175; Received: by mail-qc0-f175.google.com with SMTP id e16so4484558qcx.20 for ; Fri, 25 Apr 2014 12:50:21 -0700 (PDT) X-Received: by 10.140.33.181 with SMTP id j50mr13663201qgj.81.1398455421271; Fri, 25 Apr 2014 12:50:21 -0700 (PDT) Received: from localhost.localdomain (cpe-098-027-049-158.nc.res.rr.com. [98.27.49.158]) by mx.google.com with ESMTPSA id w2sm16056678qar.21.2014.04.25.12.50.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 12:50:19 -0700 (PDT) From: Ashwin Chaugule To: mark.rutland@arm.com Cc: 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 v8 3/3] ARM: Check if a CPU has gone offline Date: Fri, 25 Apr 2014 15:48:49 -0400 Message-Id: <1398455329-18136-4-git-send-email-ashwin.chaugule@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398455329-18136-1-git-send-email-ashwin.chaugule@linaro.org> References: <1398455329-18136-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 | 32 ++++++++++++++++++++++++++++++++ include/uapi/linux/psci.h | 5 +++++ 2 files changed, 37 insertions(+) diff --git a/arch/arm/kernel/psci_smp.c b/arch/arm/kernel/psci_smp.c index 570a48c..94e230c 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,35 @@ 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_AFFINITY_INFO_RET_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 +109,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 }; diff --git a/include/uapi/linux/psci.h b/include/uapi/linux/psci.h index a4136c3..857209b 100644 --- a/include/uapi/linux/psci.h +++ b/include/uapi/linux/psci.h @@ -74,4 +74,9 @@ #define PSCI_RET_NOT_PRESENT -7 #define PSCI_RET_DISABLED -8 +/* Return values from the PSCI_ID_AFFINITY_INFO Function. */ +#define PSCI_AFFINITY_INFO_RET_ON 0 +#define PSCI_AFFINITY_INFO_RET_OFF 1 +#define PSCI_AFFINITY_INFO_RET_ON_PENDING 2 + #endif /* _UAPI_LINUX_PSCI_H */