Received: by 2002:ab2:5d18:0:b0:1ef:7a0f:c32d with SMTP id j24csp46882lqk; Fri, 8 Mar 2024 23:21:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUKLdFGoEJEo+J0PKxqiaPvT9HiWjbR/q43xkWLSt43rhpOXzW3bJCEyFenvqrUcoaEhss7q59oveUl31wphkgW+oH4sj+6+8VqEd6i0w== X-Google-Smtp-Source: AGHT+IFrXuQFI/jwyCJunIa2PTqsroKZ02KrSqBixGbOqnLjw7zMMJWO1OlbL9tnvFPmoTshlxEi X-Received: by 2002:a05:6214:1313:b0:690:c345:26d8 with SMTP id pn19-20020a056214131300b00690c34526d8mr527110qvb.15.1709968879428; Fri, 08 Mar 2024 23:21:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709968879; cv=pass; d=google.com; s=arc-20160816; b=L1k1PCNtxgJzU6BD4Qua6wWuwkLK0hF7LUyk/ltzTvbAksrix/la7iCgON1f3Xt4Fq llzAVwFi8ko+GuFF+NdlUKnwSLMqmqgFGvrndEaBQ7LiPl6ABz6R/PnctAZ50jbhL3uv R+G+XtcJInP7r9lhpA4LN11+DgGZFf9eB3cD1DQh2byYiP7QRGMC06n4cyIYBmW4ybtk rnbvzmvWNYqqQO0tYY7QJNQOg513X1gjNkyEYuHi3VPLGKAzn9WmuKC6i1EIH2/SgKXA bqG7dVcndbOWJEKhxeFde8gy8E28F1ANfvlpRU+LpjOSCZ/SXM0wEz/XVZJ042GRCd2g G+hQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=NVjD+zur/H0cVOMWoHKFUUJ9EN9OmLsF2VzhA0+25JY=; fh=aSBlzVPTV56HMPMAATUVYAG7togAFQDUKZ8JLAeCH28=; b=PG3XWsEBrD45lDXEWC+i37roZDbMGhchzyidfo2RueCL48X7dkz1Nbi/i0VeChlLBO bvoHY0mjvuABzDUxJ7BdfK5+1x1T8HRTg/teYjk2uJEr1WnaWL2fH4pd4I9Fb6layg+U q9gQhfX/pZFIvswA0au/5AXCpw8bRwqlzGdkkqTgZT3cqa/ntZ4ovz5CWGHZ2RDXZBDl 7ctZiHRqGSvSTz+P/5X1jTPdazGOASu8TvhnfkGMObRlkEDnEsUkPupvfkKXYpzVNuFU lQqcCKj+1fMYg06gy1cfmF4ZsXM5M7oyh+yNGHxJKYNbISrCeZVLYGeXgGa5Ntt2EUJ3 Hlpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Vlyx6WWa; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-97796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u14-20020a0562141c0e00b0068fef8d0341si1154162qvc.20.2024.03.08.23.21.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 23:21:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-97796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=Vlyx6WWa; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-97796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-97796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 28DA21C20AD9 for ; Sat, 9 Mar 2024 07:21:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6709236B0E; Sat, 9 Mar 2024 07:21:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="Vlyx6WWa" Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1974E36B0A for ; Sat, 9 Mar 2024 07:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709968874; cv=none; b=Yfp9xcB3EyBgYfgAVDO4LVVNB4xiE06zyd3TMo3fJAIHf69aQzQPmjSjdio5NK33NML+1LnaBC8r3AyTkoYmHfpAdVgbLW/VenwyFNeRDc51bzUQzFCGt8+L5mYHE3KQhCIc4ZKy+/86NFwTjWR7PbtkzX+UflRYMz2YGkri6Xc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709968874; c=relaxed/simple; bh=iG1yhrg/0K2EdQmQT9vQlMQcac9QO2D1JEfhshqra/Q=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sza3pNdi4px7jtCJu9Cxqa0OF2RadGAyWJnWWVpWRP1HfIvs/ZxgJuwOjgzeqx97Hm3xbOEv3GXUU4/LRT27/wJOORy6GmS4blQWIRjxTs8OviVYZFrOy3jw1vbNeNCu87c8yaS75P790igs2W+4k0TTHaYxCbFEQVrCTcMsmcI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=Vlyx6WWa; arc=none smtp.client-ip=80.12.242.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from [192.168.1.18] ([92.140.202.140]) by smtp.orange.fr with ESMTPA id iqztrHamf72ktiqztruaWU; Sat, 09 Mar 2024 08:19:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1709968798; bh=NVjD+zur/H0cVOMWoHKFUUJ9EN9OmLsF2VzhA0+25JY=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=Vlyx6WWaSUqIPnkqhOkEiWJ4SVmH2UWSG175lIZlHSR0grVIhA0Bce1ROP3jcYXIL 7Lmpvr6QD19uzpn6jRW2IDGZu3F7c2kXAGRyS1eKEafdAYf5U58S2oDxJoQZ9Sgtcd 4LtOjh5h/qzFVkbK7zxuqT5iW5K3vOYjulF2Z4p+DItcBYqHivVe/00nbLDc/rajsu ZPdtnSKxOD1u0giEjFz7XaTs5DE9TUU32TdCEGoDjWtJZcsHFoj7HkAL3FkunU1BQK AmwB4vV9m+X5Im+QJ38quZLQCRKjEy3FOoDRvARBwdMs/rhcL2W1AWAy58Wqq8RWcb KWDl4tLJQMo2w== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 09 Mar 2024 08:19:58 +0100 X-ME-IP: 92.140.202.140 Message-ID: <63c898e4-fedf-44eb-8887-ffda4a81e1e6@wanadoo.fr> Date: Sat, 9 Mar 2024 08:19:57 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/1] clk: fractional-divider: Move mask calculations out of lock To: Andy Shevchenko , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , Heiko Stuebner References: <20240303121410.240761-1-andy.shevchenko@gmail.com> Content-Language: en-MW From: Christophe JAILLET In-Reply-To: <20240303121410.240761-1-andy.shevchenko@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 03/03/2024 à 13:14, Andy Shevchenko a écrit : > There is no need to calculate masks under the lock taken. > Move them out of it. > > Signed-off-by: Andy Shevchenko > --- > drivers/clk/clk-fractional-divider.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c > index a0178182fc72..da057172cc90 100644 > --- a/drivers/clk/clk-fractional-divider.c > +++ b/drivers/clk/clk-fractional-divider.c > @@ -195,14 +195,14 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, > n--; > } > > + mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; > + nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; > + Hi, if this is a hot path, you could maybe even compute: mask = ~(GENMASK(fd->mwidth - 1, 0) << fd->mshift | GENMASK(fd->nwidth - 1, 0) << fd->nshift) unless gcc is smart enough to do it by itself. > if (fd->lock) > spin_lock_irqsave(fd->lock, flags); > else > __acquire(fd->lock); > > - mmask = GENMASK(fd->mwidth - 1, 0) << fd->mshift; > - nmask = GENMASK(fd->nwidth - 1, 0) << fd->nshift; > - > val = clk_fd_readl(fd); > val &= ~(mmask | nmask); val &= mask; > val |= (m << fd->mshift) | (n << fd->nshift); and pre-compute "(m << fd->mshift) | (n << fd->nshift)" outside of the lock too. CJ