Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp73578rwb; Wed, 21 Sep 2022 17:44:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6gKWnMu95JO4OoIF8Rdo3ShPIOtw7MF06Mge6AHusRUe55XshFtqRi7UbyJ/DWFBwsY7Eq X-Received: by 2002:a05:6a00:2906:b0:52a:bc7f:f801 with SMTP id cg6-20020a056a00290600b0052abc7ff801mr923796pfb.49.1663807493783; Wed, 21 Sep 2022 17:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663807493; cv=none; d=google.com; s=arc-20160816; b=JQUxKsPKuGoLm7ER9jbS2uYWwQIAnhEY8cGnmTN3kw9q+XIUtgXl7+a4gOXWsqGONM 7eIXu+uvCZFjiHrNb4eWTCz52NXbrbUsKruiwcu/24hGcWNk+TbxIS9wmHI/KRbjEAr1 ZlNJQpmBQFtYrhG2dolCobzTTbyhYfuHQoUJyOb9QTKmynaw7qqJIRosbwv3Cp4GB/5/ +35SQkt45VqvnoMr5zSEzR8raY54PdN8/2ClmqHcffHHVzpbDTTF/DKQe9n9MVCEt1cW X3WIx5dIQQud0HH2l5F3qT8i8DDvIJFsHtthHH1wgEHsQ8OO0t8lyOJf5jTPK1FhYP/q w1Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=CAY1Le6iZuq4WCQqQu6cWxVZo31XqaHH/Ihp+V9i8fE=; b=lvdpAINYmDkY0xalTvI+tWP2N7LYPWhoa5qQAAig5Pg9XfdBd8cKmuaPFE/idjWuEl phwmxskGGjSkw9Cxtq/8M7qqm5u7azM1kO38u2mwoQqcXiub05KB9yDYc9KGGu0z9WF0 KsfdVotU6q4Uja3yOMA4wsnBFlvZA7aVsiwPfcRUO4UqpBLi3XvUyDKIBCu9qhNAgykF eMGfnMAA11OfEQ1GmHusD424bGpx8RgDt4NLzI4baTmht3VGSZoxLNfwKZCmY90yJ1aG Giu4QA66ZD6A7FssppL7wjVy/VrilGDcGsm7//vtgwPIiVEVh6CRJQ/un6uvWr+Ftfhe cyRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ISUiOO8Z; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc1-20020a17090b3b8100b00200aa62790dsi5003413pjb.94.2022.09.21.17.44.41; Wed, 21 Sep 2022 17:44:53 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ISUiOO8Z; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbiIVAes (ORCPT + 99 others); Wed, 21 Sep 2022 20:34:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiIVAep (ORCPT ); Wed, 21 Sep 2022 20:34:45 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C862563D9; Wed, 21 Sep 2022 17:34:43 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id n15so5961663wrq.5; Wed, 21 Sep 2022 17:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date; bh=CAY1Le6iZuq4WCQqQu6cWxVZo31XqaHH/Ihp+V9i8fE=; b=ISUiOO8ZXuObKHX8uOtYpsLkLYs3UTINopdD8z74xAsb/7dC7fpmIQGUDDcM/SfKKy RSHcv30kyrAv7xTiA2lL0DclbnlxbwmOmDOQ00ahCgzRdpAx4OYFNb40pkq1+/UUAYk8 sdwnvVZpPEqK/6ub+P2GWIvGfoAM2fjd1Jnu3kCV3g/+18JsBZTJZodbjlpSO208a07K 8jojv2QcuFHXetQuFoO/x64tCF6Mf9flhbfQ+16xNa1aX0syLmwdTvMzzbiL52Nlda+J tSUVWMU7eyv0JcSCw1be9MflIqyqMig1EF/qJ3huqFBJxS3wfGypycqZos1+zGd6gcPh spiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date; bh=CAY1Le6iZuq4WCQqQu6cWxVZo31XqaHH/Ihp+V9i8fE=; b=1F/P8kUhcG+pKSYl1XQJYoFHVaIzYwXrej/GhZ7szWN8MmLuRVyrO/2X4638x6q5ba l800JJgck2pmuRSFJ/QIyKJwf720dPqlXyI9H3QJFvfFaG1nN4uRnCoMYNxzDjdtJ3HE TXgiA/thgVQ6bi0AUqZLd3+/jvCkKXBH1lU4QmZC0F0PI3+rii3ClOc6onBWt9aiRx76 mE0UsM6eENmU9pDoGPwcXBxWxTVDko0B4GudPLJEew/vrOxtFACtldMWyhycrcultGwc VYO5J+ICk14Av9MgFWuMbZLKkBTgBeq6T1IiDwishGY6p5ClWdEMX2jCuFOHW8n2EvOi XsYQ== X-Gm-Message-State: ACrzQf2CoGIgIzf2McdnmsRoREbT+qI7OTxI5DPsvipP64SaZRvi13q4 5Dbw+E7HaRaN3/1pqLH4gapfC1e6WvgomZD9+cg= X-Received: by 2002:a5d:4302:0:b0:225:5303:39e5 with SMTP id h2-20020a5d4302000000b00225530339e5mr351125wrq.380.1663806881537; Wed, 21 Sep 2022 17:34:41 -0700 (PDT) MIME-Version: 1.0 References: <1663294501-6377-1-git-send-email-u0084500@gmail.com> In-Reply-To: From: ChiYuan Huang Date: Thu, 22 Sep 2022 08:34:29 +0800 Message-ID: Subject: Re: [RFC] PM: core: Add pm_wakeup_pending check in device suspend_noirq To: "Rafael J. Wysocki" Cc: 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Rafael J. Wysocki =E6=96=BC 2022=E5=B9=B49=E6=9C=8822= =E6=97=A5 =E9=80=B1=E5=9B=9B =E5=87=8C=E6=99=A82:13=E5=AF=AB=E9=81=93=EF=BC= =9A > > 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 handl= ing, > > 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? For the below case Once the adapter is marked as 'Suspend', any i2c_xfer or spi_xfer will directly return 'ESHUTDOWN". There's no real I/O transferred, only the direct returned error code. > > >. But some adapter was already be marked as 'suspended' > > at 'noirq' callback, any I2C/SPI xfer will return the error flag '-ESHU= TDOWN'. > > > > After the code trace, it seems all device callback will do 'pm_wakeup_p= ending' > > check, except 'noirq'. > > > > This patch is to add 'pm_wakeup_pending' check in 'noirq' sage to preve= nt this > > kind of usage. > > > > Signed-off-by: ChiYuan Huang > > --- > > Hi, > > > > Is there any rule to define when I2C/SPI host controller need to mark a= dapter 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 =3D -EBUSY; > > + goto Complete; > > + } > > + > > if (dev->power.syscore || dev->power.direct_complete) > > goto Complete; > > > > -- > > 2.7.4 > >