From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: "Jouni Högander" <jouni.hogander@intel.com>,
intel-xe@lists.freedesktop.org
Subject: Re: [Intel-xe] [PATCH v2 5/9] drivers/xe: Move Xe stolen memory handling away form fbc code
Date: Tue, 30 May 2023 16:13:30 +0200 [thread overview]
Message-ID: <bb5efbaf-f063-ed33-d167-cf87672eb40a@linux.intel.com> (raw)
In-Reply-To: <20230530104713.2570554-6-jouni.hogander@intel.com>
00000000000000
On 2023-05-30 12:47, Jouni Högander wrote:
> More correct place for Xe stolen memory handling details is in
> xe_ttm_stolen_mgr. Move it there and add necessary defines into
> i915_gem_stolen.h to satisfy fbc code.
>
> Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
> ---
> drivers/gpu/drm/i915/display/intel_fbc.c | 62 -----------------
> .../xe/compat-i915-headers/i915_gem_stolen.h | 66 +++++++++++++++++++
> drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 8 +++
> drivers/gpu/drm/xe/xe_ttm_stolen_mgr.h | 1 +
> 4 files changed, 75 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c
> index 90c48ccce1a7..19698ab117a1 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbc.c
> +++ b/drivers/gpu/drm/i915/display/intel_fbc.c
> @@ -61,68 +61,6 @@
> #define i915_gem_stolen_node_offset(node) ((node)->start)
> #define i915_gem_stolen_node_size(node) ((node)->size)
>
> -#else
> -
> -#include "xe_ttm_stolen_mgr.h"
> -#include "xe_res_cursor.h"
> -
> -static inline int i915_gem_stolen_insert_node_in_range(struct xe_device *xe,
> - struct i915_stolen_fb *fb,
> - u32 size, u32 align,
> - u32 start, u32 end)
> -{
> - struct xe_bo *bo;
> - int err;
> - u32 flags = XE_BO_CREATE_PINNED_BIT | XE_BO_CREATE_STOLEN_BIT;
> -
> - bo = xe_bo_create_locked_range(xe, to_gt(xe), NULL, size, start, end,
> - ttm_bo_type_kernel, flags);
> - if (IS_ERR(bo)) {
> - err = PTR_ERR(bo);
> - bo = NULL;
> - return err;
> - }
> - err = xe_bo_pin(bo);
> - xe_bo_unlock_vm_held(bo);
> -
> - if (err) {
> - xe_bo_put(bo);
> - bo = NULL;
> - }
> -
> - fb->bo = bo;
> -
> - return err;
> -}
> -
> -static int i915_gem_stolen_insert_node(struct xe_device *xe,
> - struct i915_stolen_fb *fb, u32 size,
> - u32 align)
> -{
> - /* Not used on xe */
> - BUG_ON(1);
> - return -ENODEV;
> -}
> -
> -static void i915_gem_stolen_remove_node(struct xe_device *xe,
> - struct i915_stolen_fb *fb)
> -{
> - xe_bo_unpin_map_no_vm(fb->bo);
> - fb->bo = NULL;
> -}
> -
> -#define i915_gem_stolen_initialized(xe) (!!ttm_manager_type(&(xe)->ttm, XE_PL_STOLEN))
> -#define i915_gem_stolen_node_allocated(fb) (!!(fb.bo))
> -
> -static inline u32 i915_gem_stolen_node_offset(struct i915_stolen_fb *fb)
> -{
> - struct xe_res_cursor res;
> -
> - xe_res_first(fb->bo->ttm.resource, 0, 4096, &res);
> - return res.start;
> -}
> -
> -#define i915_gem_stolen_node_size(fb) ((u64)((fb)->bo->ttm.base.size))
> #endif
>
> #define for_each_fbc_id(__dev_priv, __fbc_id) \
> diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
> index b6eeeba1087b..a9020d408407 100644
> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_gem_stolen.h
> @@ -1,10 +1,76 @@
> #ifndef _I915_GEM_OBJECT_H_
> #define _I915_GEM_OBJECT_H_
>
> +#include "xe_ttm_stolen_mgr.h"
> +#include "xe_res_cursor.h"
> +
> struct xe_bo;
>
> struct i915_stolen_fb {
> struct xe_bo *bo;
> };
>
> +static inline int i915_gem_stolen_insert_node_in_range(struct xe_device *xe,
> + struct i915_stolen_fb *fb,
> + u32 size, u32 align,
> + u32 start, u32 end)
> +{
> + struct xe_bo *bo;
> + int err;
> + u32 flags = XE_BO_CREATE_PINNED_BIT | XE_BO_CREATE_STOLEN_BIT;
> +
> + bo = xe_bo_create_locked_range(xe, to_gt(xe), NULL, size, start, end,
> + ttm_bo_type_kernel, flags);
> + if (IS_ERR(bo)) {
> + err = PTR_ERR(bo);
> + bo = NULL;
> + return err;
> + }
> + err = xe_bo_pin(bo);
> + xe_bo_unlock_vm_held(bo);
> +
> + if (err) {
> + xe_bo_put(fb->bo);
> + bo = NULL;
> + }
> +
> + fb->bo = bo;
> +
> + return err;
> +}
> +
> +static inline int i915_gem_stolen_insert_node(struct xe_device *xe,
> + struct i915_stolen_fb *fb,
> + u32 size, u32 align)
> +{
> + /* Not used on xe */
> + BUG_ON(1);
> + return -ENODEV;
> +}
> +
> +static inline void i915_gem_stolen_remove_node(struct xe_device *xe,
> + struct i915_stolen_fb *fb)
> +{
> + xe_bo_unpin_map_no_vm(fb->bo);
> + fb->bo = NULL;
> +}
> +
> +#define i915_gem_stolen_initialized(xe) (!!ttm_manager_type(&(xe)->ttm, XE_PL_STOLEN))
> +#define i915_gem_stolen_node_allocated(fb) (!!(fb.bo))
> +
> +static inline u32 i915_gem_stolen_node_offset(struct i915_stolen_fb *fb)
> +{
> + struct xe_res_cursor res;
> +
> + xe_res_first(fb->bo->ttm.resource, 0, 4096, &res);
> + return res.start;
> +}
> +
> +#define i915_gem_stolen_area_address(xe) (xe_ttm_stolen_gpu_offset(xe))
> +#define i915_gem_stolen_area_size(xe) (xe_ttm_stolen_size(xe))
area_size is used for a workaround that's gen9 specific, no point in adding it for xe. Could be (!WARN_ON(1)) instead.
Similarly, the check for area_address is pointless in Xe, as it's used for programming gen4-.
That's why it was ifdeffed out. If it's not expected to be used, it's better not to implement.
~Maarten
next prev parent reply other threads:[~2023-05-30 14:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 10:47 [Intel-xe] [PATCH v2 0/9] Clean-up Xe FBC additions Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 1/9] fixup! drm/i915/display: Implement FBC support Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 2/9] drivers/xe: Add new type for compressed fb Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 3/9] drm/i915/fbc: Add common type for compressed fb to avoid ifdefs Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 4/9] drm/xe: Add i915_gem.h compatibility header Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 5/9] drivers/xe: Move Xe stolen memory handling away form fbc code Jouni Högander
2023-05-30 14:13 ` Maarten Lankhorst [this message]
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 6/9] drm/i915: Move stolen memory handling into i915_gem_stolen Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 7/9] drm/i915/fbc: Stolen initialize can be checked in plane check for i915 as well Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 8/9] drm/i915/fbc: Add function to get number of fences for gt Jouni Högander
2023-05-30 10:47 ` [Intel-xe] [PATCH v2 9/9] Add new fence_id and fence count functions Jouni Högander
2023-05-30 14:01 ` Maarten Lankhorst
2023-05-30 10:49 ` [Intel-xe] ✓ CI.Patch_applied: success for Clean-up Xe FBC additions (rev2) Patchwork
2023-05-30 10:51 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-05-30 10:55 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-05-30 11:23 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-05-30 12:52 ` [Intel-xe] [PATCH v2 0/9] Clean-up Xe FBC additions Jani Nikula
2023-05-30 13:57 ` Hogander, Jouni
2023-05-31 11:27 ` Jani Nikula
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=bb5efbaf-f063-ed33-d167-cf87672eb40a@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jouni.hogander@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