Skip to content

Commit a6f311b

Browse files
committed
Merge: CNB97: dpll: add phase-offset-monitor feature
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7158 JIRA: https://issues.redhat.com/browse/RHEL-105066 This adds phase-offset-monitor feature into DPLL subsystem. Signed-off-by: Ivan Vecera <ivecera@redhat.com> Approved-by: Petr Oros <poros@redhat.com> Approved-by: Murphy Zhou <xzhou@redhat.com> Approved-by: mheib <mheib@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents f54a373 + 4c72b57 commit a6f311b

File tree

6 files changed

+132
-4
lines changed

6 files changed

+132
-4
lines changed

Documentation/driver-api/dpll.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ offset values are fractional with 3-digit decimal places and shell be
214214
divided with ``DPLL_PIN_PHASE_OFFSET_DIVIDER`` to get integer part and
215215
modulo divided to get fractional part.
216216

217+
Phase offset monitor
218+
====================
219+
220+
Phase offset measurement is typically performed against the current active
221+
source. However, some DPLL (Digital Phase-Locked Loop) devices may offer
222+
the capability to monitor phase offsets across all available inputs.
223+
The attribute and current feature state shall be included in the response
224+
message of the ``DPLL_CMD_DEVICE_GET`` command for supported DPLL devices.
225+
In such cases, users can also control the feature using the
226+
``DPLL_CMD_DEVICE_SET`` command by setting the ``enum dpll_feature_state``
227+
values for the attribute.
228+
Once enabled the phase offset measurements for the input shall be returned
229+
in the ``DPLL_A_PIN_PHASE_OFFSET`` attribute.
230+
231+
=============================== ========================
232+
``DPLL_A_PHASE_OFFSET_MONITOR`` attr state of a feature
233+
=============================== ========================
234+
217235
Embedded SYNC
218236
=============
219237

Documentation/netlink/specs/dpll.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,20 @@ definitions:
240240
integer part of a measured phase offset value.
241241
Value of (DPLL_A_PHASE_OFFSET % DPLL_PHASE_OFFSET_DIVIDER) is a
242242
fractional part of a measured phase offset value.
243+
-
244+
type: enum
245+
name: feature-state
246+
doc: |
247+
Allow control (enable/disable) and status checking over features.
248+
entries:
249+
-
250+
name: disable
251+
doc: |
252+
feature shall be disabled
253+
-
254+
name: enable
255+
doc: |
256+
feature shall be enabled
243257
244258
attribute-sets:
245259
-
@@ -293,6 +307,14 @@ attribute-sets:
293307
be put to message multiple times to indicate possible parallel
294308
quality levels (e.g. one specified by ITU option 1 and another
295309
one specified by option 2).
310+
-
311+
name: phase-offset-monitor
312+
type: u32
313+
enum: feature-state
314+
doc: Receive or request state of phase offset monitor feature.
315+
If enabled, dpll device shall monitor and notify all currently
316+
available inputs for changes of their phase offset against the
317+
dpll device.
296318
-
297319
name: pin
298320
enum-name: dpll_a_pin
@@ -483,6 +505,7 @@ operations:
483505
- temp
484506
- clock-id
485507
- type
508+
- phase-offset-monitor
486509

487510
dump:
488511
reply: *dev-attrs
@@ -499,6 +522,7 @@ operations:
499522
request:
500523
attributes:
501524
- id
525+
- phase-offset-monitor
502526
-
503527
name: device-create-ntf
504528
doc: Notification about device appearing

drivers/dpll/dpll_netlink.c

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,26 @@ dpll_msg_add_mode_supported(struct sk_buff *msg, struct dpll_device *dpll,
126126
return 0;
127127
}
128128

129+
static int
130+
dpll_msg_add_phase_offset_monitor(struct sk_buff *msg, struct dpll_device *dpll,
131+
struct netlink_ext_ack *extack)
132+
{
133+
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
134+
enum dpll_feature_state state;
135+
int ret;
136+
137+
if (ops->phase_offset_monitor_set && ops->phase_offset_monitor_get) {
138+
ret = ops->phase_offset_monitor_get(dpll, dpll_priv(dpll),
139+
&state, extack);
140+
if (ret)
141+
return ret;
142+
if (nla_put_u32(msg, DPLL_A_PHASE_OFFSET_MONITOR, state))
143+
return -EMSGSIZE;
144+
}
145+
146+
return 0;
147+
}
148+
129149
static int
130150
dpll_msg_add_lock_status(struct sk_buff *msg, struct dpll_device *dpll,
131151
struct netlink_ext_ack *extack)
@@ -591,6 +611,9 @@ dpll_device_get_one(struct dpll_device *dpll, struct sk_buff *msg,
591611
return ret;
592612
if (nla_put_u32(msg, DPLL_A_TYPE, dpll->type))
593613
return -EMSGSIZE;
614+
ret = dpll_msg_add_phase_offset_monitor(msg, dpll, extack);
615+
if (ret)
616+
return ret;
594617

595618
return 0;
596619
}
@@ -746,6 +769,31 @@ int dpll_pin_change_ntf(struct dpll_pin *pin)
746769
}
747770
EXPORT_SYMBOL_GPL(dpll_pin_change_ntf);
748771

