Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michal Wajdeczko" <michal.wajdeczko@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers
Date: Wed, 12 Aug 2026 19:29:55 +0000	[thread overview]
Message-ID: <20260812192956.20F791F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260812191450.11690-2-michal.wajdeczko@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Macros xe_any_to_drm, xe_any_to_dev, and xe_any_to_pdev fail to compile when passed const pointers due to a C11 constraint violation in the underlying xe_any_to_xe macro.
- [Low] The macros xe_any_if_type and xe_any_id silently discard side effects for unmatched types.
--

--- Patch [1]: [PATCH v4 01/32] drm/xe: Introduce xe_any helpers ---
commit 933eba9892b749844655f0d89de25fa2cfc22f5b
Author: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: drm/xe: Introduce xe_any helpers

This commit introduces a set of macros using _Generic to convert between
xe_device, xe_tile, xe_gt, drm_device, pci_dev, and device pointers. It
provides type-checking helpers and object identifier retrievals across the
xe driver.

> diff --git a/drivers/gpu/drm/xe/xe_any.h b/drivers/gpu/drm/xe/xe_any.h
> new file mode 100644
> index 0000000000000..5d97afa76915a
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_any.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),								\
> +		 __xe_any_to_self_assoc(type, (any)),				\
> +		 default : NULL)

[Severity: Low]
Could this macro discard side effects for unmatched types?

If a caller passes an expression with side effects, like a function call or
pointer increment, to xe_any_if_type() or any macro that uses it, the side
effects will be evaluated if the type matches.

However, if the type falls to the default branch, the side effects will be
completely discarded because (any) is not evaluated in the default : NULL
association.

[ ... ]
> +/**
> + * 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)

[Severity: Low]
Will this cause a C11 constraint violation during compilation if the parameter
is a const struct drm_device pointer?

When xe_any_to_drm is called with a const struct drm_device pointer, it falls
to the default branch which contains xe_any_to_xe(any).

The xe_any_to_xe macro lacks const associations for drm_device, pci_dev, and
device, and it does not have a default branch. This will cause compilation to
fail even though it is inside an unselected branch of the outer _Generic block.

[ ... ]
> +/**
> + * 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)

[Severity: Low]
Does this macro also discard side effects for unmatched types, similar to
xe_any_if_type?

If (any) is an expression with side effects, they are evaluated if the type
matches, but are lost in the default : 0 branch because (any) is omitted.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260812191450.11690-1-michal.wajdeczko@intel.com?part=1

  reply	other threads:[~2026-08-12 22:17 UTC|newest]

Thread overview: 42+ 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 [this message]
2026-08-12 19:14 ` [PATCH v4 02/32] drm/xe/log: Add structured SIGID error logging infrastructure Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 03/32] drm/xe/log: Introduce structured component/location identifiers Michal Wajdeczko
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-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-12 19:14 ` [PATCH v4 12/32] drm/xe/log: Add hardware error signatures Michal Wajdeczko
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-12 19:14 ` [PATCH v4 19/32] drm/xe: Report all probe errors " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 20/32] drm/xe/survivability: Report 'boot status' " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 21/32] drm/xe/survivability: Report 'sysfs failure' error " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 22/32] drm/xe/survivability: Report 'Boot Mode enabled' status " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 23/32] drm/xe/survivability: Report 'Runtime " Michal Wajdeczko
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-12 19:14 ` [PATCH v4 25/32] drm/xe/pcode: Report 'Mailbox failed' error " 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-12 19:14 ` [PATCH v4 27/32] drm/xe/pcode: Report 'initialization timedout' " Michal Wajdeczko
2026-08-12 19:49   ` sashiko-bot
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-12 19:14 ` [PATCH v4 31/32] drm/xe/gt: Report 'Queue full' " Michal Wajdeczko
2026-08-12 19:14 ` [PATCH v4 32/32] drm/xe/pci: Report 'cannot re-enable' " Michal Wajdeczko
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=20260812192956.20F791F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=michal.wajdeczko@intel.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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