All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Mallesh, Koujalagi" <mallesh.koujalagi@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: "Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Matthew Brost" <matthew.brost@intel.com>
Subject: Re: [PATCH 02/19] drm/xe: Introduce xe_any helpers
Date: Tue, 28 Jul 2026 10:53:55 +0530	[thread overview]
Message-ID: <06e16c41-41fb-4335-b41f-fe87cdbfe9c1@intel.com> (raw)
In-Reply-To: <20260723203754.3782-3-michal.wajdeczko@intel.com>


On 24-07-2026 02:07 am, 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. Also add
> conversion helpers to/from the struct 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>
> ---
>   drivers/gpu/drm/xe/xe_any.h | 107 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 107 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..c633c6ee83b5
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_any.h
> @@ -0,0 +1,107 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#ifndef _XE_ANY_H_
> +#define _XE_ANY_H_
> +
> +struct pci_dev;
> +struct xe_device;
> +struct xe_gt;
> +struct xe_tile;
> +
> +/**
> + * 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),								\
> +		 type * : (any),						\
> +		 const 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)
> +
> +/**
> + * xe_any_to_xe() - Get 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),								\
> +		 struct pci_dev * : pdev_to_xe_device((struct pci_dev *)(any)),	\
> +		 struct xe_device * : (any),					\
> +		 struct xe_tile * : ((struct xe_tile *)(any))->xe,		\
> +		 struct xe_gt * : ((struct xe_gt *)(any))->tile->xe)
> +

When we are supporting constant as well, need add constant sibling as 
well right.

Like:

  struct xe_tile *         : ((struct xe_tile *)(any))->xe, \

const struct xe_tile *   : ((const struct xe_tile *)(any))->xe, \


Thanks,

-/Mallesh

> +/**
> + * xe_any_to_dev() - Get the &struct 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_dev(any)							\
> +	_Generic((any),								\
> +		 struct device * : (any),					\
> +		 default : xe_any_to_xe(any)->drm.dev)
> +
> +/**
> + * xe_any_to_pdev() - Get 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),								\
> +		 struct pci_dev * : (any),					\
> +		 default : to_pci_dev(xe_any_to_dev(any)))
> +
> +/**
> + * xe_any_id() - Get the identifier of the undrlying any object pointer.
> + * @any: the &pci_dev or the &xe_device or &xe_tile or &xe_gt pointer
> + *
> + * Return: the identifier of the object, or 0 if nor applicable/available.
> + */
> +#define xe_any_id(any)							\
> +	_Generic((any),							\
> +		 struct pci_dev * : 0,						\
> +		 struct xe_device * : 0,					\
> +		 struct xe_tile * : ((struct xe_tile *)(any))->id,		\
> +		 struct xe_gt * : ((struct xe_gt *)(any))->info.id)
> +
> +#endif

  reply	other threads:[~2026-07-28  5:24 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 20:37 [PATCH 00/19] drm/xe: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 01/19] drm/xe/log: " Michal Wajdeczko
2026-07-24 13:01   ` Aravind Iddamsetty
2026-07-24 14:34     ` Michal Wajdeczko
2026-07-28 19:04       ` Rodrigo Vivi
2026-07-23 20:37 ` [PATCH 02/19] drm/xe: Introduce xe_any helpers Michal Wajdeczko
2026-07-28  5:23   ` Mallesh, Koujalagi [this message]
2026-07-23 20:37 ` [PATCH 03/19] drm/xe/log: Add simple helpers for xe_log_emit Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 04/19] drm/xe/log: Allow to emit SIGID dmesg/cper separately Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 05/19] drm/xe/log: Add Tile/GT decorations for dmesg message Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 06/19] drm/xe/log: Introduce structured log components Michal Wajdeczko
2026-07-24 13:28   ` Aravind Iddamsetty
2026-07-24 14:45     ` Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 07/19] drm/xe/log: Add component based SIGID log helper Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 08/19] drm/xe/log: Add errno-only SIGID log helpers Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 09/19] drm/xe/log: Add hardware error signatures Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 10/19] drm/xe/log: Extend components list with hardware items Michal Wajdeczko
2026-07-24 11:49   ` Aravind Iddamsetty
2026-07-24 15:11     ` Michal Wajdeczko
2026-07-28 14:47       ` Aravind Iddamsetty
2026-07-28 16:31         ` Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 11/19] drm/xe/tests: Add Kunit tests for xe_log Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 12/19] drm/xe: Report 'probe blocked' error using SIGID Michal Wajdeczko
2026-07-24 12:28   ` Aravind Iddamsetty
2026-07-24 14:19     ` Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 13/19] drm/xe: Report 'device wedged' errors " Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 14/19] drm/xe: Report 'Survivability Mode' " Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 15/19] drm/xe/guc: Report 'GuC mmio' " Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 16/19] drm/xe/pcode: Report 'Mailbox failed' error " Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 17/19] drm/xe/gt: Report 'reset failed' errors " Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 18/19] drm/xe/gt: Report 'pagefault' " Michal Wajdeczko
2026-07-23 22:02   ` Michal Wajdeczko
2026-07-23 20:37 ` [PATCH 19/19] drm/xe/pci: Report 'cannot re-enable' error " Michal Wajdeczko
2026-07-23 20:44 ` ✗ CI.checkpatch: warning for drm/xe: Add structured SIGID error logging infrastructure Patchwork
2026-07-23 20:45 ` ✓ CI.KUnit: success " Patchwork
2026-07-23 21:35 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-07-24 18:35 ` ✗ 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=06e16c41-41fb-4335-b41f-fe87cdbfe9c1@intel.com \
    --to=mallesh.koujalagi@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=michal.wajdeczko@intel.com \
    --cc=rodrigo.vivi@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 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.