linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Ludovic Desroches" <ludovic.desroches@microchip.com>,
	"Nicolas Ferre" <nicolas.ferre@microchip.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c: at91: support atomic write xfer
Date: Sun, 15 Mar 2020 23:46:33 +0300	[thread overview]
Message-ID: <9924dd54-dd8b-d130-9607-2bbbc65675d5@gmail.com> (raw)
In-Reply-To: <c05f76f74cd6a7ec2735c96861f9d5933631c112.1584296795.git.mirq-linux@rere.qmqm.pl>

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@rere.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.

...
> +	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.

  reply	other threads:[~2020-03-15 20:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-15 18:27 [PATCH] i2c: at91: support atomic write xfer Michał Mirosław
2020-03-15 20:46 ` Dmitry Osipenko [this message]
2020-03-16 14:42   ` Michał Mirosław
2020-03-16 17:20     ` Stefan Lengfeld
2020-03-16 20:43       ` Marco Felsch

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=9924dd54-dd8b-d130-9607-2bbbc65675d5@gmail.com \
    --to=digetx@gmail.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=nicolas.ferre@microchip.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).