[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200316204322.GB17716@pengutronix.de>
Date: Mon, 16 Mar 2020 21:43:22 +0100
From: Marco Felsch <m.felsch@...gutronix.de>
To: Stefan Lengfeld <contact@...fanchrist.eu>
Cc: Michał Mirosław <mirq-linux@...e.qmqm.pl>,
Dmitry Osipenko <digetx@...il.com>,
Ludovic Desroches <ludovic.desroches@...rochip.com>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] i2c: at91: support atomic write xfer
On 20-03-16 18:20, Stefan Lengfeld wrote:
> Hi Michał,
>
> On Mon, Mar 16, 2020 at 03:42:21PM +0100, Michał Mirosław wrote:
> > On Sun, Mar 15, 2020 at 11:46:33PM +0300, Dmitry Osipenko wrote:
> > > 15.03.2020 21:27, Michał Mirosław пишет:
> > > > Implement basic support for atomic write - enough to get a simple
> > > > write to PMIC on shutdown. Only for chips having ALT_CMD register,
> > > > eg. SAMA5D2.
> > > >
> > > > Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
> > > > ---
> > >
> > > Hello Michał,
> > >
> > > ...
> > > > + ret = pm_runtime_get_sync(dev->dev);
> > > > + if (ret < 0)
> > > > + goto out;
> > >
> > > Runtime PM can't be used while interrupts are disabled, unless
> > > pm_runtime_irq_safe() is used and driver's RPM callback is IRQ-safe.
> >
> > I didn't get any warnings from lockdep and friends, but I'll double
> > check if this is by luck.
>
> You can have a look at the I2C atomic patch for the imx-driver. See
>
> https://patchwork.ozlabs.org/patch/1225802/
>
> In that patch Marco Felsch is using clk_enable() and clk_disable() calls.
Yep because we need to handle the runtime_pm stuff by our-self. So for
the imx case we need to handle the clk en-/disable stuff. Runtime pm is
using a workqueue which can't be used in that late case.
Regards,
Marco
> > > ...
> > > > + timeout = jiffies + (2 + msg->len) * HZ/1000;
> > > > + for (;;) {
> > > > + stat = at91_twi_read(dev, AT91_TWI_SR);
> > > > + if (stat & AT91_TWI_TXCOMP)
> > > > + break;
> > > > + if (time_after(jiffies, timeout)) {
> > > > + ret = -ETIMEDOUT;
> > > > + goto out;
> > > > + }
> > > > + udelay(100);
> > > > + }
> > >
> > > Jiffies can't be used with the disabled interrupts because jiffies are
> > > updated by timer's interrupt.
> > >
> > > Either ktime() API or iterator-based loop should be used.
> >
> > Thanks for the pointers. In my use-case power is cut from the CPU at this
> > point so it didn't matter that the loop was infinite.
>
> Here again you can have a look at Marco Felsch's patch. He used the
> function readb_poll_timeout_atomic(). So the loop can potentially
> replaced by a single line.
>
> Kind regards,
> Stefan
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists