From patchwork Thu Aug 1 08:15:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 170319 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5085274ile; Thu, 1 Aug 2019 01:19:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4qmXjjZ9RANcPaMlB3e6zAljRjQgSMyXfOTuYTFox1hoGGG9bqLp/N44ExgNQDTzQ+Pcp X-Received: by 2002:a17:90a:cb01:: with SMTP id z1mr7125380pjt.93.1564647590267; Thu, 01 Aug 2019 01:19:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564647590; cv=none; d=google.com; s=arc-20160816; b=dyS/0SB4XuydtreBHkcR6eQu+FOmE8/4UQeKRp8UQNH5gX23LFdUZbuEomq3cP5yUw JSOo2E91CssHBvj8HW2LAf1g0IVZKhcT30oI4pNBrDSCTMQHQ7HZ7upL8sSnH5ucG7kG qBeN8zESz0897g2Q2Ex9leM0xDK/qEno/Rr10MicBBgmDLKKsz6kyGLJMQTmMKifk/Td 6pi1sy4W9glmxmNvHEWRx+HMsJscryMZfiZW3ZG4k+zqHNdLPcMV7VecPf87t7zuqIrW XZz4PauAQeOYZIoykX5NADyeerOes05i8Hf8Cl0TbUfhY8AwsBWGCWQS3oM6qzjzaAoe ofEg== 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=yP20piNFLr9nNMDvOJdiZZaGIBv6hwLQnuTF83mJgpQbT7F9Xdp2MUQweiMVYALN+w 2oHlbNQabryFHind3k8M4LgKp3PB4uJTrUNmVPLDrR+HtelEpvkDrioU4b97g5pXO1pl RD3uexmviNWnh2NVOdF6dJE7lyPo8x0wOXE8mNBGhd9OKW0TnqbxyVrT+arXGn2qoHBJ 9Q5jj1cJLiz2dkrc/RC2MCq0dohXTu1HYJrCOirJYAlPFHVwS8eSgu7qljrLW+RR5b7o mawNXuwOzv2+9EaWvqrsPstGV8ISxx4R/VlkxeFLxgRFLvl8WSCMirEbMbi6nGU48oBF xwKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IeSrybNX; 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 ch18si32232418plb.76.2019.08.01.01.19.50; Thu, 01 Aug 2019 01:19:50 -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=IeSrybNX; 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 S1730392AbfHAITt (ORCPT + 14 others); Thu, 1 Aug 2019 04:19:49 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46677 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730381AbfHAITt (ORCPT ); Thu, 1 Aug 2019 04:19:49 -0400 Received: by mail-pf1-f194.google.com with SMTP id c3so10466826pfa.13 for ; Thu, 01 Aug 2019 01:19:49 -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=IeSrybNXM1FIuaHjdY8UGbg00YzSWruFMn1J7qNAW3drOxKc0UR8dxZDM5PD/UwY9x crfCdf8Q/xTPuaVROFU/r8eIsG9JXSdJGbjUk2DQH+rIPUUK8C3VNg2wcYriMmtqGNJT 7j4NI63W+dSuf3NJWh0T7mG2Cw8wSakGtzWws8D97SnvRP6mpWDaG62Q8ukYZh3xNWAS bHT+s5u0WQ5XjcbNpFziJfAkntmqjT2wtaDVQ0RzER6/blMnFCrZhvS1x/2b6IzqPe2o t8qPEVYRxsRguSB7/QUcvmTdeatQF8Of3ll29ZRRZ4t3FmlNSiDoNElGjxoS23J1Irhp k1wQ== 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=nIcZqAAPlyPDPnAQrrtIEvtwXwaahJwdvohC56k2o1hW5qg1xCIVX6mONruT5HBFqj cZlExZWZc1IaOy68Eg/gRV7BciB5gnwwSTXp4oiF00z9NPCBSZ0/jRQaEoLNXYOcitsF 6+LvKktu30HbO+2jRJ34v5g5r6ZrPjfg2bfBCoD7Lnl31oMASmO9HPs4Q9v4NnSitGv9 MaufcW+jV+envvPWZG/kHh606tHjDwpoIUwrxxJIslj2+PaVYgsRAglLpFtbEP7DOMQU UBlNi8IxD4TfRxlOa4EFxiun5jT/Kbk9IZXKzd3EH0tcITjfSOAECXrw5VBK8kOcP1ha fCvw== X-Gm-Message-State: APjAAAVg+1lEXbk6qwJU8nxDPoWV9agKOJBTwcxdqA8Zbt/11Cm/gsu9 yyW78vQm34tZTioWHFLRwzR1X/hRxeA= X-Received: by 2002:a17:90a:1ac5:: with SMTP id p63mr7090797pjp.25.1564647588607; Thu, 01 Aug 2019 01:19:48 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id f64sm74385803pfa.115.2019.08.01.01.19.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 01:19:48 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org Cc: Viresh Kumar , Julien Thierry , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com, guohanjun@huawei.com Subject: [PATCH ARM32 v4.4 V2 05/47] firmware/psci: Expose PSCI conduit Date: Thu, 1 Aug 2019 13:45:49 +0530 Message-Id: <9af0ed2a4a54549532931e98643daa5ed274ac8f.1564646727.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;