Received: by 10.192.165.156 with SMTP id m28csp1829137imm; Thu, 12 Apr 2018 04:21:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+2CruhlHKpaCmK3SKdp07dj+dmvVVaxXWcgHhVj6snSK0xq+58oQIvDP2QyoYPNQDugfZI X-Received: by 10.98.59.4 with SMTP id i4mr7353967pfa.26.1523532078044; Thu, 12 Apr 2018 04:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523532078; cv=none; d=google.com; s=arc-20160816; b=akJLSv778dUweM/6HpR2+poCcAe1oATHZHmCSvoKp4k1lkMdpiITz26ROAjzyYHGTi Qa3uzj3GbqhsJ2W5aeqGxRctAOjZKyA8jyx7NRWfUmn/6dnqWgxmfpw9yG7G3jLvixQY YWXbVji34+HZi98d+SJ6w5o/pH3Jyw1AWSDjuY6bfltyaYIxZaAPPa5OsWZcrrfhjH6X E64EhCf0fuDTtj9vjeOFNDgLX9a8SfitghLZ/Z5K0/4tC18dpgOjQ7DaclEh+u393im3 kkgFIv5oI0vannk95xNNyDOPQn47/Qo97Ambo/Fnp/om23ZZbZ71iiRaldhvi/5HPZRW oyRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=lZist5inIuwEEJSIxPuSJiISOfPfHnqhezws3XCN9lc=; b=Mx2GqK2gBn3ZeqZgoHO/d5FL6s9/19fn/NJCGSDGu89bmDqXJq6ZrwNn4d7rsEVX6x 8szKbJKHsAq5Zp7pYR8pQoo0gNHpqQRbP3ruJVOQKj77e6aQ8090bNmtdWyv8+qfpu3q zJAP4qDTQyEPVxwbBVr23kYhc+wQfOIouurfw+8rdRG6ZCkkYuMC1u4pfuln/ruVwn+5 8WpRP/6bfijbqNWSIaDDtRHvxTzqH+edO3jBHpPpNrJX3xrZQhFtKkYnX3ma0pZGRCr3 z/FDReSdsFMpKv4lgA23n3qtf7FDYKv+nmNJXU0qPN4h8WmFQQU5eFa0OTWJGcIWYxcp 69+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WN9dcA8v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si2367677pfl.175.2018.04.12.04.20.41; Thu, 12 Apr 2018 04:21:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WN9dcA8v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753305AbeDLLPX (ORCPT + 99 others); Thu, 12 Apr 2018 07:15:23 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:41084 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753217AbeDLLPT (ORCPT ); Thu, 12 Apr 2018 07:15:19 -0400 Received: by mail-lf0-f65.google.com with SMTP id o102-v6so7097317lfg.8 for ; Thu, 12 Apr 2018 04:15:18 -0700 (PDT) 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=lZist5inIuwEEJSIxPuSJiISOfPfHnqhezws3XCN9lc=; b=WN9dcA8vguQOooj6w8FPqwlbVFl3avmSvgi73nSPSzIzPMt8tyGkFI0Aiby80guIfU YGdl2aAYZKkJ6NQjpXEKOXtFwGgPwNn3MdrB9os5ALVKnpLGbDKQVwxOO6LS/G7aIWdR VxD1XqQdMweeUzk6WjzD3vsYD/hdI/Dw7HslA= 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=lZist5inIuwEEJSIxPuSJiISOfPfHnqhezws3XCN9lc=; b=sVLtASeAsyTAUYn8nca7iMI+ab5tgvMi87dBwSCHz3c7tExZBmLFIuhUYOVHV0wAtT DxsLiTw4NvSwWoSGcXrGq47BH0bLqzMJtte85xKXzSOVVXca3RWBRC2Jpg9sOA38V3ko t9Bv3txHgVwxiJpxwvPcCttx/NGqypOPaZ0/hW71MXqfJm8tSWYq+JiJZ7OURYCb8ti2 RYuJz/yqJnwWnwEHAI5b2YtuYfQMNUXA32y6bLhbnHZQ05pRU2Pk0s6/lMQZh5s3L3a2 RUzVgsgw58GI45c7cv39c1dWGcBrw8HeIa3Ujxb2xn0uSIyGaeVltdGr1eTkyp8jvjd4 ZHZA== X-Gm-Message-State: ALQs6tDg7RHn6ao341oaA3JoRxB/u5abTerP5lpLHCvFN/ocuQSOKhAz zhkJGlRK3h8tIOPrOOM+xQ+BLQ== X-Received: by 2002:a19:9c0d:: with SMTP id f13-v6mr5201837lfe.9.1523531717327; Thu, 12 Apr 2018 04:15:17 -0700 (PDT) Received: from localhost.localdomain (h-158-174-22-210.NA.cust.bahnhof.se. [158.174.22.210]) by smtp.gmail.com with ESMTPSA id r29sm543187lje.72.2018.04.12.04.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Apr 2018 04:15:16 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , Mark Rutland , linux-pm@vger.kernel.org Cc: Kevin Hilman , Lina Iyer , Lina Iyer , Ulf Hansson , Rob Herring , Daniel Lezcano , Thomas Gleixner , Vincent Guittot , Stephen Boyd , Juri Lelli , Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 22/26] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Thu, 12 Apr 2018 13:14:27 +0200 Message-Id: <1523531671-27491-23-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> References: <1523531671-27491-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case the hierarchical layout is used in DT, we want to initialize the corresponding PM domain topology for the CPUs, by using the generic PM domain (aka genpd) infrastructure. At first glance, it may seem feasible to hook into the existing psci_dt_init() function, although because it's called quite early in the boot sequence, allocating the dynamic data structure for a genpd doesn't work. Therefore, let's export a new init function for PSCI, psci_dt_topology_init(), which the ARM machine code should call from a suitable initcall. Succeeding to initialize the PM domain topology, which means at least one instance of a genpd becomes created, allows us to continue to enable the PSCI OS initiated mode for the platform. If everything turns out fine, let's print a message in log to inform the user about the changed mode. In case of any failures, we stick to the default PSCI Platform Coordinated mode. Moreover, in case the kernel started from a kexec call, let's make sure to explicitly default to this mode during boot, in case the previous kernel changed the mode. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci/psci.c | 38 +++++++++++++++++++++++++++++++++++++- include/linux/psci.h | 2 ++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 463f78c..80c286d 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c @@ -691,9 +691,14 @@ static int __init psci_1_0_init(struct device_node *np) if (err) return err; - if (psci_has_osi_support()) + if (psci_has_osi_support()) { pr_info("OSI mode supported.\n"); + /* Make sure we default to PC mode. */ + invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_PC, 0, 0); + } + return 0; } @@ -723,6 +728,37 @@ int __init psci_dt_init(void) return ret; } +int __init psci_dt_topology_init(void) +{ + struct device_node *np; + int ret; + + if (!psci_has_osi_support()) + return 0; + + np = of_find_matching_node_and_match(NULL, psci_of_match, NULL); + if (!np) + return -ENODEV; + + /* Initialize the CPU PM domains based on topology described in DT. */ + ret = psci_dt_init_pm_domains(np); + if (ret <= 0) + goto out; + + /* Enable OSI mode. */ + ret = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, + PSCI_1_0_SUSPEND_MODE_OSI, 0, 0); + if (ret) { + pr_info("failed to enable OSI mode: %d\n", ret); + goto out; + } + + pr_info("OSI mode enabled.\n"); +out: + of_node_put(np); + return ret; +} + #ifdef CONFIG_ACPI /* * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's diff --git a/include/linux/psci.h b/include/linux/psci.h index 8b1b3b5..298a044 100644 --- a/include/linux/psci.h +++ b/include/linux/psci.h @@ -53,8 +53,10 @@ extern struct psci_operations psci_ops; #if defined(CONFIG_ARM_PSCI_FW) int __init psci_dt_init(void); +int __init psci_dt_topology_init(void); #else static inline int psci_dt_init(void) { return 0; } +static inline int psci_dt_topology_init(void) { return 0; } #endif #if defined(CONFIG_ARM_PSCI_FW) && defined(CONFIG_ACPI) -- 2.7.4