From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1244E1049527 for ; Wed, 11 Mar 2026 09:58:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8517910E87A; Wed, 11 Mar 2026 09:58:40 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="FgBvaN8L"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4F1110E3E6; Wed, 11 Mar 2026 09:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1773223117; x=1804759117; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xmfQQSexzlItJbadxzX3S+VXv/F9hU4ivxKn31l7mzY=; b=FgBvaN8LFFGsMOU+ndYrxqlUuWUHAO3UJsJ3tzuamCw7tulnMw8QOhjx TaaD4WyUm+Y0Ge3JgIx3P9Ft25uRTxoEb56+nx4pRalXdFqwhbqYa+NKN +CBRFTSOasnxdfQPe6qAaxM5U73KCHjPEE4Wp3KoJCUxUkRb+wy4/Trab x+XozNFVnC7LsSMp5vgfqKJ6Q7lIa8lstQ3D5RAK5x2g14oeqHfIVzmfV fJVQ/ShQxRs5gpcmdthDt/Hp2LjpCBm3g1LT6gYWhpiBm0e2++G1prqvL ohX5sOv9GvZx1hqLxFMgh/QrD1mjI78ozAvaMMt1miS+DYSApUR6QC/Tt w==; X-CSE-ConnectionGUID: g+jOWJRWQKGiQEshX/rMaA== X-CSE-MsgGUID: nQr9aXuYRfSIwgIBtSNrmQ== X-IronPort-AV: E=McAfee;i="6800,10657,11725"; a="74326059" X-IronPort-AV: E=Sophos;i="6.23,113,1770624000"; d="scan'208";a="74326059" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2026 02:58:36 -0700 X-CSE-ConnectionGUID: qprlaoAvRAG/K0jTR1a7EA== X-CSE-MsgGUID: Qx8StSelQVWFZ5pltWj46g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,113,1770624000"; d="scan'208";a="217095859" Received: from rtauro-desk.iind.intel.com ([10.190.238.50]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Mar 2026 02:58:30 -0700 From: Riana Tauro To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, netdev@vger.kernel.org Cc: aravind.iddamsetty@linux.intel.com, anshuman.gupta@intel.com, rodrigo.vivi@intel.com, joonas.lahtinen@linux.intel.com, simona.vetter@ffwll.ch, airlied@gmail.com, pratik.bari@intel.com, joshua.santosh.ranjan@intel.com, ashwin.kumar.kulkarni@intel.com, shubham.kumar@intel.com, ravi.kishore.koppuravuri@intel.com, raag.jadav@intel.com, anvesh.bakwad@intel.com, maarten.lankhorst@linux.intel.com, Riana Tauro , Jakub Kicinski , Zack McKevitt , Lijo Lazar , Hawking Zhang , "David S. Miller" , Paolo Abeni , Eric Dumazet Subject: [PATCH 3/4] drm/drm_ras: Add DRM RAS netlink error event notification Date: Wed, 11 Mar 2026 15:59:17 +0530 Message-ID: <20260311102913.3387468-9-riana.tauro@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20260311102913.3387468-6-riana.tauro@intel.com> References: <20260311102913.3387468-6-riana.tauro@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add support for asynchronous error notifications in drm_ras. Define a new `error-event` netlink event and a new multicast group `error-notify` in drm_ras spec. Each event contains a node-id and error-id to identify the type and source of error. Add drm_ras_error_notify() to trigger this event from drivers. Userspace can receive this event by subscribing to the multicast group error-notify. Example: Using ynl tool $ sudo ynl --family drm_ras --subscribe error-notify Cc: Jakub Kicinski Cc: Zack McKevitt Cc: Lijo Lazar Cc: Hawking Zhang Cc: David S. Miller Cc: Paolo Abeni Cc: Eric Dumazet Signed-off-by: Riana Tauro --- Documentation/gpu/drm-ras.rst | 9 +++++ Documentation/netlink/specs/drm_ras.yaml | 14 +++++++ drivers/gpu/drm/drm_ras.c | 48 ++++++++++++++++++++++++ drivers/gpu/drm/drm_ras_nl.c | 6 +++ drivers/gpu/drm/drm_ras_nl.h | 4 ++ include/drm/drm_ras.h | 2 + include/uapi/drm/drm_ras.h | 3 ++ 7 files changed, 86 insertions(+) diff --git a/Documentation/gpu/drm-ras.rst b/Documentation/gpu/drm-ras.rst index 4636e68f5678..09b2918f67bd 100644 --- a/Documentation/gpu/drm-ras.rst +++ b/Documentation/gpu/drm-ras.rst @@ -54,6 +54,8 @@ User space tools can: ``node-id`` and ``error-id`` as parameters. * Clear specific error counters with the ``clear-error-counter`` command, using both ``node-id`` and ``error-id`` as parameters. +* Listen to ``error-event`` notifications for error events by subscribing to the + ``error-notify`` multicast group. YAML-based Interface -------------------- @@ -109,3 +111,10 @@ Example: Clear an error counter for a given node sudo ynl --family drm_ras --do clear-error-counter --json '{"node-id":0, "error-id":1}' None + +Example: Listen to error events + +.. code-block:: bash + + sudo ynl --family drm_ras --subscribe error-notify + {'msg': {'error-id': 1, 'node-id': 1}, 'name': 'error-event'} diff --git a/Documentation/netlink/specs/drm_ras.yaml b/Documentation/netlink/specs/drm_ras.yaml index e113056f8c01..4dc047be59e9 100644 --- a/Documentation/netlink/specs/drm_ras.yaml +++ b/Documentation/netlink/specs/drm_ras.yaml @@ -124,3 +124,17 @@ operations: do: request: attributes: *id-attrs + - + name: error-event + doc: >- + Notify userspace of an error event. + The event includes the error-id and node-id of the error + that triggered the event. + attribute-set: error-counter-attrs + event: + attributes: *id-attrs + +mcast-groups: + list: + - + name: error-notify diff --git a/drivers/gpu/drm/drm_ras.c b/drivers/gpu/drm/drm_ras.c index d6eab29a1394..36a3a79cbbea 100644 --- a/drivers/gpu/drm/drm_ras.c +++ b/drivers/gpu/drm/drm_ras.c @@ -41,6 +41,10 @@ * Userspace must provide Node ID, Error ID. * Clears specific error counter of a node if supported. * + * 4. ERROR_EVENT: Notify userspace of an error event. + * The event includes the error-id and node-id of the error + * that triggered the event. + * * Node registration: * * - drm_ras_node_register(): Registers a new node and assigns @@ -355,6 +359,50 @@ int drm_ras_nl_clear_error_counter_doit(struct sk_buff *skb, return node->clear_error_counter(node, error_id); } +/** + * drm_ras_error_notify() - Notify userspace of an error event + * @node: Node structure + * @error_id: ID of the error counter that triggered the event + * @flags: GFP flags for memory allocation + * + * Notifies userspace of an error event related to a specific RAS node and error counter. + */ +void drm_ras_error_notify(struct drm_ras_node *node, u32 error_id, gfp_t flags) +{ + struct genl_info info; + struct sk_buff *msg; + struct nlattr *hdr; + int ret; + + genl_info_init_ntf(&info, &drm_ras_nl_family, DRM_RAS_CMD_ERROR_EVENT); + + msg = genlmsg_new(NLMSG_GOODSIZE, flags); + if (!msg) + return; + + hdr = genlmsg_iput(msg, &info); + if (!hdr) + goto err_free; + + ret = nla_put_u32(msg, DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID, node->id); + if (ret) + goto err_cancel; + + ret = nla_put_u32(msg, DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID, error_id); + if (ret) + goto err_cancel; + + genlmsg_end(msg, hdr); + genlmsg_multicast(&drm_ras_nl_family, msg, 0, DRM_RAS_NLGRP_ERROR_NOTIFY, flags); + return; + +err_cancel: + genlmsg_cancel(msg, hdr); +err_free: + nlmsg_free(msg); +} +EXPORT_SYMBOL(drm_ras_error_notify); + /** * drm_ras_node_register() - Register a new RAS node * @node: Node structure to register diff --git a/drivers/gpu/drm/drm_ras_nl.c b/drivers/gpu/drm/drm_ras_nl.c index dea1c1b2494e..ac724bb87a3b 100644 --- a/drivers/gpu/drm/drm_ras_nl.c +++ b/drivers/gpu/drm/drm_ras_nl.c @@ -58,6 +58,10 @@ static const struct genl_split_ops drm_ras_nl_ops[] = { }, }; +static const struct genl_multicast_group drm_ras_nl_mcgrps[] = { + [DRM_RAS_NLGRP_ERROR_NOTIFY] = { "error-notify", }, +}; + struct genl_family drm_ras_nl_family __ro_after_init = { .name = DRM_RAS_FAMILY_NAME, .version = DRM_RAS_FAMILY_VERSION, @@ -66,4 +70,6 @@ struct genl_family drm_ras_nl_family __ro_after_init = { .module = THIS_MODULE, .split_ops = drm_ras_nl_ops, .n_split_ops = ARRAY_SIZE(drm_ras_nl_ops), + .mcgrps = drm_ras_nl_mcgrps, + .n_mcgrps = ARRAY_SIZE(drm_ras_nl_mcgrps), }; diff --git a/drivers/gpu/drm/drm_ras_nl.h b/drivers/gpu/drm/drm_ras_nl.h index a398643572a5..17e1af8cc3b3 100644 --- a/drivers/gpu/drm/drm_ras_nl.h +++ b/drivers/gpu/drm/drm_ras_nl.h @@ -21,6 +21,10 @@ int drm_ras_nl_get_error_counter_dumpit(struct sk_buff *skb, int drm_ras_nl_clear_error_counter_doit(struct sk_buff *skb, struct genl_info *info); +enum { + DRM_RAS_NLGRP_ERROR_NOTIFY, +}; + extern struct genl_family drm_ras_nl_family; #endif /* _LINUX_DRM_RAS_GEN_H */ diff --git a/include/drm/drm_ras.h b/include/drm/drm_ras.h index f2a787bc4f64..a2d4f257c9c2 100644 --- a/include/drm/drm_ras.h +++ b/include/drm/drm_ras.h @@ -78,9 +78,11 @@ struct drm_device; #if IS_ENABLED(CONFIG_DRM_RAS) int drm_ras_node_register(struct drm_ras_node *node); void drm_ras_node_unregister(struct drm_ras_node *node); +void drm_ras_error_notify(struct drm_ras_node *node, u32 error_id, gfp_t flags); #else static inline int drm_ras_node_register(struct drm_ras_node *node) { return 0; } static inline void drm_ras_node_unregister(struct drm_ras_node *node) { } +static inline void drm_ras_error_notify(struct drm_ras_node *node, u32 error_id, gfp_t flags) { } #endif #endif diff --git a/include/uapi/drm/drm_ras.h b/include/uapi/drm/drm_ras.h index 218a3ee86805..47fafeff93e7 100644 --- a/include/uapi/drm/drm_ras.h +++ b/include/uapi/drm/drm_ras.h @@ -42,9 +42,12 @@ enum { DRM_RAS_CMD_LIST_NODES = 1, DRM_RAS_CMD_GET_ERROR_COUNTER, DRM_RAS_CMD_CLEAR_ERROR_COUNTER, + DRM_RAS_CMD_ERROR_EVENT, __DRM_RAS_CMD_MAX, DRM_RAS_CMD_MAX = (__DRM_RAS_CMD_MAX - 1) }; +#define DRM_RAS_MCGRP_ERROR_NOTIFY "error-notify" + #endif /* _UAPI_LINUX_DRM_RAS_H */ -- 2.47.1