From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D892C742A5 for ; Fri, 12 Jul 2019 05:30:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2602E21530 for ; Fri, 12 Jul 2019 05:30:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="G2tEld9u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725935AbfGLFal (ORCPT ); Fri, 12 Jul 2019 01:30:41 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42785 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbfGLFal (ORCPT ); Fri, 12 Jul 2019 01:30:41 -0400 Received: by mail-pg1-f196.google.com with SMTP id t132so3993839pgb.9 for ; Thu, 11 Jul 2019 22:30:41 -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=G2tEld9uv2oYMaQUCTBFxqa1q7vQCKFskzW+3vZ7KHoRZZE+eDzTb/9OoIHlmsgi5c dQcUGOLOIGWi7YGfHeUtx8CUU5a3d7VTyMVMNWiB6+JlPzSOxYezRtPnPUWdsotWuoVI YWbywnI5sVGB9p3r2gnWsGDeW8PY73vperHXyfQacTZcENcb9fQTHVIl35QFWMDitbCg hL9iaDqU7Jo8vVmiQg9Q+bRxP3RoTlvcD1ELyEuvVDADwr0Mzy3CbY41NKGps22/HgG4 ur76uc+Vf0fE0iBa00iavivhq6nMmZqiLxgZSnfiIiUfjjtBnFgIo5Vzu9L9WjeOQtOM xs0w== 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=dwmEDNvQwqC1/8iACq6RG4kc01MlvpuBnF8DQGx4Kk9FELFRK3f4OJADlJmbhDf0sv V4vV09skfObr9IgKONWrEhFeVPulBct60Q/uUiP8Rb+1tyE7pvpBIRfY6aNCvuF3C+3B D6/uYkv5Y752ABagqAMn1n58/1qiYYr1XfF6cAJrUn3asD+jITnIf4JLU1ipGw2wZ5Tz nZ5gbSxk6PK7zPt4vmy2BZ98cOqOOavUSDdDbzuIkD0nvS6eRExf5S+shj4hJm/i2Mtw ktL+AMuHXF4rcsCxrxaWFcALcHDvxd6fBSvrS/2XEL5XUoI4Z7k6mKUB+yM6bXYH9lU2 aEVw== X-Gm-Message-State: APjAAAWDhDtLPcANVtVU04s04pRhkX3Znvkck0PoFd5e3eHVWCs+FE4w hzhKBUIY5xnlp4ElgG8t0YmZn5yDnDQ= X-Google-Smtp-Source: APXvYqyU0wwjX1RQ1LS7189K6fCPtBPHn7spxLEhn1E3i0ZYo68woYmUYydbYl3EUP9FbO9sVq//1A== X-Received: by 2002:a17:90a:360c:: with SMTP id s12mr9552818pjb.30.1562909440598; Thu, 11 Jul 2019 22:30:40 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id f19sm10134578pfk.180.2019.07.11.22.30.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jul 2019 22:30:40 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org, Julien Thierry Cc: Viresh Kumar , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com Subject: [PATCH v4.4 V2 37/43] firmware/psci: Expose PSCI conduit Date: Fri, 12 Jul 2019 10:58:25 +0530 Message-Id: <896d2efd09dbe687aa3132c5e03f6b11feb6da9b.1562908075.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(-) 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; -- 2.21.0.rc0.269.g1a574e7a288b