From patchwork Fri Apr 25 17:27:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Chaugule X-Patchwork-Id: 29113 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 83182202E6 for ; Fri, 25 Apr 2014 17:27:43 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id pa12sf15534142veb.0 for ; Fri, 25 Apr 2014 10:27:43 -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=cIygXoFOOOKUV6MoC6AM2CsMB3m+nOKPjMsDL2BELLM=; b=mdzeCs5pec0y2vL9oGnUoPNkSQ1LVA4i3BMpqQNsFGxOxTlxGDm0JdNc43X0s8qHDp e5Sn1UqhzWPZ0+M7rWPXnEQqeOAjp40BeJ6W3mLQuL9+kUdNEJHxVdGQcfdW2T3RWRlL +RoiDzxgtdI2J/EfWkOUcKwiw04kQpQjfQ+Szh0IUwXKoaY0KQ9wmcQKvPcRVaNNsEk0 I9Zf59fBbTrDkHaHqJZ0xzNlZaex+TGj1pdOGLFTJi2LFIujdIB4obVJPR1H8a37o11y 0WyA6v+Cz4jPt7HEUEBfS0relfBSdIjLMoTptvGMWW8TTlPu84DF+nklfOnM2BqsA8jQ /6AQ== X-Gm-Message-State: ALoCoQlcEXqwwTVfC569HB05hw2gJSvSjEshL61uxjAyVuMM4EXTDIhAgi2AZxjte8p7J/9lKznm X-Received: by 10.224.36.137 with SMTP id t9mr5002191qad.4.1398446863254; Fri, 25 Apr 2014 10:27:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.20.22 with SMTP id 22ls1675657qgi.63.gmail; Fri, 25 Apr 2014 10:27:43 -0700 (PDT) X-Received: by 10.58.123.71 with SMTP id ly7mr7610440veb.11.1398446863102; Fri, 25 Apr 2014 10:27:43 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id ui2si1851225vdc.100.2014.04.25.10.27.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 10:27:43 -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.128.174; Received: by mail-ve0-f174.google.com with SMTP id oz11so5042013veb.33 for ; Fri, 25 Apr 2014 10:27:43 -0700 (PDT) X-Received: by 10.58.248.5 with SMTP id yi5mr846572vec.42.1398446863025; Fri, 25 Apr 2014 10:27:43 -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 ib8csp114787vcb; Fri, 25 Apr 2014 10:27:42 -0700 (PDT) X-Received: by 10.140.27.70 with SMTP id 64mr12871690qgw.14.1398446862355; Fri, 25 Apr 2014 10:27:42 -0700 (PDT) Received: from mail-qc0-f179.google.com (mail-qc0-f179.google.com [209.85.216.179]) by mx.google.com with ESMTPS id z8si4181826qar.42.2014.04.25.10.27.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 10:27:42 -0700 (PDT) Received-SPF: none (google.com: ashwin.chaugule@linaro.org does not designate permitted sender hosts) client-ip=209.85.216.179; Received: by mail-qc0-f179.google.com with SMTP id l6so3471855qcy.38 for ; Fri, 25 Apr 2014 10:27:42 -0700 (PDT) X-Received: by 10.224.54.68 with SMTP id p4mr13359855qag.47.1398446862195; Fri, 25 Apr 2014 10:27:42 -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 z8sm15403683qaw.17.2014.04.25.10.27.40 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Apr 2014 10:27:40 -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 v7 3/3] ARM: Check if a CPU has gone offline Date: Fri, 25 Apr 2014 13:27:15 -0400 Message-Id: <1398446835-5532-4-git-send-email-ashwin.chaugule@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398446835-5532-1-git-send-email-ashwin.chaugule@linaro.org> References: <1398446835-5532-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..0b1882b 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, retry = 0; + + 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 once more if it fails. + */ +retry_once: + err = psci_ops.affinity_info(cpu_logical_map(cpu), 0); + + if (err != PSCI_AFFINITY_INFO_RET_OFF) { + if (!retry++) { + msleep(100); + pr_info("Retrying once more to check for CPU kill\n"); + goto retry_once; + } + pr_err("psci: Cannot kill CPU:%d, psci ret val: %d\n", + cpu, err); + /* Make platform_cpu_kill() fail. */ + return 0; + } + return 1; +} + #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 */