Introduce error threshold to drm_ras
Subsystems (8)
Raag Jadav
reviewerv3 cover Introduce error threshold to drm_ras
This series reuses some pieces of [1] and introduces error threshold to drm_ras infrastructure. This allows user to get and set the error threshold of a specific counter.
Detailed description in commit message and documentation.
[1] https://patchwork.freedesktop.org/series/164393/
v2: Document threshold definition (Riana)
Return -EOPNOTSUPP on threshold callbacks absence (Riana) Cancel and free genlmsg on failure (Riana) Document threshold bounds checking responsibility (Riana) Add RAS operation status codes (Riana)
v3: Move documentation from yaml to rst file (Riana)
s/value/threshold (Riana)
Use goto for error handling (Riana)
Reuse status codes and uapi mapping from counter series (Riana) Access request/response counter using local pointer (Riana) Mark unused field as reserved (Riana)
Return -ENOENT on info absence (Riana)
Raag Jadav (3):
drm/ras: Introduce error threshold drm/xe/ras: Add support for error threshold drm/xe/drm_ras: Wire up error threshold callbacks
Riana Tauro (1):
drm/xe/xe_ras: Add support for error counter
Documentation/gpu/drm-ras.rst | 18 ++ Documentation/netlink/specs/drm_ras.yaml | 32 ++ drivers/gpu/drm/drm_ras.c | 167 ++++++++++ drivers/gpu/drm/drm_ras_nl.c | 27 ++ drivers/gpu/drm/drm_ras_nl.h | 4 + drivers/gpu/drm/xe/xe_device.c | 20 +- drivers/gpu/drm/xe/xe_device_types.h | 2 + drivers/gpu/drm/xe/xe_drm_ras.c | 71 ++++- drivers/gpu/drm/xe/xe_hw_error.c | 13 - drivers/gpu/drm/xe/xe_pci.c | 3 + drivers/gpu/drm/xe/xe_pci_types.h | 1 + drivers/gpu/drm/xe/xe_ras.c | 297 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 7 + drivers/gpu/drm/xe/xe_ras_types.h | 102 ++++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 28 ++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.h | 3 + drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 8 + include/drm/drm_ras.h | 29 ++ include/uapi/drm/drm_ras.h | 3 + include/uapi/drm/xe_drm.h | 11 +- 20 files changed, 811 insertions(+), 35 deletions(-)
Signature · 1 line
2.43.0
Raag Jadav
reviewerPATCH v3 1/4 drm/ras: Introduce error threshold
Add get-error-threshold and set-error-threshold command support which allows querying/setting error threshold of the counter. Threshold in RAS context means the number of errors the hardware is expected to accumulate before it raises them to software. This is to have a fine grained control over error notifications that are raised by the hardware.
---
v2: Document threshold definition (Riana)
Return -EOPNOTSUPP on threshold callbacks absence (Riana) Cancel and free genlmsg on failure (Riana) Document threshold bounds checking responsibility (Riana)
v3: Move documentation from yaml to rst file (Riana)
s/value/threshold (Riana)
Use goto for error handling (Riana)
--- Documentation/gpu/drm-ras.rst | 18 +++ Documentation/netlink/specs/drm_ras.yaml | 32 +++++ drivers/gpu/drm/drm_ras.c | 167 +++++++++++++++++++++++ drivers/gpu/drm/drm_ras_nl.c | 27 ++++ drivers/gpu/drm/drm_ras_nl.h | 4 + include/drm/drm_ras.h | 29 ++++ include/uapi/drm/drm_ras.h | 3 + 7 files changed, 280 insertions(+)
Documentation/gpu/drm-ras.rst +18 -0
@@ -54,6 +54,10 @@ 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. +* Query specific error counter threshold with the ``get-error-threshold`` command, using both + ``node-id`` and ``error-id`` as parameters. +* Set specific error counter threshold with the ``set-error-threshold`` command, using + ``node-id``, ``error-id`` and ``error-threshold`` as parameters. YAML-based Interface --------------------
@@ -109,3 +113,17 @@ 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: Query error threshold of a given counter + +.. code-block:: bash + + sudo ynl --family drm_ras --do get-error-threshold --json '{"node-id":0, "error-id":1}' + {'error-id': 1, 'error-name': 'error_name1', 'error-threshold': 16} + +Example: Set error threshold of a given counter + +.. code-block:: bash + + sudo ynl --family drm_ras --do set-error-threshold --json '{"node-id":0, "error-id":1, "error-threshold":8}' + None
Documentation/netlink/specs/drm_ras.yaml +32 -0
@@ -69,6 +69,10 @@ attribute-sets: name: error-value type: u32 doc: Current value of the requested error counter. + - + name: error-threshold + type: u32 + doc: Error threshold of the counter. operations: list:
@@ -124,3 +128,31 @@ operations: do: request: attributes: *id-attrs + - + name: get-error-threshold + doc: >- + Retrieve error threshold of a given counter. + The response includes the id, the name, and current threshold + of the counter. + attribute-set: error-counter-attrs + flags: [admin-perm] + do: + request: + attributes: *id-attrs + reply: + attributes: + - error-id + - error-name + - error-threshold + - + name: set-error-threshold + doc: >- + Set error threshold of a given counter. + attribute-set: error-counter-attrs + flags: [admin-perm] + do: + request: + attributes: + - node-id + - error-id + - error-threshold
drivers/gpu/drm/drm_ras.c +167 -0
209 lines not on this page · raw message
drivers/gpu/drm/drm_ras_nl.c +27 -0
@@ -28,6 +28,19 @@ static const struct nla_policy drm_ras_clear_error_counter_nl_policy[DRM_RAS_A_E [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID] = { .type = NLA_U32, }, }; +/* DRM_RAS_CMD_GET_ERROR_THRESHOLD - do */ +static const struct nla_policy drm_ras_get_error_threshold_nl_policy[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID +1 ] = { + [DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ] = { .type =NLA_U32 , }, + [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ] = { .type =NLA_U32 , }, +}; + +/* DRM_RAS_CMD_SET_ERROR_THRESHOLD - do */ +static const struct nla_policy drm_ras_set_error_threshold_nl_policy[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD +1 ] = { + [DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ] = { .type =NLA_U32 , }, + [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ] = { .type =NLA_U32 , }, + [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD ] = { .type =NLA_U32 , }, +}; +/* Ops table for drm_ras */ static const struct genl_split_ops drm_ras_nl_ops[] = { {
@@ -56,6 +69,20 @@ static const struct genl_split_ops drm_ras_nl_ops[] = { .maxattr = DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, + { + .cmd = DRM_RAS_CMD_GET_ERROR_THRESHOLD, + .doit = drm_ras_nl_get_error_threshold_doit, + .policy = drm_ras_get_error_threshold_nl_policy, + .maxattr = DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, + { + .cmd = DRM_RAS_CMD_SET_ERROR_THRESHOLD, + .doit = drm_ras_nl_set_error_threshold_doit, + .policy = drm_ras_set_error_threshold_nl_policy, + .maxattr = DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, }; struct genl_family drm_ras_nl_family __ro_after_init = {
drivers/gpu/drm/drm_ras_nl.h +4 -0
@@ -20,6 +20,10 @@ int drm_ras_nl_get_error_counter_dumpit(struct sk_buff *skb, struct netlink_callback *cb);int drm_ras_nl_clear_error_counter_doit (struct sk_buff *skb,struct genl_info *info); +int drm_ras_nl_get_error_threshold_doit (struct sk_buff *skb, +struct genl_info *info); +int drm_ras_nl_set_error_threshold_doit (struct sk_buff *skb, +struct genl_info *info);extern struct genl_family drm_ras_nl_family;
include/drm/drm_ras.h +29 -0
@@ -69,6 +69,35 @@ struct drm_ras_node {*/ int (*clear_error_counter)(struct drm_ras_node *node,u32 error_id); +/** +* @query_error_threshold: +* +* This callback is used by drm-ras to query error threshold of a +* specific counter. +* +* Driver should expect query_error_threshold() to be called with +* error_id from `error_counter_range.first` to +* `error_counter_range.last`. +* +* Returns: 0 on success, negative error code on failure. +*/ +int (*query_error_threshold)(struct drm_ras_node *node,u32 error_id, +const char **name,u32 *threshold); +/** +* @set_error_threshold: +* +* This callback is used by drm-ras to set error threshold of a specific +* counter. +* +* Driver should expect set_error_threshold() to be called with error_id +* from `error_counter_range.first` to `error_counter_range.last`. +* Driver is responsible for error threshold bounds checking. +* +* Returns: 0 on success, negative error code on failure. +*/ +int (*set_error_threshold)(struct drm_ras_node *node,u32 error_id, +u32 threshold); +/** @priv: Driver private data */ void *priv; };
include/uapi/drm/drm_ras.h +3 -0
@@ -33,6 +33,7 @@ enum {DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_NAME ,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_VALUE , +DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD , __DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX,DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX = (__DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX -1 )
@@ -42,6 +43,8 @@ enum {DRM_RAS_CMD_LIST_NODES =1 ,DRM_RAS_CMD_GET_ERROR_COUNTER ,DRM_RAS_CMD_CLEAR_ERROR_COUNTER , +DRM_RAS_CMD_GET_ERROR_THRESHOLD , +DRM_RAS_CMD_SET_ERROR_THRESHOLD , __DRM_RAS_CMD_MAX,DRM_RAS_CMD_MAX = (__DRM_RAS_CMD_MAX -1 )
Signature · 1 line
2.43.0
Tauro, Riana
maintainerRe: [PATCH v3 1/4] drm/ras: Introduce error threshold
Quoted 124 lines · Raag Jadav
Add get-error-threshold and set-error-threshold command support which allows querying/setting error threshold of the counter. Threshold in RAS context means the number of errors the hardware is expected to accumulate before it raises them to software. This is to have a fine grained control over error notifications that are raised by the hardware.
Signed-off-by Raag Jadav <[email protected]>---
v2: Document threshold definition (Riana)
Return-EOPNOTSUPPon threshold callbacks absence (Riana) Cancel and free genlmsg on failure (Riana) Document threshold bounds checking responsibility (Riana)
v3: Move documentation from yaml to rst file (Riana)
s/value/threshold (Riana)
Use goto for error handling (Riana)--- Documentation/gpu/drm-ras.rst | 18 +++ Documentation/netlink/specs/drm_ras.yaml | 32 +++++ drivers/gpu/drm/drm_ras.c | 167 +++++++++++++++++++++++ drivers/gpu/drm/drm_ras_nl.c | 27 ++++ drivers/gpu/drm/drm_ras_nl.h | 4 + include/drm/drm_ras.h | 29 ++++ include/uapi/drm/drm_ras.h | 3 + 7 files changed, 280 insertions(+)Documentation/gpu/drm-ras.rst +18
-0@@ -54,6 +54,10 @@ 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. +* Query specific error counter threshold with the ``get-error-threshold`` command, using both + ``node-id`` and ``error-id`` as parameters. +* Set specific error counter threshold with the ``set-error-threshold`` command, using + ``node-id``, ``error-id`` and ``error-threshold`` as parameters. YAML-based Interface --------------------@@ -109,3 +113,17 @@ 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: Query error threshold of a given counter + +.. code-block:: bash + + sudo ynl --family drm_ras --do get-error-threshold --json '{"node-id":0, "error-id":1}' + {'error-id': 1, 'error-name': 'error_name1', 'error-threshold': 16} + +Example: Set error threshold of a given counter + +.. code-block:: bash + + sudo ynl --family drm_ras --do set-error-threshold --json '{"node-id":0, "error-id":1, "error-threshold":8}' + NoneDocumentation/netlink/specs/drm_ras.yaml +32
-0@@ -69,6 +69,10 @@ attribute-sets: name: error-value type: u32 doc: Current value of the requested error counter. + - + name: error-threshold + type: u32 + doc: Error threshold of the counter. operations: list:@@ -124,3 +128,31 @@ operations: do: request: attributes: *id-attrs + - + name: get-error-threshold + doc: >- + Retrieve error threshold of a given counter. + The response includes the id, the name, and current threshold + of the counter. + attribute-set: error-counter-attrs + flags: [admin-perm] + do: + request: + attributes: *id-attrs + reply: + attributes: + - error-id + - error-name + - error-threshold + - + name: set-error-threshold + doc: >- + Set error threshold of a given counter. + attribute-set: error-counter-attrs + flags: [admin-perm] + do: + request: + attributes: + - node-id + - error-id + - error-thresholddrivers/gpu/drm/drm_ras.c +7
-0@@ -41,6 +41,13 @@* Userspace must provide Node ID, Error ID. * Clears specific error counter of a node if supported. * +* 4. GET_ERROR_THRESHOLD: Query error threshold of a given counter. +* Userspace must provide Node ID and Error ID. +* Returns the error threshold of a specific counter. +* +* 5. SET_ERROR_THRESHOLD: Set error threshold of a given counter. +* Userspace must provide Node ID, Error ID and threshold to be set. +* * Node registration: * * - drm_ras_node_register(): Registers a new node and assigns
drivers/gpu/drm/drm_ras.c line 77
Quoted 10 lines
drivers/gpu/drm/drm_ras.c +7
-0@@ -61,6 +68,13 @@* + The error counters in the driver doesn't need to be contiguous, but the * driver must return -ENOENT to the query_error_counter as an indication * that the ID should be skipped and not listed in the netlink API. +* + The driver can optionally implement query_error_threshold() and +* set_error_threshold() callbacks to facilitate getting/setting error +* threshold of the counter. Threshold in RAS context means the number of +* errors the hardware is expected to accumulate before it raises them to +* software. This is to have a fine grained control over error notifications +* that are raised by the hardware. +* + The driver is responsible for error threshold bounds checking.
Can the threshold be set to 0? What should the behaviour be?
Quoted 65 lines
drivers/gpu/drm/drm_ras.c +44
-0* * Netlink handlers: * @@ -72,6 +86,10 @@* operation, fetching a counter value from a specific node. * - drm_ras_nl_clear_error_counter_doit(): Implements the CLEAR_ERROR_COUNTER doit * operation, clearing a counter value from a specific node. +* - drm_ras_nl_get_error_threshold_doit(): Implements the GET_ERROR_THRESHOLD doit +* operation, fetching the error threshold of a specific counter. +* - drm_ras_nl_set_error_threshold_doit(): Implements the SET_ERROR_THRESHOLD doit +* operation, setting the error threshold of a specific counter. */ static DEFINE_XARRAY_ALLOC (drm_ras_xa);@@ -168,6 +186,43 @@ static int get_node_error_counter(u32 node_id, u32 error_id,return node->query_error_counter (node, error_id, name, value); } +static int get_node_error_threshold (u32 node_id,u32 error_id, +const char **name,u32 *threshold) +{ +struct drm_ras_node *node; + + node =xa_load (&drm_ras_xa, node_id); +if (!node) +return -ENOENT ; + +if (!node->query_error_threshold) +return -EOPNOTSUPP ; + +if (error_id < node->error_counter_range.first || + error_id > node->error_counter_range.last) +return -EINVAL ; + +return node->query_error_threshold (node, error_id, name, threshold); +} + +static int set_node_error_threshold (u32 node_id,u32 error_id,u32 threshold) +{ +struct drm_ras_node *node; + + node =xa_load (&drm_ras_xa, node_id); +if (!node) +return -ENOENT ; + +if (!node->set_error_threshold) +return -EOPNOTSUPP ; + +if (error_id < node->error_counter_range.first || + error_id > node->error_counter_range.last) +return -EINVAL ; + +return node->set_error_threshold (node, error_id, threshold); +} +static int msg_reply_value (struct sk_buff *msg,u32 error_id,const char *error_name,u32 value) {@@ -186,6 +241,24 @@ static int msg_reply_value(struct sk_buff *msg, u32 error_id, value); } +static int msg_reply_threshold (struct sk_buff *msg,u32 error_id, +const char *error_name,u32 threshold) +{
drivers/gpu/drm/drm_ras.c static int msg_reply_value(struct sk_buff *msg, u32 error_id, · line 256
Quoted 10 lines
drivers/gpu/drm/drm_ras.c +10
-0+int ret; + + ret =nla_put_u32 (msg,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID , error_id); +if (ret) +return ret; + + ret =nla_put_string (msg,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_NAME , + error_name); +if (ret) +return ret;
can be in a single line
drivers/gpu/drm/drm_ras.c static int msg_reply_value(struct sk_buff *msg, u32 error_id, · line 259
Quoted 3 lines
drivers/gpu/drm/drm_ras.c +3
-0+ +return nla_put_u32 (msg,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD , + threshold);
same
Quoted 20 lines
drivers/gpu/drm/drm_ras.c +13
-0+} +static int doit_reply_value (struct genl_info *info,u32 node_id,u32 error_id) {@@ -225,6 +298,45 @@ static int doit_reply_value(struct genl_info *info, u32 node_id,return ret; } +static int doit_reply_threshold (struct genl_info *info,u32 node_id, +u32 error_id) +{ +const char *error_name; +struct sk_buff *msg; +struct nlattr *hdr; +u32 threshold; +int ret; + + msg =genlmsg_new (NLMSG_GOODSIZE ,GFP_KERNEL ); +if (!msg)
drivers/gpu/drm/drm_ras.c static int doit_reply_value(struct genl_info *info, u32 node_id, · line 321
Quoted 10 lines
drivers/gpu/drm/drm_ras.c +10
-0+return -ENOMEM ; + + hdr =genlmsg_iput (msg, info); +if (!hdr) { + ret = -EMSGSIZE ; + goto free_msg; + } + + ret =get_node_error_threshold (node_id, error_id, + &error_name, &threshold);
same
Thanks
Riana
Quoted 204 lines
drivers/gpu/drm/drm_ras.c +73
-0+if (ret) + goto cancel_msg; + + ret =msg_reply_threshold (msg, error_id, error_name, threshold); +if (ret) + goto cancel_msg; + +genlmsg_end (msg, hdr); + +return genlmsg_reply (msg, info); + +cancel_msg: +genlmsg_cancel (msg, hdr); +free_msg: +nlmsg_free (msg); +return ret; +} +/** * drm_ras_nl_get_error_counter_dumpit() - Dump all Error Counters * @skb: Netlink message buffer @@ -358,6 +470,61 @@ int drm_ras_nl_clear_error_counter_doit(struct sk_buff *skb,return node->clear_error_counter (node, error_id); } +/** +* drm_ras_nl_get_error_threshold_doit() - Query error threshold of a counter +* @skb: Netlink message buffer +* @info: Generic Netlink info containing attributes of the request +* +* Extracts the Node ID and Error ID from the netlink attributes and retrieves +* the error threshold of the corresponding counter. Sends the result back to +* the requesting user via the standard Genl reply. +* +* Return: 0 on success, or negative errno on failure. +*/ +int drm_ras_nl_get_error_threshold_doit (struct sk_buff *skb, +struct genl_info *info) +{ +u32 node_id, error_id; + +if (!info->attrs || +GENL_REQ_ATTR_CHECK (info,DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ) || +GENL_REQ_ATTR_CHECK (info,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID )) +return -EINVAL ; + + node_id =nla_get_u32 (info->attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ]); + error_id =nla_get_u32 (info->attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ]); + +return doit_reply_threshold (info, node_id, error_id); +} + +/** +* drm_ras_nl_set_error_threshold_doit() - Set error threshold of a counter +* @skb: Netlink message buffer +* @info: Generic Netlink info containing attributes of the request +* +* Extracts the Node ID, Error ID and threshold from the netlink attributes and +* sets the error threshold of the corresponding counter. +* +* Return: 0 on success, or negative errno on failure. +*/ +int drm_ras_nl_set_error_threshold_doit (struct sk_buff *skb, +struct genl_info *info) +{ +u32 node_id, error_id, threshold; + +if (!info->attrs || +GENL_REQ_ATTR_CHECK (info,DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ) || +GENL_REQ_ATTR_CHECK (info,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ) || +GENL_REQ_ATTR_CHECK (info,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD )) +return -EINVAL ; + + node_id =nla_get_u32 (info->attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ]); + error_id =nla_get_u32 (info->attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ]); + threshold =nla_get_u32 (info->attrs[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD ]); + +return set_node_error_threshold (node_id, error_id, threshold); +} +/** * drm_ras_node_register() - Register a new RAS node * @node: Node structure to register drivers/gpu/drm/drm_ras_nl.c +27
-0@@ -28,6 +28,19 @@ static const struct nla_policy drm_ras_clear_error_counter_nl_policy[DRM_RAS_A_E [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID] = { .type = NLA_U32, }, }; +/* DRM_RAS_CMD_GET_ERROR_THRESHOLD - do */ +static const struct nla_policy drm_ras_get_error_threshold_nl_policy[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID +1 ] = { + [DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ] = { .type =NLA_U32 , }, + [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ] = { .type =NLA_U32 , }, +}; + +/* DRM_RAS_CMD_SET_ERROR_THRESHOLD - do */ +static const struct nla_policy drm_ras_set_error_threshold_nl_policy[DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD +1 ] = { + [DRM_RAS_A_ERROR_COUNTER_ATTRS_NODE_ID ] = { .type =NLA_U32 , }, + [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ] = { .type =NLA_U32 , }, + [DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD ] = { .type =NLA_U32 , }, +}; +/* Ops table for drm_ras */ static const struct genl_split_ops drm_ras_nl_ops[] = { {@@ -56,6 +69,20 @@ static const struct genl_split_ops drm_ras_nl_ops[] = { .maxattr = DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID, .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, + { + .cmd = DRM_RAS_CMD_GET_ERROR_THRESHOLD, + .doit = drm_ras_nl_get_error_threshold_doit, + .policy = drm_ras_get_error_threshold_nl_policy, + .maxattr = DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, + { + .cmd = DRM_RAS_CMD_SET_ERROR_THRESHOLD, + .doit = drm_ras_nl_set_error_threshold_doit, + .policy = drm_ras_set_error_threshold_nl_policy, + .maxattr = DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, }; struct genl_family drm_ras_nl_family __ro_after_init = {drivers/gpu/drm/drm_ras_nl.h +4
-0@@ -20,6 +20,10 @@ int drm_ras_nl_get_error_counter_dumpit(struct sk_buff *skb, struct netlink_callback *cb);int drm_ras_nl_clear_error_counter_doit (struct sk_buff *skb,struct genl_info *info); +int drm_ras_nl_get_error_threshold_doit (struct sk_buff *skb, +struct genl_info *info); +int drm_ras_nl_set_error_threshold_doit (struct sk_buff *skb, +struct genl_info *info);extern struct genl_family drm_ras_nl_family;include/drm/drm_ras.h +29
-0@@ -69,6 +69,35 @@ struct drm_ras_node {*/ int (*clear_error_counter)(struct drm_ras_node *node,u32 error_id); +/** +* @query_error_threshold: +* +* This callback is used by drm-ras to query error threshold of a +* specific counter. +* +* Driver should expect query_error_threshold() to be called with +* error_id from `error_counter_range.first` to +* `error_counter_range.last`. +* +* Returns: 0 on success, negative error code on failure. +*/ +int (*query_error_threshold)(struct drm_ras_node *node,u32 error_id, +const char **name,u32 *threshold); +/** +* @set_error_threshold: +* +* This callback is used by drm-ras to set error threshold of a specific +* counter. +* +* Driver should expect set_error_threshold() to be called with error_id +* from `error_counter_range.first` to `error_counter_range.last`. +* Driver is responsible for error threshold bounds checking. +* +* Returns: 0 on success, negative error code on failure. +*/ +int (*set_error_threshold)(struct drm_ras_node *node,u32 error_id, +u32 threshold); +/** @priv: Driver private data */ void *priv; };include/uapi/drm/drm_ras.h +3
-0@@ -33,6 +33,7 @@ enum {DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_ID ,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_NAME ,DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_VALUE , +DRM_RAS_A_ERROR_COUNTER_ATTRS_ERROR_THRESHOLD , __DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX,DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX = (__DRM_RAS_A_ERROR_COUNTER_ATTRS_MAX -1 )@@ -42,6 +43,8 @@ enum {DRM_RAS_CMD_LIST_NODES =1 ,DRM_RAS_CMD_GET_ERROR_COUNTER ,DRM_RAS_CMD_CLEAR_ERROR_COUNTER , +DRM_RAS_CMD_GET_ERROR_THRESHOLD , +DRM_RAS_CMD_SET_ERROR_THRESHOLD , __DRM_RAS_CMD_MAX,DRM_RAS_CMD_MAX = (__DRM_RAS_CMD_MAX -1 )
Raag Jadav
reviewerRe: [PATCH v3 1/4] drm/ras: Introduce error threshold
Quoted 6 lines · Riana
Quoted 5 lines · Raag Jadav
Add get-error-threshold and set-error-threshold command support which allows querying/setting error threshold of the counter. Threshold in RAS context means the number of errors the hardware is expected to accumulate before it raises them to software. This is to have a fine grained control over error notifications that are raised by the hardware.
...
Quoted 9 lines
Quoted 7 lines
+ * + The driver can optionally implement
query_error_threshold()and+ * set_error_threshold() callbacks to facilitate getting/setting error + * threshold of the counter. Threshold in RAS context means the number of + * errors the hardware is expected to accumulate before it raises them to + * software. This is to have a fine grained control over error notifications + * that are raised by the hardware.+ * + The driver is responsible for error threshold bounds checking.
Can the threshold be set to 0? What should the behaviour be?
Some may want it to be invalid while some may want it to act as a "disable notifications" toggle. So it's upto the drivers and their usecases, not for us to decide. Will add this.
Raag
Raag Jadav
reviewerPATCH v3 2/4 drm/xe/xe_ras: Add support for error counter
In reply to Raag JadavFrom: Riana Tauro <[email protected]>
Do not review, CI only.
--- drivers/gpu/drm/xe/xe_device.c | 20 +- drivers/gpu/drm/xe/xe_device_types.h | 2 + drivers/gpu/drm/xe/xe_drm_ras.c | 41 ++-- drivers/gpu/drm/xe/xe_hw_error.c | 13 -- drivers/gpu/drm/xe/xe_pci.c | 3 + drivers/gpu/drm/xe/xe_pci_types.h | 1 + drivers/gpu/drm/xe/xe_ras.c | 192 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 5 + drivers/gpu/drm/xe/xe_ras_types.h | 51 +++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.c | 28 +++ drivers/gpu/drm/xe/xe_sysctrl_mailbox.h | 3 + drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 4 + include/uapi/drm/xe_drm.h | 11 +- 13 files changed, 337 insertions(+), 37 deletions(-)
drivers/gpu/drm/xe/xe_device.c +12 -8
@@ -62,6 +62,7 @@#include "xe_psmi.h" #include "xe_pxp.h" #include "xe_query.h" +#include "xe_ras.h" #include "xe_shrinker.h" #include "xe_soc_remapper.h" #include "xe_survivability_mode.h"
@@ -742,6 +743,7 @@ static void vf_update_device_info(struct xe_device *xe) xe->info.has_late_bind =0 ; xe->info.skip_guc_pc =1 ; xe->info.skip_pcode =1 ; + xe->info.has_drm_ras = false; }static int xe_device_vram_alloc (struct xe_device *xe)
@@ -990,6 +992,16 @@ int xe_device_probe(struct xe_device *xe)if (err)return err; + err =xe_soc_remapper_init (xe); +if (err) +return err; + + err =xe_sysctrl_init (xe); +if (err) +return err; + +xe_ras_init (xe); +/* * Now that GT is initialized (TTM in particular), * we can try to init display, and inherit the initial fb.
@@ -1030,10 +1042,6 @@ int xe_device_probe(struct xe_device *xe)xe_nvm_init (xe); - err =xe_soc_remapper_init (xe); -if (err) -return err; - err =xe_heci_gsc_init (xe);if (err)return err;
@@ -1072,10 +1080,6 @@ int xe_device_probe(struct xe_device *xe)if (err) goto err_unregister_display; - err =xe_sysctrl_init (xe); -if (err) - goto err_unregister_display; - err =xe_device_sysfs_init (xe);if (err) goto err_unregister_display;
drivers/gpu/drm/xe/xe_device_types.h +2 -0
@@ -156,6 +156,8 @@ struct xe_device { u8 has_cached_pt:1;/** @info.has_device_atomics_on_smem: Supports device atomics on SMEM */ u8 has_device_atomics_on_smem:1; +/** @info.has_drm_ras: Device supports drm_ras (Reliability, Availability, Serviceability) */ + u8 has_drm_ras:1;/** @info.has_fan_control: Device supports fan control */ u8 has_fan_control:1;/** @info.has_flat_ccs: Whether flat CCS metadata is used */
drivers/gpu/drm/xe/xe_drm_ras.c +26 -15
91 lines not on this page · raw message
drivers/gpu/drm/xe/xe_hw_error.c +0 -13
@@ -516,14 +516,6 @@ void xe_hw_error_irq_handler(struct xe_tile *tile, const u32 master_ctl) } } -static int hw_error_info_init (struct xe_device *xe) -{ -if (xe->info.platform !=XE_PVC ) -return 0 ; - -return xe_drm_ras_init (xe); -} -/* * Process hardware errors during boot */
@@ -550,16 +542,11 @@ static void process_hw_errors(struct xe_device *xe)void xe_hw_error_init (struct xe_device *xe) {struct xe_tile *tile =xe_device_get_root_tile (xe); -int ret;if (!IS_DGFX (xe) ||IS_SRIOV_VF (xe))return ;INIT_WORK (&tile->csc_hw_error_work, csc_hw_error_work); - ret =hw_error_info_init (xe); -if (ret) -drm_err (&xe->drm,"Failed to initialize XE DRM RAS (%pe)\n" ,ERR_PTR (ret)); -process_hw_errors (xe); }
drivers/gpu/drm/xe/xe_pci.c +3 -0
@@ -355,6 +355,7 @@ static const __maybe_unused struct xe_device_desc pvc_desc = {PLATFORM (PVC ), .dma_mask_size = 52, .has_display = false, + .has_drm_ras = true, .has_gsc_nvm = 1, .has_heci_gscfi = 1, .max_gt_per_tile = 1,
@@ -457,6 +458,7 @@ static const struct xe_device_desc cri_desc = {PLATFORM (CRESCENTISLAND ), .dma_mask_size = 52, .has_display = false, + .has_drm_ras = true, .has_flat_ccs = false, .has_gsc_nvm = 1, .has_i2c = true,
@@ -760,6 +762,7 @@ static int xe_info_init_early(struct xe_device *xe, xe->info.is_dgfx = desc->is_dgfx; xe->info.has_cached_pt = desc->has_cached_pt; + xe->info.has_drm_ras = desc->has_drm_ras; xe->info.has_fan_control = desc->has_fan_control;/* runtime fusing may force flat_ccs to disabled later */ xe->info.has_flat_ccs = desc->has_flat_ccs;
drivers/gpu/drm/xe/xe_pci_types.h +1 -0
@@ -40,6 +40,7 @@ struct xe_device_desc { u8 has_cached_pt:1; u8 has_display:1; + u8 has_drm_ras:1; u8 has_fan_control:1; u8 has_flat_ccs:1; u8 has_gsc_nvm:1;
drivers/gpu/drm/xe/xe_ras.c +192 -0
218 lines not on this page · raw message
drivers/gpu/drm/xe/xe_ras.h +5 -0
@@ -6,10 +6,15 @@#ifndef _XE_RAS_H_#define _XE_RAS_H_ +#include <linux/types.h> +struct xe_device ;struct xe_sysctrl_event_response ;void xe_ras_counter_threshold_crossed (struct xe_device *xe,struct xe_sysctrl_event_response *response); +int xe_ras_get_counter (struct xe_device *xe,u8 severity,u8 component,u32 *value); +int xe_ras_clear_counter (struct xe_device *xe,u8 severity,u8 component); +void xe_ras_init (struct xe_device *xe);#endif
drivers/gpu/drm/xe/xe_ras_types.h +51 -0
55 lines not on this page · raw message
drivers/gpu/drm/xe/xe_sysctrl_mailbox.c +28 -0
@@ -293,6 +293,34 @@ static int sysctrl_send_command(struct xe_sysctrl *sc,return 0 ; } +/** +* xe_sysctrl_create_command() - Create system controller command +* @command: Sysctrl command structure +* @group_id: Command group ID +* @cmd_id: Command ID +* @request: Pointer to request buffer (can be NULL) +* @request_len: Size of request buffer +* @response: Pointer to response buffer +* @response_len: Size of response buffer +* +* Helper function to create sysctrl command to be sent via %xe_sysctrl_send_command() +*/ +void xe_sysctrl_create_command (struct xe_sysctrl_mailbox_command *command,u8 group_id,u8 cmd_id, +void *request,size_t request_len,void *response, +size_t response_len) +{ +struct xe_sysctrl_app_msg_hdr header = {0 }; + + header.data =FIELD_PREP (APP_HDR_GROUP_ID_MASK , group_id) | +FIELD_PREP (APP_HDR_COMMAND_MASK , cmd_id); + + command->header = header; + command->data_in = request; + command->data_in_len = request_len; + command->data_out = response; + command->data_out_len = response_len; +} +/** * xe_sysctrl_mailbox_init - Initialize System Controller mailbox interface * @sc: System controller structure
drivers/gpu/drm/xe/xe_sysctrl_mailbox.h +3 -0
@@ -23,6 +23,9 @@ struct xe_sysctrl_mailbox_command;#define XE_SYSCTRL_APP_HDR_VERSION (hdr) \ FIELD_GET(APP_HDR_VERSION_MASK, (hdr)->data) +void xe_sysctrl_create_command (struct xe_sysctrl_mailbox_command *command,u8 group_id,u8 cmd_id, +void *request,size_t request_len,void *response, +size_t response_len);void xe_sysctrl_mailbox_init (struct xe_sysctrl *sc); int xe_sysctrl_send_command(struct xe_sysctrl *sc, struct xe_sysctrl_mailbox_command *cmd,
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +4 -0
@@ -22,9 +22,13 @@ enum xe_sysctrl_group {/** * enum xe_sysctrl_gfsp_cmd - Commands supported by GFSP group * +* @XE_SYSCTRL_CMD_GET_COUNTER: Get error counter value +* @XE_SYSCTRL_CMD_CLEAR_COUNTER: Clear error counter value * @XE_SYSCTRL_CMD_GET_PENDING_EVENT: Retrieve pending event */ enum xe_sysctrl_gfsp_cmd { +XE_SYSCTRL_CMD_GET_COUNTER =0x03 , +XE_SYSCTRL_CMD_CLEAR_COUNTER =0x04 ,XE_SYSCTRL_CMD_GET_PENDING_EVENT =0x07 , };
include/uapi/drm/xe_drm.h +10 -1
@@ -2589,6 +2589,12 @@ enum drm_xe_ras_error_component {DRM_XE_RAS_ERR_COMP_CORE_COMPUTE =1 ,/** @DRM_XE_RAS_ERR_COMP_SOC_INTERNAL: SoC Internal Error */ DRM_XE_RAS_ERR_COMP_SOC_INTERNAL , +/** @DRM_XE_RAS_ERR_COMP_DEVICE_MEMORY: Device Memory Error */ +DRM_XE_RAS_ERR_COMP_DEVICE_MEMORY , +/** @DRM_XE_RAS_ERR_COMP_PCIE: PCIe Subsystem Error */ +DRM_XE_RAS_ERR_COMP_PCIE , +/** @DRM_XE_RAS_ERR_COMP_FABRIC: Fabric Subsystem Error */ +DRM_XE_RAS_ERR_COMP_FABRIC ,/** @DRM_XE_RAS_ERR_COMP_MAX: Max Error */ DRM_XE_RAS_ERR_COMP_MAX /* non-ABI */ };
@@ -2606,7 +2612,10 @@ enum drm_xe_ras_error_component {*/ #define DRM_XE_RAS_ERROR_COMPONENT_NAMES { \ [DRM_XE_RAS_ERR_COMP_CORE_COMPUTE] = "core-compute", \ - [DRM_XE_RAS_ERR_COMP_SOC_INTERNAL] = "soc-internal" \ + [DRM_XE_RAS_ERR_COMP_SOC_INTERNAL] = "soc-internal", \ + [DRM_XE_RAS_ERR_COMP_DEVICE_MEMORY] = "device-memory", \ + [DRM_XE_RAS_ERR_COMP_PCIE] = "pcie", \ + [DRM_XE_RAS_ERR_COMP_FABRIC] = "fabric", \ }#if defined(__cplusplus)
Signature · 1 line
2.43.0
Raag Jadav
reviewerPATCH v3 3/4 drm/xe/ras: Add support for error threshold
In reply to Raag JadavSystem controller allows getting/setting per counter threshold, which it uses to raise error events to the driver. Get/set it using the respective mailbox command.
---
v2: Add RAS operation status codes (Riana)
v3: Reuse status codes and uapi mapping from counter series (Riana)
Access request/response counter using local pointer (Riana) Mark unused field as reserved (Riana)
--- drivers/gpu/drm/xe/xe_ras.c | 105 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 2 + drivers/gpu/drm/xe/xe_ras_types.h | 51 +++++++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 4 + 4 files changed, 162 insertions(+)
drivers/gpu/drm/xe/xe_ras.c +105 -0
@@ -270,6 +270,111 @@ int xe_ras_clear_counter(struct xe_device *xe, u8 severity, u8 component)return 0 ; } +/** +* xe_ras_get_threshold() - Get error counter threshold +* @xe: Xe device instance +* @severity: Error severity to be queried (&enum drm_xe_ras_error_severity) +* @component: Error component to be queried (&enum drm_xe_ras_error_component) +* @threshold: Counter threshold +* +* This function retrieves the error threshold of a specific counter based on +* severity and component. +* +* Return: 0 on success, negative error code on failure. +*/ +int xe_ras_get_threshold (struct xe_device *xe,u8 severity,u8 component,u32 *threshold) +{ +struct xe_ras_get_threshold_response response = {}; +struct xe_ras_get_threshold_request request = {}; +struct xe_sysctrl_mailbox_command command = {}; +struct xe_ras_error_class *counter; +size_t len; +int ret; + + counter = &request.counter; + counter->common.severity =drm_to_xe_ras_severity (severity); + counter->common.component =drm_to_xe_ras_component (component); + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_GET_THRESHOLD , + &request,sizeof (request), &response,sizeof (response)); + +guard (xe_pm_runtime)(xe); + ret =xe_sysctrl_send_command (&xe->sc, &command, &len); +if (ret) { +xe_err (xe,"sysctrl: failed to get threshold %d\n" , ret); +return ret; + } + +if (len !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected get threshold response length %zu (expected %zu)\n" , + len,sizeof (response)); +return -EIO ; + } + + counter = &response.counter; + *threshold = response.threshold; + +xe_dbg (xe,"[RAS]: get counter threshold %u for %s %s\n" , *threshold, +comp_to_str (counter->common.component),sev_to_str (counter->common.severity)); +return 0 ; +} + +/** +* xe_ras_set_threshold() - Set error counter threshold +* @xe: Xe device instance +* @severity: Error severity to be set (&enum drm_xe_ras_error_severity) +* @component: Error component to be set (&enum drm_xe_ras_error_component) +* @threshold: Counter threshold +* +* This function sets the error threshold of a specific counter based on +* severity and component. +* +* Return: 0 on success, negative error code on failure. +*/ +int xe_ras_set_threshold (struct xe_device *xe,u8 severity,u8 component,u32 threshold) +{ +struct xe_ras_set_threshold_response response = {}; +struct xe_ras_set_threshold_request request = {}; +struct xe_sysctrl_mailbox_command command = {}; +struct xe_ras_error_class *counter; +size_t len; +int ret; + + counter = &request.counter; + counter->common.severity =drm_to_xe_ras_severity (severity); + counter->common.component =drm_to_xe_ras_component (component); + request.threshold = threshold; + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_SET_THRESHOLD , + &request,sizeof (request), &response,sizeof (response)); + +guard (xe_pm_runtime)(xe); + ret =xe_sysctrl_send_command (&xe->sc, &command, &len); +if (ret) { +xe_err (xe,"sysctrl: failed to set threshold %d\n" , ret); +return ret; + } + +if (len !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected set threshold response length %zu (expected %zu)\n" , + len,sizeof (response)); +return -EIO ; + } + + ret =ras_status_to_errno (response.status); +if (ret) { +xe_err (xe,"sysctrl: set threshold command failed with status %#x\n" , + response.status); +return ret; + } + + counter = &response.counter; + +xe_dbg (xe,"[RAS]: set counter threshold %u for %s %s\n" , response.threshold, +comp_to_str (counter->common.component),sev_to_str (counter->common.severity)); +return 0 ; +} +/** * xe_ras_init - Initialize Xe RAS * @xe: xe device instance
drivers/gpu/drm/xe/xe_ras.h +2 -0
@@ -15,6 +15,8 @@ void xe_ras_counter_threshold_crossed(struct xe_device *xe, struct xe_sysctrl_event_response *response);int xe_ras_get_counter (struct xe_device *xe,u8 severity,u8 component,u32 *value);int xe_ras_clear_counter (struct xe_device *xe,u8 severity,u8 component); +int xe_ras_get_threshold (struct xe_device *xe,u8 severity,u8 component,u32 *threshold); +int xe_ras_set_threshold (struct xe_device *xe,u8 severity,u8 component,u32 threshold);void xe_ras_init (struct xe_device *xe);#endif
drivers/gpu/drm/xe/xe_ras_types.h +51 -0
55 lines not on this page · raw message
drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +4 -0
@@ -24,11 +24,15 @@ enum xe_sysctrl_group {* * @XE_SYSCTRL_CMD_GET_COUNTER: Get error counter value * @XE_SYSCTRL_CMD_CLEAR_COUNTER: Clear error counter value +* @XE_SYSCTRL_CMD_GET_THRESHOLD: Retrieve error threshold +* @XE_SYSCTRL_CMD_SET_THRESHOLD: Set error threshold * @XE_SYSCTRL_CMD_GET_PENDING_EVENT: Retrieve pending event */ enum xe_sysctrl_gfsp_cmd {XE_SYSCTRL_CMD_GET_COUNTER =0x03 ,XE_SYSCTRL_CMD_CLEAR_COUNTER =0x04 , +XE_SYSCTRL_CMD_GET_THRESHOLD =0x05 , +XE_SYSCTRL_CMD_SET_THRESHOLD =0x06 ,XE_SYSCTRL_CMD_GET_PENDING_EVENT =0x07 , };
Signature · 1 line
2.43.0
Tauro, Riana
maintainerRe: [PATCH v3 3/4] drm/xe/ras: Add support for error threshold
Quoted 1 line · Raag Jadav
System controller allows getting/setting per counter threshold, which it
for correctable errors.
Quoted 60 lines
uses to raise error events to the driver. Get/set it using the respective mailbox command.
Signed-off-by Raag Jadav <[email protected]>---
v2: Add RAS operation status codes (Riana)
v3: Reuse status codes and uapi mapping from counter series (Riana)
Access request/response counter using local pointer (Riana) Mark unused field as reserved (Riana)--- drivers/gpu/drm/xe/xe_ras.c | 105 ++++++++++++++++++ drivers/gpu/drm/xe/xe_ras.h | 2 + drivers/gpu/drm/xe/xe_ras_types.h | 51 +++++++++ drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h | 4 + 4 files changed, 162 insertions(+)drivers/gpu/drm/xe/xe_ras.c +36
-0@@ -270,6 +270,111 @@ int xe_ras_clear_counter(struct xe_device *xe, u8 severity, u8 component)return 0 ; } +/** +* xe_ras_get_threshold() - Get error counter threshold +* @xe: Xe device instance +* @severity: Error severity to be queried (&enum drm_xe_ras_error_severity) +* @component: Error component to be queried (&enum drm_xe_ras_error_component) +* @threshold: Counter threshold +* +* This function retrieves the error threshold of a specific counter based on +* severity and component. +* +* Return: 0 on success, negative error code on failure. +*/ +int xe_ras_get_threshold (struct xe_device *xe,u8 severity,u8 component,u32 *threshold) +{ +struct xe_ras_get_threshold_response response = {}; +struct xe_ras_get_threshold_request request = {}; +struct xe_sysctrl_mailbox_command command = {}; +struct xe_ras_error_class *counter; +size_t len; +int ret; + + counter = &request.counter; + counter->common.severity =drm_to_xe_ras_severity (severity); + counter->common.component =drm_to_xe_ras_component (component); + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_GET_THRESHOLD , + &request,sizeof (request), &response,sizeof (response)); + +guard (xe_pm_runtime)(xe); + ret =xe_sysctrl_send_command (&xe->sc, &command, &len); +if (ret) { +xe_err (xe,"sysctrl: failed to get threshold %d\n" , ret); +return ret; + } + +if (len !=sizeof (response)) {
drivers/gpu/drm/xe/xe_ras.c int xe_ras_clear_counter(struct xe_device *xe, u8 severity, u8 component) · line 318
Quoted 10 lines
drivers/gpu/drm/xe/xe_ras.c +10
-0+xe_err (xe,"sysctrl: unexpected get threshold response length %zu (expected %zu)\n" , + len,sizeof (response)); +return -EIO ; + } + + counter = &response.counter; + *threshold = response.threshold; + +xe_dbg (xe,"[RAS]: get counter threshold %u for %s %s\n" , *threshold, +comp_to_str (counter->common.component),sev_to_str (counter->common.severity));
"get threshold" to be consistent with <operation> <value> <component> <severity> and other prints
Quoted 45 lines
drivers/gpu/drm/xe/xe_ras.c +45
-0+return 0 ; +} + +/** +* xe_ras_set_threshold() - Set error counter threshold +* @xe: Xe device instance +* @severity: Error severity to be set (&enum drm_xe_ras_error_severity) +* @component: Error component to be set (&enum drm_xe_ras_error_component) +* @threshold: Counter threshold +* +* This function sets the error threshold of a specific counter based on +* severity and component. +* +* Return: 0 on success, negative error code on failure. +*/ +int xe_ras_set_threshold (struct xe_device *xe,u8 severity,u8 component,u32 threshold) +{ +struct xe_ras_set_threshold_response response = {}; +struct xe_ras_set_threshold_request request = {}; +struct xe_sysctrl_mailbox_command command = {}; +struct xe_ras_error_class *counter; +size_t len; +int ret; + + counter = &request.counter; + counter->common.severity =drm_to_xe_ras_severity (severity); + counter->common.component =drm_to_xe_ras_component (component); + request.threshold = threshold; + +xe_sysctrl_create_command (&command,XE_SYSCTRL_GROUP_GFSP ,XE_SYSCTRL_CMD_SET_THRESHOLD , + &request,sizeof (request), &response,sizeof (response)); + +guard (xe_pm_runtime)(xe); + ret =xe_sysctrl_send_command (&xe->sc, &command, &len); +if (ret) { +xe_err (xe,"sysctrl: failed to set threshold %d\n" , ret); +return ret; + } + +if (len !=sizeof (response)) { +xe_err (xe,"sysctrl: unexpected set threshold response length %zu (expected %zu)\n" , + len,sizeof (response)); +return -EIO ; + } +
drivers/gpu/drm/xe/xe_ras.c int xe_ras_clear_counter(struct xe_device *xe, u8 severity, u8 component) · line 373
Quoted 10 lines
drivers/gpu/drm/xe/xe_ras.c +10
-0+ ret =ras_status_to_errno (response.status); +if (ret) { +xe_err (xe,"sysctrl: set threshold command failed with status %#x\n" , + response.status); +return ret; + } + + counter = &response.counter; + + xe_dbg(xe, "[RAS]: set counter threshold %u for %s %s\n", response.threshold,
set threshold
Quoted 64 lines
drivers/gpu/drm/xe/xe_ras.c +4
-0+ comp_to_str(counter->common.component), sev_to_str(counter->common.severity)); +return 0 ; +} +/** * xe_ras_init - Initialize Xe RAS * @xe: xe device instance drivers/gpu/drm/xe/xe_ras.h +2
-0@@ -15,6 +15,8 @@ void xe_ras_counter_threshold_crossed(struct xe_device *xe, struct xe_sysctrl_event_response *response);int xe_ras_get_counter (struct xe_device *xe,u8 severity,u8 component,u32 *value);int xe_ras_clear_counter (struct xe_device *xe,u8 severity,u8 component); +int xe_ras_get_threshold (struct xe_device *xe,u8 severity,u8 component,u32 *threshold); +int xe_ras_set_threshold (struct xe_device *xe,u8 severity,u8 component,u32 threshold);void xe_ras_init (struct xe_device *xe);#endif drivers/gpu/drm/xe/xe_ras_types.h +36
-0@@ -121,4 +121,55 @@ struct xe_ras_clear_counter_response {/** @reserved1: Reserved for future use */ u32 reserved1[3 ]; } __packed; + +/** +* struct xe_ras_get_threshold_request - Request structure for get threshold +*/ +struct xe_ras_get_threshold_request { +/** @counter: Counter to get threshold for */ +struct xe_ras_error_class counter; +/** @reserved: Reserved for future use */ +u32 reserved; +} __packed; + +/** +* struct xe_ras_get_threshold_response - Response structure for get threshold +*/ +struct xe_ras_get_threshold_response { +/** @counter: Counter ID */ +struct xe_ras_error_class counter; +/** @threshold: Threshold value */ +u32 threshold; +/** @reserved: Reserved for future use */ +u32 reserved[4 ]; +} __packed; + +/** +* struct xe_ras_set_threshold_request - Request structure for set threshold +*/ +struct xe_ras_set_threshold_request { +/** @counter: Counter to set threshold for */ +struct xe_ras_error_class counter; +/** @threshold: Threshold value to set */ +u32 threshold; +/** @reserved: Reserved for future use */ +u32 reserved; +} __packed; + +/**
drivers/gpu/drm/xe/xe_ras_types.h struct xe_ras_clear_counter_response { · line 169
Quoted 10 lines
drivers/gpu/drm/xe/xe_ras_types.h +10
-0+* struct xe_ras_set_threshold_response - Response structure for set threshold +*/ +struct xe_ras_set_threshold_response { +/** @counter: Counter ID */ +struct xe_ras_error_class counter; +/** @reserved: Reserved */ +u32 reserved; +/** @threshold: Updated threshold value */ +u32 threshold; +/** @status: Set threshold operation status */
Nit: Already part of set threshold. Can be just operation status
Thanks
Riana
Quoted 26 lines
drivers/gpu/drm/xe/xe_ras_types.h +5
-0+u32 status; +/** @reserved1: Reserved for future use */ + u32 reserved1[2]; +} __packed; +#endif drivers/gpu/drm/xe/xe_sysctrl_mailbox_types.h +4
-0@@ -24,11 +24,15 @@ enum xe_sysctrl_group {* * @XE_SYSCTRL_CMD_GET_COUNTER: Get error counter value * @XE_SYSCTRL_CMD_CLEAR_COUNTER: Clear error counter value +* @XE_SYSCTRL_CMD_GET_THRESHOLD: Retrieve error threshold +* @XE_SYSCTRL_CMD_SET_THRESHOLD: Set error threshold * @XE_SYSCTRL_CMD_GET_PENDING_EVENT: Retrieve pending event */ enum xe_sysctrl_gfsp_cmd {XE_SYSCTRL_CMD_GET_COUNTER =0x03 ,XE_SYSCTRL_CMD_CLEAR_COUNTER =0x04 , +XE_SYSCTRL_CMD_GET_THRESHOLD =0x05 , +XE_SYSCTRL_CMD_SET_THRESHOLD =0x06 ,XE_SYSCTRL_CMD_GET_PENDING_EVENT =0x07 , };
Raag Jadav
reviewerRe: [PATCH v3 3/4] drm/xe/ras: Add support for error threshold
Quoted 4 lines · Riana
Quoted 3 lines · Raag Jadav
System controller allows getting/setting per counter threshold, which it uses to raise error events to the driver. Get/set it using the respective mailbox command.
...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ xe_dbg(xe, "[RAS]: get counter threshold %u for %s %s\n", *threshold, + comp_to_str(counter->common.component), sev_to_str(counter->common.severity));"get threshold" to be consistent with <operation> <value> <component> <severity>
and other prints
I thought "counter threshold" was the correct[1] terminology?
Raag
Tauro, Riana
maintainerRe: [PATCH v3 3/4] drm/xe/ras: Add support for error threshold
Quoted 12 lines · Raag Jadav
Quoted 4 lines · Riana
Quoted 3 lines · Raag Jadav
System controller allows getting/setting per counter threshold, which it uses to raise error events to the driver. Get/set it using the respective mailbox command.
...
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ xe_dbg(xe, "[RAS]: get counter threshold %u for %s %s\n", *threshold, + comp_to_str(counter->common.component), sev_to_str(counter->common.severity));"get threshold" to be consistent with <operation> <value> <component> <severity>
and other prints
Quoted 6 lines
I thought "counter threshold" was the correct[1] terminology?
Raag
That should be fine. But keep all logs consistent. The previous logs have get threshold
Thanks
Riana
Raag Jadav
reviewerPATCH v3 4/4 drm/xe/drm_ras: Wire up error threshold callbacks
In reply to Raag JadavNow that we have get/set error threshold support in xe driver, wire them up to drm_ras so that userspace can make use of the functionality.
$ sudo ynl --family drm_ras --do get-error-threshold \
--json '{"node-id":0, "error-id":2}'
{'error-id': 2, 'error-name': 'soc-internal', 'error-threshold': 16}$ sudo ynl --family drm_ras --do set-error-threshold \
--json '{"node-id":0, "error-id":2, "error-threshold":8}'
None---
v3: Return -ENOENT on info absence (Riana)
--- drivers/gpu/drm/xe/xe_drm_ras.c | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/gpu/drm/xe/xe_drm_ras.c +34 -0
@@ -86,6 +86,38 @@ static int clear_correctable_error_counter(struct drm_ras_node *node, u32 error_return clear_error_counter (xe,DRM_XE_RAS_ERR_SEV_CORRECTABLE , error_id); } +static int query_correctable_error_threshold (struct drm_ras_node *ep,u32 error_id, +const char **name,u32 *val) +{ +struct xe_device *xe = ep->priv; +struct xe_drm_ras *ras = &xe->ras; +struct xe_drm_ras_counter *info = ras->info[DRM_XE_RAS_ERR_SEV_CORRECTABLE ]; + +if (!info || !info[error_id].name) +return -ENOENT ; + +if (!xe->info.has_sysctrl) +return -EOPNOTSUPP ; + + *name = info[error_id].name; +return xe_ras_get_threshold (xe,DRM_XE_RAS_ERR_SEV_CORRECTABLE , error_id, val); +} + +static int set_correctable_error_threshold (struct drm_ras_node *ep,u32 error_id,u32 val) +{ +struct xe_device *xe = ep->priv; +struct xe_drm_ras *ras = &xe->ras; +struct xe_drm_ras_counter *info = ras->info[DRM_XE_RAS_ERR_SEV_CORRECTABLE ]; + +if (!info || !info[error_id].name) +return -ENOENT ; + +if (!xe->info.has_sysctrl) +return -EOPNOTSUPP ; + +return xe_ras_set_threshold (xe,DRM_XE_RAS_ERR_SEV_CORRECTABLE , error_id, val); +} +static struct xe_drm_ras_counter *allocate_and_copy_counters (struct xe_device *xe) {struct xe_drm_ras_counter *counter;
@@ -134,6 +166,8 @@ static int assign_node_params(struct xe_device *xe, struct drm_ras_node *node,if (severity ==DRM_XE_RAS_ERR_SEV_CORRECTABLE ) { node->query_error_counter = query_correctable_error_counter; node->clear_error_counter = clear_correctable_error_counter; + node->query_error_threshold = query_correctable_error_threshold; + node->set_error_threshold = set_correctable_error_threshold; }else { node->query_error_counter = query_uncorrectable_error_counter; node->clear_error_counter = clear_uncorrectable_error_counter;
Signature · 1 line
2.43.0