From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: intel-xe@lists.freedesktop.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Mallesh Koujalagi" <mallesh.koujalagi@intel.com>,
"Jani Nikula" <jani.nikula@intel.com>
Subject: Re: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers
Date: Thu, 13 Aug 2026 12:51:38 -0400 [thread overview]
Message-ID: <an32GlSl8iuwKFPY@intel.com> (raw)
In-Reply-To: <20260812191450.11690-2-michal.wajdeczko@intel.com>
On Wed, Aug 12, 2026 at 09:14:17PM +0200, Michal Wajdeczko wrote:
> In upcoming patches we want to define macros that will work with
> either xe_device or xe_tile or xe_gt pointers. To make them work
> and to allow compiler optimizations, introduce set of helpers
> that will return either expected pointer type or NULL or make
> necessary conversions to/from the struct xe/device/pci_dev.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> #v2
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Reviewed-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com> #v2
> Cc: Jani Nikula <jani.nikula@intel.com>
> ---
> v2: add include (Sashiko) and const support (Mallesh)
> reuse existing to_xe() helpers (Michal)
> v3: fix another typo and fix to_pdev (Sashiko)
> use assoc macros/helpers (Jani)
> add support for drm_device (Michal)
> ---
> drivers/gpu/drm/xe/xe_any.h | 137 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 137 insertions(+)
> create mode 100644 drivers/gpu/drm/xe/xe_any.h
>
> diff --git a/drivers/gpu/drm/xe/xe_any.h b/drivers/gpu/drm/xe/xe_any.h
> new file mode 100644
> index 000000000000..5d97afa76915
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_any.h
> @@ -0,0 +1,137 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#ifndef _XE_ANY_H_
> +#define _XE_ANY_H_
> +
> +#include "xe_device.h"
> +
> +#define __xe_any_to_self_assoc(type, any) \
> + const type * : (any), \
> + type * : (any)
> +
> +/**
> + * xe_any_if_type() - Get the pointer only if it is @type pointer.
> + * @any: any pointer
> + * @type: data type to look for
> + *
> + * Return: the @type pointer or NULL.
> + */
> +#define xe_any_if_type(any, type) \
> + _Generic((any), \
> + __xe_any_to_self_assoc(type, (any)), \
> + default : NULL)
> +
> +/**
> + * xe_any_if_gt() - Get the pointer only if it is &xe_gt.
> + * @any: any pointer
> + *
> + * Return: the @xe_gt pointer or NULL.
> + */
> +#define xe_any_if_gt(any) xe_any_if_type((any), struct xe_gt)
> +
> +/**
> + * xe_any_if_tile() - Get the pointer only if it is &xe_tile.
> + * @any: any pointer
> + *
> + * Return: the @xe_tile pointer or NULL.
> + */
> +#define xe_any_if_tile(any) xe_any_if_type((any), struct xe_tile)
> +
> +/**
> + * xe_any_if_xe() - Get the pointer only if it is &xe_device.
> + * @any: any pointer
> + *
> + * Return: the @xe_device pointer or NULL.
> + */
> +#define xe_any_if_xe(any) xe_any_if_type((any), struct xe_device)
> +
> +/**
> + * xe_any_if_pdev() - Get the pointer only if it is &pci_dev.
> + * @any: any pointer
> + *
> + * Return: the @pci_dev pointer or NULL.
> + */
> +#define xe_any_if_pdev(any) xe_any_if_type((any), struct pci_dev)
> +
> +#define __xe_any_to_other_assoc(const, from, other, p) \
> + const struct from * : __##from##_to_##other((const struct from *)(p))
> +
> +#define __xe_tile_to_xe_device(p) tile_to_xe(p)
> +#define __xe_gt_to_xe_device(p) gt_to_xe(p)
> +#define __pci_dev_to_xe_device(p) pdev_to_xe_device(p)
> +#define __device_to_xe_device(p) kdev_to_xe_device(p)
> +#define __drm_device_to_xe_device(p) to_xe_device(p)
> +#define __pci_dev_to_device(p) (&(p)->dev)
> +
> +/**
> + * xe_any_to_xe() - Obtain the &xe_device pointer.
> + * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
> + *
> + * Return: the @xe_device pointer or backpointer.
> + */
> +#define xe_any_to_xe(any) \
> + _Generic((any), \
> + __xe_any_to_self_assoc(struct xe_device, (any)), \
> + __xe_any_to_other_assoc(/* */, xe_tile, xe_device, (any)), \
> + __xe_any_to_other_assoc(const, xe_tile, xe_device, (any)), \
> + __xe_any_to_other_assoc(/* */, xe_gt, xe_device, (any)), \
> + __xe_any_to_other_assoc(const, xe_gt, xe_device, (any)), \
> + __xe_any_to_other_assoc(, drm_device, xe_device, (any)), \
> + __xe_any_to_other_assoc(, pci_dev, xe_device, (any)), \
> + __xe_any_to_other_assoc(, device, xe_device, (any)))
> +
> +/**
> + * xe_any_to_drm() - Obtain the &drm_device pointer.
> + * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
> + *
> + * Return: the @drm_device pointer or backpointer.
> + */
> +#define xe_any_to_drm(any) \
> + _Generic((any), \
> + __xe_any_to_self_assoc(struct drm_device, (any)), \
> + default : &xe_any_to_xe(any)->drm)
> +
> +/**
> + * xe_any_to_dev() - Obtain the &device pointer.
> + * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
> + *
> + * Return: the @device pointer or backpointer.
> + */
> +#define xe_any_to_dev(any) \
> + _Generic((any), \
> + __xe_any_to_self_assoc(struct device, (any)), \
> + __xe_any_to_other_assoc(, pci_dev, device, (any)), \
> + default : xe_any_to_drm(any)->dev)
> +
> +/**
> + * xe_any_to_pdev() - Obtain the &pci_dev pointer.
> + * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
> + *
> + * Return: the @pci_dev pointer or backpointer.
> + */
> +#define xe_any_to_pdev(any) \
> + _Generic((any), \
> + __xe_any_to_self_assoc(struct pci_dev, (any)), \
> + default : to_pci_dev(xe_any_to_dev(any)))
> +
> +#define __xe_tile_to_id(p) ((p)->id)
> +#define __xe_gt_to_id(p) ((p)->info.id)
> +
> +/**
> + * xe_any_id() - Get the identifier of the underlying object.
> + * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
> + *
> + * Return: the identifier of the object, or 0 if not applicable/available.
> + */
> +#define xe_any_id(any) \
> + _Generic((any), \
> + __xe_any_to_other_assoc(/* */, xe_tile, id, (any)), \
> + __xe_any_to_other_assoc(const, xe_tile, id, (any)), \
> + __xe_any_to_other_assoc(/* */, xe_gt, id, (any)), \
> + __xe_any_to_other_assoc(const, xe_gt, id, (any)), \
> + default : 0)
> +
> +#endif
> --
> 2.47.1
>
next prev parent reply other threads:[~2026-08-13 16:51 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 19:14 [PATCH v4 00/32] drm/xe: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 01/32] drm/xe: Introduce xe_any helpers Michal Wajdeczko
2026-08-12 19:29 ` sashiko-bot
2026-08-13 16:51 ` Rodrigo Vivi [this message]
2026-08-12 19:14 ` [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-08-13 13:33 ` Mallesh, Koujalagi
2026-08-13 13:57 ` Michal Wajdeczko
2026-08-13 13:42 ` Nilawar, Badal
2026-08-13 19:00 ` Rodrigo Vivi
2026-08-13 18:51 ` Rodrigo Vivi
2026-08-12 19:14 ` [PATCH v4 03/32] drm/xe/log: Introduce structured component/location identifiers Michal Wajdeczko
2026-08-13 17:20 ` Rodrigo Vivi
2026-08-12 19:14 ` [PATCH v4 04/32] drm/xe/log: Add component/location decorations to dmesg Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 05/32] drm/xe/log: Add SIGID log helpers for severity Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 06/32] drm/xe/log: Add SIGID log helpers for location Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 07/32] drm/xe/log: Add SIGID log helpers for location & severity Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 08/32] drm/xe/log: Add SIGID log helpers for components Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 09/32] drm/xe/log: Add SIGID log helpers for component & severity Michal Wajdeczko
2026-08-13 4:38 ` Mallesh, Koujalagi
2026-08-12 19:14 ` [PATCH v4 10/32] drm/xe/log: Add SIGID log helpers for errno-only Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 11/32] drm/xe/log: Index all SIGID printk messages Michal Wajdeczko
2026-08-12 19:35 ` sashiko-bot
2026-08-13 12:31 ` Mallesh, Koujalagi
2026-08-13 12:54 ` Michal Wajdeczko
2026-08-13 13:29 ` Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 12/32] drm/xe/log: Add hardware error signatures Michal Wajdeczko
2026-08-13 5:03 ` Mallesh, Koujalagi
2026-08-12 19:14 ` [PATCH v4 13/32] drm/xe/log: Extend components list with hardware items Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 14/32] drm/xe/ras: Check RAS and LOG component definitions Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 15/32] drm/xe/kunit: Setup driver data in the test device Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 16/32] drm/xe/tests: Add Kunit tests for xe_log Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 17/32] drm/xe/tests: Add kunit tests for xe_any Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 18/32] drm/xe: Report 'probe blocked' error using SIGID Michal Wajdeczko
2026-08-13 6:26 ` Mallesh, Koujalagi
2026-08-12 19:14 ` [PATCH v4 19/32] drm/xe: Report all probe errors " Michal Wajdeczko
2026-08-13 6:50 ` Mallesh, Koujalagi
2026-08-13 9:12 ` Michal Wajdeczko
2026-08-13 9:58 ` Mallesh, Koujalagi
2026-08-13 10:09 ` Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' " Michal Wajdeczko
2026-08-13 8:38 ` Mallesh, Koujalagi
2026-08-13 9:28 ` Michal Wajdeczko
2026-08-13 10:07 ` Mallesh, Koujalagi
2026-08-13 10:18 ` Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 21/32] drm/xe/survivability: Report 'sysfs failure' error " Michal Wajdeczko
2026-08-13 8:54 ` Mallesh, Koujalagi
2026-08-12 19:14 ` [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status " Michal Wajdeczko
2026-08-13 10:52 ` Mallesh, Koujalagi
2026-08-13 11:01 ` Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime " Michal Wajdeczko
2026-08-13 11:40 ` Mallesh, Koujalagi
2026-08-13 12:46 ` Michal Wajdeczko
2026-08-13 13:16 ` Mallesh, Koujalagi
2026-08-12 19:14 ` [PATCH v4 24/32] drm/xe: Report 'device wedged' errors " Michal Wajdeczko
2026-08-12 22:28 ` Rodrigo Vivi
2026-08-13 11:56 ` Mallesh, Koujalagi
2026-08-12 19:14 ` [PATCH v4 25/32] drm/xe/pcode: Report 'Mailbox failed' error " Michal Wajdeczko
2026-08-13 12:10 ` Bhadane, Dnyaneshwar
2026-08-13 12:35 ` Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 26/32] drm/xe/pcode: Report 'timeout, retrying' " Michal Wajdeczko
2026-08-12 19:51 ` sashiko-bot
2026-08-13 16:46 ` Umesh Nerlige Ramappa
2026-08-13 18:42 ` Rodrigo Vivi
2026-08-12 19:14 ` [PATCH v4 27/32] drm/xe/pcode: Report 'initialization timedout' " Michal Wajdeczko
2026-08-12 19:49 ` sashiko-bot
2026-08-13 18:40 ` Rodrigo Vivi
2026-08-12 19:14 ` [PATCH v4 28/32] drm/xe/guc: Report 'GuC mmio' errors " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 29/32] drm/xe/gt: Report 'reset failed' " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 30/32] drm/xe/gt: Report 'Fault response' pagefault error " Michal Wajdeczko
2026-08-13 18:37 ` Rodrigo Vivi
2026-08-13 19:46 ` Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 31/32] drm/xe/gt: Report 'Queue full' " Michal Wajdeczko
2026-08-13 17:25 ` Rodrigo Vivi
2026-08-12 19:14 ` [PATCH v4 32/32] drm/xe/pci: Report 'cannot re-enable' " Michal Wajdeczko
2026-08-13 17:21 ` Rodrigo Vivi
2026-08-12 19:22 ` ✗ CI.checkpatch: warning for drm/xe: Add structured SIGID error logging infrastructure (rev4) Patchwork
2026-08-12 19:24 ` ✓ CI.KUnit: success " Patchwork
2026-08-12 20:34 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-08-13 2:47 ` ✗ Xe.CI.FULL: " 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=an32GlSl8iuwKFPY@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=matthew.brost@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=thomas.hellstrom@linux.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox