Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4442085ybp; Mon, 7 Oct 2019 08:30:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2FXmVPDzjHteaLRahgriYoM107u/sH9u1ErRD7xZYWA3NDrOXvAkQCSp8n/KLkS+QStOX X-Received: by 2002:a17:906:b84d:: with SMTP id ga13mr24548102ejb.236.1570462225013; Mon, 07 Oct 2019 08:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570462225; cv=none; d=google.com; s=arc-20160816; b=yxRqyEJ/Ml7cDrqJhKWJcvSAkdLtIpXwSHbuEeC0zxFkxwx0K2cHjyeBxHHTj9+2J2 anc8VblepwVt9wj/SrBj4Nl+lfeAyDnXXYTnPZqvN0yWR/Jv+BPl27rb2oi8JNF7kGZP jT8ibrDn9sFvy7YTO4E3/uS3nLS6zijOgEmUPFrK44OwhDglNU2P3PJCLeRI+hEyql8W Qy4dOINrhJQn8mujqKpK5ZVarjoGl0KghJ5PoVmSdg2x0BqDQZdNHPDn5M8kkCaT1qS3 KpvcazR3f2BxSkmbNiNrOfwvAYpWkSQ1vegHIYi/MFepnmQuDThyKJ397KHKv7Lg1wVc kvmQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DCOkxVIM+JoLp/YA+axrp58OiH/imrwWD+NmGvd4Ocg=; b=RSLd6828RdFSYCOVGVISWGh9S3/Dqs6DULPaSGr95Em5G0qNwd8dGMLfpdFuEIw0em WOYpQWlM8TrJaRGQ+OCDgjShaEnS/1r14U3zo9XysLqDPMrtTkoVgcOUMU1d1MKyo4db a/HwDdNQU8pung+Uz1BhzVGym8mPoHBZoXIkblO9zr2Xzuktm1NNi03R9rydx1aEuYa5 w9vLD9Byx0A3Xw1axHy1V0PqU3ukMNSBLAHMkUPRVcd7J4DTPyoIK1d8d0teALEUMHgW wAYDMGMCKO+ZNWsvc/z4K0NKqL2i3TibaUXDqAGMLBx6aZo7VSi7aENxdpkGkMEPDMjG Yk8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PYxYfGB6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si8238971edq.174.2019.10.07.08.30.01; Mon, 07 Oct 2019 08:30:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PYxYfGB6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728264AbfJGP2F (ORCPT + 99 others); Mon, 7 Oct 2019 11:28:05 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35120 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727830AbfJGP2F (ORCPT ); Mon, 7 Oct 2019 11:28:05 -0400 Received: by mail-wm1-f67.google.com with SMTP id y21so12826409wmi.0 for ; Mon, 07 Oct 2019 08:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DCOkxVIM+JoLp/YA+axrp58OiH/imrwWD+NmGvd4Ocg=; b=PYxYfGB6zPqtbG5xjS2Q9qk6xu1t5yFe2l7zfOc1z1MO7Cjx3Ihljkj8az2zpIEJTe 92TxrZQdhkL8Jr5XjUmbVouX5Ez39Rud2TRflwB8e9bqonoq2235fow3dFw80PEn2MwT yK1c3LlElksS2/p36HWmCRfUvBNpQ6oGvFLp8G5Y9Eje4M7lOL5hQYn4bO9ZdGpyHJxz i3Zq9KKFEmW1uPM+l3JpophHsU8IskdX8Xg0Vz/kJ40SZqz9vjnh3XeRRheiD8zKjy+u Nt6YLTFk8HUvTJ5oY4wQl+zFdjqMNkJUrQ8m1p7UPr3xqSwfuaHbJksPhAWG9jyjJQCo XI/Q== 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:in-reply-to:user-agent; bh=DCOkxVIM+JoLp/YA+axrp58OiH/imrwWD+NmGvd4Ocg=; b=I+NvCbx9lI8z7Pso1RMFNM/DfV0vD4zBXobHHB0yP27cZgF9qmAlOfFp9mFKka8Uq3 4cK1lpb6UHvpstvpjBiHe2G4JHk4v6mHShqrxO/XEtJRwKdF7I3De8ljoB1vC5C5V04r ih708iWBAx5186J+bWN2trXLt2rm8SLJ8kawsUeGtPq8cnJ4s6eSveUI/dJ+5PhM3ueQ 8VZa/EcMO2kLZ1TCjR3RgscyMxX5gFcbv3YkDYHe0x5qfZpZqlpZFeyP5+yBcCy1ALnt 1AwMh7xKgZgS9yUBe/IpxOrcKQ5UXd369vYrK9toOjSIRVy7NI33YblUoLG+Hqx+mxp6 1HRg== X-Gm-Message-State: APjAAAUs10V/Xds8l9u5T95lVtwIJ7jmrr2FQPluvXyYvNa+Vyws5Vyl sID47J03EAxdaanr99cxavP1qA== X-Received: by 2002:a1c:a8cb:: with SMTP id r194mr20184823wme.156.1570462082643; Mon, 07 Oct 2019 08:28:02 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id n14sm13722808wro.83.2019.10.07.08.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:28:02 -0700 (PDT) Date: Mon, 7 Oct 2019 16:28:00 +0100 From: Daniel Thompson To: Rasmus Villemoes Cc: Thierry Reding , Lee Jones , Jingoo Han , Bartlomiej Zolnierkiewicz , linux-pwm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] backlight: pwm_bl: drop use of int_pow() Message-ID: <20191007152800.3nhbf7h7knumriz4@holly.lan> References: <20190919140620.32407-1-linux@rasmusvillemoes.dk> <20190919140620.32407-3-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190919140620.32407-3-linux@rasmusvillemoes.dk> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 19, 2019 at 04:06:18PM +0200, Rasmus Villemoes wrote: > The scheduler uses a (currently private) fixed_power_int() in its load > average computation for computing powers of numbers 0 < x < 1 > expressed as fixed-point numbers, which is also what we want here. But > that requires the scale to be a power-of-2. It feels like there is some rationale missing in the description here. What is the benefit of replacing the explicit int_pow() with the implicit multiplications? Daniel. > > We could (and a following patch will) change to use a power-of-2 scale, > but for a fixed small exponent of 3, there's no advantage in using > repeated squaring. > > Signed-off-by: Rasmus Villemoes > --- > drivers/video/backlight/pwm_bl.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c > index 9252d51f31b9..aee6839e024a 100644 > --- a/drivers/video/backlight/pwm_bl.c > +++ b/drivers/video/backlight/pwm_bl.c > @@ -179,7 +179,8 @@ static u64 cie1931(unsigned int lightness, unsigned int scale) > if (lightness <= (8 * scale)) { > retval = DIV_ROUND_CLOSEST(lightness * 10, 9033); > } else { > - retval = int_pow((lightness + (16 * scale)) / 116, 3); > + retval = (lightness + (16 * scale)) / 116; > + retval *= retval * retval; > retval = DIV_ROUND_CLOSEST_ULL(retval, (scale * scale)); > } > > -- > 2.20.1