Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3273458rdb; Sat, 9 Dec 2023 21:22:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGSFFJs6Kpb+eKrZj1EvMmGLIvj/uwvr/0OzfxlcEhCnB9rHdF3gaPtqnMGbhvPfgKyjYm9 X-Received: by 2002:a17:90a:1347:b0:288:966e:bd02 with SMTP id y7-20020a17090a134700b00288966ebd02mr1969830pjf.60.1702185722404; Sat, 09 Dec 2023 21:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702185722; cv=none; d=google.com; s=arc-20160816; b=TJZjMoktXqIBSAWLvhTULkJy5zBHYoS5krTC4YaJ9Mnco/uKVrW0bd8do6vM8XXVGP Twwp5tzEFJaoWWcx8FNQnd2tFZCH/yM27QBIqQVaX0If27shtPZt3jeyYfApplM0QbLi tlK1ZQHdkmabEy2cxA6utC1lzCQDtGr+5ignEdCPSJu5Ke/pZLh3kr+UBilaPZr+tca2 oVwfs5ZMGQzWR30T56MMadgwbIgA4Roy7BiPDgk0Z+tWgfkrRSc6GfGoM4EIR46PHh7Y yaz+2FH0GI5Ri4Ut5xTot09MDlU4hkF1aBzzIpfCny+rzWavrC8sfz6aD7bOKHgBajR8 f/NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JVxoATa+1ijl85fOZOQ4M9ZDL263SUhZrkCE9VuLm+M=; fh=q9SNB7AWjsM+WIxFuFxlg8zSIB3QJ7serSDiuu3995c=; b=I0cSX9+lMuQN20L4Aq8FIWwpsjsEeEEWLlfVysWJV7fjt7v5n1kjT/to1lxw5JFqgQ PNWrxy8KSVzDmFhrEvEvL/DvuSM9025chc7WuZR/oYr+7MUb10cv0xLu9Zzs1MGIUlB7 E0OFLZCiUo/8wpM1CY0AhauLp8IpKvAznHeMk0piAF3EdnP6bu7Mgopuj/DwgJQhXO3G 4SoeuRlVJlTP+YMA6ampdQOI1ffFVz6FUxOLk2ytjB/MZJw9Zb4vxvbk3NCSKwHlcddx 2fh0i/a6NyTiU82L2VoEBuTaH0uUIQivi3JaZ5WKH80dubxMzgQobcVrhsSmzgKcJSWu WHig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b6-20020a170902d88600b001d08d137423si4047066plz.65.2023.12.09.21.22.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 21:22:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D4D42807C650; Sat, 9 Dec 2023 21:21:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229509AbjLJFVB convert rfc822-to-8bit (ORCPT + 99 others); Sun, 10 Dec 2023 00:21:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbjLJFU7 (ORCPT ); Sun, 10 Dec 2023 00:20:59 -0500 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8193CD; Sat, 9 Dec 2023 21:20:57 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 15CDA8043; Sun, 10 Dec 2023 13:20:42 +0800 (CST) Received: from EXMBX072.cuchost.com (172.16.6.82) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sun, 10 Dec 2023 13:20:42 +0800 Received: from localhost.localdomain (180.75.243.157) by EXMBX072.cuchost.com (172.16.6.82) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Sun, 10 Dec 2023 13:20:38 +0800 From: Ji Sheng Teoh To: CC: , , , , , Subject: Re: [PATCH v2] i2c: cadence: Add system suspend and resume PM support Date: Sun, 10 Dec 2023 13:20:17 +0800 Message-ID: <20231210052018.2063-1-jisheng.teoh@starfivetech.com> X-Mailer: git-send-email 2.43.0.windows.1 In-Reply-To: <20231209205744.ehmthjvn7nuslvhd@zenone.zhora.eu> References: <20231209205744.ehmthjvn7nuslvhd@zenone.zhora.eu> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [180.75.243.157] X-ClientProxiedBy: EXCAS066.cuchost.com (172.16.6.26) To EXMBX072.cuchost.com (172.16.6.82) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=1.7 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SORTED_RECIPS,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 09 Dec 2023 21:21:37 -0800 (PST) X-Spam-Level: * On Sat, 9 Dec 2023 21:57:44 +0100 Andi Shyti wrote: > Hi Ji Sheng, > > On Sat, Dec 09, 2023 at 09:15:16PM +0800, Ji Sheng Teoh wrote: > > Enable device system suspend and resume PM support, and mark the > > device state as suspended during system suspend to reject any data > > transfer. > > > > Signed-off-by: Ji Sheng Teoh > > --- > > Changes since v1: > > - Add missing err assignment in cdns_i2c_resume(). > > thanks for the quick version update. However, while it's nice to > see such prompt proactivity, we also need to allow more time for > others to review your change. > > Next time, please give it a bit more time before sending out > version 2. :-) > Thanks, will take note of that. > > --- > > drivers/i2c/busses/i2c-cadence.c | 33 > > ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) > > > > diff --git a/drivers/i2c/busses/i2c-cadence.c > > b/drivers/i2c/busses/i2c-cadence.c index de3f58b60dce..4bb7d6756947 > > 100644 --- a/drivers/i2c/busses/i2c-cadence.c > > +++ b/drivers/i2c/busses/i2c-cadence.c > > @@ -1176,6 +1176,18 @@ static int __maybe_unused > > cdns_i2c_runtime_suspend(struct device *dev) return 0; > > } > > > > +static int __maybe_unused cdns_i2c_suspend(struct device *dev) > > +{ > > + struct cdns_i2c *xi2c = dev_get_drvdata(dev); > > + > > + i2c_mark_adapter_suspended(&xi2c->adap); > > + > > + if (!pm_runtime_status_suspended(dev)) > > + return cdns_i2c_runtime_suspend(dev); > > + > > + return 0; > > +} > > + > > /** > > * cdns_i2c_init - Controller initialisation > > * @id: Device private data structure > > @@ -1219,7 +1231,28 @@ static int __maybe_unused > > cdns_i2c_runtime_resume(struct device *dev) return 0; > > } > > > > +static int __maybe_unused cdns_i2c_resume(struct device *dev) > > +{ > > I am not really understanding what you are trying to do here: > > > + struct cdns_i2c *xi2c = dev_get_drvdata(dev); > > + int err; > > + > > + err = cdns_i2c_runtime_resume(dev); > > First you try to resume... > > > + if (err) > > + return err; > > + > > + if (pm_runtime_status_suspended(dev)) { > > ... then you check if you are suspended ... This serves as a check and balance to ensure that when the system resumes with device in runtime suspend state, we disable the clock enabled in earlier cdns_i2c_runtime_resume() to ensure a balanced clock reference count for subsequent runtime resume transition. Similar implementation can be found in this commit: https://github.com/torvalds/linux/commit/44c99904cf61f945d02ac9976ab10dd5ccaea393 > > > + err = cdns_i2c_runtime_suspend(dev); > > ... and suspend again? Shouldn't this be _resume()? > > Thanks, > Andi > > > + if (err) > > + return err; > > + } > > + > > + i2c_mark_adapter_resumed(&xi2c->adap); > > + > > + return 0; > > +} > > + > > static const struct dev_pm_ops cdns_i2c_dev_pm_ops = { > > + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(cdns_i2c_suspend, > > cdns_i2c_resume) SET_RUNTIME_PM_OPS(cdns_i2c_runtime_suspend, > > cdns_i2c_runtime_resume, NULL) > > }; > > -- > > 2.25.1 > >