Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3355607ybt; Mon, 22 Jun 2020 23:35:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOI8RfeAVjIOfk4Y5UgSyRwluJ58WGzEHf/RfrEywFHK1QBpFDe+XDxEb35OvN3YA1jw7e X-Received: by 2002:a17:906:1513:: with SMTP id b19mr18690097ejd.1.1592894145036; Mon, 22 Jun 2020 23:35:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592894145; cv=none; d=google.com; s=arc-20160816; b=a9CQYd69Yw4R0d9NOr7vLWRIfUw9VmjpieOJBY1g0OlRf1y8bdDyeGWDu58W5kGNq5 C9X+NfZPFU5+sp22YkcYZ5ZTXBEB9oTgipp20g2zebJjew18+sOhFdEabQZE4bqv7gH/ 7UjquppDTYwN9zYDh1UEnxsg4Vs+zTIBAr3yMHQo7U4JvKc36pFH1w8Y7Afq7i3cKvBN 5BXQPOVPolXJMD/QH+mH3/dbOisX6Ime34Fxc/l2u99RZeGhrJkskpfgX0yW/LWu7s9o UogqbXeV0ADA68zswi5OKd15zEU9g9OyYi3FPvYhRNJqcKKvFHczo7qNIhstHw3URMN3 Q2Hw== 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:ironport-sdr:ironport-sdr; bh=lpo1+NGFEAxE1uTAhQqRrD2csxerqjUloR7y7N0ideg=; b=xsja1OI+BaFijgUGRQRjv3aFj+jjCPHIGT3KN4lNpSnI0d88dsRs+s9JVHvG7Qe+qD fb5/pyfABR7XSD6Sd8jmzBzWIvwhbkKGHo7u0MK4Q5HuAA0ip4UKpPNC/My5lDMaxd4M BGXzpXmmlEUQOxA97fd6K4JIstvKPWdqfeJ7h0PBNhSTmiO+FVFuriFunvatzgNsb/7c EkkWr4+ZoSG30BHXDn45J9bqut3zHRdbVbA43T8XEWlH/MOVlN68C5MpQ/xUtqJ+yUb0 DW7BxFvDlW+yxmssckTV5oXQKcXulGnqFF6iiwJHiQRkGGJS4HtTzhDiaCjpQ1Wh/LH1 BC7g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si9874084ejh.403.2020.06.22.23.35.22; Mon, 22 Jun 2020 23:35:45 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731069AbgFWGbB (ORCPT + 99 others); Tue, 23 Jun 2020 02:31:01 -0400 Received: from mga04.intel.com ([192.55.52.120]:36093 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730708AbgFWGbA (ORCPT ); Tue, 23 Jun 2020 02:31:00 -0400 IronPort-SDR: cDAWf8GMQ2+Ob/PDzKUpVYrR4YGS9MCjqBiNg5XyzoC0SmMsmf0XTyUbKJQQKWr1cjauISktbS qxBnC/4jf4Pw== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="141476614" X-IronPort-AV: E=Sophos;i="5.75,270,1589266800"; d="scan'208";a="141476614" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 23:31:00 -0700 IronPort-SDR: xE8N5qXUJHEnOuz2BAuzA8va+q19yxoPMk8TBSd8R/3vVgZqnYP1sfH7QEf5HMdJKqa+gehjZ8 1aADiwTK1tFw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,270,1589266800"; d="scan'208";a="279007713" Received: from chenyu-office.sh.intel.com ([10.239.158.173]) by orsmga006.jf.intel.com with ESMTP; 22 Jun 2020 23:30:57 -0700 From: Chen Yu To: "Rafael J. Wysocki" , Peter Zijlstra Cc: Daniel Lezcano , Len Brown , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yu , Len Brown Subject: [PATCH 2/2][v3] PM / s2idle: Code cleanup to make s2idle consistent with normal idle path Date: Tue, 23 Jun 2020 14:31:52 +0800 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently s2idle is a little different from the normal idle path. This patch makes call_s2idle() consistent with call_cpuidle(), and also s2idle_enter() is analogous to cpuidle_enter(). No functional change. Suggested-by: Peter Zijlstra (Intel) Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Peter Zijlstra (Intel) Signed-off-by: Chen Yu --- drivers/cpuidle/cpuidle.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index e092789187c6..b2e764d1ac99 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -134,8 +134,8 @@ int cpuidle_find_deepest_state(struct cpuidle_driver *drv, } #ifdef CONFIG_SUSPEND -static void enter_s2idle_proper(struct cpuidle_driver *drv, - struct cpuidle_device *dev, int index) +static void s2idle_enter(struct cpuidle_driver *drv, + struct cpuidle_device *dev, int index) { ktime_t time_start, time_end; @@ -169,6 +169,15 @@ static void enter_s2idle_proper(struct cpuidle_driver *drv, dev->states_usage[index].s2idle_usage++; } +static int call_s2idle(struct cpuidle_driver *drv, + struct cpuidle_device *dev, int index) +{ + if (!current_clr_polling_and_test()) + s2idle_enter(drv, dev, index); + + return index; +} + /** * cpuidle_enter_s2idle - Enter an idle state suitable for suspend-to-idle. * @drv: cpuidle driver for the given CPU. @@ -187,8 +196,8 @@ int cpuidle_enter_s2idle(struct cpuidle_driver *drv, struct cpuidle_device *dev) * be frozen safely. */ index = find_deepest_state(drv, dev, U64_MAX, 0, true); - if (index > 0 && !current_clr_polling_and_test()) - enter_s2idle_proper(drv, dev, index); + if (index > 0) + call_s2idle(drv, dev, index); return index; } -- 2.17.1