[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220131063803.GB4390@lst.de>
Date: Mon, 31 Jan 2022 07:38:03 +0100
From: Christoph Hellwig <hch@....de>
To: Zhi Wang <zhi.wang.linux@...il.com>
Cc: hch@....de, jgg@...dia.com, jani.nikula@...ux.intel.com,
intel-gfx@...ts.freedesktop.org,
intel-gvt-dev@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Zhi Wang <zhi.a.wang@...el.com>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Vivi Rodrigo <rodrigo.vivi@...el.com>,
Zhenyu Wang <zhenyuw@...ux.intel.com>
Subject: Re: [PATCH 2/3] i915/gvt: save the initial HW state snapshot in
i915.
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.
Powered by blists - more mailing lists