Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp573828pxa; Tue, 11 Aug 2020 09:44:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5B0G5NBd2uPtqlkXRjZWthGvm9HsPB3fCIG01L4tjIFZGKl+TwhlTof6J+r1J9L8desU1 X-Received: by 2002:a17:906:6cd:: with SMTP id v13mr12673072ejb.307.1597164270792; Tue, 11 Aug 2020 09:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597164270; cv=none; d=google.com; s=arc-20160816; b=XrbmYy70bcX48kZTLyRiCSiazVh1QSX9fzYRT2KxUMvLjndrmxwUiHNOpyScf66vW7 GMhJnlxhOvCnn2IlDReiulC1r190d6G+ba0dX0KifkSvkIJtw6wAQ9XZcKX7DVXCQgOk 93lpKI9g6i5hsCLEFtfOhO5eVUlTST4siiiyy8kSM+8Y3i9MJd68xtTgtacgWKqTSWRr ft/tisFoOy8Qb/r+QwmCF8vEhzkZpB92JMMaBSMe51AVSl4KITkWJYdMWbzsu3s4nNCB iSXVaHNABc3dvrVst/o2rBXPeZZV97rdp40BP45b8i+jUfYxLQRTb3hBYTvvpYCLDEv3 6Lbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=6L7FJ6xpxTKZ/sdV2/iPr2JUbCn9Aupkb6mFAAvK+TU=; b=mx3tfJpl4MOsUWs04kR21IZoL5X1YtMYhC1kA7ZGMwi01ZWiuEtzANvfK9bxI3G8zO 6Ipu7YskXINKp6HPDvzUHTTA6s69TyZgZ7aX3znmOxab37/ZCQ9ZA0NI6Rlhu6iAw3h9 IdjQQd72OW15Xk9sDHQXXudyBi1bj5aoUa80vgWikXfyviyVZRp1vWEeAHSv4NUsXnZS aKVg+60D6sQ0XVKrNq5xMXqT6Ecp0hRqpvt3lXPeuunbL7eyRv2uByBZga1u6gMmnXMG lFanWB/LpzRdZiRhsHf91DSWYNyH/bEYIy7er2uly46IkYs0uWaeghjIvqU9iPrQ4gYv qhrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="W3/mn+FS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m8si13267785edp.351.2020.08.11.09.44.07; Tue, 11 Aug 2020 09:44:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="W3/mn+FS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbgHKQle (ORCPT + 99 others); Tue, 11 Aug 2020 12:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728844AbgHKQle (ORCPT ); Tue, 11 Aug 2020 12:41:34 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55AC7C06174A; Tue, 11 Aug 2020 09:41:33 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id k4so4652410ilr.12; Tue, 11 Aug 2020 09:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=6L7FJ6xpxTKZ/sdV2/iPr2JUbCn9Aupkb6mFAAvK+TU=; b=W3/mn+FSAoD4JSQBtxIMkbYsT+HhAA3dEiyJ7apR1RrB3dMdZ9i9xhS5WfbVVC5JEO fCDRFwP35k5BoU+ItzCV1x5zLAo6VhXFFv2rm/qQPraB8KHRR5c8vFyCrSloIy54KRhG LKIfqGjBXMnVFC5yoYd4SCskpHPGzuy5usjJ0yEhKpwu9E1o6uNMd719i1CID7WhCVno 1FxchZo47osr5uq+MmXar08cDx86fXUbL00ef8cKzTLr/iH29VS06jCHiD1TpsZTyaQc 348n5fnxSmgSr/hyAFHoTHQD7qLHKRkkhZBs+CzI0B+YYGR6r+qVDaLKeGfVN0JH1CHN oO7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6L7FJ6xpxTKZ/sdV2/iPr2JUbCn9Aupkb6mFAAvK+TU=; b=QzHidetJKz/SVXydy3pZpjd0Rz/OWYCnoPoA3xM/eQEmRF00hG0D4i18M8/BzrwvpS Hc4C/cxgNV38fRaRAPzAzz3GGWNOHg8/6Q80LyZGbZI47LnxgOkdYis2UnbwsbgEseTu aXTZHVyMywZ9dPUMj+X5lt4HIdGFjneN42Femu+iDqbuRtEFZ8nsd7UaCI3gGFOulcua R82iztalk4qpjpw6L3wwR2ef6xcjAy3VtYRUsAw6ysavQmfWnlRpKt7FYtPM5ECvHVwQ KDrm2B8phWHXkuMk36uBAKpZgge9/C+Jckfbu5a40158yv++oiZZH92z6q8agLaUbTCl LfeA== X-Gm-Message-State: AOAM532nQqiqwpB5d8FZjlYJpJ9Ll1QI7/XYWPLeJwHSP8KY2tfMlPFu eA3jJ+p84gMlxV+uJ0Uk0Veyjqj2eTonYUtYYrur0QYc X-Received: by 2002:a92:cac8:: with SMTP id m8mr25098449ilq.168.1597164092409; Tue, 11 Aug 2020 09:41:32 -0700 (PDT) MIME-Version: 1.0 References: <20200811112507.24418-1-s.nawrocki@samsung.com> <20200811162358.GA7169@kozik-lap> <20200811163428.GA7590@kozik-lap> In-Reply-To: <20200811163428.GA7590@kozik-lap> From: Tomasz Figa Date: Tue, 11 Aug 2020 18:41:20 +0200 Message-ID: Subject: Re: [PATCH v2] clk: samsung: Prevent potential endless loop in the PLL set_rate ops To: Krzysztof Kozlowski Cc: Sylwester Nawrocki , "open list:COMMON CLK FRAMEWORK" , Chanwoo Choi , Stephen Boyd , Mike Turquette , "moderated list:SAMSUNG SOC CLOCK DRIVERS" , linux-kernel , Bartlomiej Zolnierkiewicz , Marek Szyprowski Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2020=E5=B9=B48=E6=9C=8811=E6=97=A5(=E7=81=AB) 18:34 Krzysztof Kozlowski : > > On Tue, Aug 11, 2020 at 06:28:18PM +0200, Tomasz Figa wrote: > > 2020=E5=B9=B48=E6=9C=8811=E6=97=A5(=E7=81=AB) 18:24 Krzysztof Kozlowski= : > > > > > > On Tue, Aug 11, 2020 at 02:59:07PM +0200, Tomasz Figa wrote: > > > > Hi Sylwester, > > > > > > > > 2020=E5=B9=B48=E6=9C=8811=E6=97=A5(=E7=81=AB) 13:25 Sylwester Nawro= cki : > > > > > > > > > > In the .set_rate callback for some PLLs there is a loop polling s= tate > > > > > of the PLL lock bit and it may become an endless loop when someth= ing > > > > > goes wrong with the PLL. For some PLLs there is already (a duplic= ated) > > > > > code for polling with timeout. This patch replaces that code with > > > > > the readl_relaxed_poll_timeout_atomic() macro and moves it to a c= ommon > > > > > helper function, which is then used for all the PLLs. The downsid= e > > > > > of switching to the common macro is that we drop the cpu_relax() = call. > > > > > > > > Tbh. I'm not sure what effect was exactly expected from cpu_relax()= in > > > > the functions which already had timeout handling. Could someone she= d > > > > some light on this? > > > > > > For us, it should not matter much, except: > > > 1. when on A9 with ARM_ERRATA_754327, but we do not enable it on our > > > platforms, > > > 2. it is a generic pattern for busy loops. > > > > > > On other architectures it could mean something (e.g. yield to other > > > hyper-threading CPU). > > > > Okay, thanks for confirming that it doesn't matter for us. > > > > Now, I wonder if the readx_poll_*() helpers are supposed to take all > > of those into account or on systems which would benefit from such > > operations, it would be the caller's responsibility. > > That's a very good point. In case of ARM_ERRATA_754327, busy waiting > should have a barrier thus cpu_relax() is desired. I guess the generic > macro for busy waiting therefore should use them. Is there yet another macro available somewhere or you mean read_poll_timeout_atomic()? The latter doesn't include cpu_relax(). Given that udelay() likely already does this kind of an idle call, perhaps it could be as simple as this? if (__delay_us) \ udelay(__delay_us); \ + else \ + cpu_relax(); \ On the other hand, I wonder if there are cases where a call to cpu_relax() is not desirable. Best regards, Tomasz