Netdev List
 help / color / mirror / Atom feed
From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Ivan Vecera <ivecera@redhat.com>, netdev@vger.kernel.org
Cc: Sashiko <sashiko-bot@kernel.org>,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	Simon Horman <horms@kernel.org>,
	Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Milena Olech <milena.olech@intel.com>
Subject: Re: [PATCH net] dpll: do not overwrite extack messages set by drivers
Date: Fri, 4 Dec 2026 17:47:26 +0000	[thread overview]
Message-ID: <860a764d-089c-4fda-919e-740d5b61f095@linux.dev> (raw)
In-Reply-To: <20261204155246.425636-1-ivecera@redhat.com>

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>

      reply	other threads:[~2026-12-04 17:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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=860a764d-089c-4fda-919e-740d5b61f095@linux.dev \
    --to=vadim.fedorenko@linux.dev \
    --cc=aleksandr.loktionov@intel.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=ivecera@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=milena.olech@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sashiko-bot@kernel.org \
    --cc=willemb@google.com \
    /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