Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp266090pxf; Thu, 8 Apr 2021 02:36:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFZJlOefKIeGP2w8b6PE+tQrmOy28nEkqc1euJrWKAxUalnwDjR+3KXv27vme5XY4mKi7n X-Received: by 2002:a17:907:2069:: with SMTP id qp9mr9345724ejb.175.1617874610010; Thu, 08 Apr 2021 02:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617874610; cv=none; d=google.com; s=arc-20160816; b=e/W8+Rhpjy4YjkUrfpRw2lXyxNbxPdgphIBtSlsRaO92OlO1NcIOarxicU4rfqWuoj BwtsV9/j6ir6jUiii9WE60NQ0m5L3lMVfIl2TZwzH088R1IFqmrh+wWLKtygmiRgsllA 3M1JM/dowREiau6/PTRedWhRghJcc8L8LzNahLOZyGn3322Ib99Ctp62/DRXupdpRTdz 3h50dCK3Xxny+y0+UC5SekjeLSVfiqrV+GI2TzTWyZ9HlWHNaLa1UQYcD9IF+NAYwwTr w9m5zzgkDVxqd7RRAiYyechf5RjCh7Vvkz/8CFD/fJ6cPnLuoLYGSy/q594wfSJPEvkq DW5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=E5A3vx9szPgOBeQpwWY8Jexu22dbSbPC7n9/cA4helU=; b=vLZEZn8f2IXQAo3rWflCgLRd+z7JWIfObWfkN6syf2eDwgB8xlM45CA5BEps5o3L4F M5hy2mkUVced3qBE5cvjRooRHm9BcBZ5hmqNG+AcZFYvNFa99vrfBVSd6fy/AbffTR8O J6GiAghLNzRpfExFAK2CiZ3qbi1RFNUL6TX8MRKXRbLjF02g8Ash+6J8bpC98aMMf3yG N8ESK/fjxOAUln2FwAF6miNJKkt5+zqAjq+Gpg/ffOLYtb0l4P+pwsPVqcHrKe5AFe9z GQPLvhqJHuAjYtDrNDDraIJKleGov5SBnDK5hADjrMNen1ybM8tYHRNfLCXtd8cQWVy/ qa2g== 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=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si25232028edn.71.2021.04.08.02.36.27; Thu, 08 Apr 2021 02:36:49 -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=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231283AbhDHJfg (ORCPT + 99 others); Thu, 8 Apr 2021 05:35:36 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:35107 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229640AbhDHJfe (ORCPT ); Thu, 8 Apr 2021 05:35:34 -0400 X-UUID: 0383ff6ce9bf4bad9b1b029f77ae1c80-20210408 X-UUID: 0383ff6ce9bf4bad9b1b029f77ae1c80-20210408 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 360498388; Thu, 08 Apr 2021 17:35:20 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 8 Apr 2021 17:35:18 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 8 Apr 2021 17:35:17 +0800 From: Chunfeng Yun To: Rob Herring , Mathias Nyman CC: Chunfeng Yun , Greg Kroah-Hartman , Matthias Brugger , "Rafael J. Wysocki" , Len Brown , Pavel Machek , , , , , , , Tony Lindgren , Tianping Fang , Eddie Hung , Ikjoon Jang , Nicolas Boichat Subject: [PATCH 1/6] PM: runtime: enable wake irq after runtime_suspend hook called Date: Thu, 8 Apr 2021 17:35:09 +0800 Message-ID: <1617874514-12282-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: E5C6DB1EBBB6601790860FBE2A607D826DC4ADE8017410E55972F9D1B0FDA48D2000:8 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the dedicated wake irq is level trigger, enable it before calling runtime_suspend, will trigger an interrupt. e.g. for a low level trigger type, it's low level at running time (0), and becomes high level when enters suspend (runtime_suspend (1) is called), a wakeup signal at (2) make it become low level, wake irq will be triggered. ------------------ | ^ ^| ---------------- | | -------------- |<---(0)--->|<--(1)--| (3) (2) (4) if we enable the wake irq before calling runtime_suspend during (0), an interrupt will arise, it causes resume immediately; enable wake irq after calling runtime_suspend, e.g. at (3) or (4), will works. This patch seems no side effect on edge trigger wake irq. Signed-off-by: Chunfeng Yun --- drivers/base/power/runtime.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c index a46a7e30881b..796739a015a5 100644 --- a/drivers/base/power/runtime.c +++ b/drivers/base/power/runtime.c @@ -619,12 +619,12 @@ static int rpm_suspend(struct device *dev, int rpmflags) __update_runtime_status(dev, RPM_SUSPENDING); callback = RPM_GET_CALLBACK(dev, runtime_suspend); - - dev_pm_enable_wake_irq_check(dev, true); retval = rpm_callback(callback, dev); if (retval) goto fail; + dev_pm_enable_wake_irq_check(dev, true); + no_callback: __update_runtime_status(dev, RPM_SUSPENDED); pm_runtime_deactivate_timer(dev); @@ -659,7 +659,6 @@ static int rpm_suspend(struct device *dev, int rpmflags) return retval; fail: - dev_pm_disable_wake_irq_check(dev); __update_runtime_status(dev, RPM_ACTIVE); dev->power.deferred_resume = false; wake_up_all(&dev->power.wait_queue); -- 2.18.0