From patchwork Thu Mar 1 12:54:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10251387 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 E1C39604D4 for ; Thu, 1 Mar 2018 13:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D11681FF81 for ; Thu, 1 Mar 2018 13:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5BF82013C; Thu, 1 Mar 2018 13:27:40 +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 4115C1FFB2 for ; Thu, 1 Mar 2018 13:27:40 +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=CQMQuQ2QI9zwc3UX9ivsi4SLEA9Q1OfhdS/D6+w2Kro=; b=AD9yLykbeAisR5SkH5jcPl2GuH joU+X8b0I5Dm5cDpjrqhqVjGUOd7tFktHNzU1ImfwQHiBrOdfy/YR+HE61tw32UTFdSYBu3Nfg/dZ 8MA9XUPApEIsabCiG/3tKOQP7H9D7dcved+C2HcbT8UovZXVpDSGsUzEaUqhEK8BRqmdJMwPB61b2 xLw9eFJiafJzkLBGQm4M6jBAzfFACY7iMXuWwRKed2VdohkLLoOsqDwN07L93JesaJUvsHlSMCJ7m 68BmkdoDuztkcAoDl9OSPkEOqWWvvtRmG6srieSow/ev9xV1AFBT+O3xDTQlCKDX5sKdsjOpPDSAV nadgC94g==; 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 1erOF8-0000a3-QU; Thu, 01 Mar 2018 13:27:30 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erO0H-0005NC-1i for linux-arm-kernel@bombadil.infradead.org; Thu, 01 Mar 2018 13:12:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=fRXfZa/pqv9cSqsOkccAZE6y+ qb75VFmrmzgxBzYU+AODLfxA3VQUe95AEYroLchWLVcpx+tT2RHMU2/I0vtuWskf4NUs+/vN07M12 naIWFt3tpt7vtfYXY5o3AgrGTaexyTA5UXvMZ9GcDHgKblJqZkXkKKqYaoC7bl09PE6nOZl8wOVMC K2LcW4qQYZEr6/KyN8RkLJwJlnUrWacvmBhvPzX7ffGSzYSLVtIN4DQunbBM5Qjvub0HeIwaDIq/X 9TjOunAo9iXMQ/jtXskVWio+ch+E8ONRliEgKzW8itG1HSxRBMjJedXLodGInWn1Xe8CFGpW4SUgG op1uy54xQ==; Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erNpO-0005Iv-RA for linux-arm-kernel@lists.infradead.org; Thu, 01 Mar 2018 13:00:56 +0000 Received: by mail-pg0-x242.google.com with SMTP id e9so2267606pgs.10 for ; Thu, 01 Mar 2018 05:00:44 -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=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=cD6/Rp3lDnHqh0fT/wnmni2DoWjyUxCJ4YN8useKtwZWLpatFiXbOZShawbt2vHpJg UYsR0eM+Cd79Dh1YEXxfb4M6nQGRPTw0+BOCH1zJSpGgJKVGhN0EsEdGBNiPaIeC9bNg sNcxuE4Wei3Y20W19JD8UDoef1R636+6x+on8= 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=JR0dWBMHXzRrhmbkXPj+t5C5z62Z2EIDM9UumhZBlIo=; b=sKC6ZzzVLOAxMHP2sW0kIRGZPBwn+uL5OGgLzHo0RV5ZjIpTqvqUlSacYy17EKgmf1 v21+6uUnop+/c68n3qPNKMNEBEMnFBvRVVRsk+KnpxjJKUZKiTcY0IIf7PhP9CR7/BP/ NlVTiefcWsXrs4JSbLPnkE5jsaqaY8pqOeuQ8VjyMMMHfsz+r0tBNncLifTVFuemY882 5nIOSzVDBK07vYUF9N0Afh9Wy/YWzr1QvKjayfXRu09yuD1yiIyU5xdQKAnkHl/zLkoS c/HfBrEDLAaFqmzVdfhIb5j5SRLG+RnHstxTXeCAxlLPecyh4EbIWhalQ5T4yWWP1Fnz bX+w== X-Gm-Message-State: APf1xPCck9DmJ34vNrdbmS9BgG6RHLflNxZUhru01+buVVhwCbFDRBEK NPtPBnVQUdDyv10euizF9aEgxQ== X-Google-Smtp-Source: AG47ELvIy9+GRaoxIoQvHudoFnCGLxOqiWrkP5ZK6Hu5nCo0SCr8gWbtErJFS04iZkUmk0/36xZ3yw== X-Received: by 10.98.15.72 with SMTP id x69mr1892866pfi.16.1519909241810; Thu, 01 Mar 2018 05:00:41 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.05.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 05:00:41 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 40/45] firmware/psci: Expose PSCI conduit Date: Thu, 1 Mar 2018 20:54:17 +0800 Message-Id: <1519908862-11425-41-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180301_130054_870849_CD57B120 X-CRM114-Status: GOOD ( 17.05 ) 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 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;