Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5866753rwd; Wed, 24 May 2023 07:48:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qhJFeH0qNkybb69TgQYabVAvPd3PGAQZ9xM1VGngjr3jbemhANunaJ5LGOJ6WxF6CRyL5 X-Received: by 2002:a17:90a:6641:b0:24d:dcbb:6307 with SMTP id f1-20020a17090a664100b0024ddcbb6307mr19157493pjm.6.1684939722749; Wed, 24 May 2023 07:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684939722; cv=none; d=google.com; s=arc-20160816; b=bFve9YNL2mgHV3cq9kU312RhOtIV1kmtSGNRl0rUF8Sx6m+dcFtjj2EJmpncNr3xJj RgvZTXIcNf5mgmBnHOQV9i7GUGWUIfFPYssLeeARPwPuKOIYUTMPTkJX2+/vcdVF9yQv 71oJvmDYLBoIdGhIvdV1+aaWO2OFlM2IKcAseWTK67dXxqZ30ydL4jYamaWDfB4vwyfe mBFg0QqBWMSCCKM3IoGPQkPoXT5gP/8d1TqentKbCBKQSPGi5OeNBuh+iDcKe31Ze/75 vLtMi3ozptrKkS83C2EmA6FOezluVzn+UU6r2ikojmhTR5kBOsTgZ6iKj0vSACSkXPbE ebwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5Wuen+oq9wxQs6lQR7VtdOscnIhW6Ad0LSgcAuqH/C0=; b=C68soqQ/VA800w5CsQCE7nh2PzDmbdhnISAg5oL1zU2qxsaTOxXWB1j1vcyZSEmbPx Ic0LiY8pB0KMz2cLbp9j+CQvT+ydXwOByu/z9ubob6//UcqpYH3/yFlzthkTrtnXN2aJ NldT5Q7IkDsabsFhg+4Z5LDBbZXl0FfHBFrghaZZONN52EzluA/wM7+/pM5VQe9Xgi+w MQEL5eX+dbVYNnKv5q2tfU5m1ea0Y+UunT/n9NIbQsmRBoOlieZtygdrhrPtNyjABdOb 7MbeulHzB+nNLQK4yF0bxn1Y8b6tQvUSG2o5bsy/rkwOHbES6t0r2VDU7U6/ngILvJSl eHRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=melxsfpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nk13-20020a17090b194d00b002471d40b4d0si1458746pjb.106.2023.05.24.07.48.29; Wed, 24 May 2023 07:48:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=melxsfpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234641AbjEXOce (ORCPT + 99 others); Wed, 24 May 2023 10:32:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjEXOcd (ORCPT ); Wed, 24 May 2023 10:32:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCFF12E; Wed, 24 May 2023 07:32:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B038D63DCE; Wed, 24 May 2023 14:32:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 157BAC433EF; Wed, 24 May 2023 14:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684938751; bh=ifJBDlw42lQEKWaVj8j5eUTS/S5Ep1/jzziFfDLCiO4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=melxsfpBFtterXW0JEI2hR1uTm+mQVU/WRPDBctYpMXB5oHsEhxirRtVJoWadJbB+ wm+j+6QppuphP9oXHCaBdahw5H1ZYuPJUGdgtdFdW95izchtrOT21G3jnyq5mUw0lJ da0i404+4aND5DSCX7KkT6yqfSSozVbvxwxa5GR+IW0ZKRMG8NLMIqO+9wzfZ8WoRg mcJuRH4XY3/uDJ7sSeKYUETKI3wLbdr7RANte6nVYD1eIH7ngUhE1mz4k1CB/j9IzN w41+PPU/Eu6FyDYyf13bHZEbaY7cUa/XxVEZexzaGtTJXHdMUTf+JaXpocqTBk0jp8 h8MWRCYi6pl5Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1q1pXY-0000jp-U7; Wed, 24 May 2023 16:32:37 +0200 Date: Wed, 24 May 2023 16:32:36 +0200 From: Johan Hovold To: Bjorn Andersson , Pavel Machek , Lee Jones Cc: Anjelique Melendez , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Caleb Connolly , Steev Klimaszewski Subject: Re: [PATCH v2] leds: qcom-lpg: Fix PWM period limits Message-ID: References: <20230515162604.649203-1-quic_bjorande@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230515162604.649203-1-quic_bjorande@quicinc.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 15, 2023 at 09:26:04AM -0700, Bjorn Andersson wrote: > The introduction of high resolution PWM support changed the order of the > operations in the calculation of min and max period. The result in both > divisions is in most cases a truncation to 0, which limits the period to > the range of [0, 0]. > > Both numerators (and denominators) are within 64 bits, so the whole > expression can be put directly into the div64_u64, instead of doing it > partially. > > Fixes: b00d2ed37617 ("leds: rgb: leds-qcom-lpg: Add support for high resolution PWM") > Reviewed-by: Caleb Connolly > Tested-by: Steev Klimaszewski > Signed-off-by: Bjorn Andersson Tested-by: Johan Hovold Pavel or Lee, could you pick this one up for 6.4 as it fixes a regression (e.g. broken backlight on a number of laptops like the X13s)? > --- > > Changes since v1: > - Reworded first sentence to express that it's the order and not the > previously non-existent parenthesis that changed... > - Picked up review tags. > > drivers/leds/rgb/leds-qcom-lpg.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c > index c9cea797a697..7287fadc00df 100644 > --- a/drivers/leds/rgb/leds-qcom-lpg.c > +++ b/drivers/leds/rgb/leds-qcom-lpg.c > @@ -312,14 +312,14 @@ static int lpg_calc_freq(struct lpg_channel *chan, uint64_t period) > max_res = LPG_RESOLUTION_9BIT; > } > > - min_period = (u64)NSEC_PER_SEC * > - div64_u64((1 << pwm_resolution_arr[0]), clk_rate_arr[clk_len - 1]); > + min_period = div64_u64((u64)NSEC_PER_SEC * (1 << pwm_resolution_arr[0]), > + clk_rate_arr[clk_len - 1]); > if (period <= min_period) > return -EINVAL; > > /* Limit period to largest possible value, to avoid overflows */ > - max_period = (u64)NSEC_PER_SEC * max_res * LPG_MAX_PREDIV * > - div64_u64((1 << LPG_MAX_M), 1024); > + max_period = div64_u64((u64)NSEC_PER_SEC * max_res * LPG_MAX_PREDIV * (1 << LPG_MAX_M), > + 1024); > if (period > max_period) > period = max_period; Johan