[Intel-gfx] [PATCH 2/3] i915/gvt: save the initial HW state snapshot in i915.
Christoph Hellwig
hch at lst.de
Mon Jan 31 06:38:03 UTC 2022
On Thu, Jan 27, 2022 at 07:05:07AM -0500, Zhi Wang wrote:
> +static void save_mmio(struct intel_gvt_mmio_table_iter *iter, u32 offset,
> + u32 size)
> +{
> + struct drm_i915_private *dev_priv = iter->i915;
> + void *mmio = iter->data;
> + u32 start, end, i;
> +
> + start = offset;
> + end = offset + size;
> +
> + for (i = start; i < end; i += 4) {
> + *(u32 *)(mmio + i) = intel_uncore_read_notrace(
> + to_gt(dev_priv)->uncore, _MMIO(offset));
> + }
> +}
This can be simplified to:
static void intel_gvt_save_mmio(struct intel_gvt_mmio_table_iter *iter,
u32 offset, u32 size)
{
struct drm_i915_private *dev_priv = iter->i915;
u32 *mmio = iter->data, i;
for (i = offset; i < offset + size; i += 4) {
mmio[i] = intel_uncore_read_notrace(to_gt(dev_priv)->uncore,
_MMIO(offset));
}
}
> + struct pci_dev *pdev = to_pci_dev(dev_priv->drm.dev);
> + struct intel_gvt_device_info info;
> + struct i915_virtual_gpu *vgpu = &dev_priv->vgpu;
> + struct intel_gvt_mmio_table_iter iter;
> + void *mem;
> + int i, ret;
> +
> + intel_gvt_init_device_info(dev_priv, &info);
There is no real need for this call.
> +
> + mem = kzalloc(info.cfg_space_size, GFP_KERNEL);
> + if (!mem)
> + return -ENOMEM;
info.cfg_space_size is always PCI_CFG_SPACE_EXP_SIZE, and the code relies
onb that just a few lines below.
> + mem = vzalloc(info.mmio_size);
And info.mmio_size is a constant that can just use a define.
More information about the Intel-gfx
mailing list