From: Daniel Vetter <daniel@ffwll.ch>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org,
"Christian König" <christian.koenig@amd.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2 04/15] drm/ttm: Export functions to initialize and finalize the ttm range manager standalone
Date: Tue, 18 May 2021 11:03:51 +0200 [thread overview]
Message-ID: <YKOC9/Nn9i9fpgHc@phenom.ffwll.local> (raw)
In-Reply-To: <20210518082701.997251-5-thomas.hellstrom@linux.intel.com>
On Tue, May 18, 2021 at 10:26:50AM +0200, Thomas Hellström wrote:
> i915 mock selftests are run without the device set up. In order to be able
> to run the region related mock selftests, export functions in order for the
> TTM range manager to be set up without a device to attach it to.
>
> Cc: Christian König <christian.koenig@amd.com>
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
> drivers/gpu/drm/ttm/ttm_range_manager.c | 55 +++++++++++++++++--------
> include/drm/ttm/ttm_bo_driver.h | 23 +++++++++++
> 2 files changed, 61 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> index b9d5da6e6a81..6957dfb0cf5a 100644
> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -125,55 +125,76 @@ static const struct ttm_resource_manager_func ttm_range_manager_func = {
> .debug = ttm_range_man_debug
> };
>
> -int ttm_range_man_init(struct ttm_device *bdev,
> - unsigned type, bool use_tt,
> - unsigned long p_size)
> +struct ttm_resource_manager *
> +ttm_range_man_init_standalone(unsigned long size, bool use_tt)
> {
> struct ttm_resource_manager *man;
> struct ttm_range_manager *rman;
>
> rman = kzalloc(sizeof(*rman), GFP_KERNEL);
> if (!rman)
> - return -ENOMEM;
> + return ERR_PTR(-ENOMEM);
>
> man = &rman->manager;
> man->use_tt = use_tt;
>
> man->func = &ttm_range_manager_func;
>
> - ttm_resource_manager_init(man, p_size);
> + ttm_resource_manager_init(man, size);
>
> - drm_mm_init(&rman->mm, 0, p_size);
> + drm_mm_init(&rman->mm, 0, size);
> spin_lock_init(&rman->lock);
>
> - ttm_set_driver_manager(bdev, type, &rman->manager);
> + return man;
> +}
> +EXPORT_SYMBOL(ttm_range_man_init_standalone);
> +
> +int ttm_range_man_init(struct ttm_device *bdev,
> + unsigned int type, bool use_tt,
> + unsigned long p_size)
> +{
> + struct ttm_resource_manager *man;
> +
> + man = ttm_range_man_init_standalone(p_size, use_tt);
> + if (IS_ERR(man))
> + return PTR_ERR(man);
> +
> ttm_resource_manager_set_used(man, true);
> + ttm_set_driver_manager(bdev, type, man);
> +
> return 0;
> }
> EXPORT_SYMBOL(ttm_range_man_init);
>
> +void ttm_range_man_fini_standalone(struct ttm_resource_manager *man)
> +{
> + struct ttm_range_manager *rman = to_range_manager(man);
> + struct drm_mm *mm = &rman->mm;
> +
> + spin_lock(&rman->lock);
> + drm_mm_clean(mm);
> + drm_mm_takedown(mm);
> + spin_unlock(&rman->lock);
> +
> + ttm_resource_manager_cleanup(man);
> + kfree(rman);
> +}
> +EXPORT_SYMBOL(ttm_range_man_fini_standalone);
> +
> int ttm_range_man_fini(struct ttm_device *bdev,
> unsigned type)
> {
> struct ttm_resource_manager *man = ttm_manager_type(bdev, type);
> - struct ttm_range_manager *rman = to_range_manager(man);
> - struct drm_mm *mm = &rman->mm;
> int ret;
>
> ttm_resource_manager_set_used(man, false);
> -
> ret = ttm_resource_manager_evict_all(bdev, man);
> if (ret)
> return ret;
>
> - spin_lock(&rman->lock);
> - drm_mm_clean(mm);
> - drm_mm_takedown(mm);
> - spin_unlock(&rman->lock);
> -
> - ttm_resource_manager_cleanup(man);
> ttm_set_driver_manager(bdev, type, NULL);
> - kfree(rman);
> + ttm_range_man_fini_standalone(man);
> +
> return 0;
> }
> EXPORT_SYMBOL(ttm_range_man_fini);
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index dbccac957f8f..734b1712ea72 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -321,6 +321,20 @@ int ttm_range_man_init(struct ttm_device *bdev,
> unsigned type, bool use_tt,
> unsigned long p_size);
>
> +/**
> + * ttm_range_man_init_standalone - Initialize a ttm range manager without
> + * device interaction.
> + * @size: Size of the area to be managed in pages.
> + * @use_tt: The memory type requires tt backing.
> + *
> + * This function is intended for selftests. It initializes a range manager
> + * without any device interaction.
> + *
> + * Return: pointer to a range manager on success. Error pointer on failure.
> + */
Kerneldoc is great and I'm happy you're updating them (Christian's not so
much good for this), but I think would be good to go one step further with
a prep patch:
- Make sure ttm_bo_driver.h is appropriately included in
Documentation/gpu/drm-mm.rst.
- Fix up any kerneldoc fallout. Specifically I think common usage at least
is that for non-inline functions, the kerneldoc is in the .c file, not
in the headers.
But also this might be way too much work since ttm hasn't been properly
kerneldoc-ified, so maybe later.
-Daniel
> +struct ttm_resource_manager *
> +ttm_range_man_init_standalone(unsigned long size, bool use_tt);
> +
> /**
> * ttm_range_man_fini
> *
> @@ -332,4 +346,13 @@ int ttm_range_man_init(struct ttm_device *bdev,
> int ttm_range_man_fini(struct ttm_device *bdev,
> unsigned type);
>
> +/**
> + * ttm_range_man_fini_standalone
> + * @man: The range manager
> + *
> + * Tear down a range manager initialized with
> + * ttm_range_manager_init_standalone().
> + */
> +void ttm_range_man_fini_standalone(struct ttm_resource_manager *man);
> +
> #endif
> --
> 2.31.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2021-05-18 9:04 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 8:26 [Intel-gfx] [PATCH v2 00/15] drm/i915: Move LMEM (VRAM) management over to TTM Thomas Hellström
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 01/15] drm/i915: Untangle the vma pages_mutex Thomas Hellström
2021-05-18 11:12 ` Maarten Lankhorst
2021-05-18 11:28 ` Thomas Hellström
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 02/15] drm/i915: Don't free shared locks while shared Thomas Hellström
2021-05-18 11:18 ` Maarten Lankhorst
2021-05-18 11:30 ` Thomas Hellström (Intel)
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 03/15] drm/i915: Fix i915_sg_page_sizes to record dma segments rather than physical pages Thomas Hellström
2021-05-18 8:46 ` Matthew Auld
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 04/15] drm/ttm: Export functions to initialize and finalize the ttm range manager standalone Thomas Hellström
2021-05-18 9:03 ` Daniel Vetter [this message]
2021-05-18 11:51 ` Christian König
2021-05-18 13:06 ` Thomas Hellström
2021-05-18 13:11 ` Christian König
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 05/15] drm/i915/ttm Initialize the ttm device and memory managers Thomas Hellström
2021-05-18 9:05 ` Matthew Auld
2021-05-18 9:09 ` Matthew Auld
2021-05-18 9:12 ` Thomas Hellström
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 06/15] drm/i915/ttm: Embed a ttm buffer object in the i915 gem object Thomas Hellström
2021-05-18 11:44 ` Maarten Lankhorst
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 07/15] drm/ttm: Export ttm_bo_tt_destroy() Thomas Hellström
2021-05-18 11:46 ` Maarten Lankhorst
2021-05-18 12:01 ` Christian König
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 08/15] drm/i915/ttm Add a generic TTM memcpy move for page-based iomem Thomas Hellström
2021-05-18 11:55 ` Christian König
2021-05-18 12:04 ` Thomas Hellström
2021-05-18 12:09 ` Christian König
2021-05-18 12:52 ` Thomas Hellström
2021-05-18 13:08 ` Christian König
2021-05-18 13:24 ` Thomas Hellström
2021-05-18 13:26 ` Christian König
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 09/15] drm/ttm, drm/amdgpu: Allow the driver some control over swapping Thomas Hellström
2021-05-18 12:19 ` Maarten Lankhorst
2021-05-18 15:15 ` Thomas Hellström
2021-05-18 15:18 ` Christian König
2021-05-18 15:20 ` Thomas Hellström
2021-05-18 15:28 ` Christian König
2021-05-18 15:38 ` Thomas Hellström
2021-05-18 15:42 ` Christian König
2021-05-18 16:07 ` Thomas Hellström
2021-05-18 16:30 ` Christian König
2021-05-19 6:27 ` Thomas Hellström
2021-05-19 10:43 ` Christian König
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 10/15] drm/i915/ttm: Introduce a TTM i915 gem object backend Thomas Hellström
2021-05-19 9:53 ` Matthew Auld
2021-05-19 11:29 ` Thomas Hellström
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 11/15] drm/i915/lmem: Verify checks for lmem residency Thomas Hellström
2021-05-19 10:04 ` Matthew Auld
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 12/15] drm/i915: Disable mmap ioctl for gen12+ Thomas Hellström
2021-05-18 8:41 ` Thomas Hellström
2021-05-18 8:26 ` [Intel-gfx] [PATCH v2 13/15] drm/ttm: Add BO and offset arguments for vm_access and vm_fault ttm handlers Thomas Hellström
2021-05-18 8:59 ` Thomas Hellström
2021-05-18 11:59 ` Christian König
2021-05-18 14:59 ` Thomas Hellström
2021-05-18 8:27 ` [Intel-gfx] [PATCH v2 14/15] drm/i915: Use ttm mmap handling for ttm bo's Thomas Hellström
2021-05-18 9:17 ` Thomas Hellström
2021-05-18 8:27 ` [Intel-gfx] [PATCH v2 15/15] drm/i915/ttm: Add io sgt caching to i915_ttm_io_mem_pfn Thomas Hellström
2021-05-18 9:33 ` Thomas Hellström
2021-05-18 8:44 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Move LMEM (VRAM) management over to TTM (rev2) Patchwork
2021-05-18 8:47 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-05-18 9:14 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " Patchwork
2021-05-18 17:02 ` [Intel-gfx] ✓ Fi.CI.IGT: success " 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=YKOC9/Nn9i9fpgHc@phenom.ffwll.local \
--to=daniel@ffwll.ch \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--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