[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <40a2af076fb86301dd1ffac60488ae550a083be7.camel@siemens.com>
Date: Mon, 15 May 2023 13:11:33 +0000
From: "Sverdlin, Alexander" <alexander.sverdlin@...mens.com>
To: "alexander.stein@...tq-group.com" <alexander.stein@...tq-group.com>,
"linux-imx@....com" <linux-imx@....com>
CC: "kernel@...gutronix.de" <kernel@...gutronix.de>,
"s.hauer@...gutronix.de" <s.hauer@...gutronix.de>,
"festevam@...il.com" <festevam@...il.com>,
"shawnguo@...nel.org" <shawnguo@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-i2c@...r.kernel.org" <linux-i2c@...r.kernel.org>,
"aisheng.dong@....com" <aisheng.dong@....com>
Subject: Re: [PATCH v3] i2c: lpi2c: cache peripheral clock rate
Hello Alexander,
On Fri, 2023-04-21 at 15:48 +0200, Alexander Stein wrote:
> > + lpi2c_imx->clk_change_nb.notifier_call =
> > lpi2c_imx_clk_change_cb;
> > + ret = devm_clk_notifier_register(&pdev->dev, lpi2c_imx-
> > >clks[0].clk,
> > + &lpi2c_imx-
> > >clk_change_nb);
> > + if (ret)
> > + return dev_err_probe(&pdev->dev, ret,
> > + "can't register peripheral
> > clock
> notifier\n");
> > + lpi2c_imx->rate_per = clk_get_rate(lpi2c_imx->clks[0].clk);
> > + if (!lpi2c_imx->rate_per) {
> > + dev_err(&pdev->dev, "can't get I2C peripheral clock
> rate\n");
> > + return -EINVAL;
> > + }
> > +
>
> I would switch the order of the calls to devm_clk_notifier_register()
> and
> clk_get_rate(). AFAICS this looks like a possible lost update. The
> notifier
> might change rate_per before the (old) value from clk_get_rate is
> actually
> assigned.
just swapping would not be enough I believe, in the case update event
happens between clk_get_rate() and devm_clk_notifier_register(). I'll
think about it...
--
Alexander Sverdlin
Siemens AG
www.siemens.com
Powered by blists - more mailing lists