On 04/12/2026 15:52, Ivan Vecera wrote:
> When the frequency_set(), esync_set(), ref_sync_set() or > phase_adjust_set() pin callback fails, the DPLL core sets its own > generic message like "frequency set failed for dpll_id:N" with > NL_SET_ERR_MSG_FMT(). This replaces any message set by the driver, so > userspace never sees why the driver rejected the request, e.g. the > zl3073x reasons for an invalid output frequency or reference sync > pair, or the ice admin queue status. > > Add NL_SET_ERR_MSG_FMT_WEAK(), a formatted variant of > NL_SET_ERR_MSG_WEAK() that sets the message only if none is set yet, > and use it for these generic messages. The other set callbacks already > return the driver error without a message of their own. > > Discovered by an AI code review agent (Sashiko) and confirmed by code > inspection. Tested on a GNR-D system with a ZL80132B DPLL by setting > the P-pin of an N-div output to 1 Hz, which leaves no valid frequency > for its N-pin: the reply carried "frequency set failed for dpll_id:12" > before the fix and "OUT8N freq must be at most half of OUT8P freq" > with it. The new macro was also checked in a userspace test built > from the netlink.h macros: a message set before is kept, otherwise the > generic one is set. > > Fixes: d7fbc0b7e846 ("dpll: netlink/core: add support for pin-dpll signal phase offset/adjust") > Fixes: 20f6677234d8 ("dpll: netlink/core: change pin frequency set behavior") > Fixes: cda1fba15cb2 ("dpll: add Embedded SYNC feature for a pin") > Fixes: 58256a26bfb3 ("dpll: add reference sync get/set") > Reported-by: Sashiko <sash…@kernel.org> > Closes: https://sashiko.dev/#/bug/linux-06bba4c1-85c2-43b9-9d63-a2d615540f64 > Signed-off-by: Ivan Vecera <ivec…@redhat.com> > --- > drivers/dpll/dpll_netlink.c | 24 ++++++++++++------------ > include/linux/netlink.h | 7 +++++++ > 2 files changed, 19 insertions(+), 12 deletions(-) > > diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c > index e5380d95f238b3..422e3fa3a632a8 100644 > --- a/drivers/dpll/dpll_netlink.c > +++ b/drivers/dpll/dpll_netlink.c > @@ -1132,9 +1132,9 @@ dpll_pin_freq_set(struct dpll_pin *pin, struct nlattr *a, > ret = ops->frequency_set(pin, dpll_pin_on_dpll_priv(dpll, pin), > dpll, dpll_priv(dpll), freq, extack); > if (ret) { > - NL_SET_ERR_MSG_FMT(extack, > - "frequency set failed for dpll_id:%u", > - dpll->id); > + NL_SET_ERR_MSG_FMT_WEAK(extack, > + "frequency set failed for dpll_id:%u", > + dpll->id); > return ret; > } > __dpll_pin_change_ntf(pin); > @@ -1186,9 +1186,9 @@ dpll_pin_esync_set(struct dpll_pin *pin, struct nlattr *a, > ret = ops->esync_set(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll, > dpll_priv(dpll), freq, extack); > if (ret) { > - NL_SET_ERR_MSG_FMT(extack, > - "embedded sync frequency set failed for dpll_id: %u", > - dpll->id); > + NL_SET_ERR_MSG_FMT_WEAK(extack, > + "embedded sync frequency set failed for dpll_id: %u", > + dpll->id); > return ret; > } > __dpll_pin_change_ntf(pin); > @@ -1250,9 +1250,9 @@ dpll_pin_ref_sync_state_set(struct dpll_pin *pin, > ret = ops->ref_sync_set(pin, pin_priv, ref_sync_pin, ref_sync_pin_priv, > state, extack); > if (ret) { > - NL_SET_ERR_MSG_FMT(extack, > - "reference sync set failed for dpll_id:%u", > - dpll->id); > + NL_SET_ERR_MSG_FMT_WEAK(extack, > + "reference sync set failed for dpll_id:%u", > + dpll->id); > return ret; > } > __dpll_pin_change_ntf(pin); > @@ -1462,9 +1462,9 @@ dpll_pin_phase_adj_set(struct dpll_pin *pin, struct nlattr *phase_adj_attr, > ret = ops->phase_adjust_set(pin, dpll_pin_on_dpll_priv(dpll, pin), > dpll, dpll_priv(dpll), phase_adj, extack); > if (ret) { > - NL_SET_ERR_MSG_FMT(extack, > - "phase adjust set failed for dpll_id:%u", > - dpll->id); > + NL_SET_ERR_MSG_FMT_WEAK(extack, > + "phase adjust set failed for dpll_id:%u", > + dpll->id); > return ret; > } > __dpll_pin_change_ntf(pin); > diff --git a/include/linux/netlink.h b/include/linux/netlink.h > index b4eb873850e752..18e05f81e33e0b 100644 > --- a/include/linux/netlink.h > +++ b/include/linux/netlink.h > @@ -143,6 +143,13 @@ struct netlink_ext_ack { > NL_SET_ERR_MSG_MOD((extack), msg); \ > } while (0) > +#define NL_SET_ERR_MSG_FMT_WEAK(extack, fmt, args...) do { \ > + struct netlink_ext_ack *__extack_weak = (extack); \ > + \ > + if (__extack_weak && !__extack_weak->_msg) \ > + NL_SET_ERR_MSG_FMT(__extack_weak, fmt, ##args); \ > +} while (0) > + > #define NL_SET_BAD_ATTR_POLICY(extack, attr, pol) do { \ > if ((extack)) { \ > (extack)->bad_attr = (attr); \ > > base-commit: 3c8881ee98069d3c8a1a0ad1fd6efd726e466297
Reviewed-by: Vadim Fedorenko <vadi…@linux.dev>