intel-wired-lan.lists.osuosl.org archive mirror
 help / color / mirror / Atom feed
From: "Arland, ArpanaX" <arpanax.arland@intel.com>
To: "Keller, Jacob E" <jacob.e.keller@intel.com>,
	Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
Cc: "Keller, Jacob E" <jacob.e.keller@intel.com>,
	Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Subject: Re: [Intel-wired-lan] [PATCH iwl-next] ice: add and use roundup_u64 instead of open coding equivalent
Date: Tue, 7 May 2024 07:27:39 +0000	[thread overview]
Message-ID: <BN9PR11MB5354AE756BB42E44675DD9DF80E42@BN9PR11MB5354.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240426-mirrors-iwl-v1-1-284c1d7fdc94@intel.com>

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Jacob Keller
> Sent: Saturday, April 27, 2024 4:17 AM
> To: Intel Wired LAN <intel-wired-lan@lists.osuosl.org>
> Cc: Keller, Jacob E <jacob.e.keller@intel.com>; Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH iwl-next] ice: add and use roundup_u64 instead of open coding equivalent
>
> In ice_ptp_cfg_clkout(), the ice driver needs to calculate the nearest next second of a current time value specified in nanoseconds. It implements this using div64_u64, because the time value is a u64. It could use div_u64 since NSEC_PER_SEC is smaller than 32-bits.
>
> Ideally this would be implemented directly with roundup(), but that can't work on all platforms due to a division which requires using the specific macros and functions due to platform restrictions, and to ensure that the most appropriate and fast instructions are used.
>
> The kernel doesn't currently provide any 64-bit equivalents for doing roundup. Attempting to use roundup() on a 32-bit platform will result in a link failure due to not having a direct 64-bit division.
>
> The closest equivalent for this is DIV64_U64_ROUND_UP, which does a division always rounding up. However, this only computes the division, and forces use of the div64_u64 in cases where the divisor is a 32bit value and could make use of div_u64.
>
> Introduce DIV_U64_ROUND_UP based on div_u64, and then use it to implement
> roundup_u64 which takes a u64 input value and a u32 rounding value.
>
> The name roundup_u64 matches the naming scheme of div_u64, and future patches could implement roundup64_u64 if they need to round by a multiple that is greater than 32-bits.
>
> Replace the logic in ice_ptp.c which does this equivalent with the newly added roundup_u64.
>
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> ---
> Changes since v1:
> * add DIV_U64_ROUND_UP and use it for clarity
> ---
>  drivers/net/ethernet/intel/ice/ice_ptp.c |  3 +--
>  include/linux/math64.h                   | 27 +++++++++++++++++++++++++++
>  2 files changed, 28 insertions(+), 2 deletions(-)
>

Tested-by: Arpana Arland <arpanax.arland@intel.com> (A Contingent worker at Intel)


      reply	other threads:[~2024-05-07  7:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 22:47 [Intel-wired-lan] [PATCH iwl-next] ice: add and use roundup_u64 instead of open coding equivalent Jacob Keller
2024-05-07  7:27 ` Arland, ArpanaX [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN9PR11MB5354AE756BB42E44675DD9DF80E42@BN9PR11MB5354.namprd11.prod.outlook.com \
    --to=arpanax.arland@intel.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jacob.e.keller@intel.com \
    --cc=michal.swiatkowski@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).