From: Daniel Vetter <daniel@ffwll.ch>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: dri-devel@lists.freedesktop.org, tzimmermann@suse.de,
Christian Koenig <christian.koenig@amd.com>,
Huang Rui <ray.huang@amd.com>, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 01/17] drm/ttm: turn ttm_bo_device.vma_manager into a pointer
Date: Tue, 3 Sep 2019 11:49:36 +0200 [thread overview]
Message-ID: <20190903094936.GR2112@phenom.ffwll.local> (raw)
In-Reply-To: <20190808134417.10610-2-kraxel@redhat.com>
On Thu, Aug 08, 2019 at 03:44:01PM +0200, Gerd Hoffmann wrote:
> Rename the embedded struct vma_offset_manager, it is named _vma_manager
> now. ttm_bo_device.vma_manager is a pointer now, pointing to the
> embedded ttm_bo_device._vma_manager by default.
>
> Add ttm_bo_device_init_with_vma_manager() function which allows to
> initialize ttm with a different vma manager.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
I think a todo to convert all other ttm drivers over and then move
_vma_manager into vmwgfx would be nice. If you're not volunteering
yourself for this ofc.
-Daniel
> ---
> include/drm/ttm/ttm_bo_driver.h | 11 +++++++++--
> drivers/gpu/drm/ttm/ttm_bo.c | 29 +++++++++++++++++++++--------
> drivers/gpu/drm/ttm/ttm_bo_vm.c | 6 +++---
> 3 files changed, 33 insertions(+), 13 deletions(-)
>
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index 3f1935c19a66..2f84d6bcd1a7 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -441,7 +441,8 @@ extern struct ttm_bo_global {
> *
> * @driver: Pointer to a struct ttm_bo_driver struct setup by the driver.
> * @man: An array of mem_type_managers.
> - * @vma_manager: Address space manager
> + * @vma_manager: Address space manager (pointer)
> + * @_vma_manager: Address space manager (enbedded)
> * lru_lock: Spinlock that protects the buffer+device lru lists and
> * ddestroy lists.
> * @dev_mapping: A pointer to the struct address_space representing the
> @@ -464,7 +465,8 @@ struct ttm_bo_device {
> /*
> * Protected by internal locks.
> */
> - struct drm_vma_offset_manager vma_manager;
> + struct drm_vma_offset_manager *vma_manager;
> + struct drm_vma_offset_manager _vma_manager;
>
> /*
> * Protected by the global:lru lock.
> @@ -597,6 +599,11 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
> struct ttm_bo_driver *driver,
> struct address_space *mapping,
> bool need_dma32);
> +int ttm_bo_device_init_with_vma_manager(struct ttm_bo_device *bdev,
> + struct ttm_bo_driver *driver,
> + struct address_space *mapping,
> + struct drm_vma_offset_manager *vma_manager,
> + bool need_dma32);
>
> /**
> * ttm_bo_unmap_virtual
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 10a861a1690c..0ed1a1182962 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -672,7 +672,7 @@ static void ttm_bo_release(struct kref *kref)
> struct ttm_bo_device *bdev = bo->bdev;
> struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type];
>
> - drm_vma_offset_remove(&bdev->vma_manager, &bo->base.vma_node);
> + drm_vma_offset_remove(bdev->vma_manager, &bo->base.vma_node);
> ttm_mem_io_lock(man, false);
> ttm_mem_io_free_vm(bo);
> ttm_mem_io_unlock(man);
> @@ -1353,7 +1353,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
> */
> if (bo->type == ttm_bo_type_device ||
> bo->type == ttm_bo_type_sg)
> - ret = drm_vma_offset_add(&bdev->vma_manager, &bo->base.vma_node,
> + ret = drm_vma_offset_add(bdev->vma_manager, &bo->base.vma_node,
> bo->mem.num_pages);
>
> /* passed reservation objects should already be locked,
> @@ -1704,7 +1704,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
> pr_debug("Swap list %d was clean\n", i);
> spin_unlock(&glob->lru_lock);
>
> - drm_vma_offset_manager_destroy(&bdev->vma_manager);
> + drm_vma_offset_manager_destroy(&bdev->_vma_manager);
>
> if (!ret)
> ttm_bo_global_release();
> @@ -1713,10 +1713,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)
> }
> EXPORT_SYMBOL(ttm_bo_device_release);
>
> -int ttm_bo_device_init(struct ttm_bo_device *bdev,
> - struct ttm_bo_driver *driver,
> - struct address_space *mapping,
> - bool need_dma32)
> +int ttm_bo_device_init_with_vma_manager(struct ttm_bo_device *bdev,
> + struct ttm_bo_driver *driver,
> + struct address_space *mapping,
> + struct drm_vma_offset_manager *vma_manager,
> + bool need_dma32)
> {
> struct ttm_bo_global *glob = &ttm_bo_glob;
> int ret;
> @@ -1737,7 +1738,8 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
> if (unlikely(ret != 0))
> goto out_no_sys;
>
> - drm_vma_offset_manager_init(&bdev->vma_manager,
> + bdev->vma_manager = vma_manager;
> + drm_vma_offset_manager_init(&bdev->_vma_manager,
> DRM_FILE_PAGE_OFFSET_START,
> DRM_FILE_PAGE_OFFSET_SIZE);
> INIT_DELAYED_WORK(&bdev->wq, ttm_bo_delayed_workqueue);
> @@ -1754,6 +1756,17 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,
> ttm_bo_global_release();
> return ret;
> }
> +EXPORT_SYMBOL(ttm_bo_device_init_with_vma_manager);
> +
> +int ttm_bo_device_init(struct ttm_bo_device *bdev,
> + struct ttm_bo_driver *driver,
> + struct address_space *mapping,
> + bool need_dma32)
> +{
> + return ttm_bo_device_init_with_vma_manager(bdev, driver, mapping,
> + &bdev->_vma_manager,
> + need_dma32);
> +}
> EXPORT_SYMBOL(ttm_bo_device_init);
>
> /*
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> index 85f5bcbe0c76..d4eecde8d050 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
> @@ -409,16 +409,16 @@ static struct ttm_buffer_object *ttm_bo_vm_lookup(struct ttm_bo_device *bdev,
> struct drm_vma_offset_node *node;
> struct ttm_buffer_object *bo = NULL;
>
> - drm_vma_offset_lock_lookup(&bdev->vma_manager);
> + drm_vma_offset_lock_lookup(bdev->vma_manager);
>
> - node = drm_vma_offset_lookup_locked(&bdev->vma_manager, offset, pages);
> + node = drm_vma_offset_lookup_locked(bdev->vma_manager, offset, pages);
> if (likely(node)) {
> bo = container_of(node, struct ttm_buffer_object,
> base.vma_node);
> bo = ttm_bo_get_unless_zero(bo);
> }
>
> - drm_vma_offset_unlock_lookup(&bdev->vma_manager);
> + drm_vma_offset_unlock_lookup(bdev->vma_manager);
>
> if (!bo)
> pr_err("Could not find buffer object to map\n");
> --
> 2.18.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
next prev parent reply other threads:[~2019-09-03 9:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190808134417.10610-1-kraxel@redhat.com>
2019-08-08 13:44 ` [PATCH v4 01/17] drm/ttm: turn ttm_bo_device.vma_manager into a pointer Gerd Hoffmann
2019-09-03 9:49 ` Daniel Vetter [this message]
2019-08-08 13:44 ` [PATCH v4 02/17] drm/ttm: add gem_ttm_bo_device_init() Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 03/17] drm/vram: switch vram helpers to the new gem_ttm_bo_device_init() Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 04/17] drm/qxl: switch qxl " Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 05/17] drm: add mmap() to drm_gem_object_funcs Gerd Hoffmann
2019-09-03 9:48 ` Daniel Vetter
2019-09-06 12:13 ` Gerd Hoffmann
2019-09-06 13:10 ` Daniel Vetter
2019-09-09 10:06 ` Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 06/17] drm/shmem: switch shmem helper to drm_gem_object_funcs->mmap Gerd Hoffmann
2019-08-08 22:51 ` Rob Herring
2019-08-08 13:44 ` [PATCH v4 07/17] drm/shmem: drop DEFINE_DRM_GEM_SHMEM_FOPS Gerd Hoffmann
2019-08-08 22:51 ` Rob Herring
2019-08-08 13:44 ` [PATCH v4 08/17] drm/ttm: factor out ttm_bo_mmap_vma_setup Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 09/17] drm/ttm: add drm_gem_ttm_mmap() Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 10/17] drm/vram: switch vram helper to drm_gem_object_funcs->mmap codepath Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 11/17] drm/vram: drop verify_access Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 12/17] drm: drop DRM_VRAM_MM_FILE_OPERATIONS Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 13/17] drm/qxl: use drm_gem_object_funcs Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 14/17] drm/qxl: drop qxl_ttm_fault Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 15/17] drm/qxl: switch qxl to drm_gem_object_funcs->mmap codepath Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 16/17] drm/qxl: drop verify_access Gerd Hoffmann
2019-08-08 13:44 ` [PATCH v4 17/17] drm/qxl: use DEFINE_DRM_GEM_FOPS() Gerd Hoffmann
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=20190903094936.GR2112@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=airlied@linux.ie \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ray.huang@amd.com \
--cc=tzimmermann@suse.de \
/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).