Re: [PATCH 4/8] lib/igt_drm_netlink: add set_error_threshold command support

Harish Chegondi <[email protected]>
Newsgroups org.freedesktop.lists.igt-dev
Message-ID <[email protected]>
On Wed, Jul 29, 2026 at 05:49:55PM +0530, Ravi Kishore Koppuravuri wrote:
> Add support for SET_ERROR_THRESHOLD to set the custom error threshold
> value
> 
> Signed-off-by: Ravi Kishore Koppuravuri <[email protected]>
> ---
>  lib/igt_drm_netlink.c | 39 +++++++++++++++++++++++++++++++++++++++
>  lib/igt_drm_netlink.h |  1 +
>  2 files changed, 40 insertions(+)
> 
> diff --git a/lib/igt_drm_netlink.c b/lib/igt_drm_netlink.c
> index 036660a6a..4738090af 100644
> --- a/lib/igt_drm_netlink.c
> +++ b/lib/igt_drm_netlink.c
> @@ -29,6 +29,8 @@ static int ras_command_cb(struct nl_msg *msg, void *arg)
>  	gnlh = nlmsg_data(nlh);
>  
>  	switch (gnlh->cmd) {
> +	case DRM_RAS_CMD_SET_ERROR_THRESHOLD:
The definition of DRM_RAS_CMD_SET_ERROR_THRESHOLD needs to be added in
this patch instead of the previous patch.
> +		break;
>  	case DRM_RAS_CMD_GET_ERROR_COUNTER: {
>  		struct nlattr *attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX + 1];
>  
> @@ -109,6 +111,7 @@ static int send_command(struct app_context *ctx, uint8_t cmd)
>  	}
>  
>  	switch (cmd) {
> +	case DRM_RAS_CMD_SET_ERROR_THRESHOLD:
>  	case DRM_RAS_CMD_GET_ERROR_THRESHOLD:
>  	case DRM_RAS_CMD_GET_ERROR_COUNTER:
>  		ret = nla_put_u32(msg,
> @@ -126,6 +129,16 @@ static int send_command(struct app_context *ctx, uint8_t cmd)
>  			nlmsg_free(msg);
>  			return ret;
>  		}
> +
> +		if (cmd == DRM_RAS_CMD_SET_ERROR_THRESHOLD) {
> +			ret = nla_put_u32(msg,
> +					  DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD,
> +					  ctx->error_threshold);
> +			if (ret < 0) {
> +				nlmsg_free(msg);
> +				return ret;
> +			}
> +		}
>  		break;
>  	default:
>  		nlmsg_free(msg);
> @@ -238,6 +251,14 @@ static int validate_inputs(struct app_context *ctx, uint8_t cmd)
>  		return -EINVAL;
>  	}
>  
> +	if (cmd == DRM_RAS_CMD_SET_ERROR_THRESHOLD &&
> +	    (ctx->error_threshold < 1 || ctx->error_threshold > 16)) {
> +		igt_warn("Invalid error_threshold (%u) provided. "
> +			 "error_threshold should be >= 1 and <= 16.\n",
> +			 ctx->error_threshold);
> +		return -EINVAL;
> +	}
> +
>  	return 0;
>  }
>  
> @@ -280,3 +301,21 @@ int get_error_threshold(struct app_context *ctx)
>  
>  	return 0;
>  }
> +
> +int set_error_threshold(struct app_context *ctx)
> +{
> +	int ret;
> +
> +	ret = validate_inputs(ctx, DRM_RAS_CMD_SET_ERROR_THRESHOLD);
> +	if (ret < 0)
> +		return ret;
> +
> +	ret = send_command(ctx, DRM_RAS_CMD_SET_ERROR_THRESHOLD);
> +	if (ret < 0)
> +		return ret;
> +
> +	igt_debug("Set error threshold: node_id=%u error_id=%u threshold=%u\n",
> +		  ctx->node_id, ctx->error_id, ctx->error_threshold);
> +
> +	return 0;
> +}
> diff --git a/lib/igt_drm_netlink.h b/lib/igt_drm_netlink.h
> index fae9b0e06..c44486ffa 100644
> --- a/lib/igt_drm_netlink.h
> +++ b/lib/igt_drm_netlink.h
> @@ -33,6 +33,7 @@ void cleanup_nl_socket(struct app_context *ctx);
>  int init_nl_socket(struct app_context *ctx);
>  int get_error_counter(struct app_context *ctx);
>  int get_error_threshold(struct app_context *ctx);
> +int set_error_threshold(struct app_context *ctx);
>  
>  #endif /* IGT_DRM_NETLINK_H */
>  
> -- 
> 2.34.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.