From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3BB7C4741F for ; Wed, 4 Nov 2020 18:36:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6286120756 for ; Wed, 4 Nov 2020 18:36:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="i5BcYNcM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732418AbgKDSgo (ORCPT ); Wed, 4 Nov 2020 13:36:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbgKDSgm (ORCPT ); Wed, 4 Nov 2020 13:36:42 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A791C0613D3 for ; Wed, 4 Nov 2020 10:36:41 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id x7so23173299wrl.3 for ; Wed, 04 Nov 2020 10:36:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z4vcpIwywIa5rhEfDa3o17Qy4qQsjexN6rFsZvVCzvI=; b=i5BcYNcM6qzN9gIC6Zos02dnE8rZIudFYfeZNcnVwst4EKmc2q2Ms0tbFD1K145rhN EyN53gm3SYcjXj8YeQ6px/NtuPMVkpv0swt2sKzFjniFPQHXjOXIiS7QGmMPwHCKGjEH 0Y3xO9i6IiXIkvBXE8sXwf5az6q2KrGHDE9VP6ovxCl47Hjt9bnzJ5X6mSzWBWX9/rMZ sUhvIEaRKj3w2xnjFLkI0BbBArxSG2s/9yPW2CInP6hqnbPKsOM1QaOm07yVZubZXTzR RbNN8m8Nvtbbf4tTxGVyg9zdj3UxpU6TOXKsOOF9/VaDzNPIbU98PtEkTT04FBQeh4Mu +bMg== 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=z4vcpIwywIa5rhEfDa3o17Qy4qQsjexN6rFsZvVCzvI=; b=JZF8nftghOR1XNXuxDItKCOkQHDa1AcW2ek1neRvb73AmJcGsG3zwRr6ixq07OxIYA 2Q/EJrpk1JrjNflarqlnIIwYRJ05BLHMOn/6gwrSsusqwxq5zYQlIPbGDrhtM3S08V3M UmEGhRa18YQwoHCMDu9gfPDk6Nz/3Jit18MKC5P2qLtu0ri7hi8WSXCrMALPb1wU5nEw mPq/9SN0dDG9Exc/1y+icJT2s21Lk6m5xO6laygodO9H/L6WpOLABNpAzP217GCz//hA mer4YxHJ+l7sJE4eN0vRgPR1lhhnbtXRsNk+PI1XA8pT96Ew8PArxRKSaGC0ld0Ytfa8 uogQ== X-Gm-Message-State: AOAM531WyGIFjgEBnsvpCrz0Qw8IIWdHEAg7FFVIzyOVYKcHMUwEzxtM xAg3XWdTAeythVjZWtXIh0F+dQ== X-Google-Smtp-Source: ABdhPJzrzz9sHPqQ+PdVQq+JJJnWPJd6Kn6P7U2cR/hpaxn8sZnauzi5oOrw6gyAkzxG8ER6mhlOAQ== X-Received: by 2002:a05:6000:1252:: with SMTP id j18mr32575217wrx.18.1604514999931; Wed, 04 Nov 2020 10:36:39 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:c8d2:30f2:53c6:bc2]) by smtp.gmail.com with ESMTPSA id 15sm3271469wmg.1.2020.11.04.10.36.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Nov 2020 10:36:38 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marc Zyngier , James Morse , Julien Thierry , Suzuki K Poulose , Catalin Marinas , Will Deacon , Dennis Zhou , Tejun Heo , Christoph Lameter , Mark Rutland , Lorenzo Pieralisi , Quentin Perret , Andrew Scull , kernel-team@android.com, David Brazdil Subject: [RFC PATCH 01/26] psci: Export configured PSCI version Date: Wed, 4 Nov 2020 18:36:05 +0000 Message-Id: <20201104183630.27513-2-dbrazdil@google.com> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104183630.27513-1-dbrazdil@google.com> References: <20201104183630.27513-1-dbrazdil@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The version of PSCI that the kernel should use to communicate with firmware is typically obtained from probing PSCI_VERSION. However, that doesn't work for PSCI v0.1 where the host gets the information from DT/ACPI, or if PSCI is not supported / was disabled. KVM's PSCI proxy for the host needs to be configured with the same version used by the host driver. Expose the PSCI version used by the host. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 6 ++++++ include/linux/psci.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 00af99b6f97c..ff523bdbfe3f 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -49,6 +49,8 @@ static int resident_cpu = -1; struct psci_operations psci_ops; static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE; +int psci_driver_version = PSCI_VERSION(0, 0); + bool psci_tos_resident_on(int cpu) { return cpu == resident_cpu; @@ -461,6 +463,8 @@ static int __init psci_probe(void) return -EINVAL; } + psci_driver_version = ver; + psci_0_2_set_functions(); psci_init_migrate(); @@ -514,6 +518,8 @@ static int __init psci_0_1_init(struct device_node *np) pr_info("Using PSCI v0.1 Function IDs from DT\n"); + psci_driver_version = PSCI_VERSION(0, 1); + if (!of_property_read_u32(np, "cpu_suspend", &id)) { psci_function_id[PSCI_FN_CPU_SUSPEND] = id; psci_ops.cpu_suspend = psci_cpu_suspend; diff --git a/include/linux/psci.h b/include/linux/psci.h index 2a1bfb890e58..cb35b90d1746 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -21,6 +21,14 @@ bool psci_power_state_is_valid(u32 state); int psci_set_osi_mode(bool enable); bool psci_has_osi_support(void); +/** + * The version of the PSCI specification followed by the driver. + * This is equivalent to calling PSCI_VERSION except: + * (a) it also works for PSCI v0.1, which does not support PSCI_VERSION, and + * (b) it is set to v0.0 if the PSCI driver was not initialized. + */ +extern int psci_driver_version; + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); -- 2.29.1.341.ge80a0c044ae-goog