Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2678319ybh; Mon, 16 Mar 2020 07:43:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtL/fCDtOKi3GRxEQ/r/n7xep+CvzeD9vYKHofdD3Bls2G2It9MwjiRXCDSBHWcnigA52KY X-Received: by 2002:a05:6808:3d0:: with SMTP id o16mr16535843oie.12.1584369815053; Mon, 16 Mar 2020 07:43:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584369815; cv=none; d=google.com; s=arc-20160816; b=re+Ea0GFJc/ASmuxVapi2wFGhJ432wIN3KWiaWzJkJmwyDDI9d1YIhSxXx33MKJthy CVjMHm9LxEd3PuKnZSiM6NmZemRNiwXGo+P6a/hUqUsyjBWEGA993tFAy7lfOhCV2NBb HH0R+fvel57P22A0DAwBQ2fQeLv0M0IMDhJX04selIcLVk5qn/vqASP0HvDGIpSkPcvb kgbv+hI5P/9GRqsd2TQRbDr7MTuViCcEGKFx7wwgGHeQor3nFqFBRi1H7McmNYKu6Ie6 6O2dPQUODtSfH1DRrdY1UaX+s2vNnJEFe5vokTLTtPdRbpEul+if6rAEqmb6+HTG0t6z iQYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7Y2zi8jPa6eYvmnbhlQHcXSOEL3iBWDdVoWYw8NYoMI=; b=0r3KiFkyingOtm+XtEZnKfjkZassvs7xsuCZfQHStwqio0QM2x+pmIPI+KNaYkyf73 D0CDWJGrySTSErIE/+4P8FCQniePIkstrcWjFwAqbjrs3UR2tOI22qNe7/OfWemzuqfa LvXQ7fsMbTJpVaiKme7u9yQUpSEJu2Ja+qdfDc6+K/TMwwICClNjW0aBSvXFtXCcgHO9 AQ1QD8OZ7sTH37sTAIgKSXrKsnseLafQhh5UHPsCRkMTGbNJVGkvN33bNfiLXorG0Ud9 D+cEAkYBOlch/08+yQBosali0YYX0inKuSp/Z0ma3QQX8j4TT1yDVk4nSBVy9JgpGUCV EiFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=qt3qSv5I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t193si73129oih.61.2020.03.16.07.43.22; Mon, 16 Mar 2020 07:43:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@rere.qmqm.pl header.s=1 header.b=qt3qSv5I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731894AbgCPOm0 (ORCPT + 99 others); Mon, 16 Mar 2020 10:42:26 -0400 Received: from rere.qmqm.pl ([91.227.64.183]:18186 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731642AbgCPOmZ (ORCPT ); Mon, 16 Mar 2020 10:42:25 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 48gzXt6JwWzw; Mon, 16 Mar 2020 15:42:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1584369742; bh=2ns96Yjlk6CyI7sqauauOfnPPcjHEnd9dp1VnEEEGnE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qt3qSv5IYlp/Ocv0e40GrF1C6d694xdlijScCOwP5wJDVawaNXcIyoo6FY7xBw8Qy kZHJYWEFCkBxj3jSSO5CwtfHRYwbQC7euEpKWVLYZ279skYgO/wRqUhyy9xDiCcF4+ 9EIviLxKjOgDlEQOB5FW6llnpqMzJ0n/E5+/ajjijLwE5HNV5sSNI+a+0fD9ihzU1Y iJYn00O9QTf2Kf56fpFgGDtpBmFfT6m/olxis71OwdWDxjQkrgNvcj2Pfp8EzkGq4v JKY6Nv8ElRdlDXsobPnYKT3QOLe+VzNyrtUFbp9PVuhEnXEX9/i45NrYjJkWfCvt2r swobIPU3b6OUg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.2 at mail Date: Mon, 16 Mar 2020 15:42:21 +0100 From: =?iso-8859-2?Q?Micha=B3_Miros=B3aw?= To: Dmitry Osipenko Cc: Ludovic Desroches , Nicolas Ferre , Alexandre Belloni , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] i2c: at91: support atomic write xfer Message-ID: <20200316144221.GC19141@qmqm.qmqm.pl> References: <9924dd54-dd8b-d130-9607-2bbbc65675d5@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9924dd54-dd8b-d130-9607-2bbbc65675d5@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > --- > > 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. > ... > > + 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. Best Regards Michał Mirosław