From patchwork Fri Jun 28 05:44:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thorsten Blum X-Patchwork-Id: 13715476 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 622ADC2BBCA for ; Fri, 28 Jun 2024 05:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=mKwQ+Q+9TfT4z2bS61ufsxSCCuVOp72eGiupWLKWdwU=; b=QZXSqFwpOxV0CnGUD4JtKGmh3e KHykUzXCpIcFAxXkbMC9WhBx8Y0QLmkAYORzvhpS94vgp/dXIVG7K5ge05xmlLkyDuHee80Kzf0Jk oEEJTzO8kymczdnIGk7Iu156qenWfbR/8w2b+X4GAB8OSikchpSbMfsurE5fk3TC3IycKBS1KrSzE LY4SD6ILfUSSIyaZVMfb0VHk53KJzuqWe4NYFLC6TrRcq2gjqksCWBKTMXJ7TM4hGKbNxXDKX6LYa +K8XGkKkC3ZhvdUD0jyb+SB/jhGyKqaI13TqKiCHicrTTHBN860zDsWpDIH9vtGkD0H37mWkZwYXK O02QLNUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN4Qq-0000000CeXj-1waN; Fri, 28 Jun 2024 05:46:00 +0000 Received: from mail-oo1-xc2e.google.com ([2607:f8b0:4864:20::c2e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN4Qi-0000000CeUw-1MEX for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 05:45:53 +0000 Received: by mail-oo1-xc2e.google.com with SMTP id 006d021491bc7-5b97a9a9b4bso93300eaf.0 for ; Thu, 27 Jun 2024 22:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toblux-com.20230601.gappssmtp.com; s=20230601; t=1719553550; x=1720158350; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mKwQ+Q+9TfT4z2bS61ufsxSCCuVOp72eGiupWLKWdwU=; b=hyg7ixl3cvIVM3G4htUatTRqOXMRcRuFH2qfk8q8j3LjknZDzkitrdb0aVsBWESmu4 QnKaW+/kWvy0FHsaG/F+iVSxFzeEbncA2pMnyk5dDUlvvPFefGzOnl7J0SmyRa+bTpQD 7AVbN6rRY9pVqS7Ro6PsBe2UMzbnQYEPJgcEPzWk9mG2oMSOAWNxDi7Sp4usCKZ8A7zK 6GdV9H8RJVyL7HiX5DngAlg3C1TMijaQPtcqSTX/13ienPUZ5oR0Df2YXNqpFpYSjWS6 7DhY99grFfo78lCJWSP+JEUhqvwFUajblbR90Nk8S13vi9nMNjhoSxhfmo4ENx9PUUVX +x1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719553550; x=1720158350; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mKwQ+Q+9TfT4z2bS61ufsxSCCuVOp72eGiupWLKWdwU=; b=K7HpcSIlrInVg+z+sq0EpDQTGVmmDdFuAnHrIebxwUW7I9iHY35rkctkGkBLVe3QmS GhawupEIhq0+qdmKmEvAyoa1Pmz2VOACSOK3A7NU0Lp8yfQ8vk9eTCB3h3ODEBC1S6eE VdGw1jlFFQine7T9ULiXDb7wQOwrVwBFn9j11O520wURKBk2XpV49LcqPoZWWBw+jhfL QBFaBvIBW6n1ed+HfL60u6/AUaBme+cm7SnBtGtwZGf7L3dz4Ngl9pnt1iwYcPFZ6j8+ P1U0sWCFA6rY55e72QVbFu95fk+Xj6zx4t2BmmNm3DEkZTUbt9bioSw9+CsO+fUfxuKp daUw== X-Gm-Message-State: AOJu0Yz55r+Jt5p0C8OrqKzsR5j7W6We9rTOYLLavMmiaiCpRtrh90by OZpsrB3hRoxHJ2WSrqNwwWPYTLQ4w62doIT2KeJvNHdyrsMF3pB4yKholuvv/KWFtqumgb0vnb1 J X-Google-Smtp-Source: AGHT+IG6eP69dUZnkaDfPjRZYetEYIxPWuLgvgd/psEEELnjsa9q71KwZV7BrZKfjW1XpUxUR0Bc/A== X-Received: by 2002:a05:6358:882:b0:1a6:904b:3d2a with SMTP id e5c5f4694b2df-1a6904b3f6emr62211255d.28.1719553550226; Thu, 27 Jun 2024 22:45:50 -0700 (PDT) Received: from fedora.vc.shawcable.net (S0106c09435b54ab9.vc.shawcable.net. [24.85.107.15]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-72c69b515f1sm598370a12.6.2024.06.27.22.45.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 22:45:49 -0700 (PDT) From: Thorsten Blum To: linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH] ARM: vfp: Improve data types for divisors mh and ml Date: Fri, 28 Jun 2024 07:44:06 +0200 Message-ID: <20240628054405.317236-2-thorsten.blum@toblux.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_224552_604831_DEA1E973 X-CRM114-Status: GOOD ( 10.97 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The divisors mh and ml can both be u32 instead of u64. Since do_div() implicitly casts the divisors from u64 to u32, changing their data types to u32 also removes the following Coccinelle warnings reported by do_div.cocci: arch/arm/vfp/vfp.h:121:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. arch/arm/vfp/vfp.h:135:2-8: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead. Use upper_32_bits() to compare 32-bit numbers instead of 64-bit numbers and to prevent the warning: left shift count >= width of type [-Wshift-count-overflow] Compile-tested only. Signed-off-by: Thorsten Blum --- arch/arm/vfp/vfp.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/vfp/vfp.h b/arch/arm/vfp/vfp.h index e43a630f8a16..29073d89ef00 100644 --- a/arch/arm/vfp/vfp.h +++ b/arch/arm/vfp/vfp.h @@ -109,12 +109,13 @@ static inline u64 vfp_hi64multiply64(u64 n, u64 m) static inline u64 vfp_estimate_div128to64(u64 nh, u64 nl, u64 m) { - u64 mh, ml, remh, reml, termh, terml, z; + u64 remh, reml, termh, terml, z; + u32 mh, ml; if (nh >= m) return ~0ULL; mh = m >> 32; - if (mh << 32 <= nh) { + if (mh <= upper_32_bits(nh)) { z = 0xffffffff00000000ULL; } else { z = nh; @@ -129,7 +130,7 @@ static inline u64 vfp_estimate_div128to64(u64 nh, u64 nl, u64 m) add128(&remh, &reml, remh, reml, mh, ml); } remh = (remh << 32) | (reml >> 32); - if (mh << 32 <= remh) { + if (mh <= upper_32_bits(remh)) { z |= 0xffffffff; } else { do_div(remh, mh);