From patchwork Fri Mar 9 09:07:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10270183 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 AB0FC60236 for ; Fri, 9 Mar 2018 09:26:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A357D29D8A for ; Fri, 9 Mar 2018 09:26:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 978A929DA0; Fri, 9 Mar 2018 09:26:12 +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 1699A29D8A for ; Fri, 9 Mar 2018 09:26:12 +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=CVPXLtrZltCy899MZc5LgSjuaj3W9bmUmm07TewfTRw=; b=eHJ06jJR4vT4j9O1vbFgk4ZCL1 r7rGOxp2m0Xw3Q+b5wIIJzzCgRr4/jtJl435DqTx4ZLKIaayqVy9HccEopAsfkMnP74hIZgydtuUX YWGm1F6jG0adzDZg6NmjINqDIklnQN8GpXmWXUZxWqIESsVQkudg3OHz35uj4T4KAUZq0YH/gDTZM OonrT/1zm86XgqCloPApiYIkgeGf9vxJCmJglH7jHOBcaJRsmwDFRq441F07t5qx8V0SZbUvvMMAJ E881ex+W9Id+CB4H/TlzT36+x7jycz/ey/aXIhKV7V+f8BbxaEsePjrli4b/qqZZw72r6ibmpl4Ug kfiCo/tQ==; 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 1euEHq-0008LU-17; Fri, 09 Mar 2018 09:26:02 +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 1euEHj-0006YZ-Jx for linux-arm-kernel@bombadil.infradead.org; Fri, 09 Mar 2018 09:25:55 +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=x2YC0Ct4Qr1GrJ4ZMTuFY2w9ZH6He3TSMo6/WBbz1Sg=; b=SqRW5tIowap5/gqdh8EWzWusY ab/QzrSjm9Zs4yXurqst74JkZGYjnLXcpsg78hmIRxzfWEtH1hd8ivW+98Tgng5tKpqHp94jlhtvr 1TS1eVlreBMJzHMB4b7NRjuxBYeGsbbwJYa6X/OIjB5nhUcr5lXwFToYw6h8YKl2w2J5fSHC4g044 LwXxsdr5GznMJ9U9jJGirML1uoc5Qq6Ee/7G431MCKObLhBHi8eXa81x/XtBsTyjc8rBUMMFx8VDT o6B9emXOb791gL/hWMY9jHHATXzhkYTsOxzL02bPUUGYhFJa0mn8EE9S94XHjTBnoxpWWSbd5/g7r xgvzVEtEA==; Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euE4l-0001nx-0J for linux-arm-kernel@lists.infradead.org; Fri, 09 Mar 2018 09:12:33 +0000 Received: by mail-pf0-x243.google.com with SMTP id j2so1049620pff.10 for ; Fri, 09 Mar 2018 01:12:20 -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=x2YC0Ct4Qr1GrJ4ZMTuFY2w9ZH6He3TSMo6/WBbz1Sg=; b=heZsXTS/TsST7vyIL1wC5OQiEmyM9myKvuLQ0eR5Wx075N1rMblDrYVtR8VtpFw//X AfTcjjDB8pRdZhlYkM+CXhFMCI1hW4xDUAMSItbe+ky6sqkPdznEJ0Ja85wtN0b1IE8r rGdkB9iU/L9hzowzBhnuLAlXhwRUgazOS1TAQ= 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=x2YC0Ct4Qr1GrJ4ZMTuFY2w9ZH6He3TSMo6/WBbz1Sg=; b=OKq0k4p778WoIg8+KHNMLpBoEVZz9HEa4cbR4X4E0fBE25cfU0CzQD0KlrjKjO6MPy Hw0XxhjQlcOnP2oYaI1KNN3h1Kh8GENWN+ykB9HyzvfAi/A+O1DwOlbUjL/eA3d4St+h 0YE8qBghSQMjcQN4wXKruTOt+0MZ8IMQvHDOKlk97y+DLetoR9FDSzhhgm87H6Y1emt8 CrHAaefm9WRpPkFTIj4BNm8guFGFhpU3UTljJSc3C7Ycxoyv4UvNY/b3ey5p/BKzZBIz khWPCDLgEk744vYbZm/p0dvHVxGqrTkwyjI/XbTmvTonAteSyEMkQdG6bnQYxOESIqf1 yuOw== X-Gm-Message-State: APf1xPAyA8nCimZaKrKWMNhtq1eo77yzMqtmWo51E2rHzlaeLzArxO+f GhePtnyuvKNREDYiJvXfikpxVA== X-Google-Smtp-Source: AG47ELtdj9JcVwoo5ASc5rTDkwNJcB6AQKFK2nGb+eyEznC7ewd29PRMNMZ3PW+BuYmd4FsL7HyDOQ== X-Received: by 10.99.186.73 with SMTP id l9mr23185351pgu.83.1520586738859; Fri, 09 Mar 2018 01:12:18 -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.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Mar 2018 01:12:18 -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 36/39] firmware/psci: Expose SMCCC version through psci_ops Date: Fri, 9 Mar 2018 17:07:19 +0800 Message-Id: <20180309090722.26279-37-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_091231_041582_E876F18F X-CRM114-Status: GOOD ( 16.87 ) 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 e78eef554a91 upstream. Since PSCI 1.0 allows the SMCCC version to be (indirectly) probed, let's do that at boot time, and expose the version of the calling convention as part of the psci_ops structure. 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 | 27 +++++++++++++++++++++++++++ include/linux/psci.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 9dc559955ce6..0a915a0a5a8c 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -57,6 +57,7 @@ bool psci_tos_resident_on(int cpu) struct psci_operations psci_ops = { .conduit = PSCI_CONDUIT_NONE, + .smccc_version = SMCCC_VERSION_1_0, }; typedef unsigned long (psci_fn)(unsigned long, unsigned long, @@ -339,6 +340,31 @@ static void __init psci_init_migrate(void) pr_info("Trusted OS resident on physical CPU 0x%lx\n", cpuid); } +static void __init psci_init_smccc(void) +{ + u32 ver = ARM_SMCCC_VERSION_1_0; + int feature; + + feature = psci_features(ARM_SMCCC_VERSION_FUNC_ID); + + if (feature != PSCI_RET_NOT_SUPPORTED) { + u32 ret; + ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); + if (ret == ARM_SMCCC_VERSION_1_1) { + psci_ops.smccc_version = SMCCC_VERSION_1_1; + ver = ret; + } + } + + /* + * Conveniently, the SMCCC and PSCI versions are encoded the + * same way. No, this isn't accidental. + */ + pr_info("SMC Calling Convention v%d.%d\n", + PSCI_VERSION_MAJOR(ver), PSCI_VERSION_MINOR(ver)); + +} + static void __init psci_0_2_set_functions(void) { pr_info("Using standard PSCI v0.2 function IDs\n"); @@ -387,6 +413,7 @@ static int __init psci_probe(void) psci_init_migrate(); if (PSCI_VERSION_MAJOR(ver) >= 1) { + psci_init_smccc(); psci_init_cpu_suspend(); psci_init_system_suspend(); } diff --git a/include/linux/psci.h b/include/linux/psci.h index e071a1b8ddb5..e5c3277bfd78 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -30,6 +30,11 @@ enum psci_conduit { PSCI_CONDUIT_HVC, }; +enum smccc_version { + SMCCC_VERSION_1_0, + SMCCC_VERSION_1_1, +}; + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); @@ -40,6 +45,7 @@ struct psci_operations { unsigned long lowest_affinity_level); int (*migrate_info_type)(void); enum psci_conduit conduit; + enum smccc_version smccc_version; }; extern struct psci_operations psci_ops;