772+
static int
773+
dpll_phase_offset_monitor_set(struct dpll_device *dpll, struct nlattr *a,
774+
struct netlink_ext_ack *extack)
775+
{
776+
const struct dpll_device_ops *ops = dpll_device_ops(dpll);
777+
enum dpll_feature_state state = nla_get_u32(a), old_state;
778+
int ret;
779+
780+
if (!(ops->phase_offset_monitor_set && ops->phase_offset_monitor_get)) {
781+
NL_SET_ERR_MSG_ATTR(extack, a, "dpll device not capable of phase offset monitor");
782+
return -EOPNOTSUPP;
783+
}
784+
ret = ops->phase_offset_monitor_get(dpll, dpll_priv(dpll), &old_state,
785+
extack);
786+
if (ret) {
787+
NL_SET_ERR_MSG(extack, "unable to get current state of phase offset monitor");
788+
return ret;
789+
}
790+
if (state == old_state)
791+
return 0;
792+
793+
return ops->phase_offset_monitor_set(dpll, dpll_priv(dpll), state,
794+
extack);
795+
}
796+
749797
static int
750798
dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a,
751799
struct netlink_ext_ack *extack)
@@ -1533,12 +1581,29 @@ int dpll_nl_device_get_doit(struct sk_buff *skb, struct genl_info *info)
15331581
return genlmsg_reply(msg, info);
15341582
}
15351583

1536-
int dpll_nl_device_set_doit(struct sk_buff *skb, struct genl_info *info)
1584+
static int
1585+
dpll_set_from_nlattr(struct dpll_device *dpll, struct genl_info *info)
15371586
{
1538-
/* placeholder for set command */
1587+
int ret;
1588+
1589+
if (info->attrs[DPLL_A_PHASE_OFFSET_MONITOR]) {
1590+
struct nlattr *a = info->attrs[DPLL_A_PHASE_OFFSET_MONITOR];
1591+
1592+
ret = dpll_phase_offset_monitor_set(dpll, a, info->extack);
1593+
if (ret)
1594+
return ret;
1595+
}
1596+
15391597
return 0;
15401598
}
15411599

1600+
int dpll_nl_device_set_doit(struct sk_buff *skb, struct genl_info *info)
1601+
{
1602+
struct dpll_device *dpll = info->user_ptr[0];
1603+
1604+
return dpll_set_from_nlattr(dpll, info);
1605+
}
1606+
15421607
int dpll_nl_device_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
15431608
{
15441609
struct dpll_dump_ctx *ctx = dpll_dump_context(cb);

drivers/dpll/dpll_nl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ static const struct nla_policy dpll_device_get_nl_policy[DPLL_A_ID + 1] = {
3737
};
3838

3939
/* DPLL_CMD_DEVICE_SET - do */
40-
static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_ID + 1] = {
40+
static const struct nla_policy dpll_device_set_nl_policy[DPLL_A_PHASE_OFFSET_MONITOR + 1] = {
4141
[DPLL_A_ID] = { .type = NLA_U32, },
42+
[DPLL_A_PHASE_OFFSET_MONITOR] = NLA_POLICY_MAX(NLA_U32, 1),
4243
};
4344

4445
/* DPLL_CMD_PIN_ID_GET - do */
@@ -105,7 +106,7 @@ static const struct genl_split_ops dpll_nl_ops[] = {
105106
.doit = dpll_nl_device_set_doit,
106107
.post_doit = dpll_post_doit,
107108
.policy = dpll_device_set_nl_policy,
108-
.maxattr = DPLL_A_ID,
109+
.maxattr = DPLL_A_PHASE_OFFSET_MONITOR,
109110
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
110111
},
111112
{

include/linux/dpll.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ struct dpll_device_ops {
3030
void *dpll_priv,
3131
unsigned long *qls,
3232
struct netlink_ext_ack *extack);
33+
int (*phase_offset_monitor_set)(const struct dpll_device *dpll,
34+
void *dpll_priv,
35+
enum dpll_feature_state state,
36+
struct netlink_ext_ack *extack);
37+
int (*phase_offset_monitor_get)(const struct dpll_device *dpll,
38+
void *dpll_priv,
39+
enum dpll_feature_state *state,
40+
struct netlink_ext_ack *extack);
3341
};
3442

3543
struct dpll_pin_ops {

include/uapi/linux/dpll.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,17 @@ enum dpll_pin_capabilities {
192192

193193
#define DPLL_PHASE_OFFSET_DIVIDER 1000
194194

195+
/**
196+
* enum dpll_feature_state - Allow control (enable/disable) and status checking
197+
* over features.
198+
* @DPLL_FEATURE_STATE_DISABLE: feature shall be disabled
199+
* @DPLL_FEATURE_STATE_ENABLE: feature shall be enabled
200+
*/
201+
enum dpll_feature_state {
202+
DPLL_FEATURE_STATE_DISABLE,
203+
DPLL_FEATURE_STATE_ENABLE,
204+
};
205+
195206
enum dpll_a {
196207
DPLL_A_ID = 1,
197208
DPLL_A_MODULE_NAME,
@@ -204,6 +215,7 @@ enum dpll_a {
204215
DPLL_A_TYPE,
205216
DPLL_A_LOCK_STATUS_ERROR,
206217
DPLL_A_CLOCK_QUALITY_LEVEL,
218+
DPLL_A_PHASE_OFFSET_MONITOR,
207219

208220
__DPLL_A_MAX,
209221
DPLL_A_MAX = (__DPLL_A_MAX - 1)

0 commit comments

Comments
 (0)