From patchwork Fri Jun 14 03:08:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 166777 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1506417ilk; Thu, 13 Jun 2019 20:13:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPIFpF8Q93qupDY012frn78OYw03UFXAXUzgx3SbMDgrNMP95diI0wDf08kGD81aVQWsbt X-Received: by 2002:a17:902:b94a:: with SMTP id h10mr91092106pls.265.1560482018530; Thu, 13 Jun 2019 20:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560482018; cv=none; d=google.com; s=arc-20160816; b=EvK0pFawYNvkEpCqiJk9Iwia9scXlv/e1nmGgTtVfKQSBYOpiJzcb0ZjagRYSlt76a G0m/BtXwTHLnUJ0Nc4T45wnTuuZ5LOz5w9LHguEIBat5JoBgBEO6J/mdizdraoU9oc+N y8RavkSkKPJKWBWY3wE1h7GS0hVmeyP2/9FhzWwOor03FJcJt88ECJjxa24ypjhgazh6 xsI/m7kyh0tJH6Lt+3h4uMGWpWizrQhA2DawehiZEFpv4VIQIwRTsLLesVeBjRfkcRUW dphjLsWdVOOinwNe91j21lUt2UiJ7YtKD9OcjTfZ71nuL6ObZE06f3TNAtFSb2/n0OIj qLIA== 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=0A1bmAUf5a4rGh9qAnei0228IX/OfOV/Bfuh7ZI4x0nvd0N839kHqRUqQ8vZJDOP5/ ezvQ47mbMqZPxWP0Y0er1y8MO3THdmC6dfw2ZsmxvhYghCd+nTRaKb7o660VAy3ONRHF 5F/px+kiF8H4iBgfwZTr2MWoXbYM9xOEqRffZeRgUuQadDu/3RM67cnHKhQr1dHiCQxP F6p95e6S2y7Gk4A4yhddHngiMtyV/NoMqH0QTcdGQm0nPH2nk8ww2zOmkpm1VslR83+5 EmGWm6jRS4FBbHJybGvsGlpChzRFekY0p2pptD0WHBxkmZmEad7JNLgS22PFYkuVTGpG DRqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dzAIXfjM; 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 e8si1073936plb.420.2019.06.13.20.13.38; Thu, 13 Jun 2019 20:13:38 -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=dzAIXfjM; 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 S1726750AbfFNDNh (ORCPT + 14 others); Thu, 13 Jun 2019 23:13:37 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42971 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbfFNDNh (ORCPT ); Thu, 13 Jun 2019 23:13:37 -0400 Received: by mail-pf1-f193.google.com with SMTP id q10so487408pff.9 for ; Thu, 13 Jun 2019 20:13:37 -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=dzAIXfjMtBl0yLP99Ks992Mq6IPJZ1HUk7Cbh9sMLFPdCk0tjIbGqG2zuQ02QyxMll jM+kUdcPwm9JdTju9yvrbg8ThgOP88bOWYBqRNTKKJVn7ijo43+wsVsQbqUJItl1uuqC kl9DITbxr1DjaaV0vry/PlU/VBmSmjfWu86CuurkeLAk6rmmhbUx61UfBSdkvXJWnXHx w4RX182pDEgAvFqcb21IReDHbX6IVx3u7uvXz5GUI3/M3RcKN1eDoJ1I7TfEw5jqHGKc 445EMtA6G9UfW0AnEtq03m5nA8StW9sR8G/tiN2bQeZCRzDw4CNP02qyubxU8Axkf4CU WLmg== 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=a/g0MvTqDO5O8CY6JbnXhaaVSyCY4mEnUWuQ4AtYSdMZfBzIE9jfaqk5cJhA7uHd3u q6fmrspFlNic2z++DTBDsqHan1/r2G3ie+bB2yb3vDRXG2Rgx5i4PdGWSsxOTyDdCLmR qzM6G7zUN8qCUh2oBg9qlqDWWJvg/ZJlDIwBl+houpTxnrr79WBEzg5uT+KJAF6QABYV LxIo1KAAhoT5IgU9o912zu/snvf4C7np1QC5XQph+I2VF9HPJ9QOrvsMzyC+dPFlAXRe aquxVjOirdc6jRqOLq1spzyDf3kmWf9jvOl6t+5sDOPl8uAao4jLwaijzdkeD6KAkiW1 hFBQ== X-Gm-Message-State: APjAAAU314s1CYPWV4Fu0Bvtqj0BQ+ekT1HSiEFCp0GY3c7zXf6uFO1g c1nf+wN359duPsxV4wNlA+LdDH5FEEY= X-Received: by 2002:a63:1b56:: with SMTP id b22mr32193643pgm.87.1560482016730; Thu, 13 Jun 2019 20:13:36 -0700 (PDT) Received: from localhost ([122.172.66.84]) by smtp.gmail.com with ESMTPSA id e22sm1107255pgb.9.2019.06.13.20.13.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 20:13:36 -0700 (PDT) From: Viresh Kumar To: linux-arm-kernel@lists.infradead.org, Julien Thierry Cc: Viresh Kumar , stable@vger.kernel.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com Subject: [PATCH v4.4 39/45] firmware/psci: Expose PSCI conduit Date: Fri, 14 Jun 2019 08:38:22 +0530 Message-Id: <8b5c248d26b432206c3e019d8630da59e18dfb3d.1560480942.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;