Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2128954rwl; Thu, 6 Apr 2023 06:18:59 -0700 (PDT) X-Google-Smtp-Source: AKy350ZiRnI6bsUt40MG7DpMMZpo7PpWFF15nmmK6qpMffvwXhAAzyvmvmMet09UyLDmXFmdPkiJ X-Received: by 2002:a17:907:6b0c:b0:8fd:2f01:86c0 with SMTP id rm12-20020a1709076b0c00b008fd2f0186c0mr6745683ejc.2.1680787138742; Thu, 06 Apr 2023 06:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680787138; cv=none; d=google.com; s=arc-20160816; b=nl18EF9nluATvXlOveZLcQr1xKJPynrS1Ga4AXp5W/Mr5rYz6a2O1Sg1yqeOqUfp5s z3jsK4LmiwY5sgkOEcyjjTmgAGnNj3lOEwQzGMU0G6vYJbIsvyBc52BFXLpje71N8hyu ofjLfInVBW453cL05HEc0Rwi/ePy6Ip7Jvwx2t9CKMrG4XpDA9o2Zmmut129dOL6pgrU 9B2OGQMCaQrUxZ5VmJSgyFBX2gxrcMbnt10y9bKkcbslkCZ1gdz/F5OlVLgiN5aCp/BV oF/Tn80/Gw5CuIAHzVw79CEnFLDcENfKlEYWwz6FmmkR4JIuQwrnyILVkHuOAM2Gst+3 zaxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=STr5mxs5RV8iRWYSKMYXPKQ2lS+5JB8QNOUcHMFXDhg=; b=q1FxcZJrRXZUC6Fl0WohGHsxh3MmEGh4TGw02RPS8CeoOjKs8zaaRHJLT03DEL3T1v Z7AbZt7/7TSQ6vdezEpqcLGNpXy1Gxv9kLGsa2a0mItH9EnJ3ws6ySv5Mk0NiI9fR5mE Bctq5CBpYZuSOoHMla5EolkI+1paBkcHee/KybBXGZuGwYASJi4njZqQFOOkh2lvby62 wpGEbJBhR8c7aldM+DN3T1B0gLU5jFm0++vSqNiYHU9ju7MV3sC008w9yl5mkVQsgEd5 JlG3TrgDsAWXMpG2xwHxKu6Q7cGQ56D1MOHt7Uygk5ryp9G+ySIHb9VIo2Ibxpfe5tMD VPeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=J0GukvVK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q2-20020a17090676c200b00925a428b655si1072508ejn.699.2023.04.06.06.18.34; Thu, 06 Apr 2023 06:18:58 -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=@gmail.com header.s=20210112 header.b=J0GukvVK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237633AbjDFNR5 (ORCPT + 99 others); Thu, 6 Apr 2023 09:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237743AbjDFNRx (ORCPT ); Thu, 6 Apr 2023 09:17:53 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2A2D8A50; Thu, 6 Apr 2023 06:17:48 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id 18so1315606ejo.13; Thu, 06 Apr 2023 06:17:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680787067; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=STr5mxs5RV8iRWYSKMYXPKQ2lS+5JB8QNOUcHMFXDhg=; b=J0GukvVKQKRfWam4GDIa7AfSUSXlSx3aj45N/SAND/dvPAxwVAlFeFn2k28YiHfkwP spfCWsHjznApqj/UliTjMlL+bRH1jLAVUzqXtvdV0pee3/lpqmV+JeJBTUB32Uq6NdjJ KQK0RUoVpKiYU6mfPBQDLUfRXHpqdwP7YXyxoFL7JPSUESBvn0znThSEzdce6mGy2K98 gCfVsO8+df6d3PAKrBYMcCgO2u3l7iCTJIjObhqeFteUR0REK80WSwCxLNP4GsIUWpzt 7qgKXtRxJBN7l65z4OFtVFRSAfMsRFgbDxdElCyah+2aBMU+GljKW3sWQmklaNkgDCmF 86Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680787067; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=STr5mxs5RV8iRWYSKMYXPKQ2lS+5JB8QNOUcHMFXDhg=; b=psR2iTcmjfWXWokTLp696PfWiSxB8lyzw+S3UY6kmWuCuGMZS5gV0iNdHDkQU+RRHO NZ6OmayG934DHtq6eCZwgmTOqakMFhdqPowOwGlFK6Q9a3AaZAVszdv9M/sIVzQbMfh5 XVgjRO7T4Vf9w646gIsn94U9U/tXJ64vdZ2CcXnMVeNN8UsgR8B9zTLOX8Br92p+hM2y 1+IVIGio1EO2ovRWL/mOo8T1bfwWTcTVT9E2pk2yWhIvJzg56C5Amylahki213fTmuDz cpRAQVh9HK3GZIISN1U9RNZC7Pc3F6lZ1uYcapV4bFX9vZUaYMMC8YieGluAZ/uBSbvG uRYA== X-Gm-Message-State: AAQBX9cYp5ox9kddH/v1jttbB0w83Qe2BmOAtOKp/L9gNt/qWWoXEj6L uQIZk/ZsKh7jV3C8jWwQOXQ= X-Received: by 2002:a17:906:1c49:b0:935:1565:d661 with SMTP id l9-20020a1709061c4900b009351565d661mr7225417ejg.66.1680787067367; Thu, 06 Apr 2023 06:17:47 -0700 (PDT) Received: from orome (p200300e41f1c0800f22f74fffe1f3a53.dip0.t-ipconnect.de. [2003:e4:1f1c:800:f22f:74ff:fe1f:3a53]) by smtp.gmail.com with ESMTPSA id 16-20020a170906021000b00949691d3183sm807239ejd.36.2023.04.06.06.17.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 06:17:46 -0700 (PDT) Date: Thu, 6 Apr 2023 15:17:45 +0200 From: Thierry Reding To: Conor Dooley Cc: Conor Dooley , Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= , 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: References: <20230330071203.286972-1-conor.dooley@microchip.com> <20230330071203.286972-2-conor.dooley@microchip.com> <0b91dee7-6c1d-4a33-8235-8fd5d58b200e@spud> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Wmv/6xuPkCm9WCnj" Content-Disposition: inline In-Reply-To: <0b91dee7-6c1d-4a33-8235-8fd5d58b200e@spud> User-Agent: Mutt/2.2.10 (2023-03-25) X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, 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 --Wmv/6xuPkCm9WCnj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Apr 01, 2023 at 09:50:47PM +0100, Conor Dooley wrote: > On Thu, Mar 30, 2023 at 08:12:03AM +0100, Conor Dooley wrote: >=20 > > + /* > > + * 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_st= eps > > + * is valid. > > + * > > + * period_steps can be computed from prescale: > > + * period * clk_rate > > + * period_steps =3D ----------------------------- - 1 > > + * NSEC_PER_SEC * (prescale + 1) > > + * > > + */ > > + if (tmp % (MCHPCOREPWM_PERIOD_STEPS_MAX + 1) < *prescale) { >=20 > 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_uldiv= mod' >=20 > 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. Since you already use some of the helpers from linux/math64.h, perhaps you can use something like div_u64_rem() here? Thierry >=20 > > + u16 smaller_prescale =3D *prescale - 1; > > + > > + *period_steps =3D div_u64(tmp, smaller_prescale + 1) - 1; > > + if (*period_steps < 255) { > > + *prescale =3D smaller_prescale; > > + > > + return 0; > > + } > > + } --Wmv/6xuPkCm9WCnj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmQuxnkACgkQ3SOs138+ s6FgvBAAv7hMz2KGQYKjhjDZiOF7EBFggWM0bmEOgVw8gCdcGbThvfvGS+VBsha1 6nP75xwxZIdn8mER/mAlqu2PXdaMFCzDCm75ZBBSZu9RFmAgdofBZey3Z+XQrcg8 REtkYo/szD9j9TmVmdZ2hO+zzmU+bu32/eb6KSnPKtDEIObymudlahac9stt+eI3 NOK7IMmPRLxVrKlQQ6tLXn45xd84STq1+gDLCVymKWpwD4zP+I9jOoDjsUtt/ip6 FoTg8uDeMSTWGuAcnsxZTG0pgexnOBDzeeI6l1Cq7Mv/q3dkFJpGvYL6OMOHGej9 rYu5RAIogdRq84FAeJKTfIKSxn5NGzod26NRbXr+nULTvaBx6WL6kLOrnGfgJlIP 1aNbzw+ITtG4ulJeoe5sXf7Ih5hy+trjPmxaAUqRCxn2i7IOZty+Uhb/BcBPec0R TN9czr6YmBnyQ5SWjq0aqyJMEIfYQh0PK8tB/wbVZ5yjcsNt5cOQKoTe5lYSPPo4 5OsLIVOz8ZOv7iaYXOFIYm+Gnd4xocwxM2mKpvrCmpDWeNnE2+X5gWIsHxPOepSR DJmnNadZShy4qAnAjNX8Ol6CBGM9ltCXWBpiD3Pqauc0IW0G/pJlw6ZmeS4ZWN24 Fj3dTjMi4PMMcbkuLNXDZvanVLJk0JvtBXauVHw1JB2KqEZ6nn4= =EF8+ -----END PGP SIGNATURE----- --Wmv/6xuPkCm9WCnj--