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 v2 01/22] drm/xe: Introduce xe_any helpers
Date: Wed, 29 Jul 2026 12:53:43 +0530	[thread overview]
Message-ID: <803f1acf-4e20-489a-a44e-abe590cbd45e@intel.com> (raw)
In-Reply-To: <20260728161039.579-2-michal.wajdeczko@intel.com>


On 28-07-2026 09:40 pm, 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>
> ---
> v2: add include (Sashiko) and const support (Mallesh)
>      reuse existing to_xe() helpers (Michal)
> ---
>   drivers/gpu/drm/xe/xe_any.h | 112 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 112 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..a2b1e42fbc5c
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_any.h
> @@ -0,0 +1,112 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2026 Intel Corporation
> + */
> +
> +#ifndef _XE_ANY_H_
> +#define _XE_ANY_H_
> +
> +#include "xe_device.h"
> +
> +/**
> + * 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() - 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),									\
> +		 struct xe_device * : (any),						\
> +		 const struct xe_device * : (any),					\
> +		 struct xe_tile * : tile_to_xe((struct xe_tile *)(any)),		\
> +		 const struct xe_tile * : tile_to_xe((const struct xe_tile *)(any)),	\
> +		 struct xe_gt * : gt_to_xe((struct xe_gt *)(any)),			\
> +		 const struct xe_gt * : gt_to_xe((const struct xe_gt *)(any)),		\
> +		 struct pci_dev * : pdev_to_xe_device((struct pci_dev *)(any)),		\
> +		 struct device * : kdev_to_xe_device((struct device *)(any)))
> +
> +/**
> + * 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 @xe_device pointer or backpointer.
> + */
should be device pointer right.
> +#define xe_any_to_dev(any)							\
> +	_Generic((any),								\
> +		 struct device * : (any),					\
> +		 default : xe_any_to_xe(any)->drm.dev)
> +
Add const struct device* as well.
> +/**
> + * 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),								\
> +		 struct pci_dev * : (any),					\
> +		 default : to_pci_dev(xe_any_to_dev(any)))
Please add struct pci_dev * : &((struct pci_dev *)(any))->dev  and const 
struct pci_dev *.
> +
> +/**
> + * 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 nor applicable/available.
> + */

Typo: please change "nor" to "not"

With all above cosmetic changes.

Reviewed-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>

> +#define xe_any_id(any)								\
> +	_Generic((any),								\
> +		 struct xe_gt * : ((struct xe_gt *)(any))->info.id,		\
> +		 const struct xe_gt * : ((const struct xe_gt *)(any))->info.id,	\
> +		 struct xe_tile * : ((struct xe_tile *)(any))->id,		\
> +		 const struct xe_tile * : ((const struct xe_tile *)(any))->id,	\
> +		 struct xe_device * : 0,					\
> +		 const struct xe_device * : 0,					\
> +		 struct pci_dev * : 0,						\
> +		 struct device * : 0)
> +
> +#endif

  parent reply	other threads:[~2026-07-29  7:23 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 16:10 [PATCH v2 00/22] drm/xe: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 01/22] drm/xe: Introduce xe_any helpers Michal Wajdeczko
2026-07-28 19:11   ` Rodrigo Vivi
2026-07-29  7:23   ` Mallesh, Koujalagi [this message]
2026-07-29  7:58   ` Jani Nikula
2026-07-28 16:10 ` [PATCH v2 02/22] drm/xe/log: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 03/22] drm/xe/log: Introduce structured component/location identifiers Michal Wajdeczko
2026-07-28 19:13   ` Rodrigo Vivi
2026-07-28 16:10 ` [PATCH v2 04/22] drm/xe/log: Add component/location decorations to dmesg Michal Wajdeczko
2026-07-28 19:16   ` Rodrigo Vivi
2026-07-28 16:10 ` [PATCH v2 05/22] drm/xe/log: Add SIGID log helpers for severity Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 06/22] drm/xe/log: Add SIGID log helpers for location Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 07/22] drm/xe/log: Add SIGID log helpers for location & severity Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 08/22] drm/xe/log: Add SIGID log helpers for components Michal Wajdeczko
2026-07-29  8:06   ` Jani Nikula
2026-07-29 13:32     ` Michal Wajdeczko
2026-07-29 15:02       ` Jani Nikula
2026-07-28 16:10 ` [PATCH v2 09/22] drm/xe/log: Add SIGID log helpers for errno-only Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 10/22] drm/xe/log: Add hardware error signatures Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 11/22] drm/xe/log: Extend components list with hardware items Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 12/22] drm/xe/ras: Check RAS and LOG component definitions Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 13/22] drm/xe/kunit: Setup driver data in the test device Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 14/22] drm/xe/tests: Add Kunit tests for xe_log Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 15/22] drm/xe: Report 'probe blocked' error using SIGID Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 16/22] drm/xe: Report 'device wedged' errors " Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 17/22] drm/xe: Report 'Survivability Mode' " Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 18/22] drm/xe/guc: Report 'GuC mmio' " Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 19/22] drm/xe/pcode: Report 'Mailbox failed' error " Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 20/22] drm/xe/gt: Report 'reset failed' errors " Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 21/22] drm/xe/gt: Report 'pagefault' " Michal Wajdeczko
2026-07-28 16:10 ` [PATCH v2 22/22] drm/xe/pci: Report 'cannot re-enable' error " Michal Wajdeczko
2026-07-28 16:17 ` ✗ CI.checkpatch: warning for drm/xe: Add structured SIGID error logging infrastructure (rev2) Patchwork
2026-07-28 16:18 ` ✓ CI.KUnit: success " Patchwork
2026-07-28 17:01 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-07-28 20:57 ` ✗ Xe.CI.FULL: " Patchwork
2026-07-29  8:31 ` [PATCH v2 00/22] drm/xe: Add structured SIGID error logging infrastructure Jani Nikula

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=803f1acf-4e20-489a-a44e-abe590cbd45e@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.