Commit d855d224 authored by Lucas De Marchi's avatar Lucas De Marchi Committed by Rodrigo Vivi

drm/xe: Print whitelist while applying

Besides printing the various register save-restore, it's also useful to
know the register being allowed/denied access from unprivileged batch
buffers. Print them during device probe.
Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Reviewed-by: default avatarMatt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20230314003012.2600353-4-lucas.demarchi@intel.comSigned-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 5be84050
......@@ -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
......@@ -193,6 +194,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;
......@@ -206,7 +208,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++;
......
......@@ -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);
}
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment