From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Biju Das <biju.das.jz@bp.renesas.com>,
Chris Brandt <Chris.Brandt@renesas.com>,
"andi.shyti@kernel.org" <andi.shyti@kernel.org>,
"robh@kernel.org" <robh@kernel.org>,
"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
"conor+dt@kernel.org" <conor+dt@kernel.org>,
"geert+renesas@glider.be" <geert+renesas@glider.be>,
"magnus.damm@gmail.com" <magnus.damm@gmail.com>,
"mturquette@baylibre.com" <mturquette@baylibre.com>,
"sboyd@kernel.org" <sboyd@kernel.org>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"wsa+renesas@sang-engineering.com"
<wsa+renesas@sang-engineering.com>
Cc: "linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH v2 04/12] i2c: riic: Use pm_runtime_resume_and_get()
Date: Wed, 26 Jun 2024 09:30:52 +0300 [thread overview]
Message-ID: <a8b5ccee-f9a9-4bfa-be70-085d2fe7f8d2@tuxon.dev> (raw)
In-Reply-To: <TY3PR01MB11346A47493E0EE96CB2CF17B86D62@TY3PR01MB11346.jpnprd01.prod.outlook.com>
On 26.06.2024 09:23, Biju Das wrote:
>
>
>> -----Original Message-----
>> From: claudiu beznea <claudiu.beznea@tuxon.dev>
>> Sent: Wednesday, June 26, 2024 7:14 AM
>> To: Biju Das <biju.das.jz@bp.renesas.com>; Chris Brandt <Chris.Brandt@renesas.com>;
>> andi.shyti@kernel.org; robh@kernel.org; krzk+dt@kernel.org; conor+dt@kernel.org;
>> geert+renesas@glider.be; magnus.damm@gmail.com; mturquette@baylibre.com; sboyd@kernel.org;
>> p.zabel@pengutronix.de; wsa+renesas@sang-engineering.com
>> Cc: linux-renesas-soc@vger.kernel.org; linux-i2c@vger.kernel.org; devicetree@vger.kernel.org;
>> linux-kernel@vger.kernel.org; linux-clk@vger.kernel.org; Claudiu Beznea
>> <claudiu.beznea.uj@bp.renesas.com>
>> Subject: Re: [PATCH v2 04/12] i2c: riic: Use pm_runtime_resume_and_get()
>>
>> Hi, Biju,
>>
>> On 25.06.2024 18:53, Biju Das wrote:
>>> Hi Claudiu,
>>>
>>>> -----Original Message-----
>>>> From: Claudiu <claudiu.beznea@tuxon.dev>
>>>> Sent: Tuesday, June 25, 2024 1:14 PM
>>>> Subject: [PATCH v2 04/12] i2c: riic: Use pm_runtime_resume_and_get()
>>>>
>>>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>>
>>>> pm_runtime_get_sync() may return with error. In case it returns with
>>>> error
>>>> dev->power.usage_count needs to be decremented.
>>>> dev->pm_runtime_resume_and_get()
>>>> takes care of this. Thus use it.
>>>>
>>>> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>>> ---
>>>>
>>>> Changes in v2:
>>>> - delete i2c adapter all the time in remove
>>>>
>>>> drivers/i2c/busses/i2c-riic.c | 30 ++++++++++++++++++++++++------
>>>> 1 file changed, 24 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-riic.c
>>>> b/drivers/i2c/busses/i2c-riic.c index 83e4d5e14ab6..002b11b020fa
>>>> 100644
>>>> --- a/drivers/i2c/busses/i2c-riic.c
>>>> +++ b/drivers/i2c/busses/i2c-riic.c
>>>> @@ -113,6 +113,8 @@ struct riic_irq_desc {
>>>> char *name;
>>>> };
>>>>
>>>> +static const char * const riic_rpm_err_msg = "Failed to runtime
>>>> +resume";
>>>> +
>>>> static inline void riic_writeb(struct riic_dev *riic, u8 val, u8 offset) {
>>>> writeb(val, riic->base + riic->info->regs[offset]); @@ -133,10
>>>> +135,14 @@ static int riic_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
>>>> struct riic_dev *riic = i2c_get_adapdata(adap);
>>>> struct device *dev = adap->dev.parent;
>>>> unsigned long time_left;
>>>> - int i;
>>>> + int i, ret;
>>>> u8 start_bit;
>>>>
>>>> - pm_runtime_get_sync(dev);
>>>> + ret = pm_runtime_resume_and_get(dev);
>>>> + if (ret) {
>>>> + dev_err(dev, riic_rpm_err_msg);
>>>
>>> As at the moment we don't know how to reproduce this error condition
>>> Can we use WARN_ON_ONCE() instead to catch detailed error condition here??
>>
>> [1] states "So, naturally, use of WARN_ON() is also now discouraged much of the time". I've go with
>> dev_err() or something similar.
>
> WARN_ON_ONCE() should be ok I guess as people are using for printing this info only once??
Ok, I'm leaving this to I2C maintainers.
Andi, Wolfram,
Would you prefer having WARN_ON_ONCE() instead of dev_err() for potential
failures of pm_runtime_resume_and_get()?
Thank you,
Claudiu Beznea
>
> Currently we don't know how to trigger pm_runtime_resume_and_get() error
> condition in our setup using a testapp and we are expecting an error may
> happen in future. If at all there is an error in future, we need detailed
> error info so that we can handle it and fix the bug.
>
> Cheers,
> Biju
>
>>
>> Thank you,
>> Claudiu Beznea
>>
>> [1] https://lwn.net/Articles/969923/
>>
>>>
>>> Cheers,
>>> Biju
>>>
>>>> + return ret;
>>>> + }
>>>>
>>>> if (riic_readb(riic, RIIC_ICCR2) & ICCR2_BBSY) {
>>>> riic->err = -EBUSY;
>>>> @@ -301,6 +307,7 @@ static const struct i2c_algorithm riic_algo = {
>>>>
>>>> static int riic_init_hw(struct riic_dev *riic, struct i2c_timings
>>>> *t) {
>>>> + int ret;
>>>> unsigned long rate;
>>>> int total_ticks, cks, brl, brh;
>>>> struct device *dev = riic->adapter.dev.parent; @@ -379,7 +386,11 @@
>>>> static int riic_init_hw(struct riic_dev *riic, struct i2c_timings *t)
>>>> t->scl_fall_ns / (1000000000 / rate),
>>>> t->scl_rise_ns / (1000000000 / rate), cks, brl, brh);
>>>>
>>>> - pm_runtime_get_sync(dev);
>>>> + ret = pm_runtime_resume_and_get(dev);
>>>> + if (ret) {
>>>> + dev_err(dev, riic_rpm_err_msg);
>>>> + return ret;
>>>> + }
>>>>
>>>> /* Changing the order of accessing IICRST and ICE may break things! */
>>>> riic_writeb(riic, ICCR1_IICRST | ICCR1_SOWP, RIIC_ICCR1); @@
>>>> -498,11 +509,18 @@ static void riic_i2c_remove(struct platform_device *pdev) {
>>>> struct riic_dev *riic = platform_get_drvdata(pdev);
>>>> struct device *dev = &pdev->dev;
>>>> + int ret;
>>>>
>>>> - pm_runtime_get_sync(dev);
>>>> - riic_writeb(riic, 0, RIIC_ICIER);
>>>> - pm_runtime_put(dev);
>>>> i2c_del_adapter(&riic->adapter);
>>>> +
>>>> + ret = pm_runtime_resume_and_get(dev);
>>>> + if (ret) {
>>>> + dev_err(dev, riic_rpm_err_msg);
>>>> + } else {
>>>> + riic_writeb(riic, 0, RIIC_ICIER);
>>>> + pm_runtime_put(dev);
>>>> + }
>>>> +
>>>> pm_runtime_disable(dev);
>>>> }
>>>>
>>>> --
>>>> 2.39.2
>>>>
>>>
next prev parent reply other threads:[~2024-06-26 6:30 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 12:13 [PATCH v2 00/12] i2c: riic: Add support for Renesas RZ/G3S Claudiu
2024-06-25 12:13 ` [PATCH v2 01/12] clk: renesas: r9a08g045: Add clock, reset and power domain support for I2C Claudiu
2024-06-26 12:19 ` Geert Uytterhoeven
2024-06-25 12:13 ` [PATCH v2 02/12] i2c: riic: Use temporary variable for struct device Claudiu
2024-07-04 22:30 ` Andi Shyti
2024-07-08 5:13 ` claudiu beznea
2024-06-25 12:13 ` [PATCH v2 03/12] i2c: riic: Call pm_runtime_get_sync() when need to access registers Claudiu
2024-07-04 22:32 ` Andi Shyti
2024-06-25 12:13 ` [PATCH v2 04/12] i2c: riic: Use pm_runtime_resume_and_get() Claudiu
2024-06-25 15:53 ` Biju Das
2024-06-26 6:13 ` claudiu beznea
2024-06-26 6:23 ` Biju Das
2024-06-26 6:30 ` claudiu beznea [this message]
2024-06-27 19:21 ` Andi Shyti
2024-06-26 7:10 ` Geert Uytterhoeven
2024-06-26 8:15 ` Biju Das
2024-07-04 22:42 ` Andi Shyti
2024-07-05 7:19 ` Geert Uytterhoeven
2024-07-05 12:14 ` Andi Shyti
2024-07-08 5:19 ` claudiu beznea
2024-07-08 5:36 ` Biju Das
2024-07-08 9:33 ` Biju Das
2024-06-25 12:13 ` [PATCH v2 05/12] i2c: riic: Enable runtime PM autosuspend support Claudiu
2024-06-25 12:13 ` [PATCH v2 06/12] i2c: riic: Add suspend/resume support Claudiu
2024-06-25 12:13 ` [PATCH v2 07/12] i2c: riic: Define individual arrays to describe the register offsets Claudiu
2024-06-28 5:59 ` Biju Das
2024-06-28 7:32 ` claudiu beznea
2024-06-28 7:55 ` Biju Das
2024-06-28 8:02 ` claudiu beznea
2024-06-28 8:04 ` claudiu beznea
2024-06-28 8:09 ` Biju Das
2024-06-28 8:12 ` claudiu beznea
2024-06-28 8:24 ` Biju Das
2024-06-28 8:29 ` Biju Das
2024-06-28 10:25 ` claudiu beznea
2024-06-28 10:49 ` Biju Das
2024-06-28 11:24 ` claudiu beznea
2024-06-28 11:29 ` Biju Das
2024-06-28 15:05 ` Biju Das
2024-06-28 9:13 ` Geert Uytterhoeven
2024-06-28 10:28 ` claudiu beznea
2024-06-28 11:39 ` Geert Uytterhoeven
2024-06-29 11:11 ` claudiu beznea
2024-08-19 19:56 ` Andi Shyti
2024-06-28 9:08 ` Geert Uytterhoeven
2024-06-28 9:13 ` Biju Das
2024-06-25 12:13 ` [PATCH v2 08/12] dt-bindings: i2c: renesas,riic: Document the R9A08G045 support Claudiu
2024-06-25 16:28 ` Conor Dooley
2024-06-25 12:13 ` [PATCH v2 09/12] i2c: riic: Add support for fast mode plus Claudiu
2024-06-28 9:22 ` Geert Uytterhoeven
2024-06-28 10:06 ` claudiu beznea
2024-07-10 14:20 ` claudiu beznea
2024-07-11 7:53 ` Geert Uytterhoeven
2024-07-11 10:55 ` claudiu beznea
2024-06-29 5:38 ` Biju Das
2024-06-29 11:13 ` claudiu beznea
2024-06-25 12:13 ` [PATCH v2 10/12] arm64: dts: renesas: r9a08g045: Add I2C nodes Claudiu
2024-06-25 12:13 ` [PATCH v2 11/12] arm64: dts: renesas: rzg3s-smarc: Enable i2c0 node Claudiu
2024-06-25 12:13 ` [PATCH v2 12/12] arm64: dts: renesas: rzg3s-smarc-som: Enable i2c1 node Claudiu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a8b5ccee-f9a9-4bfa-be70-085d2fe7f8d2@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=Chris.Brandt@renesas.com \
--cc=andi.shyti@kernel.org \
--cc=biju.das.jz@bp.renesas.com \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=wsa+renesas@sang-engineering.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).