From: "Koppuravuri, Ravi Kishore" <ravi.kishore.koppuravuri@intel.com>
To: "Purkait, Soham" <soham.purkait@intel.com>,
<igt-dev@lists.freedesktop.org>
Cc: Riana Tauro <riana.tauro@intel.com>,
Gupta Anshuman <anshuman.gupta@intel.com>,
Jadav Raag <raag.jadav@intel.com>,
Nilawar Badal <badal.nilawar@intel.com>,
Koujalagi Mallesh <mallesh.koujalagi@intel.com>,
Harish Chegondi <harish.chegondi@intel.com>
Subject: Re: [PATCH v4 08/10] lib/igt_drm_netlink: add event notify subscription and event wait support
Date: Fri, 9 Oct 2026 17:58:27 +0530 [thread overview]
Message-ID: <5f60e040-8329-4de3-beb5-bfac91627029@intel.com> (raw)
In-Reply-To: <ecc0560a-f5a4-4ec6-a90b-8509174915a0@intel.com>
Hi Soham,
On 18-09-2026 20:33, Purkait, Soham wrote:
> Hi Ravi,
>
> On 03-09-2026 13:03, Ravi Kishore Koppuravuri wrote:
>> Added event notification support with subscribe for an error-notify
>> event
>> and wait for the event notification functionalities.
>>
>> Cc: Purkait Soham <soham.purkait@intel.com>
>> Cc: Riana Tauro <riana.tauro@intel.com>
>> Cc: Gupta Anshuman <anshuman.gupta@intel.com>
>> Cc: Jadav Raag <raag.jadav@intel.com>
>> Cc: Nilawar Badal <badal.nilawar@intel.com>
>> Cc: Koujalagi Mallesh <mallesh.koujalagi@intel.com>
>> Cc: Harish Chegondi <harish.chegondi@intel.com>
>> Signed-off-by: Ravi Kishore Koppuravuri
>> <ravi.kishore.koppuravuri@intel.com>
>> ---
>> v2:Handled SEQ_CHECK nl response using separate callback
>> Added monotonic-clock deadline to wait for messages without
>> exceeding the
>> caller’s total timeout.
>> Added support to receive events until it sees an event whose node
>> ID and
>> error ID match the requested values.
>> v4:Renamed the library functions with prefix "igt_drm_netlink_*" (Nikula
>> Jani & Kamil)
>> updated error event name from error-notify to error-report to align
>> with the latest changes in drm-uapi/drm_ras.h
>> ---
>> lib/igt_drm_netlink.c | 154 +++++++++++++++++++++++++++++++++++++++++-
>> lib/igt_drm_netlink.h | 6 ++
>> 2 files changed, 157 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/igt_drm_netlink.c b/lib/igt_drm_netlink.c
>> index c0e3aff9b..6a3e475e8 100644
>> --- a/lib/igt_drm_netlink.c
>> +++ b/lib/igt_drm_netlink.c
>> @@ -6,6 +6,7 @@
>> #include <errno.h>
>> #include <poll.h>
>> #include <stdint.h>
>> +#include <time.h>
>> #include <netlink/genl/ctrl.h>
>> #include <netlink/genl/genl.h>
>> @@ -28,6 +29,27 @@ static int ras_command_cb(struct nl_msg *msg, void
>> *arg)
>> switch (gnlh->cmd) {
>> case DRM_RAS_CMD_SET_ERROR_THRESHOLD:
>> break;
>> + case DRM_RAS_CMD_ERROR_EVENT: {
>> + struct nlattr *attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_MAX + 1];
> Move this at the start of the function.
will separate the attrs for event and other commands. events specific
attr will be needed only for DRM_RAS_CMD_ERROR_EVENT and so will create
struct nlattr *attrs inside the switch case itself. And will move the
attrs for all other commands to the beginning of the function.
>> +
>> + ret = genlmsg_parse(nlh, 0, attrs,
>> + DRM_RAS_A_ERROR_EVENT_ATTRS_MAX, NULL);
>> + if (ret < 0)
>> + return NL_SKIP;
>> +
>> + if (!attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_NODE_ID] ||
>> + !attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_ID] ||
>> + !attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_VALUE])
>> + return NL_SKIP;
>> +
>> + ctx->event_node_id =
>> nla_get_u32(attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_NODE_ID]);
>> + ctx->event_error_id =
>> nla_get_u32(attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_ID]);
>> + ctx->event_error_value =
>> + nla_get_u32(attrs[DRM_RAS_A_ERROR_EVENT_ATTRS_ERROR_VALUE]);
>> + ctx->event_received = ctx->event_node_id == ctx->node_id &&
>> + ctx->event_error_id == ctx->error_id;
>> + break;
>> + }
>> case DRM_RAS_CMD_GET_ERROR_COUNTER: {
>> struct nlattr *attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX + 1];
>> @@ -61,13 +83,20 @@ static int ras_command_cb(struct nl_msg *msg,
>> void *arg)
>> return NL_SKIP;
>> }
>> - ctx->reply_received = true;
>> - if (ctx->ack_received)
>> - ctx->cmd_done = true;
>> + if (gnlh->cmd != DRM_RAS_CMD_ERROR_EVENT) {
>> + ctx->reply_received = true;
>> + if (ctx->ack_received)
>> + ctx->cmd_done = true;
>> + }
>> return NL_OK;
>> }
>> +static int ras_multicast_seq_check_cb(struct nl_msg *msg, void *arg)
> What is the use of this callback ?
libnl checks the seq no of responses against the requests and if it does
not match then the response will be rejected. For
DRM_RAS_CMD_ERROR_EVENT, we are not sending any request but listening
for the broadcasts from kernel, which will not have any matching
sequence number to compare against. This function is registered in
register_multicast_callbacks() to just return NL_OK to skip that check.
>> +{
>> + return NL_OK;
>> +}
>> +
>> static int ras_error_cb(struct sockaddr_nl *nla, struct nlmsgerr
>> *err, void *arg)
>> {
>> struct app_context *ctx = arg;
>> @@ -121,6 +150,23 @@ static int register_callbacks(struct nl_cb *cb,
>> struct app_context *ctx)
>> return 0;
>> }
>> +static int register_multicast_callbacks(struct nl_cb *cb,
>> + struct app_context *ctx)
>> +{
>> + int ret;
>> +
>> + ret = nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, ras_command_cb,
>> ctx);
>> + if (ret < 0)
>> + return ret;
>> +
>> + ret = nl_cb_set(cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM,
>> + ras_multicast_seq_check_cb, ctx);
>> + if (ret < 0)
>> + return ret;
>> +
>> + return 0;
>> +}
>> +
>> static int send_and_recv_nl_msg(struct app_context *ctx,
>> struct nl_cb *cb,
>> struct nl_msg *msg)
>> @@ -263,6 +309,10 @@ static void reset_drm_ras_netlink_context(struct
>> app_context *ctx)
>> ctx->ack_received = false;
>> ctx->response_required = false;
>> ctx->error_threshold = 0;
>> + ctx->event_node_id = UINT32_MAX;
>> + ctx->event_error_id = UINT32_MAX;
>> + ctx->event_error_value = 0;
>> + ctx->event_received = false;
>> ctx->family_id = -1;
>> }
>> @@ -407,3 +457,101 @@ int
>> igt_drm_netlink_set_error_threshold(struct app_context *ctx)
>> return 0;
>> }
>> +
>> +int igt_drm_netlink_subscribe_error_report(struct app_context *ctx,
>> const char *notify_group_name)
>> +{
>> + int grp_id;
>> + int ret;
>> +
>> + if (!ctx || !ctx->sock || ctx->family_id < 0 ||
>> + !notify_group_name || notify_group_name[0] == '\0')
>> + return -EINVAL;
>> +
>> + grp_id = genl_ctrl_resolve_grp(ctx->sock,
>> + DRM_RAS_FAMILY_NAME,
>> + notify_group_name);
>> + if (grp_id < 0)
>> + return grp_id;
>> +
>> + ret = nl_socket_add_membership(ctx->sock, grp_id);
> Before this it is better to have a check for duplicate-subscription.
Even though multiple subscriptions are registered for the same group,
kernel broadcasts only single message and it does not lead to any error.
But it is safer to add a guard to check if already subscribed to the
same multicast group or not. will add it.
>> + if (ret < 0)
>> + return ret;
>
> libnl error codes (NLE_*) are not the same as standard errno/-errno
> codes.
Will convert libnl error codes to standard error codes.
>
> Thanks,
> Soham
>> +
>> + igt_debug("Subscribed to DRM RAS multicast group '%s' (id=%d).\n",
>> + notify_group_name, grp_id);
>> +
>> + return 0;
>> +}
>> +
>> +int igt_drm_netlink_wait_for_error_report_event(struct app_context
>> *ctx, int timeout_ms)
>> +{
>> + struct nl_cb *cb;
>> + struct pollfd pfd;
>> + struct timespec start, now;
>> + int remaining_ms;
>> + int ret;
>> +
>> + if (!ctx || !ctx->sock || ctx->family_id < 0)
>> + return -EINVAL;
>> +
>> + if (timeout_ms < -1)
>> + return -EINVAL;
>> +
>> + cb = nl_cb_alloc(NL_CB_DEFAULT);
>> + if (!cb)
>> + return -ENOMEM;
>> +
>> + ret = register_multicast_callbacks(cb, ctx);
>> + if (ret < 0) {
>> + nl_cb_put(cb);
>> + return ret;
>> + }
>> +
>> + ctx->event_received = false;
>> + clock_gettime(CLOCK_MONOTONIC, &start);
>> +
>> + pfd.fd = nl_socket_get_fd(ctx->sock);
>> + pfd.events = POLLIN;
>> + pfd.revents = 0;
>> +
>> + while (!ctx->event_received) {
>> + if (timeout_ms == -1) {
>> + remaining_ms = -1;
>> + } else {
>> + clock_gettime(CLOCK_MONOTONIC, &now);
>> + remaining_ms = timeout_ms -
>> + (int)((now.tv_sec - start.tv_sec) * 1000 +
>> + (now.tv_nsec - start.tv_nsec) / 1000000);
>> + if (remaining_ms <= 0) {
>> + ret = -ETIMEDOUT;
>> + break;
>> + }
>> + }
>> +
>> + ret = poll(&pfd, 1, remaining_ms);
>> + if (ret == 0) {
>> + ret = -ETIMEDOUT;
>> + break;
>> + }
>> +
>> + if (ret < 0) {
>> + ret = -errno;
>> + break;
>> + }
>> +
>> + ret = nl_recvmsgs(ctx->sock, cb);
>> + if (ret < 0)
>> + break;
>> + }
>> + nl_cb_put(cb);
>> + if (ret < 0)
>> + return ret;
>> +
>> + if (!ctx->event_received)
>> + return -ENOMSG;
>> +
>> + igt_debug("Received error-notify event: node_id=%u error_id=%u
>> value=%u\n",
>> + ctx->event_node_id, ctx->event_error_id,
>> ctx->event_error_value);
>> +
>> + return 0;
>> +}
>> diff --git a/lib/igt_drm_netlink.h b/lib/igt_drm_netlink.h
>> index 9376e3dee..ebc575da6 100644
>> --- a/lib/igt_drm_netlink.h
>> +++ b/lib/igt_drm_netlink.h
>> @@ -19,6 +19,10 @@ struct app_context {
>> bool ack_received;
>> bool response_required;
>> uint32_t error_threshold;
>> + uint32_t event_node_id;
>> + uint32_t event_error_id;
>> + uint32_t event_error_value;
>> + bool event_received;
>> int family_id;
>> };
>> @@ -27,6 +31,8 @@ int igt_drm_netlink_init(struct app_context *ctx);
>> int igt_drm_netlink_get_error_counter(struct app_context *ctx);
>> int igt_drm_netlink_get_error_threshold(struct app_context *ctx);
>> int igt_drm_netlink_set_error_threshold(struct app_context *ctx);
>> +int igt_drm_netlink_subscribe_error_report(struct app_context *ctx,
>> const char *notify_group_name);
>> +int igt_drm_netlink_wait_for_error_report_event(struct app_context
>> *ctx, int timeout_ms);
>> #endif /* IGT_DRM_NETLINK_H */
next prev parent reply other threads:[~2026-10-09 12:29 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 7:33 [PATCH v4 00/10] Xe3P GPU Error Injection Test Suite with DRM RAS Netlink Support Ravi Kishore Koppuravuri
2026-09-03 7:33 ` [PATCH v4 01/10] drm-uapi/drm_ras: Sync with kernel b2207d4c4e84 Ravi Kishore Koppuravuri
2026-09-10 11:12 ` Raag Jadav
2026-09-11 4:19 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 02/10] lib/meson: Add libnl dependencies for DRM RAS support Ravi Kishore Koppuravuri
2026-09-10 8:45 ` Purkait, Soham
2026-09-03 7:33 ` [PATCH v4 03/10] lib/igt_drm_netlink: Introduce DRM RAS Netlink interface library Ravi Kishore Koppuravuri
2026-09-10 6:17 ` Purkait, Soham
2026-09-21 5:16 ` Tauro, Riana
2026-10-09 10:27 ` Koppuravuri, Ravi Kishore
2026-10-01 7:49 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 04/10] lib/igt_drm_netlink: add get_error_counter support Ravi Kishore Koppuravuri
2026-09-10 12:05 ` Purkait, Soham
2026-09-28 8:57 ` Tauro, Riana
2026-10-09 11:23 ` Koppuravuri, Ravi Kishore
2026-10-01 7:58 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 05/10] lib/igt_drm_netlink: add get_error_threshold command support Ravi Kishore Koppuravuri
2026-09-18 13:58 ` Purkait, Soham
2026-10-09 11:41 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 06/10] lib/igt_drm_netlink: add set_error_threshold " Ravi Kishore Koppuravuri
2026-09-11 11:48 ` Purkait, Soham
2026-10-01 8:07 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 07/10] tests/intel/xe_err_injection: Add GT UC Unicast GAM Walker Command Parity Error Injection Ravi Kishore Koppuravuri
2026-09-03 16:45 ` Purkait, Soham
2026-10-01 7:47 ` Koppuravuri, Ravi Kishore
2026-09-11 15:03 ` Kamil Konieczny
2026-10-01 8:07 ` Koppuravuri, Ravi Kishore
2026-09-21 5:09 ` Tauro, Riana
2026-10-09 8:14 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 08/10] lib/igt_drm_netlink: add event notify subscription and event wait support Ravi Kishore Koppuravuri
2026-09-18 15:03 ` Purkait, Soham
2026-10-09 12:28 ` Koppuravuri, Ravi Kishore [this message]
2026-09-03 7:33 ` [PATCH v4 09/10] tests/intel/xe_err_injection: Add tests for L2 bank Corr err threshold scenarios Ravi Kishore Koppuravuri
2026-09-11 8:14 ` Purkait, Soham
2026-10-01 8:02 ` Koppuravuri, Ravi Kishore
2026-09-03 7:33 ` [PATCH v4 10/10] tests/intel/xe_err_injection: add CRI GPU requirement check Ravi Kishore Koppuravuri
2026-09-10 6:19 ` Purkait, Soham
2026-10-01 7:55 ` Koppuravuri, Ravi Kishore
2026-09-03 20:21 ` ✓ Xe.CI.BAT: success for Xe3P GPU Error Injection Test Suite with DRM RAS Netlink Support (rev7) Patchwork
2026-09-03 20:56 ` ✓ i915.CI.BAT: " Patchwork
2026-09-04 8:50 ` ✓ Xe.CI.FULL: " Patchwork
2026-09-04 10:51 ` ✗ i915.CI.Full: failure " Patchwork
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=5f60e040-8329-4de3-beb5-bfac91627029@intel.com \
--to=ravi.kishore.koppuravuri@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=harish.chegondi@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=mallesh.koujalagi@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=soham.purkait@intel.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 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.