Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp577511pxa; Tue, 11 Aug 2020 09:50:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCp1jBgIkUFGe+1qr90wTOVEB1Tvek4leWflHeWK+A4fjNZZ8d+GKS8uGPVPYRMM+QEup/ X-Received: by 2002:a17:907:408c:: with SMTP id nt20mr26515605ejb.503.1597164605602; Tue, 11 Aug 2020 09:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597164605; cv=none; d=google.com; s=arc-20160816; b=yD7XcLY8GXESu2uEdLPnE2dk5lNHX1GcntSO2y5MYg3PxgrYEPO0irHEycf5RvBHST toIe9hxJGIEN50TDflKkQNbTrA2r84pd7RIaWAnsRGS3E29SBHP+Ln5xP8nVS9nIViPz 9Aan328Aqc00ciuI+sqjPUJAXzft5ndytIgu7BxzSfuvbOUnW/FU7CjNL4D5wed84CzC sTLwCRXc0wbbkUElfhdjGhC3rGdAHdRSdMYz7oQeQnzpPLsAMue5oMfTnpWExm/BZSXI AR1607Uwvj9tiW7FSuaKTOlXPwVaDij5Aw379OsQbWi+mw/hAAx74gNApsF5GUxujXhc Ceeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=XdfcMV/Bs5/gBLVRvFMN+EGfOrw3e4FZpOILJzIiW6g=; b=qjzwK+DjO27bAp1MtnjqXqTde6SUCRbsbJEspznAGEzjqhDD6K3tLeHfeVppvSU2mh VK0j8b4IRtxwRTQiC/QusBIU12mJrC9H6/rnXwPKRmgOtbIYQ9lpPX7od3C3GQpT7l8U MbA1sJLEeyPYjoiLV55zHcXraDGQsPqDYasQYVjp7W6R7gwyBX9P2XTaYqqWiTAgz4E4 WTAph3Eq6HiiBDd+dhu1n6wVsmCuaNQxnR5vOrhkrH/YQckkXerPopeDqJ9kg/wevm3s sh7if2HjZ03gAdWUnWZ75/ISMIcFrLTxNbgYOuTI5zLNkCVQJDXhiSLinrV/FoVxVr5P HgGw== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c11si13201232edq.178.2020.08.11.09.49.42; Tue, 11 Aug 2020 09:50:05 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729293AbgHKQqe convert rfc822-to-8bit (ORCPT + 99 others); Tue, 11 Aug 2020 12:46:34 -0400 Received: from mail-ej1-f65.google.com ([209.85.218.65]:34295 "EHLO mail-ej1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728844AbgHKQqd (ORCPT ); Tue, 11 Aug 2020 12:46:33 -0400 Received: by mail-ej1-f65.google.com with SMTP id o23so13832274ejr.1; Tue, 11 Aug 2020 09:46:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=G2/FL5p/UBsN/pTnJvwvZ3cpq1IwMUSfHcFh9xZXbUU=; b=JZxbYiDYcNlPUWjyr8sFwXVi2gKMAytqf4PrQMKEwRk+aFxPHrKWLwrxXfRJ3m1Jxv Rry97EZGsv9+ZVBISjHP8b689bQ49LTHt/tNbjq49qor6oVQxqjzeMMtvXXVJ8+trE90 RIpm567TQYAroMWk88VvdIp1ooM2Xe9yYPeCRbWY7GHm2OTTaVP9C7rV6y9tHlNclQuj +H9bB/EMeT2dji5HOSzfqql4T+GKBFPFdPHoQfUgMk1gm4ijv9WiEBIJJjmhrtaaxMIa TWOmNtY0ulzs60tABqny7mvbReZv6o2zuZLSMctFaA5XXf/yT5J/ufg3Ub3xqoGfpeix /wRQ== X-Gm-Message-State: AOAM531dCnVo7WgwNjKdK4I4WA8ytPp3DSYjf+sYFw291Tc7XehRJedz IAZ2A/wPXRI5BqnZbWoXRnmIe/ZzFyg= X-Received: by 2002:a17:906:a413:: with SMTP id l19mr27923288ejz.15.1597164391237; Tue, 11 Aug 2020 09:46:31 -0700 (PDT) Received: from kozik-lap ([194.230.155.117]) by smtp.googlemail.com with ESMTPSA id p20sm15338656ejy.107.2020.08.11.09.46.30 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Aug 2020 09:46:30 -0700 (PDT) Date: Tue, 11 Aug 2020 18:46:28 +0200 From: Krzysztof Kozlowski To: Tomasz Figa 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 Subject: Re: [PATCH v2] clk: samsung: Prevent potential endless loop in the PLL set_rate ops Message-ID: <20200811164628.GA7958@kozik-lap> References: <20200811112507.24418-1-s.nawrocki@samsung.com> <20200811162358.GA7169@kozik-lap> <20200811163428.GA7590@kozik-lap> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 11, 2020 at 06:41:20PM +0200, Tomasz Figa wrote: > 2020年8月11日(火) 18:34 Krzysztof Kozlowski : > > > > On Tue, Aug 11, 2020 at 06:28:18PM +0200, Tomasz Figa wrote: > > > 2020年8月11日(火) 18:24 Krzysztof Kozlowski : > > > > > > > > On Tue, Aug 11, 2020 at 02:59:07PM +0200, Tomasz Figa wrote: > > > > > Hi Sylwester, > > > > > > > > > > 2020年8月11日(火) 13:25 Sylwester Nawrocki : > > > > > > > > > > > > In the .set_rate callback for some PLLs there is a loop polling state > > > > > > of the PLL lock bit and it may become an endless loop when something > > > > > > goes wrong with the PLL. For some PLLs there is already (a duplicated) > > > > > > code for polling with timeout. This patch replaces that code with > > > > > > the readl_relaxed_poll_timeout_atomic() macro and moves it to a common > > > > > > helper function, which is then used for all the PLLs. The downside > > > > > > 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 shed > > > > > 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(). Yes, I meant the generic read_poll_timeout_atomic(). > 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(); \ > I think udelay does not have it. Delaying by some simple operations (e.g. multiplication) does not require IO barriers. > On the other hand, I wonder if there are cases where a call to > cpu_relax() is not desirable. Hmmm, it is really a generic pattern all over the kernel, so I doubt that generic macros should target such case. Best regards, Krzysztof