Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5750260rwb; Wed, 21 Sep 2022 11:52:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM46ZPXIs3Cnq4Fy1rg9XBi2wQfr5OjiMAdEXI+xOXxVrAigkmi10sFNrwOFcMiTksa0+Xym X-Received: by 2002:a17:90a:fd8c:b0:200:8cf9:63f4 with SMTP id cx12-20020a17090afd8c00b002008cf963f4mr10910941pjb.201.1663786366558; Wed, 21 Sep 2022 11:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663786366; cv=none; d=google.com; s=arc-20160816; b=d08tf0yPZY1lLd9Wj3S4BHt3w1ArlprbDExy9cBKSpgrkB8JlW/p9wT/dcHhROw2zf pN2tEoQ4YrkThVjg2XEhpagm+n+I1yacd/CUdPzstV6qzoUNujqLU5r9aB+DDK2ClyzZ AKRgzCqnEOV2g/VmfIk8s5smf/oQmq0TaGdVJUS8Fv/bDx3toqOFJ0LrSuKrSUoklykq esBI9qDuwizRey9VCrTp9fSEHd7kzVmxPHqlbO/5iCvkM7LPt2/1gfJHPzfVdm+Vvi05 uFYXYsN5UAahvS6Nn9YZRJoAGTMTq7XksXlBVxVLXgrBR/kCutz1hcqpmAG40hj3FNkA pIfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=mInsceIHKGpEA4Fy20VkkW8wh0vIm2v2E7BS4tpCcY0=; b=r7gbD8LK55ld+h+9VqlidoIAe4jE/k5vPUIzI0xzpBUhoPo5CSOA/4TOTM+2a977rm hVscOdTv3zwOEw/ZPWpPKbscPtIL98jDSBPQDNi/X4JdprX6jaJdZzJgbC0IABgjQE0J Dr2CDvafMkyqOiGY565hQ8+ZS9aDgKA3zTH6EqcHmZ8DJe0ZkKGC9MxxBNid9zZWuCuc /j8kYnwVxp8R19g3MkkU6O0882gIXe94GR+z8u0UtrZ5mhf+iGgp3B7/8Pj2E6CIbT89 ffcEtvFr3fo3qN+HJA9DLxiaDSbCX77PAk7xWRuxZQ9MGuE/CN5b1J3QBvGMc7sp3TyG hNGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h71-20020a636c4a000000b0042bfa0c0b69si3638284pgc.686.2022.09.21.11.52.33; Wed, 21 Sep 2022 11:52:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230091AbiIUSNp (ORCPT + 99 others); Wed, 21 Sep 2022 14:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230452AbiIUSNm (ORCPT ); Wed, 21 Sep 2022 14:13:42 -0400 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C63967EFE4; Wed, 21 Sep 2022 11:13:41 -0700 (PDT) Received: by mail-qk1-f181.google.com with SMTP id h28so4607783qka.0; Wed, 21 Sep 2022 11:13:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=mInsceIHKGpEA4Fy20VkkW8wh0vIm2v2E7BS4tpCcY0=; b=Km82qcvQWGOD45vqFeIn6v0yx/OuO3secDt6hD5s+UWZKrnP1kNhNMYpR1rxTJddeG 9xvbSH2EY1SF43gsvpYoM2c9DePvK9NMSAPuU/Cl8+6gbjb/Mh7sl0gjL7S1i3joI5AG 1ynEvKwh528kzHmEyL9m2WyYdSyZC41EYBa6sC42K97lwciqFRDa7rsNo8M0hF/Wn5Ry x9FtBBVLeN1orilKAlfKKyqQfgZRKRKcg/MZNAVaqMPtkNop4o2hd7KusjwFMATzJnDN WUhKDej9JJrPw1IcYSEM3Dml+LgIzndUuBOwBgkW//Q+i/ZwPoPaN5SpkFEtOb1GeE5v g4rQ== X-Gm-Message-State: ACrzQf3mgehJ8CeO4B0kaACV6/8rZCEIh+bF23g7dCyzpu2SiBjQE8ud hZL+NScl5N46DzotydqBSROfrkgAAHKqWdWZyJA= X-Received: by 2002:a05:620a:4008:b0:6ce:8725:cb7 with SMTP id h8-20020a05620a400800b006ce87250cb7mr21224231qko.480.1663784020888; Wed, 21 Sep 2022 11:13:40 -0700 (PDT) MIME-Version: 1.0 References: <1663294501-6377-1-git-send-email-u0084500@gmail.com> In-Reply-To: <1663294501-6377-1-git-send-email-u0084500@gmail.com> From: "Rafael J. Wysocki" Date: Wed, 21 Sep 2022 20:13:29 +0200 Message-ID: Subject: Re: [RFC] PM: core: Add pm_wakeup_pending check in device suspend_noirq To: cy_huang Cc: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck , cy_huang@richtek.com, gene_chen@richtek.com, Linux PM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 16, 2022 at 4:15 AM cy_huang wrote: > > From: ChiYuan Huang > > In 'dpm_suspend_noirq', it will do the sychronized_irq to guarantee all > irqs are all done, and then do any wakeup flag set. > > For some peripherial deivces like as I2C/SPI, to speed up the irq handling, > it may use 'pm_stay_awake' and really handle in another thread context like > as workqueue. > > But in mem suspend flow, after 'dpm_suspend_noirq" stage, the next > 'pm_wakeup_pending' check will be at 'syscore_suspend'. > > The checkpoint seems too late and cause I2C/SPI fail during 'noirq' to > 'syscore_suspend' What exactly do you mean by "fail" here? >. But some adapter was already be marked as 'suspended' > at 'noirq' callback, any I2C/SPI xfer will return the error flag '-ESHUTDOWN'. > > After the code trace, it seems all device callback will do 'pm_wakeup_pending' > check, except 'noirq'. > > This patch is to add 'pm_wakeup_pending' check in 'noirq' sage to prevent this > kind of usage. > > Signed-off-by: ChiYuan Huang > --- > Hi, > > Is there any rule to define when I2C/SPI host controller need to mark adapter as > 'suspended'? > > I trace 'drivers/i2c/buses'.It seems there's no common rule, Some are 'suspend', > others may did it at 'suspend_noirq'. > > --- > drivers/base/power/main.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c > index c501392..7cd7dc5 100644 > --- a/drivers/base/power/main.c > +++ b/drivers/base/power/main.c > @@ -1210,6 +1210,11 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a > if (async_error) > goto Complete; > > + if (pm_wakeup_pending()) { > + async_error = -EBUSY; > + goto Complete; > + } > + > if (dev->power.syscore || dev->power.direct_complete) > goto Complete; > > -- > 2.7.4 >