From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Osipenko Subject: Re: [PATCH] i2c: at91: support atomic write xfer Date: Sun, 15 Mar 2020 23:46:33 +0300 Message-ID: <9924dd54-dd8b-d130-9607-2bbbc65675d5@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from mail-lf1-f65.google.com ([209.85.167.65]:39509 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729103AbgCOUqi (ORCPT ); Sun, 15 Mar 2020 16:46:38 -0400 In-Reply-To: Content-Language: en-US Sender: linux-i2c-owner@vger.kernel.org List-Id: linux-i2c@vger.kernel.org To: =?UTF-8?B?TWljaGHFgiBNaXJvc8WCYXc=?= , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org 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 > --- 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.