From patchwork Wed Feb 12 23:51:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 212867 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=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 A4A94C352A4 for ; Wed, 12 Feb 2020 23:53:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 745DF2173E for ; Wed, 12 Feb 2020 23:53:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fsl+VrDn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729564AbgBLXxI (ORCPT ); Wed, 12 Feb 2020 18:53:08 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:45669 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729347AbgBLXwS (ORCPT ); Wed, 12 Feb 2020 18:52:18 -0500 Received: by mail-lj1-f194.google.com with SMTP id e18so4398186ljn.12; Wed, 12 Feb 2020 15:52:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KHrYqBDKYlz+lEpjkINyfV+xDsRET+kxSXkiOpMcGaI=; b=fsl+VrDnL7WiHbTcAd9P0ifXg0qE0zRu5C3CLwQ9sCU8JIgZi6xwcdiSN9rTEWzwb/ mh/RI764BLtOtQDE5a0JBW4DAodouHEC8ndP/tIvmcvKqnyRr+8lN8ANBDUvh7RPldik BBzkK0jj1wgH6FrG0hElA8XSYXplfse5gLpQ0FIcwR2HMc9HWIss6rlj+XzTfdMQhSXp FHFbI5L/OGP3pKt7YVskUtapD0GjxmNTfh2D5SQrB2zqSLfv0onbKLwxw0y4DVtELsE1 e6gD2LCoaTKN4G34YoyAQ9vlKTIRqqlM2yOYRI746SjF4qPTEwGH/HLjgBE/3t4Vu/4B xqrg== 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=KHrYqBDKYlz+lEpjkINyfV+xDsRET+kxSXkiOpMcGaI=; b=N+IewRma3E2U7H3zGq86Kd/MuPnsKIDupyU4WqIaQIbXj96Z2BZSdSgV2DjeRxceZq ZHmQMlw4Orz0jFRzZpDYx0x5H9A1RmSXTzoy/td5K50MCq9FW17ANLMtFnAJ+fAWKrFH /+fX2k7UTJGWCu3Mtbv9io+/JDbiCe0J8po4o7ZOWL+Xj564Ivzv0ccKh8l0jn4ZhvvX ZPzhetABFUMTzEHcUEUXTBK9hUO/K6eTdk7h1Ly7cFYmBgLCuc/BgG3hNZ4niOpzWxRZ KypQovstPLU2s2Qt8tIdZP+B+JBnieSRqSH2nck68lTZtafYRp6AuuY6sPoDSc0pte6a 2qdQ== X-Gm-Message-State: APjAAAUQ+AfvYO8Jlrz8JlA8IRNiyD2jf7sdtU2ZD1lRkubNSdFCdrg+ ueOMM3ND6vZ9Nwsq7Sl0BB8= X-Google-Smtp-Source: APXvYqzVk+PeVXZr6ke6FXgvT6ZBYF4v/LvqXXjYgZPEGiXy4XOapVBPuLj3DejgyYu3OqG74TjMzQ== X-Received: by 2002:a2e:a36a:: with SMTP id i10mr8988621ljn.107.1581551534332; Wed, 12 Feb 2020 15:52:14 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id d5sm251686lfb.20.2020.02.12.15.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 15:52:13 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Peter De Schrijver , "Rafael J. Wysocki" , Daniel Lezcano , =?utf-8?q?Micha=C5=82_Miro?= =?utf-8?b?c8WCYXc=?= , Jasper Korten , David Heidelberg , Peter Geis Cc: linux-pm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v9 05/17] ARM: tegra: Propagate error from tegra_idle_lp2_last() Date: Thu, 13 Feb 2020 02:51:22 +0300 Message-Id: <20200212235134.12638-6-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200212235134.12638-1-digetx@gmail.com> References: <20200212235134.12638-1-digetx@gmail.com> MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Technically cpu_suspend() may fail and it's never good to lose information about failure. For example things like cpuidle core could correctly sample idling time in the case of failure. Acked-by: Peter De Schrijver Tested-by: Peter Geis Tested-by: Jasper Korten Tested-by: David Heidelberg Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/cpuidle-tegra20.c | 6 ++++-- arch/arm/mach-tegra/cpuidle-tegra30.c | 4 +--- arch/arm/mach-tegra/pm.c | 8 ++++++-- arch/arm/mach-tegra/pm.h | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c index f7d5041e73cc..9789541adb7d 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c @@ -87,15 +87,17 @@ static bool tegra20_cpu_cluster_power_down(struct cpuidle_device *dev, struct cpuidle_driver *drv, int index) { + bool ret; + while (!tegra_cpu_rail_off_ready()) cpu_relax(); - tegra_idle_lp2_last(); + ret = !tegra_idle_lp2_last(); if (cpu_online(1)) tegra20_wake_cpu1_from_reset(); - return true; + return ret; } #ifdef CONFIG_SMP diff --git a/arch/arm/mach-tegra/cpuidle-tegra30.c b/arch/arm/mach-tegra/cpuidle-tegra30.c index a3ce8dabfe18..17cbd118abee 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra30.c +++ b/arch/arm/mach-tegra/cpuidle-tegra30.c @@ -68,9 +68,7 @@ static bool tegra30_cpu_cluster_power_down(struct cpuidle_device *dev, return false; } - tegra_idle_lp2_last(); - - return true; + return !tegra_idle_lp2_last(); } #ifdef CONFIG_SMP diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index a72f9a2d3cb7..a094acaca307 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -189,14 +189,16 @@ static void tegra_pm_set(enum tegra_suspend_mode mode) tegra_pmc_enter_suspend_mode(mode); } -void tegra_idle_lp2_last(void) +int tegra_idle_lp2_last(void) { + int err; + tegra_pm_set(TEGRA_SUSPEND_LP2); cpu_cluster_pm_enter(); suspend_cpu_complex(); - cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); + err = cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); /* * Resume L2 cache if it wasn't re-enabled early during resume, @@ -208,6 +210,8 @@ void tegra_idle_lp2_last(void) restore_cpu_complex(); cpu_cluster_pm_exit(); + + return err; } enum tegra_suspend_mode tegra_pm_validate_suspend_mode( diff --git a/arch/arm/mach-tegra/pm.h b/arch/arm/mach-tegra/pm.h index 2c294f6365c0..7d72f31dee77 100644 --- a/arch/arm/mach-tegra/pm.h +++ b/arch/arm/mach-tegra/pm.h @@ -25,7 +25,7 @@ void tegra30_sleep_core_init(void); void tegra_clear_cpu_in_lp2(void); void tegra_set_cpu_in_lp2(void); -void tegra_idle_lp2_last(void); +int tegra_idle_lp2_last(void); extern void (*tegra_tear_down_cpu)(void); #ifdef CONFIG_PM_SLEEP