From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62A10C433EF for ; Thu, 18 Nov 2021 10:11:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4871D61ABD for ; Thu, 18 Nov 2021 10:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244525AbhKRKOW (ORCPT ); Thu, 18 Nov 2021 05:14:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244516AbhKRKMv (ORCPT ); Thu, 18 Nov 2021 05:12:51 -0500 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F09A7C061764; Thu, 18 Nov 2021 02:09:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LbHt7EJoFhOZV5kub5JngiZnvgmRApjPOTDxo+lLz4I=; b=yn/MviBBs9GuGJOPYQtbWTc10J 3bJXszwjy2n4ksLEz5pN3TssG6jLuQ7sloPDL/FkW1EEnTXGE0uNZwSGfd1+rV/gpp31so/+LrdmE G40SSHuM6NCyJ+LOZ+jISQ3AUBIGszfgs3k7GiftgJ0f6Itusd7TgmweSscUc3rCo/98OA6l5qLLD yLuHTZsYByFB9FyvFktEV6wbXp/4+1xsCHd9UnTULsnxpE3pXDBjSE5ppcnTZxK1yfaCB+hD+dp6H rzwlQe4d3vypAQ6v76WYLKoL8tral5qXuNoHfPx7t5MyHRG/xj1DRgGWYaFjhQXoBIIhpZbWMptjt 3tp3Z5rg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55710) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mneMT-0002nO-5y; Thu, 18 Nov 2021 10:09:45 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mneMP-0003qm-4t; Thu, 18 Nov 2021 10:09:41 +0000 Date: Thu, 18 Nov 2021 10:09:41 +0000 From: "Russell King (Oracle)" To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: cgel.zte@gmail.com, linux-pwm@vger.kernel.org, alexandre.belloni@bootlin.com, Zeal Robot , linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, thierry.reding@gmail.com, Changcheng Deng , lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] pwm: Use div64_ul instead of do_div Message-ID: References: <20211117020426.159242-1-deng.changcheng@zte.com.cn> <20211117112400.bkscb2pyavonpfsn@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20211117112400.bkscb2pyavonpfsn@pengutronix.de> Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-pwm@vger.kernel.org On Wed, Nov 17, 2021 at 12:24:00PM +0100, Uwe Kleine-König wrote: > Hello, > > On Wed, Nov 17, 2021 at 02:04:26AM +0000, cgel.zte@gmail.com wrote: > > From: Changcheng Deng > > > > do_div() does a 64-by-32 division. If the divisor is unsigned long, using > > div64_ul can avoid truncation to 32-bit. > > After some research I understood your commit log. I'd write: > > do_div() does a 64-by-32 division. Here the divsor is an > unsigned long which on some platforms is 64 bit wide. So use > div64_ul instead of do_div to avoid a possible truncation. > > The priority of this patch seems to be low, as the device seems to exist > only on (32bit) arm. ... where unsigned long is 32-bit. In any case, for this to overflow, we would need to have a clock in excess of 2^32-1 Hz, or around 4GHz - and if we had such a situation on 32-bit devices, we need to change the type for holding the frequency in the clk API, and probably a lot of code in the CCF as well. Unless there is a real reason for this change, I would suggest leaving the code as is - there is absolutely no point in making these divisions more expensive unless there is a real reason. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A617C433FE for ; Thu, 18 Nov 2021 10:11:28 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DF5561ABD for ; Thu, 18 Nov 2021 10:11:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2DF5561ABD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QwVt7V6qNbO2LbqZSL7Rh9v6tkyKOqoG0frD8Xxy+fE=; b=YuVzVaH7l4KStz 2aAeqU/2i5uwt5R9N1AKmdobvNftjkD9q4AEowRxW8IskrHES08iL9CZjh7V7/7ZYWlw7EGhX9rRG GiZbVeObAuVdTImplSjEgaE2D3hK4LzFcdoXVpoWCYXjDrF/xsojZ7uAg2sD71YT+td5tsjPyLCQP nyohXluwkAy9X91yaLXnEck7+UpioDo8Y3be2wnprvzL2dLfMA2BGClIunfEsNFlJLmz5m9O63MOC Dn47isQJ7oL7ZevRF1ffiCYotTHHJ6eH6IaQmChAJusXdimAxnlU2yyO+0383qpzl3LM/WyO/8dzN tZq1me9udnnfJCnco7ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mneMm-007RBF-8S; Thu, 18 Nov 2021 10:10:04 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mneMh-007RA0-Qx for linux-arm-kernel@lists.infradead.org; Thu, 18 Nov 2021 10:10:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LbHt7EJoFhOZV5kub5JngiZnvgmRApjPOTDxo+lLz4I=; b=yn/MviBBs9GuGJOPYQtbWTc10J 3bJXszwjy2n4ksLEz5pN3TssG6jLuQ7sloPDL/FkW1EEnTXGE0uNZwSGfd1+rV/gpp31so/+LrdmE G40SSHuM6NCyJ+LOZ+jISQ3AUBIGszfgs3k7GiftgJ0f6Itusd7TgmweSscUc3rCo/98OA6l5qLLD yLuHTZsYByFB9FyvFktEV6wbXp/4+1xsCHd9UnTULsnxpE3pXDBjSE5ppcnTZxK1yfaCB+hD+dp6H rzwlQe4d3vypAQ6v76WYLKoL8tral5qXuNoHfPx7t5MyHRG/xj1DRgGWYaFjhQXoBIIhpZbWMptjt 3tp3Z5rg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55710) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mneMT-0002nO-5y; Thu, 18 Nov 2021 10:09:45 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mneMP-0003qm-4t; Thu, 18 Nov 2021 10:09:41 +0000 Date: Thu, 18 Nov 2021 10:09:41 +0000 From: "Russell King (Oracle)" To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: cgel.zte@gmail.com, linux-pwm@vger.kernel.org, alexandre.belloni@bootlin.com, Zeal Robot , linux-kernel@vger.kernel.org, ludovic.desroches@microchip.com, thierry.reding@gmail.com, Changcheng Deng , lee.jones@linaro.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] pwm: Use div64_ul instead of do_div Message-ID: References: <20211117020426.159242-1-deng.changcheng@zte.com.cn> <20211117112400.bkscb2pyavonpfsn@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211117112400.bkscb2pyavonpfsn@pengutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211118_020959_897064_9FD667AE X-CRM114-Status: GOOD ( 16.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 17, 2021 at 12:24:00PM +0100, Uwe Kleine-K=F6nig wrote: > Hello, > = > On Wed, Nov 17, 2021 at 02:04:26AM +0000, cgel.zte@gmail.com wrote: > > From: Changcheng Deng > > = > > do_div() does a 64-by-32 division. If the divisor is unsigned long, usi= ng > > div64_ul can avoid truncation to 32-bit. > = > After some research I understood your commit log. I'd write: > = > do_div() does a 64-by-32 division. Here the divsor is an > unsigned long which on some platforms is 64 bit wide. So use > div64_ul instead of do_div to avoid a possible truncation. > = > The priority of this patch seems to be low, as the device seems to exist > only on (32bit) arm. ... where unsigned long is 32-bit. In any case, for this to overflow, we would need to have a clock in excess of 2^32-1 Hz, or around 4GHz - and if we had such a situation on 32-bit devices, we need to change the type for holding the frequency in the clk API, and probably a lot of code in the CCF as well. Unless there is a real reason for this change, I would suggest leaving the code as is - there is absolutely no point in making these divisions more expensive unless there is a real reason. -- = RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel