All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] dpll: do not overwrite extack messages set by drivers
@ 2026-12-04 15:52 Ivan Vecera
  2026-12-04 17:47 ` Vadim Fedorenko
  2026-12-05 16:49 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Ivan Vecera @ 2026-12-04 15:52 UTC (permalink / raw)
  To: netdev
  Cc: Sashiko, Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, Aleksandr Loktionov,
	Przemek Kitszel, Milena Olech

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 <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-06bba4c1-85c2-43b9-9d63-a2d615540f64
Signed-off-by: Ivan Vecera <ivecera@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
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] dpll: do not overwrite extack messages set by drivers
  2026-12-04 15:52 [PATCH net] dpll: do not overwrite extack messages set by drivers Ivan Vecera
@ 2026-12-04 17:47 ` Vadim Fedorenko
  2026-12-05 16:49 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2026-12-04 17:47 UTC (permalink / raw)
  To: Ivan Vecera, netdev
  Cc: Sashiko, Arkadiusz Kubalewski, Jiri Pirko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Willem de Bruijn,
	Simon Horman, Aleksandr Loktionov, Przemek Kitszel, Milena Olech

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 <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/bug/linux-06bba4c1-85c2-43b9-9d63-a2d615540f64
> Signed-off-by: Ivan Vecera <ivecera@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 <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] dpll: do not overwrite extack messages set by drivers
  2026-12-04 15:52 [PATCH net] dpll: do not overwrite extack messages set by drivers Ivan Vecera
  2026-12-04 17:47 ` Vadim Fedorenko
@ 2026-12-05 16:49 ` netdev-bot+sashiko
  1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 16:49 UTC (permalink / raw)
  To: ivecera
  Cc: netdev, sashiko-bot, vadim.fedorenko, arkadiusz.kubalewski, jiri,
	davem, edumazet, kuba, pabeni, willemb, horms,
	aleksandr.loktionov, przemyslaw.kitszel, milena.olech

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The fix is incomplete against its own subject line ("do not
  overwrite extack messages set by drivers").
- [Low] netlink: missing NL_SET_ERR_MSG_FMT_WEAK in
  newline_in_nl_msg.cocci

--

dpll: do not overwrite extack messages set by drivers

When the frequency_set(), esync_set(), ref_sync_set() or
phase_adjust_set() pin callbacks fail, the DPLL core now keeps any extack
message the driver already set. Before, its generic "... set failed for
dpll_id:N" message replaced it. The patch adds NL_SET_ERR_MSG_FMT_WEAK()
to include/linux/netlink.h for this and uses it in the four set paths of
drivers/dpll/dpll_netlink.c.

> diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
> index e5380d95f238b..422e3fa3a632a 100644
> --- a/drivers/dpll/dpll_netlink.c
> +++ b/drivers/dpll/dpll_netlink.c

[ ... ]

> @@ -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);

[Severity: Medium]

The subject says the core no longer overwrites extack messages set by
drivers. Does that also hold for the get callback that runs just before
esync_set() in this function?

Earlier in dpll_pin_esync_set():

	ret = ops->esync_get(pin, dpll_pin_on_dpll_priv(dpll, pin), dpll,
			     dpll_priv(dpll), &esync, extack);
	if (ret) {
		NL_SET_ERR_MSG(extack, "unable to get current embedded sync frequency value");
		return ret;
	}

In ice, ice_dpll_input_esync_get(), ice_dpll_output_esync_get() and
ice_dpll_input_ref_sync_get() all start with:

	if (ice_dpll_is_reset(pf, extack))
		return -EBUSY;

ice_dpll_is_reset() sets "PF reset in progress". These callbacks are wired
as .esync_get and .ref_sync_get in the ice pin ops.

So during a PF reset, a DPLL_CMD_PIN_SET request for esync or ref-sync on
an ice pin would follow this path:

dpll_pin_esync_set() -> ops->esync_get() -> ice_dpll_is_reset()

The reply would still carry the generic "unable to get ..." string from the
core, not the driver's reason.

The other pin set paths call plain NL_SET_ERR_MSG() after their get
callback in the same way:

  dpll_pin_freq_set(): "unable to get old frequency value"
  dpll_pin_ref_sync_state_set(): "unable to get old reference sync state"
  dpll_pin_phase_adj_set(): "unable to get old phase adjust value"

The device-level paths dpll_mode_set(), dpll_phase_offset_monitor_set()
and dpll_freq_monitor_set() do the same with their "unable to get ..."
messages.

Should these also switch to NL_SET_ERR_MSG_WEAK()? Or should the subject
be narrowed to cover only the set callbacks?

[ ... ]

> diff --git a/include/linux/netlink.h b/include/linux/netlink.h
> --- 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);		\
>

[Severity: Low]
This adds a new member to the NL_SET_ERR_MSG* family, but
scripts/coccinelle/misc/newline_in_nl_msg.cocci was not updated to
know about it.

That script lists the extack helpers from include/linux/netlink.h and
include/net/genetlink.h. The list includes GENL_SET_ERR_MSG,
NL_SET_ERR_MSG_FMT, NL_SET_ERR_MSG_WEAK, NL_SET_ERR_MSG_WEAK_MOD and
NL_SET_ERR_MSG_ATTR_FMT, among others. The script flags message
literals passed to those helpers that end in a newline.

NL_SET_ERR_MSG_FMT_WEAK is not in that disjunction. A later caller
that passes something like "frequency set failed\n" to the new macro
would therefore not be reported by make coccicheck.

There is no runtime impact, and the four dpll callers in this patch
are fine. The list has been brought in sync with these headers
before, though. Could you add NL_SET_ERR_MSG_FMT_WEAK to the
newline_in_nl_msg.cocci match list, either in this patch or as a
small follow-up?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204155246.425636-1-ivecera%40redhat.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-05 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 15:52 [PATCH net] dpll: do not overwrite extack messages set by drivers Ivan Vecera
2026-12-04 17:47 ` Vadim Fedorenko
2026-12-05 16:49 ` netdev-bot+sashiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.