intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Zhi Wang <zhi.wang.linux@gmail.com>
Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, jgg@nvidia.com,
	intel-gvt-dev@lists.freedesktop.org, hch@lst.de
Subject: Re: [Intel-gfx] [PATCH 2/3] i915/gvt: save the initial HW state snapshot in i915.
Date: Mon, 31 Jan 2022 07:38:03 +0100	[thread overview]
Message-ID: <20220131063803.GB4390@lst.de> (raw)
In-Reply-To: <20220127120508.11330-2-zhi.a.wang@intel.com>

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.

  reply	other threads:[~2022-01-31  6:38 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 12:05 [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API Zhi Wang
2022-01-27 12:05 ` [Intel-gfx] [PATCH 2/3] i915/gvt: save the initial HW state snapshot in i915 Zhi Wang
2022-01-31  6:38   ` Christoph Hellwig [this message]
2022-01-27 12:05 ` [Intel-gfx] [PATCH 3/3] i915/gvt: Use the initial HW state snapshot saved " Zhi Wang
2022-01-27 14:52 ` [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API Christoph Hellwig
2022-01-27 15:17 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] " Patchwork
2022-01-27 15:18 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-01-27 15:48 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-01-27 17:14 ` [Intel-gfx] [PATCH 1/3] " kernel test robot
2022-01-27 17:46 ` kernel test robot
2022-01-27 19:08 ` kernel test robot
2022-01-27 20:50 ` [Intel-gfx] ✗ Fi.CI.IGT: failure for series starting with [1/3] " Patchwork
2022-01-28  5:01 ` [Intel-gfx] [RFC PATCH] i915/gvt: intel_gvt_match_device() can be static kernel test robot
2022-01-28  5:11 ` [Intel-gfx] [PATCH 1/3] i915/gvt: Introduce the mmio_table.c to support VFIO new mdev API kernel test robot
2022-01-31  6:34 ` Christoph Hellwig
2022-02-07  7:32 ` Christoph Hellwig
2022-02-07  8:28   ` Wang, Zhi A
2022-02-07  8:35     ` Christoph Hellwig
2022-02-07 10:48       ` Jani Nikula
2022-02-07 11:57         ` Zhi Wang
2022-02-07 12:06           ` Christoph Hellwig
2022-02-07 12:13             ` Jani Nikula
2022-02-08  8:04         ` Joonas Lahtinen
2022-02-07 14:47 ` kernel test robot
2022-02-08 14:38 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-11-08 21:27 [Intel-gfx] [PATCH 1/3] i915/gvt: seperate tracked MMIO table from handlers.c Zhi Wang
2021-11-08 21:27 ` [Intel-gfx] [PATCH 2/3] i915/gvt: save the initial HW state snapshot in i915 Zhi Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220131063803.GB4390@lst.de \
    --to=hch@lst.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jgg@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zhi.wang.linux@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).