From patchwork Thu Aug 29 11:34:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 172615 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2092726ily; Thu, 29 Aug 2019 04:36:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRtWF63KWfEv0nOQSH14jEzCef6oJVMG2Te6SGiOxGNKVs1yrZAj6/3opwZ9ql7MqsLpGi X-Received: by 2002:a65:68d9:: with SMTP id k25mr7928353pgt.337.1567078595297; Thu, 29 Aug 2019 04:36:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567078595; cv=none; d=google.com; s=arc-20160816; b=B/C5OsS29kpuq2sU7zpwcC5WLkW66KBAYX7Pwm2elDklNpPnKmIqKL6I44vATPYT/S NVslChT2sdnZJcoIVMu22MBays3/fQRBD4cnkUAkkhyWC5n3XZwBI/HgVVG3NFwob35L YlvXpPYdcx6SnExuo5TaUOiQxuKR5btrXmD33pxymUvB7sMEUgy1f16uq4i2h27Dp8Ed q7dUTx0oHrJCWTSiaepZs6VKws4n/7dc58bxtpca6lPA/SA7U/JL0/u8I2Xk0JZH6cuC ZYOyiX7ulOucoLK5XMeTyMKLInVDJY88EzW13bJ26sinpuRxrKzts/3HtHrFKYd40SZF l8Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lhetsf/v1WHqsODDPiuS8lCaAlBwJqZTnWnIuf4OhuE=; b=xXGW9N56xSnSSIQfvtpOufI1GF07ML5YpigJA5oEcVAmAQW7luk4IXqW57SpWjWj1i +63SPbAKe31XyTMxU2zWqz4WV/mSmkF3jr71xtkOlLhtrnf8ZqbJOuDZ8pgrEcSp996T Rc3nrIInx4fb7uz4WWLLm3NbjxA5Y65EkmTWUNKK+sb0iz5N774jJZrxnwzMZnzpEt0U XYi9frlk7cO57eovr5FHwTmQuE9eZ0zk1M7B5epXfMXl7qvNZmoEAdVNsHOnuVZoPq82 repE0BUWLfWIVN9GC33h3vJsaBUG2ETEXkrA2LgNsWxcouV4R3y9gZ/bpYbHZQkbFPq4 86KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cNwMOzQn; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 c67si2276378pfb.211.2019.08.29.04.36.35; Thu, 29 Aug 2019 04:36:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=cNwMOzQn; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1727559AbfH2Lge (ORCPT + 14 others); Thu, 29 Aug 2019 07:36:34 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33299 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727066AbfH2Lge (ORCPT ); Thu, 29 Aug 2019 07:36:34 -0400 Received: by mail-pl1-f196.google.com with SMTP id go14so1458414plb.0 for ; Thu, 29 Aug 2019 04:36:34 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=lhetsf/v1WHqsODDPiuS8lCaAlBwJqZTnWnIuf4OhuE=; b=cNwMOzQnTLEHODvHIhQEnk+Or/WiI+H6A+OFIgCMQxmFa7qTizeB59vjBlk2ZlWxoS yoNczpSvCyLVXQRZy+fLaAbQw0CFyX3aIxQekDbCNGzplBly07uvwFrMXE3dfv1V49xv 6Mde+wGHyN2HFXTsAEoYaP0yJ/eU+95AGWAt54rttyYtEzIrQM4L5QPY0jiyU9mdvzZf hy/YSEaACuc2AYos9Pj/veNFe69xiuRljYhJcpic/XY8UF/2hu0p1OPAKvDByDJWfMho c8EzaXuTX+F9YQ7MZhYOJNt5DRR1TDqjDdCp4Qm3EicA5Ck/031pqGP4/+DUCBChh9B6 yCyw== 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:mime-version:content-transfer-encoding; bh=lhetsf/v1WHqsODDPiuS8lCaAlBwJqZTnWnIuf4OhuE=; b=rQ6LeaQ1lB7gCfZGFpJRxcxaMoqoydLTz/r5vc1VxWUTv+jh4Ww3LcKtWECBiyewd0 qCqERE0gcmercUtkpMusVBd1EjSyWU8EaSlnKJ78MAjC/nNdvDl/jEXaJzSwaO3Tju/O K8m4y5zDxkplZuPivyB1QCiTXvOUemSoaUXUAe4uk+Co284FkY6f0iEr79NbiiI1n92S keInXH9zeW6ihbD1QKmPaXBu+wOP/2eME18dKuuH8Q7/oSH86soq3/fpBqirSugIMsn/ i+5N1tRfVqIybrYBdQ2YKqd9pwDP8jHxyDiMXOQCNwM7xiT/DHfMkOIFB7pIkCn4Ri7t jfWw== X-Gm-Message-State: APjAAAU9ohGV+FidNiN0wGGTdZtSUW76L4mPUxG/zFECrSBk409MrMZC TuEWOMmL4V5/CKtMVibJ3tWhmsoIikY= X-Received: by 2002:a17:902:bd4a:: with SMTP id b10mr9277181plx.219.1567078593597; Thu, 29 Aug 2019 04:36:33 -0700 (PDT) Received: from localhost ([122.167.132.221]) by smtp.gmail.com with ESMTPSA id b6sm2266314pgq.26.2019.08.29.04.36.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 04:36:33 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org, Julien Thierry , Mark Rutland Cc: Viresh Kumar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com Subject: [PATCH ARM64 v4.4 V3 38/44] firmware/psci: Expose PSCI conduit Date: Thu, 29 Aug 2019 17:04:23 +0530 Message-Id: <9325adff57fcdbf3524e2dbb35d8616a0343051e.1567077734.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marc Zyngier commit 09a8d6d48499f93e2abde691f5800081cd858726 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: Viresh Kumar --- drivers/firmware/psci.c | 28 +++++++++++++++++++++++----- include/linux/psci.h | 7 +++++++ 2 files changed, 30 insertions(+), 5 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 290f8982e7b3..7b2665f6b38d 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -54,7 +54,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); @@ -187,6 +189,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; @@ -199,9 +217,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; @@ -463,9 +481,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 04b4d92c7791..e071a1b8ddb5 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -24,6 +24,12 @@ bool psci_tos_resident_on(int cpu); bool psci_power_state_loses_context(u32 state); bool psci_power_state_is_valid(u32 state); +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); @@ -33,6 +39,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;