From patchwork Fri Jun 2 08:50:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13264895 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D908BC7EE2C for ; Fri, 2 Jun 2023 08:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=E3WVzjUdizA3zSxR/HcC4k16isZciO9HqwDFe5Co10w=; b=QVHjQnR45KDgv3 7jKrLSKEv5Rj8dFBj/dm7+UtNDz8s9V7Fj+kWOdYjlyowjwJgw5aR663Kmf7gjs3/5g5XJR1izJ/Z eBOiuW8LEhpcYTJR/sR1+ZG5KKCuTnF0oIZdDXrQabDZWoxkn6D9j39PVRk7vh5EAOkEk0bGm5gT2 la96ajc6wFOofvZylcjGe8uI479aOfWPkN0LIGIILSmP/JCwrF7NuD2aeNXlVHbMshYYPIMelt03P O9AZxm9tjA7zHOSZHynbunZrdOXjdZll5xNLAwNNPairD81wJvYWyVzCaBqotb4ZxOwE7iiGA1VcK JPDIBGVRUjj7l2l4VzOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q50VH-006EId-0k; Fri, 02 Jun 2023 08:51:23 +0000 Received: from xavier.telenet-ops.be ([2a02:1800:120:4::f00:14]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q50VC-006ECo-2m for linux-arm-kernel@lists.infradead.org; Fri, 02 Jun 2023 08:51:20 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed30:158c:2ccf:1f70:e136]) by xavier.telenet-ops.be with bizsmtp id 48qo2A0031tRZS8018qoDE; Fri, 02 Jun 2023 10:51:12 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1q50UO-00BhY8-RL; Fri, 02 Jun 2023 10:50:48 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1q50Uh-00APxP-UC; Fri, 02 Jun 2023 10:50:47 +0200 From: Geert Uytterhoeven To: Michael Turquette , Stephen Boyd , Yoshihiro Shimoda , Magnus Damm , Joerg Roedel , Robin Murphy Cc: Tomasz Figa , Sylwester Nawrocki , Will Deacon , Arnd Bergmann , Wolfram Sang , Dejin Zheng , Kai-Heng Feng , Nicholas Piggin , Heiko Carstens , Peter Zijlstra , Russell King , John Stultz , Thomas Gleixner , Tony Lindgren , Krzysztof Kozlowski , Tero Kristo , Ulf Hansson , "Rafael J . Wysocki" , Vincent Guittot , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v3 0/7] iopoll: Busy loop and timeout improvements + conversions Date: Fri, 2 Jun 2023 10:50:35 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230602_015119_042709_1FB3120C X-CRM114-Status: GOOD ( 24.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi all, When implementing a polling loop, a common review comment is to use one of the read*_poll_timeout*() helpers. Unfortunately this is not always possible, or might introduce subtle bugs. This patch series aims to improve these helpers, so they can gain wider use. 1. The first patch improves busy-looping behavior of both the atomic and non-atomic read*_poll_timeout*() helpers. The issue addressed by this patch was discussed before[1-2], but I am not aware of any patches moving forward. 2. The second patch fixes timeout handling of the atomic variants. Some of the issues addressed by this patch were mitigated in various places[3-5], and some of these findings may be of interest to the authors of [6-8]. The first two patches were sent before, and already received some acks and reviews. I plan to queue these in an immutable and tagged branch after the weekend, for consumption by myself, and by other interested parties. The last five patches are new, and convert several Renesas-specific drivers from open-coded loops to the fixed read*_poll_timeout_atomic() helpers: - I plan to queue the clk and soc patches in renesas-devel resp. renesas-clk for v6.5, - The IOMMU patch can wait for v6.6, unless the IOMMU maintainers already want to merge the immutable branch, too. Thanks for your comments! Changes compared to v2[9]: - Add Acked-by, Reviewed-by, - Add comment about not using timekeeping, and its impact, - Add conversion patches 3-7. Changes compared to v1[10]: - Add Acked-by, - Add compiler barrier and inlining explanation (thanks, Peter!), - Add patch [2/2]. Thanks for your comments! [1] "Re: [PATCH 6/7] clk: renesas: rcar-gen3: Add custom clock for PLLs" https://lore.kernel.org/all/CAMuHMdWUEhs=nwP+a0vO2jOzkq-7FEOqcJ+SsxAGNXX1PQ2KMA@mail.gmail.com [2] "Re: [PATCH v2] clk: samsung: Prevent potential endless loop in the PLL set_rate ops" https://lore.kernel.org/all/20200811164628.GA7958@kozik-lap [3] b3e9431854e8f305 ("bus: ti-sysc: Fix timekeeping_suspended warning on resume") [4] 44a9e78f9242872c ("clk: samsung: Prevent potential endless loop in the PLL ops") [5] 3d8598fb9c5a7783 ("clk: ti: clkctrl: use fallback udelay approach if timekeeping is suspended") [6] bd40cbb0e3b37a4d ("PM: domains: Move genpd's time-accounting to ktime_get_mono_fast_ns()") [7] c155f6499f9797f2 ("PM-runtime: Switch accounting over to ktime_get_mono_fast_ns()") [8] 15efb47dc560849d ("PM-runtime: Fix deadlock with ktime_get()") [9] https://lore.kernel.org/all/cover.1683722688.git.geert+renesas@glider.be [10] https://lore.kernel.org/r/8d492ee4a391bd089a01c218b0b4e05cf8ea593c.1674729407.git.geert+renesas@glider.be/ Geert Uytterhoeven (7): iopoll: Call cpu_relax() in busy loops iopoll: Do not use timekeeping in read_poll_timeout_atomic() clk: renesas: cpg-mssr: Convert to readl_poll_timeout_atomic() clk: renesas: mstp: Convert to readl_poll_timeout_atomic() clk: renesas: rzg2l: Convert to readl_poll_timeout_atomic() soc: renesas: rmobile-sysc: Convert to readl_poll_timeout_atomic() iommu/ipmmu-vmsa: Convert to read_poll_timeout_atomic() drivers/clk/renesas/clk-mstp.c | 18 ++++++--------- drivers/clk/renesas/renesas-cpg-mssr.c | 31 +++++++++----------------- drivers/clk/renesas/rzg2l-cpg.c | 16 +++++-------- drivers/iommu/ipmmu-vmsa.c | 15 +++++-------- drivers/soc/renesas/rmobile-sysc.c | 31 +++++++++----------------- include/linux/iopoll.h | 24 +++++++++++++++----- 6 files changed, 58 insertions(+), 77 deletions(-)