From: Ivan Vecera <ivecera@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Michal Schmidt <mschmidt@redhat.com>,
Petr Oros <poros@redhat.com>,
Prathosh Satish <Prathosh.Satish@microchip.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Jiri Pirko <jiri@resnulli.us>, Jonathan Corbet <corbet@lwn.net>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
Donald Hunter <donald.hunter@gmail.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] dpll: add phase-adjust-gran pin attribute
Date: Wed, 29 Oct 2025 08:44:52 +0100 [thread overview]
Message-ID: <b3f45ab3-348b-4e3e-95af-5dc16bb1be96@redhat.com> (raw)
In-Reply-To: <20251028183919.785258a9@kernel.org>
Hi Kuba,
On 10/29/25 2:39 AM, Jakub Kicinski wrote:
> On Fri, 24 Oct 2025 16:49:26 +0200 Ivan Vecera wrote:
>> + -
>> + name: phase-adjust-gran
>> + type: s32
>> + doc: |
>> + Granularity of phase adjustment, in picoseconds. The value of
>> + phase adjustment must be a multiple of this granularity.
>
> Do we need this to be signed?
>
To have it unsigned brings a need to use explicit type casting in the
core and driver's code. The phase adjustment can be both positive and
negative it has to be signed. The granularity specifies that adjustment
has to be multiple of granularity value so the core checks for zero
remainder (this patch) and the driver converts the given adjustment
value using division by the granularity.
If we would have phase-adjust-gran and corresponding structure fields
defined as u32 then we have to explicitly cast the granularity to s32
because for:
<snip>
s32 phase_adjust, remainder;
u32 phase_gran = 1000;
phase_adjust = 5000;
remainder = phase_adjust % phase_gran;
/* remainder = 0 -> OK for positive adjust */
phase_adjust = -5000;
remainder = phase_adjust % phase_gran;
/* remainder = 296
* Wrong for negative adjustment because phase_adjust is casted to u32
* prior division -> 2^32 - 5000 = 4294962296.
* 4294962296 % 1000 = 296
*/
remainder = phase_adjust % (s32)phase_gran;
/* remainder = 0
* Now OK because phase_adjust remains to be s32
*/
</snip>
Similarly for division in the driver code if the granularity would be
u32.
So I have proposed phase adjustment granularity to be s32 to avoid these
explicit type castings and potential bugs in drivers.
Thanks,
Ivan
next prev parent reply other threads:[~2025-10-29 7:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-24 14:49 [PATCH net-next 0/2] dpll: Add support for phase adjustment granularity Ivan Vecera
2025-10-24 14:49 ` [PATCH net-next 1/2] dpll: add phase-adjust-gran pin attribute Ivan Vecera
2025-10-29 1:39 ` Jakub Kicinski
2025-10-29 7:44 ` Ivan Vecera [this message]
2025-10-29 14:20 ` Jiri Pirko
2025-10-29 15:00 ` Ivan Vecera
2025-10-29 10:20 ` Vadim Fedorenko
2025-10-29 11:17 ` Ivan Vecera
2025-10-24 14:49 ` [PATCH net-next 2/2] dpll: zl3073x: Specify phase adjustment granularity for pins Ivan Vecera
2025-10-29 1:36 ` [PATCH net-next 0/2] dpll: Add support for phase adjustment granularity Jakub Kicinski
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=b3f45ab3-348b-4e3e-95af-5dc16bb1be96@redhat.com \
--to=ivecera@redhat.com \
--cc=Prathosh.Satish@microchip.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=vadim.fedorenko@linux.dev \
/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 NNTP newsgroup(s).