Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp960735rwl; Wed, 29 Mar 2023 10:38:25 -0700 (PDT) X-Google-Smtp-Source: AKy350bsmmvNkApfmgxF5RY3Jd3kQGxuN5zaycR4BGhU61UHPpwjAdWuBSAL4IG1yD5OzAxCtRoT X-Received: by 2002:a05:6402:204c:b0:500:2cc6:36da with SMTP id bc12-20020a056402204c00b005002cc636damr21110535edb.19.1680111505387; Wed, 29 Mar 2023 10:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680111505; cv=none; d=google.com; s=arc-20160816; b=sIp3NbcpdiUssOs2OZZeR+mJUw3rzBd1A47NNCzs5MnzUZOh5eSygjRXrmVENllZRw VZLtDw/9eys5q/1tJdSmH+v4uEJ3CoFJRwEcg0PKh1jgkl28NKVn/VjnOzYAmtDSOSGP pyjfA5P2KiZaeY7mdmvnRXt14xTQ4LA8cb8zfKrgQwvf3Pw1MkX815COrD0gT7LmIuuz VcCI1blvTc/ZzgQuGL+YRpto5Z9vSCS0s3S+QIeXvQx0Y/WehRflb7PiPmJetpax5D8W S94riqwMp6PXvQET62LlWLFLNtC9D0uLJ1rd0Eydgnyaw+RrKcLiahSSDtHvtQBtq4Bi Famw== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Z6Iu4zN11ZwYZryC1/WL4wMaJf/cJotn2dkH5vrfiLA=; b=PqTioyOXfVmls/obLCtaGaa0B3TPblDLb1EKJxoNBKpQfds+GR9WNkXeEIfGurUSy+ yqFCgOm3VmpDvcZPnicpFQ6B5BfjL3dGvo1c7WQZkJKgGMelLt49LGhzdueRIA1ytmwd owCslG0EVo0V8zXnjIkVpmxZh8DautyJ/IGzvI1ats2fBqjdoJ2V3F9R+LEXWkS5vmDH t6Tw8Mg7Yh1mWM7RDANLcmQlQqU1JP/aC6sQgFEoZjMb2bVXLgIaiFoaMVmL7GhCTl3J sPkjhIoGuIs9cMSTKBvZqcNS+3ONE8oWyd+AajJgflhHWrGCq1wjzw37V9M9emxg9Tmk aKaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="mM0Da/zR"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 v6-20020aa7d9c6000000b005021d19dcdesi13357355eds.171.2023.03.29.10.38.06; Wed, 29 Mar 2023 10:38:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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="mM0Da/zR"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 S230256AbjC2RZE (ORCPT + 59 others); Wed, 29 Mar 2023 13:25:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229987AbjC2RZD (ORCPT ); Wed, 29 Mar 2023 13:25:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE16549FA; Wed, 29 Mar 2023 10:25:01 -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 78CC361DDB; Wed, 29 Mar 2023 17:25:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1367DC433D2; Wed, 29 Mar 2023 17:24:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680110700; bh=HcR9a4qjBB8LKDYe607WkBKXaWerJixcvHnMfM4MQbI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mM0Da/zR0ywsu1h5uDbGPboafXOhhH0p1GVywEQRUjEWuyhH8iHj6V1G4l0f1rVbp 4FhHlR2G3U+LguTiTwKRkTv7xn0C1WvJ26ZTJqLGIQKKwy95NWlmHJe5pboYYEJWHd UwI2mFR2P7JSwvirNOUMtnEk68aIY8KO3PINtUbKKplwUyzkfIuvzLDLh4ZVNJ2WaX Mz6ut5KFXihPDAfFxusHsaJvaomG4p9B0SiGqmEi5rVGyDQhTBTLRqpvAIymCjfiS+ ONmYuTJFDKMjaygHQJINuyoR4LojG6gInqL1lzr/OLz1OUyeeuFJ4v5vrvlVcwwr8i 7JbBh2zqDmy5w== Date: Wed, 29 Mar 2023 10:24:58 -0700 From: Nathan Chancellor To: Johannes Berg Cc: gregory.greenman@intel.com, kvalo@kernel.org, ndesaulniers@google.com, trix@redhat.com, avraham.stern@intel.com, krishnanand.prabhu@intel.com, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, Arnd Bergmann , "kernelci.org bot" Subject: Re: [PATCH wireless-next] wifi: iwlwifi: mvm: Avoid 64-bit division in iwl_mvm_get_crosstimestamp_fw() Message-ID: <20230329172458.GA209886@dev-arch.thelio-3990X> References: <20230329-iwlwifi-ptp-avoid-64-bit-div-v1-1-ad8db8d66bc2@kernel.org> <9058a032c177e9b04adbf944ad34c5ed8090d9d6.camel@sipsolutions.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9058a032c177e9b04adbf944ad34c5ed8090d9d6.camel@sipsolutions.net> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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-wireless@vger.kernel.org On Wed, Mar 29, 2023 at 07:20:43PM +0200, Johannes Berg wrote: > On Wed, 2023-03-29 at 10:05 -0700, Nathan Chancellor wrote: > > > > GCC has optimizations for division by a constant that clang does not > > implement, so this issue is not visible when building with GCC. > > Huh yeah, we did 32-bit builds with gcc ... > > > Using div_u64() would resolve this issue, but Arnd points out that this > > can be quite expensive and the timestamp is being read at nanosecond > > granularity.? > > Doesn't matter though, all the calculations are based on just the > command response from the firmware, which (tries to) take it in a > synchronised fashion. Okay, that is good information, thanks for providing it! > So taking more time here would be fine, as far as I can tell. > > > Nick pointed out that the result of this division is being > > stored to a 32-bit type anyways, so truncate gp2_10ns first then do the > > division, which elides the need for libcalls. > > That loses ~7 top bits though, no? I'd be more worried about that, than > the time div_u64() takes. Right, I sent this version of the fix to spur discussion around whether or not this was an acceptable approach, rather than having the question sit unanswered in our issue tracker :) I have no problems sending a v2 to use div_u64() and be done with it, which I will do shortly. Thanks for the quick input, cheers! Nathan