Message ID | 20221128105158.1536551-1-carsten.haitzler@foss.arm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5575820wrr; Mon, 28 Nov 2022 02:59:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf6wkz5LU/QnNSknlojicFkh8DTKgpubsof+N5SNEuKcyXT4VoZUpQ7+/i75vFmfuLM9x5Kw X-Received: by 2002:a17:902:ee89:b0:187:1a3f:d54b with SMTP id a9-20020a170902ee8900b001871a3fd54bmr45290402pld.9.1669633192782; Mon, 28 Nov 2022 02:59:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669633192; cv=none; d=google.com; s=arc-20160816; b=fdFnVjUTLj9ObyUhvqWLjs9CTnFcsXyPYVwceef86YdzHtzP9XeepqO9hHtfbbhes9 M5diNoJRNEvQwE/LJ9/AduXKXs5YQkFDmBnuyplgUmK0BcSm4928H79r09sX/dFccKtp UOQ/DY97tlxx3AYJUrMp1KRgWS4rhTYKk1Xw0RHhhKlRn0hWEvbU80pzxgfQuE4BlN13 eEFutHrwma1UzQ/XlzfeHqY4OBaOmeyS1qmN2VPTMdGPgdgIwahlkU7Jrd2r62nTUiAn 8Nj/wS7EZMpHP4WMV5/Qspbzcjnz4hsbwlZHxiwnuGfmTQVtdXIV7Swwtc2LGfoyp9pj GI4A== 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 :message-id:date:subject:to:from; bh=3IpEVpw+NlMJdpzWSVX9cce5C5RyiPzRNgOi3Wmk6+U=; b=ElEsfuvo9A1Pr/99Jk1tSjlIclyXCOGdZNJD13J9erIjXTFXlpCEy/hWpvmEeLTkfY BRbSJhNwC5Zv/D7JBLLennTuuW/mZfETVQYy+RWx1mS7lX0LqdZ8q6/EbgmzXsqD5gYL hUtgHypfYVSdI3vnAcD0Ug6Pa5oXeqtLsX+FLx+AKty6VYEf+2Qt7DMK2GKOrP9EDiJQ AiMc4jtp220+r1M9JJDGkmcd646CirI6yOAJ2+r31gNOHit13UwAEkdidt1ulz2/O7db TW/l/VlqGO7l/MFtrZZQEeOqRbGMOwQPbUT9uGZ3rs9Nj+3MjXQMdHoWICxjFNL++FvF le3g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a170902c94800b0017f5ea2e8easi12725517pla.357.2022.11.28.02.59.39; Mon, 28 Nov 2022 02:59:52 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230043AbiK1Kw2 (ORCPT <rfc822;gah0developer@gmail.com> + 99 others); Mon, 28 Nov 2022 05:52:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbiK1Kw0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 28 Nov 2022 05:52:26 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 544C1BF9; Mon, 28 Nov 2022 02:52:26 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AE694D6E; Mon, 28 Nov 2022 02:52:32 -0800 (PST) Received: from e126387.arm.com (unknown [10.57.87.52]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 400DE3F73B; Mon, 28 Nov 2022 02:52:25 -0800 (PST) From: carsten.haitzler@foss.arm.com To: michal.simek@xilinx.com, shubhrajyoti.datta@xilinx.com, linux-arm-kernel@lists.infradead.org, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] i2c: cadence: Fix regression with bus recovery Date: Mon, 28 Nov 2022 10:51:58 +0000 Message-Id: <20221128105158.1536551-1-carsten.haitzler@foss.arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750469593354588696?= X-GMAIL-MSGID: =?utf-8?q?1750737294913388924?= |
Series |
[v2] i2c: cadence: Fix regression with bus recovery
|
|
Commit Message
Carsten Haitzler
Nov. 28, 2022, 10:51 a.m. UTC
From: Carsten Haitzler <carsten.haitzler@arm.com> Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c devices that have no pinctrl defined. There is no requirement for this to exist in the DT. This has worked perfectly well without this before in at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to talk to a tda99xx phy). Adding the requirement to have pinctrl set up in the device tree (or otherwise be found) is a regression where the whole i2c device is lost entirely (in this case dropping entire devices which then leads to the drm display stack unable to find the phy for display output, thus having no drm display device and so on down the chain). This converts the above commit to an enhancement if pinctrl can be found for the i2c device, providing a timeout on read with recovery, but if not, do what used to be done rather than a fatal loss of a device. This restores the mentioned display devices to their working state again. Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support") Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> --- Note: This issue was discovered during the porting of the linux kernel on Morello [1]. [1] https://git.morello-project.org/morello/kernel/linux --- drivers/i2c/busses/i2c-cadence.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Comments
[AMD Official Use Only - General] > -----Original Message----- > From: carsten.haitzler@foss.arm.com <carsten.haitzler@foss.arm.com> > Sent: Monday, November 28, 2022 4:22 PM > To: michal.simek@xilinx.com; shubhrajyoti.datta@xilinx.com; linux-arm- > kernel@lists.infradead.org; linux-i2c@vger.kernel.org; linux- > kernel@vger.kernel.org > Subject: [PATCH v2] i2c: cadence: Fix regression with bus recovery > > CAUTION: This message has originated from an External Source. Please use > proper judgment and caution when opening attachments, clicking links, or > responding to this email. > > > From: Carsten Haitzler <carsten.haitzler@arm.com> > > Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c > devices that have no pinctrl defined. There is no requirement for this to exist > in the DT. This has worked perfectly well without this before in at least 1 real > usage case on hardware (Mali Komeda DPU, Cadence i2c to talk to a tda99xx > phy). Adding the requirement to have pinctrl set up in the device tree (or > otherwise be found) is a regression where the whole i2c device is lost > entirely (in this case dropping entire devices which then leads to the drm > display stack unable to find the phy for display output, thus having no drm > display device and so on down the chain). > > This converts the above commit to an enhancement if pinctrl can be found > for the i2c device, providing a timeout on read with recovery, but if not, do > what used to be done rather than a fatal loss of a device. > > This restores the mentioned display devices to their working state again. > > Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support") > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> Reviewed-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
+Wolfram, On 11/28/22 11:51, carsten.haitzler@foss.arm.com wrote: > CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email. > > > From: Carsten Haitzler <carsten.haitzler@arm.com> > > Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c > devices that have no pinctrl defined. There is no requirement for this > to exist in the DT. This has worked perfectly well without this before in > at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to > talk to a tda99xx phy). Adding the requirement to have pinctrl set up in > the device tree (or otherwise be found) is a regression where the whole > i2c device is lost entirely (in this case dropping entire devices which > then leads to the drm display stack unable to find the phy for display > output, thus having no drm display device and so on down the chain). > > This converts the above commit to an enhancement if pinctrl can be found > for the i2c device, providing a timeout on read with recovery, but if not, > do what used to be done rather than a fatal loss of a device. > > This restores the mentioned display devices to their working state again. > > Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support") > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> > --- > Note: This issue was discovered during the porting of the linux kernel > on Morello [1]. > > [1] https://git.morello-project.org/morello/kernel/linux > --- > drivers/i2c/busses/i2c-cadence.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c > index fe0cd205502d..09acd2d399d5 100644 > --- a/drivers/i2c/busses/i2c-cadence.c > +++ b/drivers/i2c/busses/i2c-cadence.c > @@ -852,7 +852,8 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, > CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US); > if (ret) { > ret = -EAGAIN; > - i2c_recover_bus(adap); > + if (id->adap.bus_recovery_info) > + i2c_recover_bus(adap); > goto out; > } > > @@ -1263,9 +1264,13 @@ static int cdns_i2c_probe(struct platform_device *pdev) > > id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev); > if (IS_ERR(id->rinfo.pinctrl)) { > + int err = PTR_ERR(id->rinfo.pinctrl); > + > dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); > - return PTR_ERR(id->rinfo.pinctrl); > - } > + if (err != -ENODEV) > + return err; > + } else > + id->adap.bus_recovery_info = &id->rinfo; > > id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem); > if (IS_ERR(id->membase)) > @@ -1283,7 +1288,6 @@ static int cdns_i2c_probe(struct platform_device *pdev) > id->adap.retries = 3; /* Default retry value. */ > id->adap.algo_data = id; > id->adap.dev.parent = &pdev->dev; > - id->adap.bus_recovery_info = &id->rinfo; > init_completion(&id->xfer_done); > snprintf(id->adap.name, sizeof(id->adap.name), > "Cadence I2C at %08lx", (unsigned long)r_mem->start); > -- > 2.32.0 > Acked-by: Michal Simek <michal.simek@amd.com> Wolfram: up2you if you want to take it for 6.1. If it is too late I think it should be labeled as stable material for 6.1. Thanks, Michal
On Mon, Nov 28, 2022 at 10:51:58AM +0000, carsten.haitzler@foss.arm.com wrote: > From: Carsten Haitzler <carsten.haitzler@arm.com> > > Commit "i2c: cadence: Add standard bus recovery support" breaks for i2c > devices that have no pinctrl defined. There is no requirement for this > to exist in the DT. This has worked perfectly well without this before in > at least 1 real usage case on hardware (Mali Komeda DPU, Cadence i2c to > talk to a tda99xx phy). Adding the requirement to have pinctrl set up in > the device tree (or otherwise be found) is a regression where the whole > i2c device is lost entirely (in this case dropping entire devices which > then leads to the drm display stack unable to find the phy for display > output, thus having no drm display device and so on down the chain). > > This converts the above commit to an enhancement if pinctrl can be found > for the i2c device, providing a timeout on read with recovery, but if not, > do what used to be done rather than a fatal loss of a device. > > This restores the mentioned display devices to their working state again. > > Fixes: 58b924241d0a ("i2c: cadence: Add standard bus recovery support") > Signed-off-by: Carsten Haitzler <carsten.haitzler@arm.com> Fixed this checkpatch check: CHECK: Unbalanced braces around else statement #55: FILE: drivers/i2c/busses/i2c-cadence.c:1272: + } else and applied to for-current, thanks!
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index fe0cd205502d..09acd2d399d5 100644 --- a/drivers/i2c/busses/i2c-cadence.c +++ b/drivers/i2c/busses/i2c-cadence.c @@ -852,7 +852,8 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, CDNS_I2C_POLL_US, CDNS_I2C_TIMEOUT_US); if (ret) { ret = -EAGAIN; - i2c_recover_bus(adap); + if (id->adap.bus_recovery_info) + i2c_recover_bus(adap); goto out; } @@ -1263,9 +1264,13 @@ static int cdns_i2c_probe(struct platform_device *pdev) id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev); if (IS_ERR(id->rinfo.pinctrl)) { + int err = PTR_ERR(id->rinfo.pinctrl); + dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); - return PTR_ERR(id->rinfo.pinctrl); - } + if (err != -ENODEV) + return err; + } else + id->adap.bus_recovery_info = &id->rinfo; id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &r_mem); if (IS_ERR(id->membase)) @@ -1283,7 +1288,6 @@ static int cdns_i2c_probe(struct platform_device *pdev) id->adap.retries = 3; /* Default retry value. */ id->adap.algo_data = id; id->adap.dev.parent = &pdev->dev; - id->adap.bus_recovery_info = &id->rinfo; init_completion(&id->xfer_done); snprintf(id->adap.name, sizeof(id->adap.name), "Cadence I2C at %08lx", (unsigned long)r_mem->start);