Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1996758rwd; Wed, 17 May 2023 04:31:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4JFf7QNjANozDe6VVarPaBCWDCY5iLviR0ZPNJNy6CD2GnvaD96NVYXJWEw+dSdfztZ/eH X-Received: by 2002:a05:6a00:24cf:b0:641:3bf8:6514 with SMTP id d15-20020a056a0024cf00b006413bf86514mr741337pfv.10.1684323072064; Wed, 17 May 2023 04:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684323072; cv=none; d=google.com; s=arc-20160816; b=OHq3awvycLFOUkRcUXI5j65+4gAy4ZM8QT4RpW5rbbBAZOlzP5CA5psq3DSIp757rZ O0cNjz8ZCsbjr2AE6WCfD5fhTqbbk/9Ad3BercSL8ywi37MDMNteApEOTUOOtO5Y8vI8 30S/F5u5n6aj0XDT1nDHIegOMJjR/decgfM6gP9dYPO+vJpDwvuR9ntPI0cm0PEOLr+x NxVUL0nTP1vk2qTG/VETIt/2bjolz1rWZSucBODFEJfAUGiEJZ98VAZkXKmi7Ldjf7no f6pTAZeYyFLHmTZwTJvCzSesMzj0QNUo/aVzLlnrPSRZijzQQsKlZ+Do8BZoQYeFjhpJ emzQ== 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=PyvZ9lh/7SpjqgQNRMl2zh+teP9Exb4juLMiCwQGMWc=; b=RIbYN98jr0sMGM64DkyPxk+XjLS68O202PxfsM2GLDsfll1aMSnXe9yUADmE5MLsir MeTmX27U0JTQz85OXX0pNZ5Qt5Wy2K3gmSeT+9frttgboEmA3TnJdDwM2p8YmZiiqLkC +dg02PPICagXtMlQVpbn1TAYzGqINlxsohFObhA3KRRxDNbumZbdtjNF4FOGh6a4UzAF +0d71wW2zms9RrCMMd+XXDnFSNlG8cGDNpR9xC2S8XeRudvA4sci55vWGsDY+1zXJC26 v4VCA+CjJqADkIVCyn2fpMmS2H2MoPsoAFV+/FPkrYPTupYC1cAQaEPJueDIjeg5xOda zvwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=axX8PbLp; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e27-20020a63745b000000b00530b5c81690si10784835pgn.585.2023.05.17.04.30.58; Wed, 17 May 2023 04:31:12 -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=@microchip.com header.s=mchp header.b=axX8PbLp; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjEQLFS (ORCPT + 99 others); Wed, 17 May 2023 07:05:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231390AbjEQLFN (ORCPT ); Wed, 17 May 2023 07:05:13 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F412691; Wed, 17 May 2023 04:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1684321494; x=1715857494; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=r2C53q37nasETW8R0y62vJQzUer3lCIfLyK7Hf9/7k8=; b=axX8PbLpY9PsCKFDzZNUFo/vEuC91gM+29zbxdq5GSxrvk/en9g2ap/T QYr/az5gn598UL2VgilXah8J2eRmEAIid3mtNAXSBs4OWeGPLOqp9KT3i imwaz3MGavyD9glOS4eMG9R6LLkP83y7mLhxyFszw0KXTj3UsVziFX+nb Cgft0b9Zt5lBgZ89f7SumfxLIoZiLv6sx0xr03r1OMt2vH6JLERatA1s1 coaqkhTPOJJK+sYXaxQEQCMYDUWtx3PeMWHrHqxyuxSujxWvVod3aBowp eSNBVdAMprB4mZPCiwogQ6Sa/Qv1aHkkbXArmL68bs1qLVAxLffw9EB3P w==; X-IronPort-AV: E=Sophos;i="5.99,281,1677567600"; d="asc'?scan'208";a="215862137" X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 17 May 2023 03:57:37 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 17 May 2023 03:57:36 -0700 Received: from wendy (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21 via Frontend Transport; Wed, 17 May 2023 03:57:35 -0700 Date: Wed, 17 May 2023 11:57:14 +0100 From: Conor Dooley To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= CC: Thierry Reding , Daire McNamara , , , Subject: Re: [PATCH v17 1/2] pwm: add microchip soft ip corePWM driver Message-ID: <20230517-sinner-remember-a5f6b86194ab@wendy> References: <20230421-neurology-trapezoid-b4fa29923a23@wendy> <20230421-sleek-bottom-88b867f56609@wendy> <20230517102030.b4nyo2dmpfl7v7fk@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wz8/6k7ZC8Bn65VB" Content-Disposition: inline In-Reply-To: <20230517102030.b4nyo2dmpfl7v7fk@pengutronix.de> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 --wz8/6k7ZC8Bn65VB Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 17, 2023 at 12:20:30PM +0200, Uwe Kleine-K=F6nig wrote: > Hello Conor, >=20 > I found one remaining issue: >=20 > On Fri, Apr 21, 2023 at 10:27:09AM +0100, Conor Dooley wrote: > > +static u64 mchp_core_pwm_calc_duty(const struct pwm_state *state, u64 = clk_rate, > > + u8 prescale, u8 period_steps) > > +{ > > + u64 duty_steps, tmp; > > + > > + /* > > + * Calculate the duty cycle in multiples of the prescaled period: > > + * duty_steps =3D duty_in_ns / step_in_ns > > + * step_in_ns =3D (prescale * NSEC_PER_SEC) / clk_rate > > + * The code below is rearranged slightly to only divide once. > > + */ > > + tmp =3D (prescale + 1) * NSEC_PER_SEC; >=20 > If prescale > 4 this overflows on 32bit archs, doesn't it? Ooh, I think you are right. > (I think prescale + 1 is promoted to unsigned int, then the > multiplication is done and only then the range is extended to u64. I'll respin with an explicit cast. Thanks, Conor. --wz8/6k7ZC8Bn65VB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHQEABYIAB0WIQRh246EGq/8RLhDjO14tDGHoIJi0gUCZGSzCgAKCRB4tDGHoIJi 0hR/AQCX5o1i7KOyi7nlg0yPqhSWIWjpqh9ysAtfM1Ro3HafgwD4+ygsDH16bb3k qDc8pgBDgXVyZ+OhNF7rK7RJvQMNDA== =7JAi -----END PGP SIGNATURE----- --wz8/6k7ZC8Bn65VB--