From patchwork Wed Mar 14 16:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 10283179 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 1ED15602C2 for ; Wed, 14 Mar 2018 18:10:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0319328606 for ; Wed, 14 Mar 2018 18:10:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EAF47285BD; Wed, 14 Mar 2018 18:10:51 +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=unavailable 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 833F8285F5 for ; Wed, 14 Mar 2018 18:10:51 +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=NCKOPrETLvI1nRkdra1P2NpBEEUKRi14Q3P7b9SO2O8=; b=kWR35iVoaJO9aEPjk1r2IYdPHF NfM1WOkGUqpx/fS+pOaI5mvneSpFCYcgXwBZ4IQM7l0SicG0YbtF8iKuh/H++4qf5FjKG3KwlAHj1 BWMnMY1aymzQuT/kr1z+vGIyhRzKZqAcYCmjGcvHKTmcgJ/lW/ZiZILzbJSwuiYCOoy3RG1gTsVz2 QaOR6pVLxRTpInhCN4nprWQH286aaCOJ+CHfkKNlNEQwQf8OV6DlAZNB3uphA0J97dvtOXguo6M06 JuPaWKVlEF3Edk00dfzFRkkdYdjMJJ/fsvSTjOyVGCp6xq/p4AX850H6Uvrq8PatzbsZ5Ra52/O9p NKspeSSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewArO-0007zu-H3; Wed, 14 Mar 2018 18:10:46 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewAqU-00064J-T2 for linux-arm-kernel@bombadil.infradead.org; Wed, 14 Mar 2018 18:09:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=mq4+J0pC2Wn7IvcR83xeCnLTN s0D7UY5PIjRXGj7lvQeU4WqZnwYJuaUvTe9gCnkPAxSypUe4v1XlMjZH4NbKvPlH3OnBD11KUcmHU P858yhgvdtNGmchWUPapK09QllEaUXuUVQ3sgMZ9eu9qlDGJ4rsLQnrzu6dXH68PA1K1ED5LcxEcp pI/HrqarXnzqh+aK6Q3wiYfZSMktLnVbrgVedWBd/ti984fhE/41P1TXISNDj7JDvdqE2N4AVCZj0 42NTJeK4Au4jLT0ioP0Vr2uaxCHft6IYMuJPa+VeneLk6cnookN4wTrNzZo3UdJseUZUVMZHYIQQJ ZCwNgyX3w==; Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ew9kl-0003Sv-90 for linux-arm-kernel@lists.infradead.org; Wed, 14 Mar 2018 16:59:52 +0000 Received: by mail-lf0-x241.google.com with SMTP id y2-v6so3754303lfc.5 for ; Wed, 14 Mar 2018 09:59:41 -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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=bJsp5eRlmCMocTNQ0XY0nAB/13CIzu81IWmweUGbKsK8ozyRxYPacnWimkKl48EXPE GAqSWKOQ9UMM3xsRUbOu+JtVAvrmofhA9IHumg6d+AcoEeg7KDO8LwDqEtVchdU6Jl2u /J8NkshQUjwp2swIoGuyQuO+E7Sfth0iRWAKg= 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=Ast09lSxwhE28SWe0BPPBHYfUP0z3fhspWiO7rL6yzA=; b=cfXrmrzS5eSkAjNvXnETo2LQLm2KmlMEuyVjJ9yt8/Yds+yTByv/Ku1sZa4I+wNi5p NWCiG2WPM3UMXlJbEqBT8LrQpVb93rGxO20km0jphjD3uftl6PnRJI0gubKYTsqmVzw5 ekwogAykcf8CrmQXA3MX2TfeS2XNkk7ErgHuFzlrjEQdhwY9WxVvnilHgLqSAWddxRH1 J5eL372h50ZlDuknJxS7t4v1242mkFiapTPzrJnyTgckS0Zu0cV1bZF86715uitQO3xl SVOF1gl7sgP2ZF/POWtpbt/JtlGgJRXZa/lPnfF2cyRGjkxQCaoSof+0YL6j6KeJ0qSk ppXw== X-Gm-Message-State: AElRT7FqAJATnvG8htcpqo/kGZW7QH9uvJmYhzJ+Q6zDCsbFpSrN/yVH PkdlWOlZO7OezDcZpq1pGMEI1A== X-Google-Smtp-Source: AG47ELvEEHwelkTNoXneR4eZQC4jFrF+I2Vrwl6pGfqZ4XbkGzZEG0okk0FFvlQg9Z1os7B1ZF4dpA== X-Received: by 2002:a19:4f5d:: with SMTP id a29-v6mr3821778lfk.97.1521046779274; Wed, 14 Mar 2018 09:59:39 -0700 (PDT) Received: from uffe-XPS-13-9360.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id t24-v6sm724849lfi.30.2018.03.14.09.59.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Mar 2018 09:59:38 -0700 (PDT) From: Ulf Hansson To: "Rafael J . Wysocki" , Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org Subject: [PATCH v6 20/25] drivers: firmware: psci: Introduce psci_dt_topology_init() Date: Wed, 14 Mar 2018 17:58:30 +0100 Message-Id: <1521046715-30683-21-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> References: <1521046715-30683-1-git-send-email-ulf.hansson@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180314_125951_361758_8898BFEC X-CRM114-Status: GOOD ( 21.25 ) 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: Ulf Hansson , Vincent Guittot , Juri Lelli , Geert Uytterhoeven , Kevin Hilman , Stephen Boyd , linux-arm-msm@vger.kernel.org, Daniel Lezcano , linux-kernel@vger.kernel.org, Lina Iyer , Rob Herring , linux-arm-kernel@lists.infradead.org, Thomas Gleixner , Lina Iyer 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 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. Cc: Lina Iyer Co-developed-by: Lina Iyer Signed-off-by: Ulf Hansson --- drivers/firmware/psci.c | 31 +++++++++++++++++++++++++++++++ include/linux/psci.h | 2 ++ 2 files changed, 33 insertions(+) diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c index 463f78c..45d55fc 100644 --- a/drivers/firmware/psci.c +++ b/drivers/firmware/psci.c @@ -723,6 +723,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)