From patchwork Tue May 24 14:02:04 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: 575766 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D542AC433F5 for ; Tue, 24 May 2022 14:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238078AbiEXOCR (ORCPT ); Tue, 24 May 2022 10:02:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbiEXOCO (ORCPT ); Tue, 24 May 2022 10:02:14 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AA6841316 for ; Tue, 24 May 2022 07:02:13 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id c190-20020a1c35c7000000b0038e37907b5bso1503221wma.0 for ; Tue, 24 May 2022 07:02:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5mhXJbAqcgTA4KWN8H8AXnpke49ZRdi4wrpj76K6Kgc=; b=G4IYSvljgIaJ8D7CbXZ8ZTGNlBhC8ZJEkiFFe4/VgEZ4ayxT9sz/RUrl+u+mGqF6D7 pX+r4VIucEoGZ+xWS5l71vorfyTLIRDipriFyM7i08So4Po/MDdKVnLoHm0W3MF7d2Ja 8286NQ7ZOwCXSTklo9hRhkdd5b1DWPy55Tj6sDAn7W6jFeHYHC8hS/NBUVkBtiBvGZa7 kFKvZK8tWbOsCjcUIqhng4VhdIrW2mXtqFYEHaOFHlwkEqUdVS/SyHkplXO3bQ6BILAX tN85jZ6H5Yd/lLpipDHEItXggB1uewAL6vm4ew3kold8e3q9Lt1U+XCEUy9e6wN9pcBg sfqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5mhXJbAqcgTA4KWN8H8AXnpke49ZRdi4wrpj76K6Kgc=; b=z3DSW6Pg9YsxbvGmS3+JuYLUK192jmbZCkYl4d+zoQskbvUB1f4aCZYg5uEky/OnA2 LV/CW1PCG0hdWQ1BbP1HxUfJxv7HUJK5n7QcXrEfJ+tKARb6XEPEpHOZtSpK8xTHqgXq vFWofzMZpsFFXz0/ERdHjsSMKTyb/dn6hXdQGfNxtkAold+oE4TseIDgXEgrsLybrHkx LTYiPNOokBchH0V3AmDKXwCU431Pug+n8qObH65o5eFFVMv4y3GSi2ch/q4NII1wD+Zb eW+OF8WWWXdnM9fQWbZHo6FPlnSIzHxwCOZtpiiQg78if11WtQby8euxll5K/E8LCLSl pu3w== X-Gm-Message-State: AOAM533sBKVB3kVbUtXJHAcjzWkKt1qWG4bap1tpSlXow4MK5DryBsp6 f6bBI/lqeYKyaWmKCe06em5u5g== X-Google-Smtp-Source: ABdhPJxGjXM5D1+3NyM22sjywl+lIjmmgPdGLTImyxax0NR8FmreG4ZYBqLqU8ZJPz38USbY0UUT/Q== X-Received: by 2002:a05:600c:4fcc:b0:397:5a83:fac5 with SMTP id o12-20020a05600c4fcc00b003975a83fac5mr3435937wmq.107.1653400931852; Tue, 24 May 2022 07:02:11 -0700 (PDT) Received: from sagittarius-a.chello.ie (188-141-3-169.dynamic.upc.ie. [188.141.3.169]) by smtp.gmail.com with ESMTPSA id f9-20020adfc989000000b0020c5253d8e0sm12829030wrh.44.2022.05.24.07.02.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 07:02:11 -0700 (PDT) From: Bryan O'Donoghue To: robert.foss@linaro.org, todor.too@gmail.com, agross@kernel.org, bjorn.andersson@linaro.org Cc: vladimir.zapolskiy@linaro.org, mchehab@kernel.org, robh+dt@kernel.org, krzk+dt@kernel.org, linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, mmitkov@quicinc.com, jgrahsl@snap.com, hfink@snap.com, Bryan O'Donoghue Subject: [PATCH v2 1/4] i2c: qcom-cci: Fix ordering of pm_runtime_xx and i2c_add_adapter Date: Tue, 24 May 2022 15:02:04 +0100 Message-Id: <20220524140207.2758605-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220524140207.2758605-1-bryan.odonoghue@linaro.org> References: <20220524140207.2758605-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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 Signed-off-by: Bryan O'Donoghue --- drivers/i2c/busses/i2c-qcom-cci.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 5c7cc862f08f..90d02effeae9 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -638,6 +638,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; @@ -649,14 +654,13 @@ 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_put(dev); + 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);