[PATCH] drm/i915/gvt: add a whitelist for force-nonpriv registers

Zhenyu Wang zhenyuw at linux.intel.com
Mon Feb 20 08:05:17 UTC 2017


On 2017.02.20 13:56:26 +0800, Zhao Yan wrote:
> Signed-off-by: Zhao Yan <yan.y.zhao at intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/handlers.c | 78 +++++++++++++++++++++++++++++++++++--
>  drivers/gpu/drm/i915/gvt/render.c   | 16 ++++++++
>  2 files changed, 90 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
> index 8f2c164..542da6f 100644
> --- a/drivers/gpu/drm/i915/gvt/handlers.c
> +++ b/drivers/gpu/drm/i915/gvt/handlers.c
> @@ -369,6 +369,75 @@ static int pipeconf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
>  	return 0;
>  }
>  
> +/* ascendingly sorted */
> +static i915_reg_t force_nonpriv_white_list[] = {
> +	GEN9_CS_DEBUG_MODE1, //_MMIO(0x20ec)
> +	GEN9_CTX_PREEMPT_REG,//_MMIO(0x2248)
> +	GEN8_CS_CHICKEN1,//_MMIO(0x2580)
> +	_MMIO(0x2690),
> +	_MMIO(0x2694),
> +	_MMIO(0x2698),
> +	_MMIO(0x4de0),
> +	_MMIO(0x4de4),
> +	_MMIO(0x4dfc),
> +	GEN7_COMMON_SLICE_CHICKEN1,//_MMIO(0x7010)
> +	_MMIO(0x7014),
> +	HDC_CHICKEN0,//_MMIO(0x7300)
> +	GEN8_HDC_CHICKEN1,//_MMIO(0x7304)
> +	_MMIO(0x7700),
> +	_MMIO(0x7704),
> +	_MMIO(0x7708),
> +	_MMIO(0x770c),
> +	_MMIO(0xb110),
> +	GEN8_L3SQCREG4,//_MMIO(0xb118)
> +	_MMIO(0xe100),
> +	_MMIO(0xe18c),
> +	_MMIO(0xe48c),
> +	_MMIO(0xe5f4),
> +};
> +
> +/* a simple bsearch */
> +static inline int in_whitelist(unsigned int reg)
> +{
> +	int left = 0, right = ARRAY_SIZE(force_nonpriv_white_list);
> +	i915_reg_t *array = force_nonpriv_white_list;
> +
> +	while (left < right) {
> +		int mid = (left + right)/2;
> +
> +		if (reg > array[mid].reg)
> +			left = mid + 1;
> +		else if (reg < array[mid].reg)
> +			right = mid;
> +		else
> +			return 1;
> +	}
> +	return 0;
> +}
> +
> +static int force_nonpriv_write(struct intel_vgpu *vgpu,
> +	unsigned int offset, void *p_data, unsigned int bytes)
> +{
> +	u32 reg_nonpriv = *(u32 *)p_data;
> +	int ret = 1;
> +
> +	if ((bytes != 4) || ((offset & (bytes - 1)) != 0)) {
> +		gvt_err("vgpu(%d) Invalid FORCE_NONPRIV offset %x(%dB)\n",
> +			vgpu->id, offset, bytes);
> +		return ret;
> +	}
> +
> +	if (in_whitelist(reg_nonpriv)) {
> +		ret = intel_vgpu_default_mmio_write(vgpu, offset, p_data,
> +			bytes);
> +	} else {
> +		gvt_err("vgpu(%d) Invalid FORCE_NONPRIV write %x\n",
> +			vgpu->id, reg_nonpriv);
> +		ret = 1;
> +	}
> +	return ret;
> +}
> +
>  static int ddi_buf_ctl_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
>  		void *p_data, unsigned int bytes)
>  {
> @@ -2376,10 +2445,11 @@ static int init_broadwell_mmio_info(struct intel_gvt *gvt)
>  	MMIO_D(0xb10c, D_BDW);
>  	MMIO_D(0xb110, D_BDW);
>  
> -	MMIO_DFH(0x24d0, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
> -	MMIO_DFH(0x24d4, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
> -	MMIO_DFH(0x24d8, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
> -	MMIO_DFH(0x24dc, D_BDW_PLUS, F_CMD_ACCESS, NULL, NULL);
> +	MMIO_DFH(0x24d0, D_BDW_PLUS, F_CMD_ACCESS, NULL, force_nonpriv_write);
> +	MMIO_DFH(0x24d4, D_BDW_PLUS, F_CMD_ACCESS, NULL, force_nonpriv_write);
> +	MMIO_DFH(0x24d8, D_BDW_PLUS, F_CMD_ACCESS, NULL, force_nonpriv_write);
> +	MMIO_F(0x24dc, 36, F_CMD_ACCESS, 0, 0, D_BDW_PLUS,
> +		NULL, force_nonpriv_write);

Combine this together?

>  
>  	MMIO_D(0x22040, D_BDW_PLUS);
>  	MMIO_D(0x44484, D_BDW_PLUS);
> diff --git a/drivers/gpu/drm/i915/gvt/render.c b/drivers/gpu/drm/i915/gvt/render.c
> index 2b3a642..73f052a 100644
> --- a/drivers/gpu/drm/i915/gvt/render.c
> +++ b/drivers/gpu/drm/i915/gvt/render.c
> @@ -53,6 +53,14 @@ struct render_mmio {
>  	{RCS, _MMIO(0x24d4), 0, false},
>  	{RCS, _MMIO(0x24d8), 0, false},
>  	{RCS, _MMIO(0x24dc), 0, false},
> +	{RCS, _MMIO(0x24e0), 0, false},
> +	{RCS, _MMIO(0x24e4), 0, false},
> +	{RCS, _MMIO(0x24e8), 0, false},
> +	{RCS, _MMIO(0x24ec), 0, false},
> +	{RCS, _MMIO(0x24f0), 0, false},
> +	{RCS, _MMIO(0x24f4), 0, false},
> +	{RCS, _MMIO(0x24f8), 0, false},
> +	{RCS, _MMIO(0x24fc), 0, false},
>  	{RCS, _MMIO(0x7004), 0xffff, true},
>  	{RCS, _MMIO(0x7008), 0xffff, true},
>  	{RCS, _MMIO(0x7000), 0xffff, true},
> @@ -76,6 +84,14 @@ struct render_mmio {
>  	{RCS, _MMIO(0x24d4), 0, false},
>  	{RCS, _MMIO(0x24d8), 0, false},
>  	{RCS, _MMIO(0x24dc), 0, false},
> +	{RCS, _MMIO(0x24e0), 0, false},
> +	{RCS, _MMIO(0x24e4), 0, false},
> +	{RCS, _MMIO(0x24e8), 0, false},
> +	{RCS, _MMIO(0x24ec), 0, false},
> +	{RCS, _MMIO(0x24f0), 0, false},
> +	{RCS, _MMIO(0x24f4), 0, false},
> +	{RCS, _MMIO(0x24f8), 0, false},
> +	{RCS, _MMIO(0x24fc), 0, false},
>  	{RCS, _MMIO(0x7004), 0xffff, true},
>  	{RCS, _MMIO(0x7008), 0xffff, true},
>  	{RCS, _MMIO(0x7000), 0xffff, true},

This should be splitted as not for mmio handler but for ctx save/restore.

> 
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20170220/83a031dd/attachment.sig>


More information about the intel-gvt-dev mailing list