From patchwork Mon Feb 26 08:20:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10241591 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 AD15A60386 for ; Mon, 26 Feb 2018 08:38:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99AF829C93 for ; Mon, 26 Feb 2018 08:38:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E66729C9D; Mon, 26 Feb 2018 08:38:58 +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=unavailable 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 19E1A29C93 for ; Mon, 26 Feb 2018 08:38:58 +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:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CQMQuQ2QI9zwc3UX9ivsi4SLEA9Q1OfhdS/D6+w2Kro=; b=Kni35f/mZNlx7e I8AcWUndcppnGzR/Sb0EjMaHJQDNoKOyRhAtwrwb8LuoLMSNBlgwTiIOtN9R/wpfmULwwnehK4FI3 bTyxMqJNphDT/sR/O2KkZ2TIqU1yKmx4JPcpZhl0WrjoSh7a9WejlOdWSz23q51RKe3oVs1EezU1f gKSAxubgeWygYNfo0Q4qw7mjDGdzsQvL0aYV6wbqyhu3fiYiFW1lWKTZKC0IwAnI1PlPx5pQJm4FV 5P6/0csWqjwNmvnXjCQfHcLw41CdQ220vb54MjSwdMLIpS+tGf8HCcqjYjNaiubnxF59A1v01mhj8 TIqGcoODsNb0hWyvXBww==; 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 1eqEJ7-0005Tv-6w; Mon, 26 Feb 2018 08:38:49 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE7D-0004YL-Pf for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:26:44 +0000 Received: by mail-pf0-x244.google.com with SMTP id j20so2793547pfi.1 for ; Mon, 26 Feb 2018 00:26:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=huHrpEo6HLIOd/KCc5P5goXLlPyVPKyl03CHY/finVtxl91PHNnKqPl1/1YP2WqAsm NjdQMb7k5FS24kD+aFBkl9E5Mj/OfUQUs32hPUlH3OeRuMeUITA0wu0ISkHiNuH9Gevb LGTstrvHqEnLSBwKPgo7TG+lM+9ekuPdvnG34= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=oqPgVUxw9VkTtkdIJ+3qG0TKPuyeslzt1kdcIrNIkoC8oNhQJMZAac9NFDn3c6/met r1ukGlELEBr/xLgmukW3CIpAMAQ9Cl1jC7dq7dygzKyyrVpP6q5bXsZTtZDSYm0ojb9H 29yVP/S1GL+3nf1IA5fVAqk3CNtz8B2N5Iz8Na2OHT5DuuOXt4M6Srp1cEJa+ACc737j B+h3kbghSKyGXn8w5hAI+eVCulnETXjgDow5LzKV8yASjOkk8xWM0Oxv4H4BdT30p+Ap YcSYYQm/HuR5fAT7q80shunFY5hc2p1FRhm4KMKZKQaOgfQWHodhJxjzzulOoMujcXcu +JJw== X-Gm-Message-State: APf1xPDKMCJnpSLCFD6AL9/l5BZcfZkhb07PCQ2L7krenY7jev6emIxR rR0dTrUoFCWSHclp1wuD/QzfsQ== X-Google-Smtp-Source: AH8x227WHIv+AGasd75v7+PfrIYN5U34GJY/+eIrvDcuB2iVxLOU3POXs6CXS3SNK9tI71mLAe3+3w== X-Received: by 10.167.131.135 with SMTP id u7mr9827489pfm.50.1519633581094; Mon, 26 Feb 2018 00:26:21 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.26.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:26:20 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, Mark Rutland , Lorenzo Pieralisi , linux-arm-kernel@lists.infradead.org (open list:POWER STATE COORDINATION INTERFACE (PSCI)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 40/52] firmware/psci: Expose PSCI conduit Date: Mon, 26 Feb 2018 16:20:14 +0800 Message-Id: <1519633227-29832-41-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_002632_041724_8BC91328 X-CRM114-Status: GOOD ( 14.12 ) 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: , 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 9a3ce76..a49196a 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -59,7 +59,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); @@ -210,6 +212,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; @@ -222,9 +240,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; @@ -654,9 +672,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 6306ab1..66ff547 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -25,6 +25,12 @@ bool psci_tos_resident_on(int cpu); int psci_cpu_init_idle(unsigned int cpu); int psci_cpu_suspend_enter(unsigned long index); +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); @@ -34,6 +40,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;