Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2480212ybl; Thu, 9 Jan 2020 13:32:37 -0800 (PST) X-Google-Smtp-Source: APXvYqw3NNIZDiUuPXD4cLdsP3tTRurVTIhVwri9NLF/VOvySjj2rlUlxj0VpIvdwn/7WgqsErcK X-Received: by 2002:a05:6808:64e:: with SMTP id z14mr4634143oih.79.1578605557129; Thu, 09 Jan 2020 13:32:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578605557; cv=none; d=google.com; s=arc-20160816; b=mz/fLNwtQiN4zmIiQlPYZxR3al8Jqk0AXuUIbTrCnpm74pb9/jxE/SpM6rJ1mR/D6k tz8z0bzLCRtNCMEW2RhwSxDm3zK1HHszeUNCJeYgP0Z1QSvKGz9AklILbVBfl3hCqh2E B2RTfKqHqnjGlExOxJIVF9i+uJJyLzPeQ7BI3ox+4cwY46lfIDlbKDoduiyQL1kosIiv mWSGJms3/t1fCTdXgDjvqlJzSrEQNZXX1iq1s9CudQ4CNMenzeT9gM3Lou21f7o5BgxE WITK/Mlii08FSFGUtug6jTis/fT47p0qYj+UiKnmxjFYBwnrYZ9mCl4qK4OwurbSF57m GVgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:in-reply-to:subject:cc:to:from :date; bh=gWBtny/EMsAys+/faJ8J4qILc+N8VB6CFw3xO7B4Gso=; b=zt1LgMC721zuk8jdClBKipFPTUUAfpNUqqsQJCMREITVkSiq55JbYtNP5FrEwM40TZ 08w09kRjnxWovZRf+Dj61p6jOIdveAnvIo/zCry4bCfCqkarZlYt1aI3tCah0SAPl/fJ tSeR9KTT+UbEzqiCAwjzcrjaGjy8vJexA0jOzJABtx2IxM3VS774+G3p4UTvOOG3R0KV F61zxV1T/TwCU9HyiQD74pifnemyAwxcGF0c9QBjWA23vo6pEWQYBVyuUuNXLiKFsiHz a+kWNtBN6qMkA1q91+hPtF3WPcK8Sn4MxmVQF/rm7FxZm92hgtWo2sl8dzAfKTljciFx NGrw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c2si4932499oto.207.2020.01.09.13.32.22; Thu, 09 Jan 2020 13:32:37 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728588AbgAIVax (ORCPT + 99 others); Thu, 9 Jan 2020 16:30:53 -0500 Received: from foss.arm.com ([217.140.110.172]:37040 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbgAIVax (ORCPT ); Thu, 9 Jan 2020 16:30:53 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E0B8F31B; Thu, 9 Jan 2020 13:30:52 -0800 (PST) Received: from localhost (unknown [10.37.6.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6897C3F534; Thu, 9 Jan 2020 13:30:52 -0800 (PST) Date: Thu, 09 Jan 2020 21:30:50 +0000 From: Mark Brown To: Sameer Pujar Cc: broonie@kernel.org, jonathanh@nvidia.com, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Mark Brown Subject: Applied "regmap: add iopoll-like atomic polling macro" to the regmap tree In-Reply-To: <1578546590-24737-1-git-send-email-spujar@nvidia.com> Message-Id: X-Patchwork-Hint: ignore Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regmap: add iopoll-like atomic polling macro has been applied to the regmap tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-5.6 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 50816a4c39263913d8cfd1ee32f90102679606c6 Mon Sep 17 00:00:00 2001 From: Sameer Pujar Date: Thu, 9 Jan 2020 10:39:50 +0530 Subject: [PATCH] regmap: add iopoll-like atomic polling macro This patch adds a macro 'regmap_read_poll_timeout_atomic' that works similar to 'readx_poll_timeout_atomic' defined in linux/iopoll.h; This is atomic version of already available 'regmap_read_poll_timeout' macro. It should be noted that above atomic macro cannot be used by all regmaps. If the regmap is set up for atomic use (flat or no cache and MMIO) then only it can use. Signed-off-by: Sameer Pujar Link: https://lore.kernel.org/r/1578546590-24737-1-git-send-email-spujar@nvidia.com Signed-off-by: Mark Brown --- include/linux/regmap.h | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/linux/regmap.h b/include/linux/regmap.h index dfe493ac692d..f0a092a1a96d 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -144,6 +144,51 @@ struct reg_sequence { __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ }) +/** + * regmap_read_poll_timeout_atomic - Poll until a condition is met or a timeout occurs + * + * @map: Regmap to read from + * @addr: Address to poll + * @val: Unsigned integer variable to read the value into + * @cond: Break condition (usually involving @val) + * @delay_us: Time to udelay between reads in us (0 tight-loops). + * Should be less than ~10us since udelay is used + * (see Documentation/timers/timers-howto.rst). + * @timeout_us: Timeout in us, 0 means never timeout + * + * Returns 0 on success and -ETIMEDOUT upon a timeout or the regmap_read + * error return value in case of a error read. In the two former cases, + * the last read value at @addr is stored in @val. + * + * This is modelled after the readx_poll_timeout_atomic macros in linux/iopoll.h. + * + * Note: In general regmap cannot be used in atomic context. If you want to use + * this macro then first setup your regmap for atomic use (flat or no cache + * and MMIO regmap). + */ +#define regmap_read_poll_timeout_atomic(map, addr, val, cond, delay_us, timeout_us) \ +({ \ + u64 __timeout_us = (timeout_us); \ + unsigned long __delay_us = (delay_us); \ + ktime_t __timeout = ktime_add_us(ktime_get(), __timeout_us); \ + int __ret; \ + for (;;) { \ + __ret = regmap_read((map), (addr), &(val)); \ + if (__ret) \ + break; \ + if (cond) \ + break; \ + if ((__timeout_us) && \ + ktime_compare(ktime_get(), __timeout) > 0) { \ + __ret = regmap_read((map), (addr), &(val)); \ + break; \ + } \ + if (__delay_us) \ + udelay(__delay_us); \ + } \ + __ret ?: ((cond) ? 0 : -ETIMEDOUT); \ +}) + /** * regmap_field_read_poll_timeout - Poll until a condition is met or timeout * -- 2.20.1