From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <dri-devel@lists.freedesktop.org>,
<intel-xe@lists.freedesktop.org>,
"Zack McKevitt" <zachary.mckevitt@oss.qualcomm.com>,
Lukas Wunner <lukas@wunner.de>, Lijo Lazar <lijo.lazar@amd.com>,
Hawking Zhang <Hawking.Zhang@amd.com>,
Aravind Iddamsetty <aravind.iddamsetty@linux.intel.com>
Subject: Re: [PATCH 1/2] drm/ras: Introduce the DRM RAS infrastructure over generic netlink
Date: Thu, 6 Nov 2025 08:30:37 -0500 [thread overview]
Message-ID: <aQyi_VL5AzzXsYtT@intel.com> (raw)
In-Reply-To: <20251030183254.10d64ee1@kernel.org>
On Thu, Oct 30, 2025 at 06:32:54PM -0700, Jakub Kicinski wrote:
> On Mon, 29 Sep 2025 17:44:13 -0400 Rodrigo Vivi wrote:
> > Introduces the DRM RAS infrastructure over generic netlink.
>
> Can't comment on the merits but in terms of netlink..
>
> > + ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/drm_ras.yaml --dump list-nodes
>
> We recommend using the "installed" syntax in examples, so:
>
> ynl --family drm_ras
>
> instead of:
>
> ./tools/net/ynl/pyynl/cli.py --spec
> Documentation/netlink/specs/drm_ras.yaml
That's really neat. Thank you
$ sudo ynl --family drm_ras --dump list-nodes
[{'device-name': '00:02.0',
'node-id': 0,
'node-name': 'non-fatal',
'node-type': 'error-counter'},
{'device-name': '00:02.0',
'node-id': 1,
'node-name': 'correctable',
'node-type': 'error-counter'}]
>
> If you're using Fedora or another good distro ynl CLI is packaged (for
> Fedora in kernel-tools). The in-tree syntax is a bit verbose.
I didn't know this tool was getting package with the kernel-tools
I thought it was only helping for debug during the development.
Now I'm even wondering if we really need to code a user-space tool
for this drm-ras, or simply recommending the kernel-tools/ynl as
the official consumer of this API.
>
> > + xa_for_each(&drm_ras_xa, id, node) {
> > + if (id < ctx->restart)
> > + continue;
>
> IIRC xa_for_each_start can make this simpler?
indeed. I will attempt that on the next revision.
>
> > + hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
> > + cb->nlh->nlmsg_seq,
> > + &drm_ras_nl_family, NLM_F_MULTI,
> > + DRM_RAS_CMD_LIST_NODES);
>
> genlmsg_iput()
> genl_info_dump(cb) to get info
I was taking a look to other examples that was using the genl
but I will try this on the next round. Thanks.
>
> > + if (!hdr) {
> > + ret = -EMSGSIZE;
> > + break;
> > + }
> > +
> > + ret = nla_put_u32(skb, DRM_RAS_A_NODE_ATTRS_NODE_ID, node->id);
> > + if (ret) {
> > + genlmsg_cancel(skb, hdr);
> > + break;
> > + }
> > +
> > + ret = nla_put_string(skb, DRM_RAS_A_NODE_ATTRS_DEVICE_NAME,
> > + node->device_name);
> > + if (ret) {
> > + genlmsg_cancel(skb, hdr);
> > + break;
> > + }
> > +
> > + ret = nla_put_string(skb, DRM_RAS_A_NODE_ATTRS_NODE_NAME,
> > + node->node_name);
> > + if (ret) {
> > + genlmsg_cancel(skb, hdr);
> > + break;
> > + }
> > +
> > + ret = nla_put_u32(skb, DRM_RAS_A_NODE_ATTRS_NODE_TYPE,
> > + node->type);
> > + if (ret) {
> > + genlmsg_cancel(skb, hdr);
> > + break;
> > + }
> > +
> > + genlmsg_end(skb, hdr);
> > + }
> > +
> > + if (ret == -EMSGSIZE) {
> > + ctx->restart = id;
> > + return skb->len;
> > + }
> > +
> > + return ret;
>
> Separate handling of -EMSGSIZE and returning skb->len is not necessary
> as of a few releases ago. Just return ret; core will do the right thing
> if ret == -EMSGSIZE and skb->len != 0
Any good modern example that I could get the right inspiration from?
>
>
> > +static int doit_reply_value(struct genl_info *info, u32 node_id,
> > + u32 error_id)
> > +{
> > + struct sk_buff *msg;
> > + struct nlattr *hdr;
> > + const char *error_name;
> > + u32 value;
> > + int ret;
> > +
> > + msg = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
> > + if (!msg)
> > + return -ENOMEM;
> > + hdr = genlmsg_put_reply(msg, info, &drm_ras_nl_family, 0,
> > + DRM_RAS_CMD_QUERY_ERROR_COUNTER);
> > + if (!hdr) {
> > + nlmsg_free(msg);
> > + return -EMSGSIZE;
> > + }
> > +
> > + ret = get_node_error_counter(node_id, error_id,
> > + &error_name, &value);
> > + if (ret)
> > + return ret;
> > +
> > + ret = msg_reply_value(msg, error_id, error_name, value);
> > + if (ret)
> > + return ret;
>
> Leaking message on errors?
good catch! will fix
Thanks a lot,
Rodrigo.
>
> > + genlmsg_end(msg, hdr);
> > +
> > + return genlmsg_reply(msg, info);
> > +}
>
next prev parent reply other threads:[~2025-11-06 13:30 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 21:44 [PATCH 0/2] Introduce DRM_RAS using generic netlink for RAS Rodrigo Vivi
2025-09-29 21:44 ` [PATCH 1/2] drm/ras: Introduce the DRM RAS infrastructure over generic netlink Rodrigo Vivi
2025-10-31 1:32 ` Jakub Kicinski
2025-11-06 13:30 ` Rodrigo Vivi [this message]
2025-11-06 14:58 ` Jakub Kicinski
2025-09-29 21:44 ` [PATCH 2/2] drm/xe: Introduce the usage of drm_ras with supported HW errors Rodrigo Vivi
2025-09-30 2:07 ` kernel test robot
2025-09-29 21:49 ` ✗ CI.checkpatch: warning for Introduce DRM_RAS using generic netlink for RAS Patchwork
2025-09-29 21:50 ` ✗ CI.KUnit: failure " Patchwork
2025-10-02 20:38 ` [PATCH 0/2] " Zack McKevitt
2025-10-28 19:14 ` Rodrigo Vivi
2025-11-06 13:42 ` Rodrigo Vivi
2025-11-07 20:20 ` Zack McKevitt
2025-11-08 3:01 ` Rodrigo Vivi
2025-12-09 21:40 ` Rodrigo Vivi
2025-10-28 19:13 ` DRM_RAS for CPER Error logging?! Rodrigo Vivi
2025-10-29 2:00 ` Zhang, Hawking
2025-11-06 13:16 ` Rodrigo Vivi
2025-11-10 3:34 ` Dave Airlie
2025-11-10 5:13 ` John Hubbard
2025-11-10 20:35 ` Rodrigo Vivi
2025-11-17 14:39 ` Jason Gunthorpe
2025-10-30 14:47 ` Rodrigo Vivi
2025-10-30 15:37 ` DRM_RAS (netlink genl family) " Rodrigo Vivi
2025-10-31 5:38 ` DRM_RAS " Lukas Wunner
2025-11-06 13:08 ` Rodrigo Vivi
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=aQyi_VL5AzzXsYtT@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=Hawking.Zhang@amd.com \
--cc=aravind.iddamsetty@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=kuba@kernel.org \
--cc=lijo.lazar@amd.com \
--cc=lukas@wunner.de \
--cc=zachary.mckevitt@oss.qualcomm.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.