From: "Christian König" <christian.koenig@amd.com>
To: "Dave Airlie" <airlied@gmail.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Ben Skeggs" <skeggsb@gmail.com>
Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH v10 03/11] drm/ttm: Add a generic TTM memcpy move for page-based iomem
Date: Mon, 30 Aug 2021 08:16:20 +0200 [thread overview]
Message-ID: <1c8ee7b0-97ef-0c04-8e92-ec6bdc56bd40@amd.com> (raw)
In-Reply-To: <CAPM=9twjYTME6CPuNmn3S7A_ACUNhMOAY1QcpoOqAZ5RHM6JzA@mail.gmail.com>
Am 30.08.21 um 03:54 schrieb Dave Airlie:
> I've just been talking with Ben about nouveau having some issues since
> this path,
>
> ttm_resource can be subclassed by drivers, and the code below that
> copies ttm_resources around pretty much seems to destroy that.
>
>
>> + struct ttm_resource *src_mem = &bo->mem;
>> + struct ttm_resource_manager *src_man =
>> + ttm_manager_type(bdev, src_mem->mem_type);
>> + struct ttm_resource src_copy = *src_mem;
> This here ^^
Mhm, that's most likely a rebase/merge conflict between my change to
subclass ttm_resource which came in through the drm-misc-next tree and
Thomas change here.
Thomas can you take a look?
Thanks,
Christian.
>
>> + union {
>> + struct ttm_kmap_iter_tt tt;
>> + struct ttm_kmap_iter_linear_io io;
>> + } _dst_iter, _src_iter;
>> + struct ttm_kmap_iter *dst_iter, *src_iter;
>> + int ret = 0;
>>
>> - /*
>> - * TTM might be null for moves within the same region.
>> - */
>> - if (ttm) {
>> + if (ttm && ((ttm->page_flags & TTM_PAGE_FLAG_SWAPPED) ||
>> + dst_man->use_tt)) {
>> ret = ttm_tt_populate(bdev, ttm, ctx);
>> if (ret)
>> - goto out1;
>> + return ret;
>> }
>>
>> - for (i = 0; i < new_mem->num_pages; ++i) {
>> - if (old_iomap == NULL) {
>> - pgprot_t prot = ttm_io_prot(bo, old_mem, PAGE_KERNEL);
>> - ret = ttm_copy_ttm_io_page(ttm, new_iomap, i,
>> - prot);
>> - } else if (new_iomap == NULL) {
>> - pgprot_t prot = ttm_io_prot(bo, new_mem, PAGE_KERNEL);
>> - ret = ttm_copy_io_ttm_page(ttm, old_iomap, i,
>> - prot);
>> - } else {
>> - ret = ttm_copy_io_page(new_iomap, old_iomap, i);
>> - }
>> - if (ret)
>> - goto out1;
>> + dst_iter = ttm_kmap_iter_linear_io_init(&_dst_iter.io, bdev, dst_mem);
>> + if (PTR_ERR(dst_iter) == -EINVAL && dst_man->use_tt)
>> + dst_iter = ttm_kmap_iter_tt_init(&_dst_iter.tt, bo->ttm);
>> + if (IS_ERR(dst_iter))
>> + return PTR_ERR(dst_iter);
>> +
>> + src_iter = ttm_kmap_iter_linear_io_init(&_src_iter.io, bdev, src_mem);
>> + if (PTR_ERR(src_iter) == -EINVAL && src_man->use_tt)
>> + src_iter = ttm_kmap_iter_tt_init(&_src_iter.tt, bo->ttm);
>> + if (IS_ERR(src_iter)) {
>> + ret = PTR_ERR(src_iter);
>> + goto out_src_iter;
>> }
>> - mb();
>> -out2:
>> - old_copy = *old_mem;
>>
>> - ttm_bo_assign_mem(bo, new_mem);
>> -
>> - if (!man->use_tt)
>> - ttm_bo_tt_destroy(bo);
>> + ttm_move_memcpy(bo, dst_mem->num_pages, dst_iter, src_iter);
>> + src_copy = *src_mem;
>> + ttm_bo_move_sync_cleanup(bo, dst_mem);
>>
>> -out1:
>> - ttm_resource_iounmap(bdev, old_mem, new_iomap);
>> -out:
>> - ttm_resource_iounmap(bdev, &old_copy, old_iomap);
>> + if (!src_iter->ops->maps_tt)
>> + ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, &src_copy);
> passes a copy into linear_io_fini which calls the driver io_mem_free
> without the subclass data.
>
> Dave.
next prev parent reply other threads:[~2021-08-30 6:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 8:38 [PATCH v10 00/11] Move LMEM (VRAM) management over to TTM Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 01/11] drm/i915/ttm Initialize the ttm device and memory managers Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 02/11] drm/i915/ttm: Embed a ttm buffer object in the i915 gem object Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 03/11] drm/ttm: Add a generic TTM memcpy move for page-based iomem Thomas Hellström
2021-08-30 1:54 ` [Intel-gfx] " Dave Airlie
2021-08-30 6:16 ` Christian König [this message]
2021-08-30 7:08 ` Thomas Hellström
2021-08-30 7:53 ` Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 04/11] drm: Add a prefetching memcpy_from_wc Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 05/11] drm/ttm: Use drm_memcpy_from_wc for TTM bo moves Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 06/11] drm/ttm: Document and optimize ttm_bo_pipeline_gutting() Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 07/11] drm/ttm, drm/amdgpu: Allow the driver some control over swapping Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 08/11] drm/i915/ttm: Introduce a TTM i915 gem object backend Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 09/11] drm/i915/lmem: Verify checks for lmem residency Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 10/11] drm/vma: Add a driver_private member to vma_node Thomas Hellström
2021-06-02 8:38 ` [PATCH v10 11/11] drm/i915: Use ttm mmap handling for ttm bo's Thomas Hellström
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=1c8ee7b0-97ef-0c04-8e92-ec6bdc56bd40@amd.com \
--to=christian.koenig@amd.com \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=skeggsb@gmail.com \
--cc=thomas.hellstrom@linux.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;
as well as URLs for NNTP newsgroup(s).