[Intel-xe] [PATCH v2 03/12] drm/xe: Print whitelist while applying
Matt Roper
matthew.d.roper at intel.com
Fri Mar 10 23:55:44 UTC 2023
On Fri, Mar 10, 2023 at 02:15:40PM -0800, Lucas De Marchi wrote:
> Besides printing the various register save-restore, it's also useful to
> know the register being allowed/denied access to unprivilige batch
s/to/from/
> buffers. Print them during device probe.
>
> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
> ---
> drivers/gpu/drm/xe/xe_reg_sr.c | 4 +++
> drivers/gpu/drm/xe/xe_reg_whitelist.c | 41 +++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_reg_whitelist.h | 7 +++++
> 3 files changed, 52 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_reg_sr.c b/drivers/gpu/drm/xe/xe_reg_sr.c
> index c6f92fe9aad1..f6ed9e6e5697 100644
> --- a/drivers/gpu/drm/xe/xe_reg_sr.c
> +++ b/drivers/gpu/drm/xe/xe_reg_sr.c
> @@ -20,6 +20,7 @@
> #include "xe_gt_mcr.h"
> #include "xe_macros.h"
> #include "xe_mmio.h"
> +#include "xe_reg_whitelist.h"
> #include "xe_rtp_types.h"
>
> #define XE_REG_SR_GROW_STEP_DEFAULT 16
> @@ -194,6 +195,7 @@ void xe_reg_sr_apply_whitelist(struct xe_reg_sr *sr, u32 mmio_base,
> {
> struct xe_device *xe = gt_to_xe(gt);
> struct xe_reg_sr_entry *entry;
> + struct drm_printer p;
> unsigned long reg;
> unsigned int slot = 0;
> int err;
> @@ -207,7 +209,9 @@ void xe_reg_sr_apply_whitelist(struct xe_reg_sr *sr, u32 mmio_base,
> if (err)
> goto err_force_wake;
>
> + p = drm_debug_printer(KBUILD_MODNAME);
> xa_for_each(&sr->xa, reg, entry) {
> + xe_reg_whitelist_print_entry(&p, 0, reg, entry);
> xe_mmio_write32(gt, RING_FORCE_TO_NONPRIV(mmio_base, slot).reg,
> reg | entry->set_bits);
> slot++;
> diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
> index 2dd10e62718f..6c8577e8dba6 100644
> --- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
> +++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
> @@ -67,3 +67,44 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
> {
> xe_rtp_process(register_whitelist, &hwe->reg_whitelist, hwe->gt, hwe);
> }
> +
> +/**
> + * xe_reg_whitelist_print_entry - print one whitelist entry
> + * @p: DRM printer
> + * @indent: indent level
> + * @reg: register allowed/denied
> + * @entry: save-restore entry
> + *
> + * Print details about the entry added to allow/deny access
> + */
> +void xe_reg_whitelist_print_entry(struct drm_printer *p, unsigned int indent,
> + u32 reg, struct xe_reg_sr_entry *entry)
> +{
> + u32 val = entry->set_bits;
> + const char *access_str = "(invalid)";
> + unsigned range_bit = 2;
> + u32 range_start, range_end;
> + bool deny;
> +
> + deny = val & RING_FORCE_TO_NONPRIV_DENY;
> +
> + switch (val & RING_FORCE_TO_NONPRIV_RANGE_MASK) {
> + case RING_FORCE_TO_NONPRIV_RANGE_4: range_bit = 4; break;
> + case RING_FORCE_TO_NONPRIV_RANGE_16: range_bit = 6; break;
> + case RING_FORCE_TO_NONPRIV_RANGE_64: range_bit = 8; break;
> + }
> +
> + range_start = reg & REG_GENMASK(25, range_bit);
> + range_end = range_start | REG_GENMASK(range_bit, 0);
> +
> + switch (val & RING_FORCE_TO_NONPRIV_ACCESS_MASK) {
> + case RING_FORCE_TO_NONPRIV_ACCESS_RW: access_str = "rw"; break;
> + case RING_FORCE_TO_NONPRIV_ACCESS_RD: access_str = "read"; break;
> + case RING_FORCE_TO_NONPRIV_ACCESS_WR: access_str = "write"; break;
> + }
> +
> + drm_printf_indent(p, indent, "REG[0x%x-0x%x]: %s %s access\n",
> + range_start, range_end,
> + deny ? "deny" : "allow",
> + access_str);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.h b/drivers/gpu/drm/xe/xe_reg_whitelist.h
> index 6e861b1bdb01..c76d81c528da 100644
> --- a/drivers/gpu/drm/xe/xe_reg_whitelist.h
> +++ b/drivers/gpu/drm/xe/xe_reg_whitelist.h
> @@ -6,8 +6,15 @@
> #ifndef _XE_REG_WHITELIST_
> #define _XE_REG_WHITELIST_
>
> +#include <linux/types.h>
> +
> +struct drm_printer;
> struct xe_hw_engine;
> +struct xe_reg_sr_entry;
>
> void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
>
> +void xe_reg_whitelist_print_entry(struct drm_printer *p, unsigned int indent,
> + u32 reg, struct xe_reg_sr_entry *entry);
> +
> #endif
> --
> 2.39.0
>
--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
More information about the Intel-xe
mailing list