From patchwork Sat Apr 25 11:03:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1115 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A23893F078 for ; Sat, 25 Apr 2020 13:04:13 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id u28sf6624629pgn.18 for ; Sat, 25 Apr 2020 04:04:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812652; cv=pass; d=google.com; s=arc-20160816; b=v3wx7+/BJSIarszgmeWzPH9yqvbB35S5JXsNhxOpzqMaUo8yygKd81kZCnaS2kOTbk /OA8ELMp5EWOlqg9eaqhDSbIUReBVo29FinorOMcGm79sqmOFtVSFv1HzcSlr3XY93H0 m+Z38I7M08z56sBtqiBNJReeVEiVFdX8s+VohEaVi14oLdXslWQlq+OlyI0ieoPLFKUq dH1XoWRkSOeksnUaMwwle9WJ3uJNqgNaz1fetnd1nxGoi+r+1j+widVxNL9/vclJ5x5V VhZNEkyO3yLVlEDhDCrW2S1zsaXe6qv3uVPr8bX2uUpcgH/nWThBNIUoABQHcnFp+Yox Ledg== 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=EUJEicapXnzAJItfJeLFVDW8zrD0XmpWD4MfansJXCw=; b=Uw3TOvqm1NdM6ZbM9SSbZaCDIJ51DIkjmbz7Sv/GivpkitV1qoPwm5G+RZPQLWEowI kfO+rTUGOL+D/GOreWVUT222d0qdz2BFvOqPYAR2XXdC4lm2GTyycjYsvyz5bQdSxz3I t0fk6UA8/HjkjHjs4TIFp+HsR1CnFkb8mKXHq1sJzcnrnYzCMmkvsBeV5qbbKKfHyjGw T0n0+Iaw7kYvrBlGxTf5OaghJkS4vYsY6WBzvQYpiLy4FOvkmo3BMV69g0IBrVHC2YuT 3aMluobcgmEnjA1JDxfDtzoGBi8+qQq3fNlzNABU/66AYKGCp0xwuv3bUQ7ODf0hbGjb ZASA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Py6BLBmu; 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=EUJEicapXnzAJItfJeLFVDW8zrD0XmpWD4MfansJXCw=; b=P13QSoXvYvJ1rW5iyNt5QlMGlUd2u2IkTBGserNOX4HDOnhg+EW0VN0rmGJplXRRrT 5MRNL9eAd0hsYAMPIYNAImQSstxu2+6yqPxPBGnhtqORCKwESWgyPzE0VQ0FLZqDK1ob wZft61FGZE5Gn8ttORkizfAw16aNSatV3XMa8= 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=EUJEicapXnzAJItfJeLFVDW8zrD0XmpWD4MfansJXCw=; b=rtKjIBIkpDaWK5Fwa7YvbsgyIrfqaE/a00Fcld7Zghk60QmCzEC+Li9td6d1VmTaf7 q7Yr34ZhJtLf0jwbkGEiHKBxlvnUsOXvtYopKCxyAj1owBEgkUqf7qw9Vr9fOKaGQtIq DYMPXmmcwXGv8acVKDjn2McicMwWESADuutti+sn3XUZap+BzKzf+8N91swHKuJSewUg nvkRzAsqlp+HF8y3PExLQKqZo1H5LIZ63UISZQl2638M5jKxrrISV8dYRhoGJYjaKauI 28+REgwu9Crm3Wf3TCDAAeD/2NoI6Fmsxq6hP1XtTw1APynaXA3Xuc2RaNWZ/ZsuEPaM 66qg== X-Gm-Message-State: AGi0PuafyDTBExPmFnU4h5UKnLgcZKM2Rw+SMYPiY1ic0vSP+RXgGG6+ ptpPPv7Am2x3UY31SoCseOMjQB/f X-Google-Smtp-Source: APiQypJa6g3hXTcwx2bl6KVe1G++4bJfuUcQdP5LB8jw+RoLgjWIMfe/L/gaEjYIEJwhNBvkNda3IQ== X-Received: by 2002:a17:90a:cb86:: with SMTP id a6mr11927155pju.127.1587812651927; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:4383:: with SMTP id q125ls6782951pga.7.gmail; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) X-Received: by 2002:a62:4e88:: with SMTP id c130mr14823793pfb.122.1587812651467; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812651; cv=none; d=google.com; s=arc-20160816; b=o+KqQmN2w8oJJrN+vwICeJSU78w+Xvc/E/IgkDIoK5waGMXa3NIaE6FAoM1AxVNFhy L8vEdl/BYmS0kVdEGdoocEvsxzctqBLDyrUIphCuG2lnugVvjd0YcYp46gc/3/0PGgSN Csk6de8Z5EQUbPxD2DDI24zzDWG0d6RRCUgDaX00YBkDWCw3nghWkwfVOCbpfaCRWZL5 SWQJOcs1mXPSJ5oYToAu0IB4utujjmAsLzx+K/ezx/7DXIi1jAOjsqimiwbP9mYaAnvG VapV0fbYJf0Oyt+2YKSojGyTRNyPcVFkMQ7ev3Ihn3ZY+sFUsI6sKFKRYHKEEavOw5+N UBKA== 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=KSjRhow/FzmNp0a4JMMIZ4uuTafzN1q6iJz8aYRJVeY=; b=IpBbdYcv2fH9iORKd0/CaiSubyIckyErL6NcnVP6bn8hZsMpKXzYiUT+yayhBVGyzn bPVrlgsceN6Az95cBp++xErL4BgQDm16WSOuuGv9A2cCnyhQygMhYGYLQsMETiMNPG6J WTuJGJtMt4ffyuSpTqS6Wq3klTU4KO06QKuMOJXyQT896JzlsrxkOs6LU/sbL8IAYRCh ClX6lSaT0xAVvuQik8mtYoMiy0MBRdbpoCC4p/qXDUAuKzGhM/Ednd4tp2oCr8r2CPur MwgQb87cEp3/mQGjuewoITlEmltWRkPWLhdazOF4xuPxjiJkadh7lGJ/VDobweZWE6c1 cmHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Py6BLBmu; 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 z19sor11435563pjq.5.2020.04.25.04.04.11 for (Google Transport Security); Sat, 25 Apr 2020 04:04:11 -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:90b:3d8:: with SMTP id go24mr11616409pjb.33.1587812651122; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:10 -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 1/8] iopoll: Add dealy to read poll Date: Sat, 25 Apr 2020 16:33:47 +0530 Message-Id: <20200425110354.12381-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=Py6BLBmu; 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 --- 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 */