From: Andi Shyti <andi.shyti@linux.intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: intel-gfx@lists.freedesktop.org,
Andrzej Hajda <andrzej.hajda@intel.com>,
Nirmoy Das <nirmoy.das@intel.com>
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915/ttm: implement access_memory
Date: Mon, 3 Oct 2022 18:45:04 +0200 [thread overview]
Message-ID: <YzsRkMCop0IDWeOh@ashyti-mobl2.lan> (raw)
In-Reply-To: <20221003151936.74462-1-matthew.auld@intel.com>
Hi Matt,
[...]
> +static int i915_ttm_access_memory(struct ttm_buffer_object *bo,
> + unsigned long offset, void *buf,
> + int len, int write)
> +{
> + struct drm_i915_gem_object *obj = i915_ttm_to_gem(bo);
> + resource_size_t iomap = obj->mm.region->iomap.base -
> + obj->mm.region->region.start;
> + unsigned long page = offset >> PAGE_SHIFT;
> + unsigned long bytes_left = len;
> +
> + /*
> + * TODO: For now just let it fail if the resource is non-mappable,
> + * otherwise we need to perform the memcpy from the gpu here, without
> + * interfering with the object (like moving the entire thing).
> + */
> + if (!i915_ttm_resource_mappable(bo->resource))
> + return -EIO;
> +
> + offset -= page << PAGE_SHIFT;
> + do {
> + unsigned long bytes = min(bytes_left, PAGE_SIZE - offset);
> + void __iomem *ptr;
> + dma_addr_t daddr;
> +
> + daddr = i915_gem_object_get_dma_address(obj, page);
> + ptr = ioremap_wc(iomap + daddr + offset, PAGE_SIZE);
PAGE_SIZE or bytes? We don't know what there is after "bytes".
Andi
> + if (!ptr)
> + return -EIO;
> +
> + if (write)
> + memcpy_toio(ptr, buf, bytes);
> + else
> + memcpy_fromio(buf, ptr, bytes);
> + iounmap(ptr);
> +
> + page++;
> + buf += bytes;
> + bytes_left -= bytes;
> + offset = 0;
> + } while (bytes_left);
> +
> + return len;
> +}
next prev parent reply other threads:[~2022-10-03 16:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-03 15:19 [Intel-gfx] [PATCH v2] drm/i915/ttm: implement access_memory Matthew Auld
2022-10-03 16:26 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/ttm: implement access_memory (rev2) Patchwork
2022-10-03 16:45 ` Andi Shyti [this message]
2022-10-03 18:56 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
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=YzsRkMCop0IDWeOh@ashyti-mobl2.lan \
--to=andi.shyti@linux.intel.com \
--cc=andrzej.hajda@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=nirmoy.das@intel.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