Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3388068rdb; Sun, 10 Dec 2023 03:58:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWJCDU3Ks2VVwUPkgmcC9/wmPuOcAE4O5FOBz9nM0ZKYdXfEB/Uo4iNRfsSK9zQMdccttU X-Received: by 2002:a17:903:2283:b0:1d0:5531:ef8 with SMTP id b3-20020a170903228300b001d055310ef8mr2660170plh.22.1702209495181; Sun, 10 Dec 2023 03:58:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702209495; cv=none; d=google.com; s=arc-20160816; b=HsJ5DCYRNOzFtVAmAhZD7LyDlHru1IMCBxggGuOlwIHKLhq2sp6iJwQwGg9BuNz8wi vx1+Uawc8ZZk/F4gJ07Z1TTLeBMC6jCnyaaMGYZ/MG0XzQrG0umauCD8cNLKFgsm47fa vsSQw+/yKMyMePC5iDengZAenVjqbSpHk6KRByJcIAJ/m9eWlwLj49wT+s1R/cJ1jKs1 AagkBSON+j5wDqo1FrmMUEupjzRR1SvXp3X9MN4GmJMw6hqiEbKXOF+FrMj20lB49Rgj /7EWOh0nELBJ8xN+Pl/MrigNdZZ0wqggDFiUZcAZUiO3ZUajdz0WVr72UIz4FWjCWkOO 0uiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AK/wwfR9mHwPgOhu0F/scJGrVagCVRB9xlssE+5acK0=; fh=NE47LR/KXzxAPIpniE231vef1U0WCpUz9yDn0+9L6/E=; b=FXGnV+l7IWgKYIZ76iKMBgCc/Eho4SvG3RFc9ZssfsiMs7Xu0Z2ctVrh89rjhrTKQp NXrPnQnBs1C8KooHDw3k7TLxeTe7GfcNGNxjLo4NOEkp1bIyufqRJx6kd74coihmQLTy pzPlhsN9e4jiMSZbIH4C0M7Wuh0d0wC0jqx5dZHDchgLimhycj4VhODmFTDKYsm4mWcd nIZUYB3Rn5woLKQ/oPQyLakuh2VhJ7oIOb2TBxHw3MZeyFCGQSa3ZmzHKy65mRYnm2F1 hYfDx99K/H1hs2jXMgxDSvqVok1HHuwfjzyvO9amQWHQkfg2JP5eX3Q5Uq4xPwPj+e1k V6qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GAUlHc1u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b6-20020a170902d88600b001d08d137423si4440389plz.65.2023.12.10.03.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 03:58:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GAUlHc1u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7FE4C806E171; Sun, 10 Dec 2023 03:58:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231778AbjLJLyN (ORCPT + 99 others); Sun, 10 Dec 2023 06:54:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229482AbjLJLyM (ORCPT ); Sun, 10 Dec 2023 06:54:12 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE7C999 for ; Sun, 10 Dec 2023 03:54:18 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26B7CC433C7; Sun, 10 Dec 2023 11:54:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702209258; bh=VcO895aojfnwILlplXsvhD/oc+9HK3LQQDHWerPGqLc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GAUlHc1uSvYUyDeIsd3y5qj6MWZwM6fbj9FGyK+HvJTSFrEbZCgdq+uVwyuEP/412 wtXPehU1VmhFvzKOJYCr0Zeh2X0TOcjzb8aFB5H4Ba0C1qsVFdpGoeEhg3dUbOxGAM E6mWJfU2x6Prt2EEseU2ZKMCsOyNAFa6WcVwZoHdoQMXNOVmc5DOurN1oVDvwyNh5V 4LkiPwSnum1kbC8Fw2edcyHQ24o1WNqhvrwaL3TQEDCZaDoTcfsUbwcSI0YF9KFP2M HrfIPstbSH2DMy83MxrH1Z4zR3acACR45eXCzx2xUv2deeMeCXArEeJt3/DBjoPq0E K5CTmExcA5tpw== Date: Sun, 10 Dec 2023 12:54:12 +0100 From: Andi Shyti To: Ji Sheng Teoh Cc: leyfoon.tan@starfivetech.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, michal.simek@amd.com Subject: Re: [PATCH v2] i2c: cadence: Add system suspend and resume PM support Message-ID: <20231210115412.hztjrubacnmenbvz@zenone.zhora.eu> References: <20231209205744.ehmthjvn7nuslvhd@zenone.zhora.eu> <20231210052018.2063-1-jisheng.teoh@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20231210052018.2063-1-jisheng.teoh@starfivetech.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Sun, 10 Dec 2023 03:58:12 -0800 (PST) Hi Ji Sheng, [...] > > > +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 =3D dev_get_drvdata(dev); > > > + int err; > > > + > > > + err =3D 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 ... >=20 > 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/44c99904cf61f945d02ac9976ab10dd5= ccaea393 OK, this is done purely for clock balancing, but then, I still don't understand the case. I expect the clock counter to be unbalanced when you suspend (because is moving towards '0'). While, if you check if the clock is unbalanced when resuming, it means that the clock had a negative counter (which is impossible because the clock counter is unsigned). If there is any unbalancing at this stage, then I recommend you to check what has happened previously. =2E.. Or is there anything I am missing? Thanks, Andi > > > + err =3D cdns_i2c_runtime_suspend(dev); > > > > ... and suspend again? Shouldn't this be _resume()? > > > > Thanks, > =1B[O> Andi > > > > > + if (err) > > > + return err; > > > + } > > > + > > > + i2c_mark_adapter_resumed(&xi2c->adap); > > > + > > > + return 0; > > > +}