Received: by 10.223.185.116 with SMTP id b49csp7397326wrg; Thu, 1 Mar 2018 05:02:22 -0800 (PST) X-Google-Smtp-Source: AG47ELtN516g7Om3TxkFl+P74u1O11GlOPREpY8OnzljKs0X+Ee6V+KhIMxlj0YNqKu21ur9bWWy X-Received: by 10.99.95.71 with SMTP id t68mr1478604pgb.321.1519909342339; Thu, 01 Mar 2018 05:02:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909342; cv=none; d=google.com; s=arc-20160816; b=e4hvffIhUgECWtaHyFPc1188NjYOAjg/w6rJdVVjgf7c51uKau46V35z9kviJHYFIn CIVATuzzEpSbKAXNH5DX3TCXGNr+RIEwD49TvDPW0L9OY4ZgV+oaDIdYo9bz693QG9r+ b4RxKC4gXpwhugFeNeEd0Jp6C4ROdbBIJpb5LpePnZh0zqIrzguZflWW7ansiNCkNRzl WxPvvq7gB4S5L96D8pzIBscVCsgBUwPpZYa4pLVoWu3ls8WOb3eJbU5zC39ALcCE7R0q J3l4cWnwMQQrFeQ3I1CbgCj5pfq3qnu/exzHMBTIUwWoMGcKJY/BaxSf+8hP0a/CJZj+ OwFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=akDgzCa5YtuRJNj54LwJKZtDLDBl23n/7+9GevK/PdQXJwTDDXrK3EuVcbNZ7JWPHY gwH40FuH7UNrqguiLbFgu2Vn6KgcVS/C1FaWTB0XxebpYLlUuzLfSUuhZWusSjjapeRs dWzOIFcHp7N0r7TuBYHbtxuRRy/lrHtNzTWyANAQOWRLJQqP5iutUdeZIaIIUFT3TGsE w3cNy8zB2P2UrrHxuo4d2MBB5oiw+oQYzU1tghlUMVKus8nZiYM9iCboSG/eqJ71zJ8x U7L23O3kILeNqcThURD7NnW5sF+gKlAFS8SrbRkocNCpOkC1qliBcLeBx+q54Fzk0BMO 66Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cD6/Rp3l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si49530pge.342.2018.03.01.05.01.59; Thu, 01 Mar 2018 05:02:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cD6/Rp3l; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031138AbeCANAr (ORCPT + 99 others); Thu, 1 Mar 2018 08:00:47 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34525 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030312AbeCANAn (ORCPT ); Thu, 1 Mar 2018 08:00:43 -0500 Received: by mail-pg0-f67.google.com with SMTP id m19so2280109pgn.1 for ; Thu, 01 Mar 2018 05:00:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=cD6/Rp3lDnHqh0fT/wnmni2DoWjyUxCJ4YN8useKtwZWLpatFiXbOZShawbt2vHpJg UYsR0eM+Cd79Dh1YEXxfb4M6nQGRPTw0+BOCH1zJSpGgJKVGhN0EsEdGBNiPaIeC9bNg sNcxuE4Wei3Y20W19JD8UDoef1R636+6x+on8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=ITT3q0cO2072nb6AcPsI8uVVz+eAjPWOJULoTj8F4S+H9tNTjZcn+S3EgqY/D5kdYV rHHRx5xQzl8GiAC2QdPrglcDwche27tD8mGk/hMszs+uskD3FhFBCTrtLe8WM6UolQNn fGSA4DGlnPfjeyfvggwJaMiYwkmd8orMgAaoDRDghaZZGivZtEb6RcBOOv/imykbtT7x SHuj8ERAsxcN3gqP9U8QY6bPKSAVuLEQ18FEUPImWk3cFy7P6VCoC964R8UpbSlWauEx /ScUUSolZnbQ8Vnh9ugVq4ejDjwc0dpaOAxiucpcfziA920NlIDzgBLjZ4V+bzQ6eVJp 7lZA== X-Gm-Message-State: APf1xPAYyHZIcu2V772iYITjlLCXX7oOBGXi8P19WwKL6oxEEIs+xinH XBpBueL5JJvoFhJjaiFa0XkBZ+Ke7x0= X-Received: by 10.98.15.72 with SMTP id x69mr1892866pfi.16.1519909241810; Thu, 01 Mar 2018 05:00:41 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.05.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 05:00:41 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 40/45] firmware/psci: Expose PSCI conduit Date: Thu, 1 Mar 2018 20:54:17 +0800 Message-Id: <1519908862-11425-41-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit 09a8d6d48499 upstream. In order to call into the firmware to apply workarounds, it is useful to find out whether we're using HVC or SMC. Let's expose this through the psci_ops. Acked-by: Lorenzo Pieralisi Reviewed-by: Robin Murphy Tested-by: Ard Biesheuvel Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Alex Shi --- drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 9a3ce76..a49196a 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -59,7 +59,9 @@ bool psci_tos_resident_on(int cpu) return cpu == resident_cpu; } -struct psci_operations psci_ops; +struct psci_operations psci_ops = { + .conduit = PSCI_CONDUIT_NONE, +}; typedef unsigned long (psci_fn)(unsigned long, unsigned long, unsigned long, unsigned long); @@ -210,6 +212,22 @@ static unsigned long psci_migrate_info_up_cpu(void) 0, 0, 0); } +static void set_conduit(enum psci_conduit conduit) +{ + switch (conduit) { + case PSCI_CONDUIT_HVC: + invoke_psci_fn = __invoke_psci_fn_hvc; + break; + case PSCI_CONDUIT_SMC: + invoke_psci_fn = __invoke_psci_fn_smc; + break; + default: + WARN(1, "Unexpected PSCI conduit %d\n", conduit); + } + + psci_ops.conduit = conduit; +} + static int get_set_conduit_method(struct device_node *np) { const char *method; @@ -222,9 +240,9 @@ static int get_set_conduit_method(struct device_node *np) } if (!strcmp("hvc", method)) { - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); } else if (!strcmp("smc", method)) { - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); } else { pr_warn("invalid \"method\" property: %s\n", method); return -EINVAL; @@ -654,9 +672,9 @@ int __init psci_acpi_init(void) pr_info("probing for conduit method from ACPI.\n"); if (acpi_psci_use_hvc()) - invoke_psci_fn = __invoke_psci_fn_hvc; + set_conduit(PSCI_CONDUIT_HVC); else - invoke_psci_fn = __invoke_psci_fn_smc; + set_conduit(PSCI_CONDUIT_SMC); return psci_probe(); } diff --git a/include/linux/psci.h b/include/linux/psci.h index 6306ab1..66ff547 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -25,6 +25,12 @@ bool psci_tos_resident_on(int cpu); int psci_cpu_init_idle(unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); +enum psci_conduit { + PSCI_CONDUIT_NONE, + PSCI_CONDUIT_SMC, + PSCI_CONDUIT_HVC, +}; + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); @@ -34,6 +40,7 @@ struct psci_operations { int (*affinity_info)(unsigned long target_affinity, unsigned long lowest_affinity_level); int (*migrate_info_type)(void); + enum psci_conduit conduit; }; extern struct psci_operations psci_ops; -- 2.7.4