Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp233726lqz; Fri, 29 Mar 2024 14:55:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXbLaEJx4mbpFV6P1sLWc3mMB6tp4ISzg3zZkCU9vayEQZdUcJmXMND7ay20eLS/lcm3hkVxPQll4QZaPoVEWUHz8AJOhaLpWGM78ndJg== X-Google-Smtp-Source: AGHT+IErYs9bugDYajAoi8Il7yo+IHwMVnnMF/rN9NpcfbPBl0tLMbGQQtVvL/q9D6nr3ed6IsMG X-Received: by 2002:a05:6512:3e4:b0:515:ccd8:37c2 with SMTP id n4-20020a05651203e400b00515ccd837c2mr2032082lfq.44.1711749351895; Fri, 29 Mar 2024 14:55:51 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a6-20020a170906684600b00a4e4a05cf34si63572ejs.488.2024.03.29.14.55.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 14:55:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125461-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b=fKdsPb2U; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-125461-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125461-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9C1E11F25106 for ; Fri, 29 Mar 2024 21:55:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E9B213D526; Fri, 29 Mar 2024 21:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fKdsPb2U" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF3C813CFB6; Fri, 29 Mar 2024 21:54:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711749280; cv=none; b=TBvw4HgdvNM6TLbX63gtHYuMclrKSoD+EQa8k9z6ovD7BghszI7JzXFFxBy5MGRpbQTCNhHlwC6SkwobEakLC9lsq87T8Hi0s/lboB59edOqWWIxwQJ67qkEcHzfiIS3vW5VkLyS15tM244YVbjLBenK27QS8ls4FEkMEiaHahg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711749280; c=relaxed/simple; bh=Yn8bzggNIrMa+0R7bvxUaO/IzMm910e79pkJIvx8Hnc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BKRTpClhAqfwGsFSPez5rabrricXyBvdVqGjpBpyIqVfdkySdj+6McU5/DACG5XBLDcF1UNiS6i5nBcRClElpZOxm4i5Ek/YQ2ETDBYbiRxkV0KS5JZwMhC3iH7M+vjL2lroUY/exhu4gr/0HfwadBwPLSgWQWsARg13GGotOms= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fKdsPb2U; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C83AC433C7; Fri, 29 Mar 2024 21:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711749280; bh=Yn8bzggNIrMa+0R7bvxUaO/IzMm910e79pkJIvx8Hnc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fKdsPb2UFJgihUWr17wPQxP+Tdvkpf4bKqJLLWHNAyUl0/HqzhCd9qeckgyPi1nOo 7W8VcGKAWIiVHrlXZWYYRfTokXIvJSK01h9pS04Bh1mJSEWAD3XfgLNbn8o5sHzj1k P6se1H4guq5J368QwdB1F2PQeeLT0cMYSjNbP4X/YjhY/LHZAzeYILF7qumb4ZmBn6 7QaCUBWMkHrTJWZwB9UU5CLzshD+G+z+6oPukZ6IcpO7jSSA1BF7aOLNLihf0TVwvL C/4ozm4iw8yElwUMdTExrFHw+vegnhd9jR2LjY53D0IzRTQXNKFOxFYxdcpiokpJg7 ZqvzoQUWSf/8Q== Date: Fri, 29 Mar 2024 22:54:36 +0100 From: Andi Shyti To: Mukesh Kumar Savaliya Cc: konrad.dybcio@linaro.org, andersson@kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, quic_vdadhani@quicinc.com, Vinod Koul Subject: Re: [PATCH v1] i2c: i2c-qcom-geni: Serve transfer during early resume stage Message-ID: References: <20240328123743.1713696-1-quic_msavaliy@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240328123743.1713696-1-quic_msavaliy@quicinc.com> Hi Mukesh, On Thu, Mar 28, 2024 at 06:07:43PM +0530, Mukesh Kumar Savaliya wrote: > pm_runtime_get_sync() function fails during PM early resume and returning > -EACCES because runtime PM for the device is disabled at the early stage > causing i2c transfer to fail. Make changes to serve transfer with force > resume. > > 1. Register interrupt with IRQF_EARLY_RESUME and IRQF_NO_SUSPEND flags > to avoid timeout of transfer when IRQ is not enabled during early stage. > 2. Do force resume if pm_runtime_get_sync() is failing after system > suspend when runtime PM is not enabled. > 3. Increment power usage count after forced resume to balance > it against regular runtime suspend. > > Co-developed-by: Viken Dadhaniya > Signed-off-by: Viken Dadhaniya > Signed-off-by: Mukesh Kumar Savaliya Is this a fix? O mostly an improvement? .. > gi2c->err = 0; > reinit_completion(&gi2c->done); > - ret = pm_runtime_get_sync(gi2c->se.dev); > - if (ret < 0) { > - dev_err(gi2c->se.dev, "error turning SE resources:%d\n", ret); > - pm_runtime_put_noidle(gi2c->se.dev); > - /* Set device in suspended since resume failed */ > - pm_runtime_set_suspended(gi2c->se.dev); > - return ret; > + > + if (!pm_runtime_enabled(dev) && gi2c->suspended) { > + dev_dbg(gi2c->se.dev, "RT_PM disabled, Do force resume, usage_count:%d\n", dev nit: you could leave a space after the ':'. > + atomic_read(&dev->power.usage_count)); > + ret = geni_i2c_force_resume(gi2c); > + if (ret) > + return ret; > + } else { > + ret = pm_runtime_get_sync(dev); > + if (ret == -EACCES && gi2c->suspended) { > + dev_dbg(gi2c->se.dev, "PM get_sync() failed-%d, force resume\n", ret); dev > + ret = geni_i2c_force_resume(gi2c); > + if (ret) > + return ret; > + } Are we missing some cases here? Do we need a few more else's? Andi > } > > qcom_geni_i2c_conf(gi2c); > @@ -702,8 +730,15 @@ static int geni_i2c_xfer(struct i2c_adapter *adap, > else > ret = geni_i2c_fifo_xfer(gi2c, msgs, num); > > - pm_runtime_mark_last_busy(gi2c->se.dev); > - pm_runtime_put_autosuspend(gi2c->se.dev); > + if (!pm_runtime_enabled(dev) && !gi2c->suspended) { > + pm_runtime_put_noidle(dev); > + pm_runtime_set_suspended(dev); this looks like repeated code, how about making it a function? > + gi2c->suspended = 0; > + } else { > + pm_runtime_mark_last_busy(gi2c->se.dev); > + pm_runtime_put_autosuspend(gi2c->se.dev); > + } > + > gi2c->cur = NULL; > gi2c->err = 0; > return ret; > @@ -820,7 +855,7 @@ static int geni_i2c_probe(struct platform_device *pdev) > init_completion(&gi2c->done); > spin_lock_init(&gi2c->lock); > platform_set_drvdata(pdev, gi2c); > - ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, 0, > + ret = devm_request_irq(dev, gi2c->irq, geni_i2c_irq, IRQF_EARLY_RESUME | IRQF_NO_SUSPEND, Can you provide a bit more information on how an early interrupt would be handled once the device is resumed? Thanks, Andi > dev_name(dev), gi2c); > if (ret) { > dev_err(dev, "Request_irq failed:%d: err:%d\n", > -- > 2.25.1 >