Message ID | 20221125115103.674756-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 q4csp3961284wrr; Fri, 25 Nov 2022 04:04:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf4wSGBUb9fBQ6lHdfZounaFUfU+iwttC7XkD/IHYUUqR2oR4RgAgmJaQbCk+CuJza1Ku41k X-Received: by 2002:a05:6402:24a0:b0:458:ad54:20d5 with SMTP id q32-20020a05640224a000b00458ad5420d5mr34011463eda.86.1669377892813; Fri, 25 Nov 2022 04:04:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669377892; cv=none; d=google.com; s=arc-20160816; b=LDAFgKZVJvfNkIMNb5B2Zh4kdY+dZCa4TL/taCb3XsHPYzxlVMoV5MX79mwY9wxYCw EgQLeMKmIC8CrVW9c/UBFWN0Rbbldw8LwFxqrgSqZRGwlr15ECQlgjT4MJNIJMIKN8iD 7JtMyF/5dKmFPUJAQgLsPmJH1gMDS8/o10Utj/rRbGaR2E82mudHIk5JoEdIhfxyCDx/ 8ZlN6b/sNSbaRmIylQinBonSwxSaN9VkW0PNcmY/et2tkNM0RYZCMIG3mnjrF+r0tERI zl/ZcJ3hf9p5l4aHxcC5JbJ9gu7gXyzj2JJJEaVPTxIVlnhbFeHPVAC1pbsbQA24hbkI 2gag== 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:cc:to:from; bh=2a4CX+gYe+eN51d05ycJaDwYRz++pqjqEKJMBZgVZ1c=; b=M1NyE9aIYHCfmvI9516JCx0GVnPMXUyKGYHcLwSzUYWuB/OxGvSdIIGwX7glioeynT z0H1Cr6GtqWOaRC9YYobUxLzxi9qi73h6QwdysnsIBjAo5ZYBCDqVocWjqO4/Jx+NKGj v8xZLI4yNCZjS2xWBQ36idbmTdjlbPxEpU88pwNAhk25IOFRrwUG37s610ZYf654HyNF /QLMDQGOrNKf1xgpQi9sWbsrfyMqOfIt2MIawDKb1D9Dz2KWZdmpXOgLL3CBfquOfWoC FXDapZZBelnxFgouRwcoRoQda2AB6kbmyI3zJ0OvG/AK187BzjttXicTEP4FzFInNqhV 4tZg== 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 b17-20020aa7df91000000b0045d539f05a8si2730163edy.576.2022.11.25.04.04.26; Fri, 25 Nov 2022 04:04: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 S230145AbiKYLve (ORCPT <rfc822;zxc52fgh@gmail.com> + 99 others); Fri, 25 Nov 2022 06:51:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbiKYLva (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 25 Nov 2022 06:51:30 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68DB422B1D; Fri, 25 Nov 2022 03:51:28 -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 B2CEA2B; Fri, 25 Nov 2022 03:51:34 -0800 (PST) Received: from e126387.arm.com (unknown [10.57.87.138]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 30D553F73D; Fri, 25 Nov 2022 03:51:27 -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 Cc: torvalds@linux-foundation.org Subject: [PATCH] i2c: cadence: Fix regression with bus recovery Date: Fri, 25 Nov 2022 11:51:03 +0000 Message-Id: <20221125115103.674756-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?1750469593354588696?= |
Series |
i2c: cadence: Fix regression with bus recovery
|
|
Commit Message
Carsten Haitzler
Nov. 25, 2022, 11: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 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Comments
[AMD Official Use Only - General] Hi , Thanks for the patch > -----Original Message----- > From: carsten.haitzler@foss.arm.com <carsten.haitzler@foss.arm.com> > Sent: Friday, November 25, 2022 5:21 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 > Cc: torvalds@linux-foundation.org > Subject: [PATCH] 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> > --- > Note: This issue was discovered during the porting of the linux kernel on > Morello [1]. > > [1] > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit. > morello- > project.org%2Fmorello%2Fkernel%2Flinux&data=05%7C01%7Cshubhraj > yoti.datta%40amd.com%7C651e141296fb497b6c2e08dacedb65ad%7C3dd896 > 1fe4884e608e11a82d994e183d%7C0%7C0%7C638049738949855658%7CUnkn > own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik > 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ny08zTdgJKxXC > dwYaCWFS3mwd65LDqFAIYfjao6gO8Y%3D&reserved=0 > --- > drivers/i2c/busses/i2c-cadence.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c- > cadence.c > index fe0cd205502d..40d0cc6bb996 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; > } > > @@ -1262,10 +1263,10 @@ static int cdns_i2c_probe(struct platform_device > *pdev) > } > > id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev); > - if (IS_ERR(id->rinfo.pinctrl)) { > + if (IS_ERR(id->rinfo.pinctrl)) > dev_info(&pdev->dev, "can't get pinctrl, bus recovery not > supported\n"); > - return PTR_ERR(id->rinfo.pinctrl); > - } > + else > + id->adap.bus_recovery_info = &id->rinfo; May be we could differentiate between ENODEV and other errors. As we want to do this for the case when it is not provided. > > id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, > &r_mem); > if (IS_ERR(id->membase)) > @@ -1283,7 +1284,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
On 11/28/22 06:24, Datta, Shubhrajyoti wrote: > [AMD Official Use Only - General] > > > Hi , > Thanks for the patch > >> -----Original Message----- >> From: carsten.haitzler@foss.arm.com <carsten.haitzler@foss.arm.com> >> Sent: Friday, November 25, 2022 5:21 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 >> Cc: torvalds@linux-foundation.org >> Subject: [PATCH] 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> >> --- >> Note: This issue was discovered during the porting of the linux kernel on >> Morello [1]. >> >> [1] >> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit. >> morello- >> project.org%2Fmorello%2Fkernel%2Flinux&data=05%7C01%7Cshubhraj >> yoti.datta%40amd.com%7C651e141296fb497b6c2e08dacedb65ad%7C3dd896 >> 1fe4884e608e11a82d994e183d%7C0%7C0%7C638049738949855658%7CUnkn >> own%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik >> 1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ny08zTdgJKxXC >> dwYaCWFS3mwd65LDqFAIYfjao6gO8Y%3D&reserved=0 >> --- >> drivers/i2c/busses/i2c-cadence.c | 10 +++++----- >> 1 file changed, 5 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c- >> cadence.c >> index fe0cd205502d..40d0cc6bb996 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; >> } >> >> @@ -1262,10 +1263,10 @@ static int cdns_i2c_probe(struct platform_device >> *pdev) >> } >> >> id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev); >> - if (IS_ERR(id->rinfo.pinctrl)) { >> + if (IS_ERR(id->rinfo.pinctrl)) >> dev_info(&pdev->dev, "can't get pinctrl, bus recovery not >> supported\n"); >> - return PTR_ERR(id->rinfo.pinctrl); >> - } >> + else >> + id->adap.bus_recovery_info = &id->rinfo; > > May be we could differentiate between ENODEV and other errors. > As we want to do this for the case when it is not provided. We could, but just keep in mind this patch is essentially restoring behavior on any pinctrl error to previous behavior - so trying to undo the regression as strictly as possible. Certainly checking specifically for ENODEV does fix it for me which is the case of no pinctrl. I'll send a v2. >> id->membase = devm_platform_get_and_ioremap_resource(pdev, 0, >> &r_mem); >> if (IS_ERR(id->membase)) >> @@ -1283,7 +1284,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
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c index fe0cd205502d..40d0cc6bb996 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; } @@ -1262,10 +1263,10 @@ static int cdns_i2c_probe(struct platform_device *pdev) } id->rinfo.pinctrl = devm_pinctrl_get(&pdev->dev); - if (IS_ERR(id->rinfo.pinctrl)) { + if (IS_ERR(id->rinfo.pinctrl)) dev_info(&pdev->dev, "can't get pinctrl, bus recovery not supported\n"); - return PTR_ERR(id->rinfo.pinctrl); - } + 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 +1284,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);