Skip to content

Commit caac979

Browse files
committed
dpll: add phase-adjust-gran pin attribute
JIRA: https://issues.redhat.com/browse/RHEL-126529 Upstream commit(s): commit 30176bf Author: Ivan Vecera <ivecera@redhat.com> Date: Wed Oct 29 16:32:06 2025 +0100 dpll: add phase-adjust-gran pin attribute Phase-adjust values are currently limited by a min-max range. Some hardware requires, for certain pin types, that values be multiples of a specific granularity, as in the zl3073x driver. Add a `phase-adjust-gran` pin attribute and an appropriate field in dpll_pin_properties. If set by the driver, use its value to validate user-provided phase-adjust values. Reviewed-by: Michal Schmidt <mschmidt@redhat.com> Reviewed-by: Petr Oros <poros@redhat.com> Tested-by: Prathosh Satish <Prathosh.Satish@microchip.com> Signed-off-by: Ivan Vecera <ivecera@redhat.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com> Link: https://patch.msgid.link/20251029153207.178448-2-ivecera@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent d53e4aa commit caac979

File tree

5 files changed

+40
-17
lines changed

5 files changed

+40
-17
lines changed

Documentation/driver-api/dpll.rst

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,26 +198,28 @@ be requested with the same attribute with ``DPLL_CMD_DEVICE_SET`` command.
198198
================================== ======================================
199199

200200
Device may also provide ability to adjust a signal phase on a pin.
201-
If pin phase adjustment is supported, minimal and maximal values that pin
202-
handle shall be provide to the user on ``DPLL_CMD_PIN_GET`` respond
203-
with ``DPLL_A_PIN_PHASE_ADJUST_MIN`` and ``DPLL_A_PIN_PHASE_ADJUST_MAX``
201+
If pin phase adjustment is supported, minimal and maximal values and
202+
granularity that pin handle shall be provided to the user on
203+
``DPLL_CMD_PIN_GET`` respond with ``DPLL_A_PIN_PHASE_ADJUST_MIN``,
204+
``DPLL_A_PIN_PHASE_ADJUST_MAX`` and ``DPLL_A_PIN_PHASE_ADJUST_GRAN``
204205
attributes. Configured phase adjust value is provided with
205206
``DPLL_A_PIN_PHASE_ADJUST`` attribute of a pin, and value change can be
206207
requested with the same attribute with ``DPLL_CMD_PIN_SET`` command.
207208

208-
=============================== ======================================
209-
``DPLL_A_PIN_ID`` configured pin id
210-
``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase adjustment
211-
``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase adjustment
212-
``DPLL_A_PIN_PHASE_ADJUST`` attr configured value of phase
213-
adjustment on parent dpll device
214-
``DPLL_A_PIN_PARENT_DEVICE`` nested attribute for requesting
215-
configuration on given parent dpll
216-
device
217-
``DPLL_A_PIN_PARENT_ID`` parent dpll device id
218-
``DPLL_A_PIN_PHASE_OFFSET`` attr measured phase difference
219-
between a pin and parent dpll device
220-
=============================== ======================================
209+
================================ ==========================================
210+
``DPLL_A_PIN_ID`` configured pin id
211+
``DPLL_A_PIN_PHASE_ADJUST_GRAN`` attr granularity of phase adjustment value
212+
``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase adjustment
213+
``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase adjustment
214+
``DPLL_A_PIN_PHASE_ADJUST`` attr configured value of phase
215+
adjustment on parent dpll device
216+
``DPLL_A_PIN_PARENT_DEVICE`` nested attribute for requesting
217+
configuration on given parent dpll
218+
device
219+
``DPLL_A_PIN_PARENT_ID`` parent dpll device id
220+
``DPLL_A_PIN_PHASE_OFFSET`` attr measured phase difference
221+
between a pin and parent dpll device
222+
================================ ==========================================
221223

222224
All phase related values are provided in pico seconds, which represents
223225
time difference between signals phase. The negative value means that
@@ -384,6 +386,8 @@ according to attribute purpose.
384386
frequencies
385387
``DPLL_A_PIN_ANY_FREQUENCY_MIN`` attr minimum value of frequency
386388
``DPLL_A_PIN_ANY_FREQUENCY_MAX`` attr maximum value of frequency
389+
``DPLL_A_PIN_PHASE_ADJUST_GRAN`` attr granularity of phase
390+
adjustment value
387391
``DPLL_A_PIN_PHASE_ADJUST_MIN`` attr minimum value of phase
388392
adjustment
389393
``DPLL_A_PIN_PHASE_ADJUST_MAX`` attr maximum value of phase

Documentation/netlink/specs/dpll.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,12 @@ attribute-sets:
440440
doc: |
441441
Capable pin provides list of pins that can be bound to create a
442442
reference-sync pin pair.
443+
-
444+
name: phase-adjust-gran
445+
type: u32
446+
doc: |
447+
Granularity of phase adjustment, in picoseconds. The value of
448+
phase adjustment must be a multiple of this granularity.
443449
444450
-
445451
name: pin-parent-device
@@ -616,6 +622,7 @@ operations:
616622
- capabilities
617623
- parent-device
618624
- parent-pin
625+
- phase-adjust-gran
619626
- phase-adjust-min
620627
- phase-adjust-max
621628
- phase-adjust

drivers/dpll/dpll_netlink.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,10 @@ dpll_cmd_pin_get_one(struct sk_buff *msg, struct dpll_pin *pin,
637637
ret = dpll_msg_add_pin_freq(msg, pin, ref, extack);
638638
if (ret)
639639
return ret;
640+
if (prop->phase_gran &&
641+
nla_put_u32(msg, DPLL_A_PIN_PHASE_ADJUST_GRAN,
642+
prop->phase_gran))
643+
return -EMSGSIZE;
640644
if (nla_put_s32(msg, DPLL_A_PIN_PHASE_ADJUST_MIN,
641645
prop->phase_range.min))
642646
return -EMSGSIZE;
@@ -1261,7 +1265,13 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr,
12611265
if (phase_adj > pin->prop.phase_range.max ||
12621266
phase_adj < pin->prop.phase_range.min) {
12631267
NL_SET_ERR_MSG_ATTR(extack, phase_adj_attr,
1264-
"phase adjust value not supported");
1268+
"phase adjust value of out range");
1269+
return -EINVAL;
1270+
}
1271+
if (pin->prop.phase_gran && phase_adj % (s32)pin->prop.phase_gran) {
1272+
NL_SET_ERR_MSG_ATTR_FMT(extack, phase_adj_attr,
1273+
"phase adjust value not multiple of %u",
1274+
pin->prop.phase_gran);
12651275
return -EINVAL;
12661276
}
12671277

include/linux/dpll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ struct dpll_pin_properties {
193193
u32 freq_supported_num;
194194
struct dpll_pin_frequency *freq_supported;
195195
struct dpll_pin_phase_adjust_range phase_range;
196+
u32 phase_gran;
196197
};
197198

198199
#if IS_ENABLED(CONFIG_DPLL)

include/uapi/linux/dpll.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ enum dpll_a_pin {
251251
DPLL_A_PIN_ESYNC_FREQUENCY_SUPPORTED,
252252
DPLL_A_PIN_ESYNC_PULSE,
253253
DPLL_A_PIN_REFERENCE_SYNC,
254+
DPLL_A_PIN_PHASE_ADJUST_GRAN,
254255

255256
__DPLL_A_PIN_MAX,
256257
DPLL_A_PIN_MAX = (__DPLL_A_PIN_MAX - 1)

0 commit comments

Comments
 (0)