From patchwork Fri Mar 9 09:07:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10270379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4279860594 for ; Fri, 9 Mar 2018 10:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 292322999B for ; Fri, 9 Mar 2018 10:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DF2529D4D; Fri, 9 Mar 2018 10:22:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 693622999B for ; Fri, 9 Mar 2018 10:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=80nKGc2+Zdi6uSXYYZaJsw9AO2iUpVENaqno9EFS0rA=; b=MovH6rOj32PupRty0Sxf/VUeYF dkstVWrUbKcXQPDGxFPS5oPLKUpHPJzPlMijUKfaRj8GEkls2jW5Rfq/vFKffh9la2vH/C+5qDM+2 9zphWXV8fIPSuZWjgdz0/mvmWPwVwia069JcxvfvRE62tca/22pmM1jxF33YosrRUQKFd71AGngI9 NCgbOCh08DoDLFHA3mpz0Pd+5lMSiQQcl2DgZoJyHeMmOTHCbh2Gqq2m/9uEk5cLtgbt3vNxvuC2Z HOugZ1EOG0IfdI8Lefl4gciHNLZFCftagZTYE8mQppVVI/6ERBRHRMyvfDnazvPFL0ATMlPXF8Ru3 MT0nB4+A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euFA3-0005Zb-SX; Fri, 09 Mar 2018 10:22:03 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euF7W-0002qN-Ju for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Mar 2018 10:19:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Gp3eSpAAUGQXvv1okN5loNVx4sRO7TAz19EuZTPZ8ZM=; b=MM878hnKOvSUEQeQQTZUnHFEb lsJmc3djDKhUfo9IzacR2p8wag7dY1pP/CL/Ry6kk+SSJcLYhTT0178DdRKjMPshMRDswYSPg6+Do uCnUDPFao8Aod0CueeneMcgPcl2xOfd3G1o9Kj9onkki1PNxBkaRFuYzeq6/3SKZ54vaLlaRqPYUD KwVT5LPLJQR76qRbWaRHJvc1KSWTzJV//uIcAm/yup3lkJsCKLa3nJb260C7nLc22Wv8GjQ8uJZXI 6WE4THVzi426OeAoUDd5PCskcIjz1+dMvp5gP4kyZS8WHoqS/YxCtrHiE+/jKE7ztNn4tYKok2QTs wQqF+XsYQ==; Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]) by merlin.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euE4d-0002jq-NR for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 09:12:24 +0000 Received: by mail-pg0-x244.google.com with SMTP id g12so3341126pgs.0 for ; Fri, 09 Mar 2018 01:12:13 -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=Gp3eSpAAUGQXvv1okN5loNVx4sRO7TAz19EuZTPZ8ZM=; b=Adn4+w5I+1ft2iThiYr+0NV7oZeOL99Yyyq/9EHstKQInv+CoUrRemCmDGWmKevjI4 CQFyONJ7d208+mmGgHC5vwyi92MaJdDCcvx7TMaehpIPt9JRupki0nV8+Pa2dxh/LoCD 85yH/ld1mO5XWqAmt6oiIV8Wz2eSDHng3EqoI= 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=Gp3eSpAAUGQXvv1okN5loNVx4sRO7TAz19EuZTPZ8ZM=; b=ZgRJlFI+XaSU0fN/2w3fhIzjos6cncbQ9tz4W3Cj3qIgbe29U41bme2d3EpVS9bTsF /cX/riJN+BAADChc6mRsHEImSfgpLUy4Ct2EfWDaJz6aYU4SW3SjKPyk3Dd+4aORG7Pw ifTxUa+Ghv1gtyJQofiZxN3yjnEnfb9sZ8xmb2mpCg54r6nvasb6uQ/XWywF8at+9V7G fRRqD+qkYi+cYVs0l+T1ZBVDwFmA6/7LfuituMJEi5KEqMQJVNzHtiq9XapUVUjSZTDR NaSNFWYo3RkrHFZtWi3jX3Nee2+2o8yB4MLxESUSj9pCoPrmhwdRt/8Fy1f3hZm4SL7x li4w== X-Gm-Message-State: APf1xPADgAlQDrhOs8NZf3yZtswzNJy0bICcHcXRpqHAK4TEtvIRkf2B 8w7kV8y1HjJkVlcjitnLzTg6jA== X-Google-Smtp-Source: AG47ELs+9+K5eK4Zk9H4L0EZqz4FUQomZEZhTn8KYh2TUPblfcNAehm0woGWf9ndDA4SlS2zrVwUog== X-Received: by 10.101.87.132 with SMTP id b4mr23231780pgr.282.1520586731553; Fri, 09 Mar 2018 01:12:11 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id c7sm1961752pfg.36.2018.03.09.01.12.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 01:12:10 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , broonie@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 35/39] firmware/psci: Expose PSCI conduit Date: Fri, 9 Mar 2018 17:07:18 +0800 Message-Id: <20180309090722.26279-36-alex.shi@linaro.org> X-Mailer: git-send-email 2.16.2.440.gc6284da In-Reply-To: <20180309090722.26279-1-alex.shi@linaro.org> References: <20180309090722.26279-1-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_041223_794163_6CDDB1A0 X-CRM114-Status: GOOD ( 16.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alex Shi MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 0f35aebb30a7..9dc559955ce6 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -55,7 +55,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); @@ -206,6 +208,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; @@ -218,9 +236,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; @@ -482,9 +500,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;