From patchwork Thu Apr 30 07:04:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1132 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 0A0143F0D3 for ; Thu, 30 Apr 2020 09:04:30 +0200 (CEST) Received: by mail-pj1-f72.google.com with SMTP id l40sf729764pjb.8 for ; Thu, 30 Apr 2020 00:04:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588230268; cv=pass; d=google.com; s=arc-20160816; b=Y72O/gA/SlTN7hjtBGkxNtSlfsEcAOzJ7FxtIkKtZCjRMbGIc/2ehfUrfQmZ02z6H8 qekQiGWk2iEnhlKncDQKRYKQa5GsHj0L6urQBR11yRX4UMyJsPBpaov99KJcu7DoSqW/ UDFnqTSOHxIMqxtvTKYAymso4X8BCnVxdQQQ/hSypNIUw/aTn9d0iNnxIhgNIiyWYxQl w8NvC+BIu9DyCeT+Q2TYnRXHAj2JfYs7sFG2HC2DBuxunBwMe9vRwu6CpVgVPRUKKvzt Tn0k3yF6zrnfYv3UWKq0ZId+TvVCIiawlw5I5kjiGorH1UDh3Px99GtZLJ8S80WxqaAf t2FQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=0z5t+1DqXG7NePlBljcWxleqB0wSmvt5+4pFLXh1mWQ=; b=Yi0de9z1RasLvBAHpqr8pL7KXAvQYGu7UZPrdonvyGemLgHW6z90vRJehMNMN4KbKh cN4uYJi6js2ZornW/8DGfUPIwiyIb2+izmcU8y1UvGPWlobOPCJAKcmSXsw/A821uj81 Xb0XSzKB0c+DNnnt/dnrXgxsOFEbCN7QxK74ZX276W0n3Ljbe8kjscsTGTHvlNMzUhtt +u4XLTi9EtNPeCbvc05QI5vaHiVLgd9nwaeUm7owaDfHwKHm/qkQLvhoJNTy0LdBs/cO Su8wpKHwRxqgh0rmz/7I53knGOB9lVfYHZMWuJ+UgomZgJsScbfSCZwc/HV5VCsPjlhV JOYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iY+ebA4C; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=0z5t+1DqXG7NePlBljcWxleqB0wSmvt5+4pFLXh1mWQ=; b=W539/RMaS9sRuBzEqh8EaUn5r86pkv43qlVApih8LX7109lINdznavrr6ZHBJW57pS S9ErrQggnxyd21sRdH3RUm3L7t2O30i7WfuVjmrHU42Yxp9YozCZYxDtlSg6NafDLaX3 LqkEiE3qzVIFL1T3SYDUYvS9bttPzee87Oe3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=0z5t+1DqXG7NePlBljcWxleqB0wSmvt5+4pFLXh1mWQ=; b=NQUjWnZ7zY0vk+WRVlHujoqu1Y7n09OzIUMWoG2iDiuGPFW9kkkHByqpi4NDUC03oC 2ZV+gLKCjTT9lcJBWPbqGRlusUnNaTCpUUsZKFnfpls0fsg/TbkL0S4X3M4WP9SZsZrS tnPDRF2APqYOHFqgN/WXYBmsXMWmq73+9RxWbcO0mFkVdac9285y9nF+oQK5lwJp8IzB P9Y8GRVSGIt2mynHMLezPUvb7ojDiKj+k0R9nn36tUdpbdf7OiwUB2B+ZUWCShxzJ/Sf /PM9gc3RdkFey4tv+SNXVSD6ahKC7q3H+AOg+/ZZQAxfxcyKa1JzqDPiAm3mghTEO4Ko oTIg== X-Gm-Message-State: AGi0PubU371/vK+AQd1BDJZVVfEsBmEGetMpsNu+2lE5y5ek439JEsKn d77iOfAMSS2dIlena6XoapMziuWv X-Google-Smtp-Source: APiQypJzrvmv7RmnjdF7rU1mVqmdjmY24qXa3hqY2oXNpUSlOMZiTgGXCFijpaxJLpYY/1qW2jT1aQ== X-Received: by 2002:a17:902:a413:: with SMTP id p19mr2351975plq.1.1588230268047; Thu, 30 Apr 2020 00:04:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:224f:: with SMTP id c73ls1620747pje.3.canary-gmail; Thu, 30 Apr 2020 00:04:27 -0700 (PDT) X-Received: by 2002:a17:90a:8c85:: with SMTP id b5mr1276667pjo.187.1588230267568; Thu, 30 Apr 2020 00:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588230267; cv=none; d=google.com; s=arc-20160816; b=pS1pXquS4qhSqQ2PbBhWyok0FapvlrtCQLqSzlxFnNc54GdSaCi7DiZlIiX8u03EMQ EDOfsyJXLt+cSC4JhZm9CghDD5v8/Hc2MNuk7rY4nieQl3K87Gxe4LBpT852jMcNjgeU R8sDjdx7oje+C8SnBJk+AA8KVNBv0FIZpa3xIWNkWxcaDu6S6V7KsjZVG+izCqWcOMRF RKaP7MuMj1rdRpFrDA0ijs9Evf6ZdAZSugGy7xrDTj5T4eyIH7/q1BrrTckpIYBxLWiR oy/Ba2Ek8B5zw8+HeFtXqmI8M5K1iISDo1TL3DTfOalTxEdztsKGVfRKJhRaLHlGbZaT qZQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QZQxIM9Lp5gBpYd0vuqexfM8OFH70HyOZiX2o76/vfc=; b=xZfcV57ZtX0V16cTDGHy1Yh9qJAPeC72+loj2eSv+JfFmNdiAUq9wBMnfARuUlXtIb IQlreuQqs7i3yM5JT+4ri8Ce0gnJLWoUDO3VnieRK9VRg+2wjCuDozlM8FZzbiRC9Mmp d538V5rJnh4UWmBHkW9GMXhA1VobVTrdxHXo6SJ4WhQ2TfvQrN+tHQ96VDRfNganXsx5 OFISsfrNiay0lwGMw9i2qRB0T4emy1tZdM4XL9guZQXsHWESOKjWrqwRlpZr1GMyxMat QDYT3xKLaKoe4yFOKBRxQAVfljhNV9fKn6Jfnmu4A3wKYRrCu3+tum1PQ5YX1Yp9mgV2 gTrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iY+ebA4C; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q15sor975596pjl.0.2020.04.30.00.04.27 for (Google Transport Security); Thu, 30 Apr 2020 00:04:27 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:fc8a:: with SMTP id ci10mr1307246pjb.152.1588230267082; Thu, 30 Apr 2020 00:04:27 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:6514:3619:d1af:85f6]) by smtp.gmail.com with ESMTPSA id p64sm964143pjp.7.2020.04.30.00.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 00:04:25 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki , Tom Rini Subject: [PATCH v2 1/8] iopoll: Add dealy to read poll Date: Thu, 30 Apr 2020 12:34:05 +0530 Message-Id: <20200430070412.12499-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200430070412.12499-1-jagan@amarulasolutions.com> References: <20200430070412.12499-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=iY+ebA4C; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Some drivers and other bsp code not only poll the register with timeout but also required to delay on each transaction. This patch add that requirement by adding sleep_us variable so-that read_poll_timeout now support delay as well. Cc: Tom Rini Signed-off-by: Jagan Teki --- Changes for v2: - none include/linux/iopoll.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h index ab0ae1969a..0bbd757939 100644 --- a/include/linux/iopoll.h +++ b/include/linux/iopoll.h @@ -16,6 +16,7 @@ * @addr: Address to poll * @val: Variable to read the value into * @cond: Break condition (usually involving @val) + * @sleep_us: Maximum time to sleep in us * @timeout_us: Timeout in us, 0 means never timeout * * Returns 0 on success and -ETIMEDOUT upon a timeout. In either @@ -24,7 +25,7 @@ * When available, you'll probably want to use one of the specialized * macros defined below rather than this macro directly. */ -#define readx_poll_timeout(op, addr, val, cond, timeout_us) \ +#define readx_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) \ ({ \ unsigned long timeout = timer_get_us() + timeout_us; \ for (;;) { \ @@ -35,33 +36,34 @@ (val) = op(addr); \ break; \ } \ + if (sleep_us) \ + udelay(sleep_us); \ } \ (cond) ? 0 : -ETIMEDOUT; \ }) - #define readb_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readb, addr, val, cond, timeout_us) + readx_poll_timeout(readb, addr, val, cond, false, timeout_us) #define readw_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readw, addr, val, cond, timeout_us) + readx_poll_timeout(readw, addr, val, cond, false, timeout_us) #define readl_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readl, addr, val, cond, timeout_us) + readx_poll_timeout(readl, addr, val, cond, false, timeout_us) #define readq_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readq, addr, val, cond, timeout_us) + readx_poll_timeout(readq, addr, val, cond, false, timeout_us) #define readb_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readb_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readb_relaxed, addr, val, cond, false, timeout_us) #define readw_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readw_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readw_relaxed, addr, val, cond, false, timeout_us) #define readl_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readl_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readl_relaxed, addr, val, cond, false, timeout_us) #define readq_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readq_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readq_relaxed, addr, val, cond, false, timeout_us) #endif /* _LINUX_IOPOLL_H */