From: Jani Nikula <jani.nikula@linux.intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>,
intel-xe@lists.freedesktop.org
Cc: Matt Roper <matthew.d.roper@intel.com>,
Lucas De Marchi <lucas.demarchi@intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-xe] [PATCH 17/17] drm/xe: Move helper macros to separate header
Date: Wed, 19 Apr 2023 19:17:14 +0300 [thread overview]
Message-ID: <875y9ryhh1.fsf@intel.com> (raw)
In-Reply-To: <20230419074440.4006398-18-lucas.demarchi@intel.com>
On Wed, 19 Apr 2023, Lucas De Marchi <lucas.demarchi@intel.com> wrote:
> The macros to handle the RTP tables are very scary, but shouldn't be
> used outside of the header adding the infra. Move it to a separate
> header and make sure it's only included when it can be.
I've wondered if the macros are more trouble than they're worth...
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> drivers/gpu/drm/xe/Makefile | 2 +-
> drivers/gpu/drm/xe/tests/xe_rtp_test.c | 2 +-
> drivers/gpu/drm/xe/xe_rtp.h | 40 +++------------------
> drivers/gpu/drm/xe/xe_rtp_helpers.h | 48 ++++++++++++++++++++++++++
> 4 files changed, 55 insertions(+), 37 deletions(-)
> create mode 100644 drivers/gpu/drm/xe/xe_rtp_helpers.h
>
> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile
> index aceca651de57..f3c38815011e 100644
> --- a/drivers/gpu/drm/xe/Makefile
> +++ b/drivers/gpu/drm/xe/Makefile
> @@ -225,7 +225,7 @@ endif
>
> # header test
> always-$(CONFIG_DRM_XE_WERROR) += \
> - $(patsubst %.h,%.hdrtest, $(shell cd $(srctree)/$(src) && find * -name '*.h' $(skipdisplay)))
> + $(patsubst %.h,%.hdrtest, $(shell cd $(srctree)/$(src) && find * -name '*.h' -not -path xe_rtp_helpers.h $(skipdisplay)))
>
> quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@)
> cmd_hdrtest = $(CC) -DHDRTEST $(filter-out $(CFLAGS_GCOV), $(c_flags)) $(cflags-display) -S -o /dev/null -x c /dev/null -include $<; touch $@
> diff --git a/drivers/gpu/drm/xe/tests/xe_rtp_test.c b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
> index ad917638d088..a5ec9ae22156 100644
> --- a/drivers/gpu/drm/xe/tests/xe_rtp_test.c
> +++ b/drivers/gpu/drm/xe/tests/xe_rtp_test.c
> @@ -57,7 +57,7 @@ static const struct rtp_test_case cases[] = {
> .entries = (const struct xe_rtp_entry[]) {
> { XE_RTP_NAME("basic-1"),
> XE_RTP_RULES(FUNC(match_yes)),
> - XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(1)))
> + XE_RTP_ACTIONS(SET(REGULAR_REG1, REG_BIT(0)))
Ah, this was changed earlier in the series.
> },
> { XE_RTP_NAME("basic-2"),
> XE_RTP_RULES(FUNC(match_yes)),
> diff --git a/drivers/gpu/drm/xe/xe_rtp.h b/drivers/gpu/drm/xe/xe_rtp.h
> index ca458e4b0d3c..7242342f4971 100644
> --- a/drivers/gpu/drm/xe/xe_rtp.h
> +++ b/drivers/gpu/drm/xe/xe_rtp.h
> @@ -9,8 +9,13 @@
> #include <linux/types.h>
> #include <linux/xarray.h>
>
> +#define _XE_RTP_INCLUDE_PRIVATE_HELPERS
> +
> +#include "xe_rtp_helpers.h"
> #include "xe_rtp_types.h"
>
> +#undef _XE_RTP_INCLUDE_PRIVATE_HELPERS
> +
> /*
> * Register table poke infrastructure
> */
> @@ -19,41 +24,6 @@ struct xe_hw_engine;
> struct xe_gt;
> struct xe_reg_sr;
>
> -/*
> - * Helper macros - not to be used outside this header.
> - */
> -#define _XE_ESC(...) __VA_ARGS__
> -#define _XE_COUNT_ARGS(...) _XE_ESC(__XE_COUNT_ARGS(__VA_ARGS__,5,4,3,2,1,))
> -#define __XE_COUNT_ARGS(_,_5,_4,_3,_2,X_,...) X_
> -
> -#define _XE_CONCAT(a, b) __XE_CONCAT(a, b)
> -#define __XE_CONCAT(a, b) a ## b
> -
> -#define _XE_FIRST(...) _XE_ESC(__XE_FIRST(__VA_ARGS__,))
> -#define __XE_FIRST(x_,...) x_
> -#define _XE_TUPLE_TAIL(...) _XE_ESC(__XE_TUPLE_TAIL(__VA_ARGS__))
> -#define __XE_TUPLE_TAIL(x_,...) (__VA_ARGS__)
> -
> -#define __XE_PASTE_SEP_COMMA ,
> -#define __XE_PASTE_SEP_BITWISE_OR |
> -#define __XE_PASTE(prefix_, sep_, args_) _XE_ESC(_XE_CONCAT(__XE_PASTE_,_XE_COUNT_ARGS args_)(prefix_, sep_, args_))
> -#define __XE_PASTE_1(prefix_, sep_, args_) prefix_ args_
> -#define __XE_PASTE_2(prefix_, sep_, args_) prefix_(_XE_FIRST args_) __XE_PASTE_SEP_ ## sep_ __XE_PASTE_1(prefix_, sep_, _XE_TUPLE_TAIL args_)
> -#define __XE_PASTE_3(prefix_, sep_, args_) prefix_(_XE_FIRST args_) __XE_PASTE_SEP_ ## sep_ __XE_PASTE_2(prefix_, sep_, _XE_TUPLE_TAIL args_)
> -#define __XE_PASTE_4(prefix_, sep_, args_) prefix_(_XE_FIRST args_) __XE_PASTE_SEP_ ## sep_ __XE_PASTE_3(prefix_, sep_, _XE_TUPLE_TAIL args_)
> -
> -#define _XE_DROP_FIRST(x_, ...) __VA_ARGS__
> -#define _XE_DROP_CAST(...) _XE_ESC(_XE_DROP_FIRST _XE_ESC __VA_ARGS__)
> -
> -/*
> - * Helper macros for concatenating prefix - do not use them directly outside
> - * this header
> - */
> -#define __XE_PASTE_XE_RTP_ENTRY_FLAG_(x_) _XE_CONCAT(XE_RTP_ENTRY_FLAG_, x_)
> -#define __XE_PASTE_XE_RTP_ACTION_FLAG_(x_) _XE_CONCAT(XE_RTP_ACTION_FLAG_, x_)
> -#define __XE_PASTE_XE_RTP_ACTION_(x_) _XE_CONCAT(XE_RTP_ACTION_, x_)
> -#define __XE_PASTE_XE_RTP_RULE_(x_) _XE_CONCAT(XE_RTP_RULE_, x_)
> -
> /*
> * Macros to encode rules to match against platform, IP version, stepping, etc.
> * Shouldn't be used directly - see XE_RTP_RULES()
> diff --git a/drivers/gpu/drm/xe/xe_rtp_helpers.h b/drivers/gpu/drm/xe/xe_rtp_helpers.h
> new file mode 100644
> index 000000000000..0f0635692254
> --- /dev/null
> +++ b/drivers/gpu/drm/xe/xe_rtp_helpers.h
> @@ -0,0 +1,48 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Copyright © 2023 Intel Corporation
> + */
> +
> +#ifndef _XE_RTP_HELPERS_
> +#define _XE_RTP_HELPERS_
> +
> +#ifndef _XE_RTP_INCLUDE_PRIVATE_HELPERS
> +#error "This header is supposed to be included by xe_rtp.h only"
> +#endif
> +
> +/*
> + * Helper macros - not to be used outside xe_rtp.h/xe_rtp_helpers.h
> + */
> +#define _XE_ESC(...) __VA_ARGS__
> +#define _XE_COUNT_ARGS(...) _XE_ESC(__XE_COUNT_ARGS(__VA_ARGS__,5,4,3,2,1,))
> +#define __XE_COUNT_ARGS(_,_5,_4,_3,_2,X_,...) X_
> +
> +#define _XE_CONCAT(a, b) __XE_CONCAT(a, b)
> +#define __XE_CONCAT(a, b) a ## b
> +
> +#define _XE_FIRST(...) _XE_ESC(__XE_FIRST(__VA_ARGS__,))
> +#define __XE_FIRST(x_,...) x_
> +#define _XE_TUPLE_TAIL(...) _XE_ESC(__XE_TUPLE_TAIL(__VA_ARGS__))
> +#define __XE_TUPLE_TAIL(x_,...) (__VA_ARGS__)
> +
> +#define __XE_PASTE_SEP_COMMA ,
> +#define __XE_PASTE_SEP_BITWISE_OR |
> +#define __XE_PASTE(prefix_, sep_, args_) _XE_ESC(_XE_CONCAT(__XE_PASTE_,_XE_COUNT_ARGS args_)(prefix_, sep_, args_))
> +#define __XE_PASTE_1(prefix_, sep_, args_) prefix_ args_
> +#define __XE_PASTE_2(prefix_, sep_, args_) prefix_(_XE_FIRST args_) __XE_PASTE_SEP_ ## sep_ __XE_PASTE_1(prefix_, sep_, _XE_TUPLE_TAIL args_)
> +#define __XE_PASTE_3(prefix_, sep_, args_) prefix_(_XE_FIRST args_) __XE_PASTE_SEP_ ## sep_ __XE_PASTE_2(prefix_, sep_, _XE_TUPLE_TAIL args_)
> +#define __XE_PASTE_4(prefix_, sep_, args_) prefix_(_XE_FIRST args_) __XE_PASTE_SEP_ ## sep_ __XE_PASTE_3(prefix_, sep_, _XE_TUPLE_TAIL args_)
> +
> +#define _XE_DROP_FIRST(x_, ...) __VA_ARGS__
> +#define _XE_DROP_CAST(...) _XE_ESC(_XE_DROP_FIRST _XE_ESC __VA_ARGS__)
> +
> +/*
> + * Helper macros for concatenating prefix - do not use them directly outside
> + * this header
> + */
> +#define __XE_PASTE_XE_RTP_ENTRY_FLAG_(x_) _XE_CONCAT(XE_RTP_ENTRY_FLAG_, x_)
> +#define __XE_PASTE_XE_RTP_ACTION_FLAG_(x_) _XE_CONCAT(XE_RTP_ACTION_FLAG_, x_)
> +#define __XE_PASTE_XE_RTP_ACTION_(x_) _XE_CONCAT(XE_RTP_ACTION_, x_)
> +#define __XE_PASTE_XE_RTP_RULE_(x_) _XE_CONCAT(XE_RTP_RULE_, x_)
> +
> +#endif
--
Jani Nikula, Intel Open Source Graphics Center
next prev parent reply other threads:[~2023-04-19 16:17 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-19 7:44 [Intel-xe] [PATCH 00/17] Cleanup registers and introduce xe_reg_t Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 01/17] drm/xe: Cleanup page-related defines Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 02/17] fixup! drm/i915/display: Remaining changes to make xe compile Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 03/17] fixup! drm/i915/display: Allow fbdev to allocate stolen memory Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 04/17] drm/xe: Rename RC0/RC6 macros Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 05/17] drm/xe: Rename instruction field to avoid confusion Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 06/17] drm/xe/guc: Rename GEN11_SOFT_SCRATCH for clarity Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 07/17] drm/xe/guc: Move GuC registers to regs/ Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 08/17] drm/xe/guc: Convert GuC registers to REG_FIELD/REG_BIT Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 09/17] drm/xe: Drop gen prefixes and suffixes from registers Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 10/17] drm/xe: Use REG_FIELD/REG_BIT for all regs/*.h Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 11/17] drm/xe: Introduce xe_reg_t Lucas De Marchi
2023-04-19 16:06 ` Jani Nikula
2023-04-19 17:17 ` Lucas De Marchi
2023-04-19 19:39 ` Jani Nikula
2023-04-19 20:30 ` Lucas De Marchi
2023-04-19 17:33 ` Matt Roper
2023-04-19 18:49 ` Lucas De Marchi
2023-04-19 19:30 ` Rodrigo Vivi
2023-04-19 20:19 ` Lucas De Marchi
2023-04-19 20:24 ` Matt Roper
2023-04-19 21:09 ` Lucas De Marchi
2023-04-19 23:14 ` Matt Roper
2023-04-19 23:38 ` Lucas De Marchi
2023-04-19 19:49 ` Jani Nikula
2023-04-19 20:13 ` Lucas De Marchi
2023-04-19 20:13 ` Matt Roper
2023-04-19 21:24 ` Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 12/17] drm/xe: Clarify register types on PAT programming Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 13/17] drm/xe/rtp: Improve magic macros for RTP tables Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 14/17] drm/xe: Add XE_REG/XE_REG_MCR Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 15/17] drm/xe: Annotate masked registers used by RTP Lucas De Marchi
2023-04-19 7:44 ` [Intel-xe] [PATCH 16/17] drm/xe: Plumb xe_reg_t into WAs, rtp, etc Lucas De Marchi
2023-04-19 16:15 ` Jani Nikula
2023-04-19 7:44 ` [Intel-xe] [PATCH 17/17] drm/xe: Move helper macros to separate header Lucas De Marchi
2023-04-19 16:17 ` Jani Nikula [this message]
2023-04-19 17:06 ` Lucas De Marchi
2023-04-19 7:47 ` [Intel-xe] ✓ CI.Patch_applied: success for Cleanup registers and introduce xe_reg_t Patchwork
2023-04-19 7:48 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-04-19 7:52 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-04-19 8:12 ` [Intel-xe] ○ CI.BAT: info " 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=875y9ryhh1.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=matthew.d.roper@intel.com \
--cc=rodrigo.vivi@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