Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2740848rwl; Sat, 1 Apr 2023 13:51:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YFsOuZs0tIUDRfib50G+HPIA16Jd//jsJconqk6Ov8YxXZf5NofCmVb/TzJzADyckcNkQe X-Received: by 2002:aa7:9a5c:0:b0:628:1347:a619 with SMTP id x28-20020aa79a5c000000b006281347a619mr31668399pfj.10.1680382297960; Sat, 01 Apr 2023 13:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680382297; cv=none; d=google.com; s=arc-20160816; b=i22PW32pvSLs0rHDpTQzIqdUgJKsEmN4ffJWnybULYK0SGoBEi+bNhTE5lRykRzpwV zAjBweOKgRpSlZRMBAFDBOKJpbIB06Ra+0Uw8mO5HeOWJm+m/h/FOMJsE9nXnBMJw2KB ONz51FpJP183XCieYkIHwwgNMzHUYiw2woICU72PccWi3/V8Y61DCbtAzzwNfCO+cRIe uXOjX9r/5yR4xcQ7ceTjeKwigmXGVKnZybmbyj8tC8o0TKWMrIywZiCXWo1FWZGgbT61 0AOb1nuHRbZex4B0xZpPTNi0hzI2F/UqMzjoDwaeYLmfgR+CFUC+Xu/r1QhIbZ9+04KG 6jaQ== 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=Sog5ihibANZR0bZpUlMvUUuQA13doWlHd+lFwWqxlxE=; b=OPmxAbA9RW15h+a6CG/c6uoEyfrGUpa+kSd97Fzy/IhfdT9sf/ZDzrv8aQLT+Yzq1I RdBcvuuCpo6NaPiTyupy5m9zkSYaEynsotOC0VflsGtvWwRkepwi9JGJHJ9M+drNlyaz ld3JoSuwbrOguPGKZ5/nqft3lAu39X1d+0hzh6QTLL3GR3LaVBmdgu0eR3Bwacect0WE I/jC0n6UJpIIRKip6t1CJGkfcytqdq/xhTCYyHrlivKNnDEFGOBFSTUJhD6SHlC3U42j M+Z0b1d44YFXrnQH/duhTfOMiwAACjFVYzD7D4n5g21bFlvbYUs0EIOLLw0SPw1CixGq hdIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=R2Xsf7Om; 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 e13-20020a056a0000cd00b005a7def83ee0si5334530pfj.210.2023.04.01.13.51.27; Sat, 01 Apr 2023 13:51:37 -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=R2Xsf7Om; 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 S229915AbjDAUvA (ORCPT + 99 others); Sat, 1 Apr 2023 16:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjDAUuz (ORCPT ); Sat, 1 Apr 2023 16:50:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42B0A27804; Sat, 1 Apr 2023 13:50:52 -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 C101E60FC8; Sat, 1 Apr 2023 20:50:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A83A1C433EF; Sat, 1 Apr 2023 20:50:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680382251; bh=cblNPwspiLiu6TBVBEScNWqtn9HgaLDxVomWxXoSOWQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=R2Xsf7OmDrvxKOnaV1o2olTZD/+xO24c1NxVVjgi4tY54cdvVXRkP8hJX46e8UoKN vHFfU3gTbKbx1gzg/9ZYBwKR77EFvO/bE9X5mbcwTnp5Xav6jrPMbaxht6AO6eYeeU 8uZ8Q6WVgufuMawepfUsnfuH+0iPYWMfn+pjTVn+FOP5n6swmE7RwLL05Fp4hH719s trz6qOMwQ7pEP0BXeCulcHfwhx2FbZDit9dRQgxqa4X+m6eps5Cu7fkyEs8Jd/kMXl yBu1tZ0WR2yiKZf80HCi8SKkX8C0Q74lFP4zMMEs70FtCI4Ykck7/2RopRFMfOCEyW HPxAvf8S4LXqQ== Date: Sat, 1 Apr 2023 21:50:47 +0100 From: Conor Dooley To: Conor Dooley Cc: Thierry Reding , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Daire McNamara , linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, linux-riscv@lists.infradead.org Subject: Re: [PATCH v15 1/2] pwm: add microchip soft ip corePWM driver Message-ID: <0b91dee7-6c1d-4a33-8235-8fd5d58b200e@spud> References: <20230330071203.286972-1-conor.dooley@microchip.com> <20230330071203.286972-2-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WqrHL50fzIiM0DjG" Content-Disposition: inline In-Reply-To: <20230330071203.286972-2-conor.dooley@microchip.com> X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=unavailable 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 --WqrHL50fzIiM0DjG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Mar 30, 2023 at 08:12:03AM +0100, Conor Dooley wrote: > + /* > + * Because 0xff is not a permitted value some error will seep into the > + * calculation of prescale as prescale grows. Specifically, this error > + * occurs where the remainder of the prescale calculation is less than > + * prescale. > + * For small values of prescale, only a handful of values will need > + * correction, but overall this applies to almost half of the valid > + * values for tmp. > + * > + * To keep the algorithm's decision making consistent, this case is > + * checked for and the simple solution is to, in these cases, > + * decrement prescale and check that the resulting value of period_steps > + * is valid. > + * > + * period_steps can be computed from prescale: > + * period * clk_rate > + * period_steps = ----------------------------- - 1 > + * NSEC_PER_SEC * (prescale + 1) > + * > + */ > + if (tmp % (MCHPCOREPWM_PERIOD_STEPS_MAX + 1) < *prescale) { Hmm, looks like 32-bit doesn't like this modulus. I pushed things out for LKP to test before sending as I felt I'd not be allowed to do that operation, but got a build success email from it. I'm not sure why the mail wasn't sent as a reply to this, but <202304020410.A86IBNES-lkp@intel.com> complains: pwm-microchip-core.c:(.text+0x20a): undefined reference to `__aeabi_uldivmod' I know that tmp < 65536 at this point, so if the general approach is fine, I can always cast it to a non 64-bit type without losing any information. > + u16 smaller_prescale = *prescale - 1; > + > + *period_steps = div_u64(tmp, smaller_prescale + 1) - 1; > + if (*period_steps < 255) { > + *prescale = smaller_prescale; > + > + return 0; > + } > + } --WqrHL50fzIiM0DjG Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZCiZJwAKCRB4tDGHoIJi 0iJlAQCB2UJl++XV4NMR+7ECnWEx79RdqD/XDFZb1Ug8Y9BRwwEAvSU+APt+rIRQ PbPJgMxFUNyTzMFYCMWtE6d2M3dPCQ8= =v2Y6 -----END PGP SIGNATURE----- --WqrHL50fzIiM0DjG--