From patchwork Wed Nov 4 18:36:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11881875 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 8CED8C2D0A3 for ; Wed, 4 Nov 2020 18:38:33 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB9D52067C for ; Wed, 4 Nov 2020 18:38:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="26OvdY22"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="i5BcYNcM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB9D52067C Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=QsNDoYj7D1TI1Ty4MINc8Id7KpCvD8UxMd6in/DR2+s=; b=26OvdY22QD/+cpVezThy41JGE t99KfZk464u4yg8p+oUCu749ia4DugnEBJswf1xiqqBuaMcntESED9H/HOyKwTK4w4vpZxgb0aVt8 4t5GiK7KxibiIEAxf4IgZ4MMhWt+nhmHLCx4dGzss1eviyJcM5TZRodAfo7/g+ygI5W2e54csYZhh APPf5fLrq3+Qam2FEx/eAIY6Mj0YzG+8ZvCz8qbzvM4hBf/DLhYi7zj3+anlGIXhj1+VR/eq90pE1 RYEOMjPGZkF4kbfaWE2n2E7h6WwVoiPa4yIYeuIsJt8KlqK2FFY0380oODbk2mI6pQqIOt1v6ljG4 tvmQi1ZUQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNeJ-0001eW-3M; Wed, 04 Nov 2020 18:36:47 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaNeE-0001cp-Q6 for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 18:36:43 +0000 Received: by mail-wr1-x443.google.com with SMTP id w14so23120906wrs.9 for ; Wed, 04 Nov 2020 10:36:40 -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=YRwQ1cgP9TMD0wUTpOnVj7owH0LHEz+qaYdYasgnjCXqjrhrHUSdQi6/h19HXN7k3u f7GDdYUpyFKqJUZ5bd6luMLpIAcCsGMvB6ZIjM6O2/Cod7DbFtnldLj7iqpAXYFnyHkf yIy8uN3pm+k9EKbCZQstPub9ch+Uy7saFC/GmQJR5i4p8dw0Oc+PRWLQhyeh0qXl2TCl NdeZLqDMj8RpkcMPHiMl42y/x1IGDF2gQfBav65aNmSObfQ8Tv6xKLAbiz7OlW3c13l3 qLYmvNgqr3qxjWLav59CyhtjOq8WGRwQHuofoiILBj2kNk2KIHsmzOwz5P8khjCFIBh9 gGqQ== X-Gm-Message-State: AOAM530JorYuKvjMHQKLAo/xLIkEL4abDyf+axXqTPXyYPp4rT86I99M MPuUOxCTjbNXQ8ptYng2meAIZg== 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_133642_895410_E1713DD9 X-CRM114-Status: GOOD ( 20.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Lorenzo Pieralisi , kernel-team@android.com, Suzuki K Poulose , Marc Zyngier , Quentin Perret , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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);