Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3136207pxb; Mon, 9 Nov 2020 03:41:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1t5VGiopGX3IKV5aEfcxReA6YGZ1NHp5vtJ3cjyMU+q1tzKJ83CdhnSP/xNYsMfZJFzD6 X-Received: by 2002:a17:906:8812:: with SMTP id zh18mr13786003ejb.361.1604922063166; Mon, 09 Nov 2020 03:41:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604922063; cv=none; d=google.com; s=arc-20160816; b=YDyoP8UI6mUwu/SZZyw/tROyQb3284H257DJ8OusSCWqyuDdvbb13VKH9xa5NZCWYG aJt241RHn78eQhhz6hTulYW2cETGXSog9bOrRoFduO58AgMFX4YJ7nUS0p+Kp2sd+G6X 8HcaPiBubEXrCm897yEERLbFWWz3LizulSRCVDcCbaR8gfcaWNcJjHKx09ndGzDVlfVS 8azW7lKbp3rWvVsXJfo6Ry/edBkxRat3aw5sbbvQPX/BqstxuU1EpcAYEqhiqZzNXvJ/ rSJO++qRhEG9BE0D6f0+4bXXxksXjTA0HsGf06BzmFYFCAM97lWmfl8hV9Tc9hTUEHZL zDDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pzuHJ5pL7t9NbTEFogq/8Y23xeOn+spq7fy4sQhhUGw=; b=C2LUYQ3n8df6q3IibSa3sliHHVK460MSU63AGLu7/lrOdQiK5be70UCweH7FemTm0m JZWaX1pjHdy8+q+1AmtUi97Es66DWbj42FdOWgnjP95z9ACrJRDcxDIeWEH2i8IgBIEo nlpZ5AHMt2D/EWucWSPmts7QC0hKQgAFHzzou6USa3tu8XI4KDeMXgzMYbl61QWlNdRd 0YQPHGtO2iSMbXUQwUGNaHsfQHs4EQSqXpRMNr0y5XWfBANBfqGXsi24cV9wGzIMD9g5 lIwu4brc9VTprphFxHs/Q3TkEbWhiBseonz2Ap5XT8aTcTo+DtNKCa68nUjr/QWALgaL UOkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WWfakKwG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si6712986ejb.615.2020.11.09.03.40.39; Mon, 09 Nov 2020 03:41:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WWfakKwG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729452AbgKILcr (ORCPT + 99 others); Mon, 9 Nov 2020 06:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729159AbgKILcn (ORCPT ); Mon, 9 Nov 2020 06:32:43 -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 35810C0613CF for ; Mon, 9 Nov 2020 03:32:43 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id s8so1209977wrw.10 for ; Mon, 09 Nov 2020 03:32:43 -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=pzuHJ5pL7t9NbTEFogq/8Y23xeOn+spq7fy4sQhhUGw=; b=WWfakKwGe1YouBXlERhaEppVHXGHFfpGO6bW/qiGXsfrnx2X9Lb/WvrzQ1BmW5RS/5 zHLiFC7sJhMK2RlWUkklFx+QINQJt1MhJ3kSxKkvhs0XrDOB01DonqHn5Emvim+ioae0 mzXqV6OD7rZ1HSeAlSSDGTafFQGnM2ub6vcj/8Xmt2enbD8TouDTCyPN/DRyQDDtF59k mWUJLHIx+sJoEQIEa+cOmDc1ijKk+N4l7rd1M6uJti+h61k4Lpgatharg5X9b8N/s2tO 3ys6wT2kD/LsHwgKSgmM2snJbpUNI7giobddJY6xsKxnsjnqKVOAuK1ozzqZAQuNkoXW p8NQ== 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=pzuHJ5pL7t9NbTEFogq/8Y23xeOn+spq7fy4sQhhUGw=; b=XjRb1Vhs5F8hUyfm6VrhwJHEi28Wa5NqTlmv/RSQxCFDy6mie5j6rcdQnZGnOwaQDJ ruvfugGZhnJiED5rnpvFb1K9JkVAdxHqL1A93Z5k7uNQkqKI3gmlkBU98PGhdTIXR3pm sBnh5v8LO4hC6yCF6cf2TDGJbvddjUafLdJM26NAOhc27WtMKdbDJBmLvGka4zXH+3Sw h/PLUYaSnW25OxBSkyVoqsjB8ZBq1TD6lp4C0CtlTPBmKk/B3TjjpNNyzfPwJqABgC9Q sBFCBu7e+UDCXxrVR93GaBAkNLarKWWhyxAM27rbpmhvgswTuliLQHT8rllUm49/if5x aHXA== X-Gm-Message-State: AOAM5300NmRjEU8X38Fefti+o3/FGqWxRGf7C7J9GoOIUR/vyBRVCGir HEDWEZs2Fp6IokICHtIM6Vzo8g== X-Received: by 2002:adf:ef48:: with SMTP id c8mr17832902wrp.399.1604921561816; Mon, 09 Nov 2020 03:32:41 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:209d:10b7:c480:3e1f]) by smtp.gmail.com with ESMTPSA id y20sm12191934wma.15.2020.11.09.03.32.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Nov 2020 03:32:40 -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 , Andrew Walbran , kernel-team@android.com, David Brazdil Subject: [PATCH v1 01/24] psci: Accessor for configured PSCI version Date: Mon, 9 Nov 2020 11:32:10 +0000 Message-Id: <20201109113233.9012-2-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109113233.9012-1-dbrazdil@google.com> References: <20201109113233.9012-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 host PSCI proxy needs to be configured with the same version used by the host driver. Expose the PSCI version used by the host with a read-only accessor. Signed-off-by: David Brazdil --- drivers/firmware/psci/psci.c | 11 +++++++++++ include/linux/psci.h | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 00af99b6f97c..bc1b2d60fdbf 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -49,6 +49,13 @@ static int resident_cpu = -1; struct psci_operations psci_ops; static enum arm_smccc_conduit psci_conduit = SMCCC_CONDUIT_NONE; +static int driver_version = PSCI_VERSION(0, 0); + +int psci_driver_version(void) +{ + return driver_version; +} + bool psci_tos_resident_on(int cpu) { return cpu == resident_cpu; @@ -461,6 +468,8 @@ static int __init psci_probe(void) return -EINVAL; } + driver_version = ver; + psci_0_2_set_functions(); psci_init_migrate(); @@ -514,6 +523,8 @@ static int __init psci_0_1_init(struct device_node *np) pr_info("Using PSCI v0.1 Function IDs from DT\n"); + 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..5b5dcf176aa6 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. + */ +int psci_driver_version(void); + struct psci_operations { u32 (*get_version)(void); int (*cpu_suspend)(u32 state, unsigned long entry_point); -- 2.29.2.222.g5d2a92d10f8-goog