From patchwork Tue Oct 18 02:19:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 3902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1741730wrs; Mon, 17 Oct 2022 19:30:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6KcknYMQcSxAE4hRq5eI++2mOidCv/Ma3X/yjrcyUmWqGi0VXB/2zoGvveh/eAKFbD4ocj X-Received: by 2002:a17:907:a059:b0:78d:1a16:fc5c with SMTP id gz25-20020a170907a05900b0078d1a16fc5cmr549147ejc.31.1666060221300; Mon, 17 Oct 2022 19:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666060221; cv=none; d=google.com; s=arc-20160816; b=teEllz8cbB1cgAvjvbYpt4RyrKzo51SkPx8RM3Dpvjcth3wZIbMkK1yOkWMld1O16H T2kTPukuoxWqH+nOYYCZiSJO0SBxI8gknOtCLpOjVaIO2DCmygZ5T7XZgBeVTQCRzEsd DuY4gBsuCDVLlZbDftCQMuGuDNVsLB4FWzKxuIvFjYP4te0cuzXYbH7TUZ0CCNkAKvsw aoMmBNf5QHUhguZoScWDOxs8WCAFfhBHnlFh7hdmqrGVbF5Z3ALgzArgPfG/7mE4CerK F6yHa0pf5T9QEva2x+Fx4d3KIkaEIT5VwkKK+HOwJr72lQh8YnnksRplOHIro/1V/0NX fAjw== 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 :dkim-signature; bh=uwZtrx9kBniYABoRvDcMY2qPNP6zFDKkhZk2pmiIljM=; b=KjjXwiLZSS7NDVq5EL2j30HcqFXXzC+6/C+UMaNyu34aeHIlHc19mT3qxnZ+HVO3Mj SFCC1XYDjoTSQ0mrKAFAOQcwaak82UzAfABxEitLaMLaHhAuNcAntFlITlJbK5E22zHj lxe2ECiZcEgaDKQY4qnhK8qNpK7U/V1gHalB3cPISaUzVZqVDwiI/f6WqXJGogdo1pLB s4EYymgJrmux9czXuwyQeGiWH1TtkfkGw1uQeC54iv1DC3PHln+oAdQa9KAO6l62hrSF SWFBYXglswMgC1iWkaKALqZCceIK1oOYCKwS0m+j1MFIpAypFRG0BDqhhw/XNYdvGJ3q bpjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TUF3fe60; 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=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht8-20020a170907608800b0078356aaeb63si11453689ejc.288.2022.10.17.19.29.57; Mon, 17 Oct 2022 19:30:21 -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=@linaro.org header.s=google header.b=TUF3fe60; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbiJRCTk (ORCPT + 99 others); Mon, 17 Oct 2022 22:19:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230127AbiJRCTf (ORCPT ); Mon, 17 Oct 2022 22:19:35 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9B16DE88 for ; Mon, 17 Oct 2022 19:19:31 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id bp11so21267288wrb.9 for ; Mon, 17 Oct 2022 19:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uwZtrx9kBniYABoRvDcMY2qPNP6zFDKkhZk2pmiIljM=; b=TUF3fe60ezCdKamcKj9noLbVquPlFC4py7fg2C0YZ3gZljw0ncz1qm0Ur0OJFnUpjN +YgqmR8qAMljbPSDcQ5+aRZ2Ou0jP+691hI4RgfGwkEH93kxxEjwEmAM9ba45tMuaiVZ Hwns6NdkCj6+wwbkbzqta+TlpX9hXba63MFgeqbFpKjkY9jK38Ed3WgQTwlo2G07BMdF 07IkWOwHdK2YnS5RCDBjDhevkcwBOuJwmv8SWHTWYaOXDz5WX3btLBe9VJnUZqsrvjzc z+XruvrmOjdF3FT7bMl2YRmtq+rmLhJlVwDPf+t3GLAg4na8iE6HCfKy5GDan75gFkA1 irQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uwZtrx9kBniYABoRvDcMY2qPNP6zFDKkhZk2pmiIljM=; b=cWbMPwsnZlXy3ORgb996Wjn6gdu41LfepCdjmig1+MbwoikBJEC/w8iz8KNvyS7XTT OjzvY4NZoCUe0UsNovpSy4lDVSQ6YQN3kpdBGGpgJi/Za8FA4vL6mXbcwFrS8ch+ZaYq wd9O1nKTbs/txAL5oVL3J2U0bTIVcuWkWaXg8WOC3/yz/2FLU8c7uuYMy+rfW7ZZXUs4 aG1X6Y4OyDPyNVacyVFJYykle6lBgGk+1lj+aTYor72tOXxvCpL2c7kZI9jPHJrgjkCN DrkhD4TAOsD5NoNdFXQmhEwmL69AiQLR644xaHpGv/7/VpY2Xh1is5HhR/ecgr1Wmgq0 SAxQ== X-Gm-Message-State: ACrzQf14HS5QljoswspEDJOnTrdpFVWXRLOo8KrV/FsUCVpO9Qw6Z2NQ hp2Osovc/xdGyItiaKxQ1/4cXg== X-Received: by 2002:a5d:6d8e:0:b0:22e:60ae:8875 with SMTP id l14-20020a5d6d8e000000b0022e60ae8875mr357716wrs.676.1666059570349; Mon, 17 Oct 2022 19:19:30 -0700 (PDT) Received: from planet9.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id y6-20020a1c4b06000000b003a83ca67f73sm11921533wma.3.2022.10.17.19.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Oct 2022 19:19:29 -0700 (PDT) From: Bryan O'Donoghue To: loic.poulain@linaro.org, robert.foss@linaro.org, wsa@kernel.org, linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vladimir.zapolskiy@linaro.org, bryan.odonoghue@linaro.org, stable@vger.kernel.org Subject: [PATCH v3 1/1] i2c: qcom-cci: Fix ordering of pm_runtime_xx and i2c_add_adapter Date: Tue, 18 Oct 2022 03:19:20 +0100 Message-Id: <20221018021920.3747344-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018021920.3747344-1-bryan.odonoghue@linaro.org> References: <20221018021920.3747344-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746990762301540561?= X-GMAIL-MSGID: =?utf-8?q?1746990762301540561?= When we compile-in the CCI along with the imx412 driver and run on the RB5 we see that i2c_add_adapter() causes the probe of the imx412 driver to happen. This probe tries to perform an i2c xfer() and the xfer() in i2c-qcom-cci.c fails on pm_runtime_get() because the i2c-qcom-cci.c::probe() function has not completed to pm_runtime_enable(dev). Fix this sequence by ensuring pm_runtime_xxx() calls happen prior to adding the i2c adapter. Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver") Reported-by: Vladimir Zapolskiy Reviewed-by: Vladimir Zapolskiy Tested-by: Vladimir Zapolskiy Cc: Signed-off-by: Bryan O'Donoghue Reviewed-by: Robert Foss --- drivers/i2c/busses/i2c-qcom-cci.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 87739fb4388b..a4b97fe3c3a5 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -639,6 +639,11 @@ static int cci_probe(struct platform_device *pdev) if (ret < 0) goto error; + pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC); + pm_runtime_use_autosuspend(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + for (i = 0; i < cci->data->num_masters; i++) { if (!cci->master[i].cci) continue; @@ -650,14 +655,12 @@ static int cci_probe(struct platform_device *pdev) } } - pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC); - pm_runtime_use_autosuspend(dev); - pm_runtime_set_active(dev); - pm_runtime_enable(dev); - return 0; error_i2c: + pm_runtime_disable(dev); + pm_runtime_dont_use_autosuspend(dev); + for (--i ; i >= 0; i--) { if (cci->master[i].cci) { i2c_del_adapter(&cci->master[i].adap);