From: Matthew Brost <matthew.brost@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/xe/guc: Use GuC ID Manager in submission code
Date: Mon, 22 Jan 2024 04:10:06 +0000 [thread overview]
Message-ID: <Za3qnkhVxR1FXyTK@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240110174622.409-5-michal.wajdeczko@intel.com>
On Wed, Jan 10, 2024 at 06:46:22PM +0100, Michal Wajdeczko wrote:
> We are ready to replace private guc_ids management code with
> separate GuC ID Manager that can be shared with upcoming SR-IOV
> PF provisioning code.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/xe_guc_submit.c | 36 ++++--------------------------
> drivers/gpu/drm/xe/xe_guc_types.h | 4 ----
> drivers/gpu/drm/xe/xe_uc.c | 5 +++++
> 3 files changed, 9 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 022e93796bf8..845b03f0b6b2 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -25,6 +25,7 @@
> #include "xe_gt.h"
> #include "xe_guc.h"
> #include "xe_guc_ct.h"
> +#include "xe_guc_id_mgr.h"
> #include "xe_guc_exec_queue_types.h"
> #include "xe_guc_submit_types.h"
> #include "xe_hw_engine.h"
> @@ -235,16 +236,10 @@ static void guc_submit_fini(struct drm_device *drm, void *arg)
> struct xe_guc *guc = arg;
>
> xa_destroy(&guc->submission_state.exec_queue_lookup);
> - ida_destroy(&guc->submission_state.guc_ids);
> - bitmap_free(guc->submission_state.guc_ids_bitmap);
> free_submit_wq(guc);
> mutex_destroy(&guc->submission_state.lock);
> }
>
> -#define GUC_ID_NUMBER_MLRC 4096
> -#define GUC_ID_NUMBER_SLRC (GUC_ID_MAX - GUC_ID_NUMBER_MLRC)
> -#define GUC_ID_START_MLRC GUC_ID_NUMBER_SLRC
> -
> static const struct xe_exec_queue_ops guc_exec_queue_ops;
>
> static void primelockdep(struct xe_guc *guc)
> @@ -267,22 +262,14 @@ int xe_guc_submit_init(struct xe_guc *guc)
> struct xe_gt *gt = guc_to_gt(guc);
> int err;
>
> - guc->submission_state.guc_ids_bitmap =
> - bitmap_zalloc(GUC_ID_NUMBER_MLRC, GFP_KERNEL);
> - if (!guc->submission_state.guc_ids_bitmap)
> - return -ENOMEM;
> -
> err = alloc_submit_wq(guc);
> - if (err) {
> - bitmap_free(guc->submission_state.guc_ids_bitmap);
> + if (err)
> return err;
> - }
>
> gt->exec_queue_ops = &guc_exec_queue_ops;
>
> mutex_init(&guc->submission_state.lock);
> xa_init(&guc->submission_state.exec_queue_lookup);
> - ida_init(&guc->submission_state.guc_ids);
>
> spin_lock_init(&guc->submission_state.suspend.lock);
> guc->submission_state.suspend.context = dma_fence_context_alloc(1);
> @@ -305,12 +292,7 @@ static void __release_guc_id(struct xe_guc *guc, struct xe_exec_queue *q, u32 xa
> for (i = 0; i < xa_count; ++i)
> xa_erase(&guc->submission_state.exec_queue_lookup, q->guc->id + i);
>
> - if (xe_exec_queue_is_parallel(q))
> - bitmap_release_region(guc->submission_state.guc_ids_bitmap,
> - q->guc->id - GUC_ID_START_MLRC,
> - order_base_2(q->width));
> - else
> - ida_simple_remove(&guc->submission_state.guc_ids, q->guc->id);
> + xe_guc_id_mgr_release_locked(&guc->idm, q->guc->id, order_base_2(q->width));
> }
>
> static int alloc_guc_id(struct xe_guc *guc, struct xe_exec_queue *q)
> @@ -328,21 +310,11 @@ static int alloc_guc_id(struct xe_guc *guc, struct xe_exec_queue *q)
> */
> lockdep_assert_held(&guc->submission_state.lock);
>
> - if (xe_exec_queue_is_parallel(q)) {
> - void *bitmap = guc->submission_state.guc_ids_bitmap;
> -
> - ret = bitmap_find_free_region(bitmap, GUC_ID_NUMBER_MLRC,
> - order_base_2(q->width));
> - } else {
> - ret = ida_simple_get(&guc->submission_state.guc_ids, 0,
> - GUC_ID_NUMBER_SLRC, GFP_NOWAIT);
> - }
> + ret = xe_guc_id_mgr_reserve_locked(&guc->idm, order_base_2(q->width));
> if (ret < 0)
> return ret;
>
> q->guc->id = ret;
> - if (xe_exec_queue_is_parallel(q))
> - q->guc->id += GUC_ID_START_MLRC;
>
> for (i = 0; i < q->width; ++i) {
> ptr = xa_store(&guc->submission_state.exec_queue_lookup,
> diff --git a/drivers/gpu/drm/xe/xe_guc_types.h b/drivers/gpu/drm/xe/xe_guc_types.h
> index 04529be0917e..d2668889919f 100644
> --- a/drivers/gpu/drm/xe/xe_guc_types.h
> +++ b/drivers/gpu/drm/xe/xe_guc_types.h
> @@ -68,10 +68,6 @@ struct xe_guc {
> struct {
> /** @exec_queue_lookup: Lookup an xe_engine from guc_id */
> struct xarray exec_queue_lookup;
> - /** @guc_ids: used to allocate new guc_ids, single-lrc */
> - struct ida guc_ids;
> - /** @guc_ids_bitmap: used to allocate new guc_ids, multi-lrc */
> - unsigned long *guc_ids_bitmap;
> /** @stopped: submissions are stopped */
> atomic_t stopped;
> /** @lock: protects submission state */
> diff --git a/drivers/gpu/drm/xe/xe_uc.c b/drivers/gpu/drm/xe/xe_uc.c
> index 4408ea1751e7..3a0023d3fa2c 100644
> --- a/drivers/gpu/drm/xe/xe_uc.c
> +++ b/drivers/gpu/drm/xe/xe_uc.c
> @@ -10,6 +10,7 @@
> #include "xe_gt.h"
> #include "xe_guc.h"
> #include "xe_guc_db_mgr.h"
> +#include "xe_guc_id_mgr.h"
> #include "xe_guc_pc.h"
> #include "xe_guc_submit.h"
> #include "xe_huc.h"
> @@ -65,6 +66,10 @@ int xe_uc_init(struct xe_uc *uc)
> if (ret)
> goto err;
>
> + ret = xe_guc_id_mgr_init(&uc->guc.idm, ~0);
Nit - I'd probably move this into xe_guc_submit_init() with
s/guc.idm/guc.submission_state.idm.
Otherwise LGTM.
Matt
> + if (ret)
> + goto err;
> +
> return 0;
>
> err:
> --
> 2.25.1
>
next prev parent reply other threads:[~2024-01-22 4:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-10 17:46 [PATCH 0/4] Introduce GuC context ID Manager Michal Wajdeczko
2024-01-10 17:46 ` [PATCH 1/4] drm/xe/guc: Move GUC_ID_MAX definition to GuC ABI header Michal Wajdeczko
2024-01-22 3:15 ` Matthew Brost
2024-01-10 17:46 ` [PATCH 2/4] drm/xe/guc: Introduce GuC context ID Manager Michal Wajdeczko
2024-01-22 3:53 ` Matthew Brost
2024-03-13 22:09 ` Michal Wajdeczko
2024-01-10 17:46 ` [PATCH 3/4] drm/xe/kunit: Add basic tests for " Michal Wajdeczko
2024-01-10 17:46 ` [PATCH 4/4] drm/xe/guc: Use GuC ID Manager in submission code Michal Wajdeczko
2024-01-22 4:10 ` Matthew Brost [this message]
2024-01-10 22:08 ` ✓ CI.Patch_applied: success for Introduce GuC context ID Manager Patchwork
2024-01-10 22:09 ` ✗ CI.checkpatch: warning " Patchwork
2024-01-10 22:10 ` ✓ CI.KUnit: success " Patchwork
2024-01-10 22:17 ` ✓ CI.Build: " Patchwork
2024-01-10 22:18 ` ✓ CI.Hooks: " Patchwork
2024-01-10 22:19 ` ✓ CI.checksparse: " Patchwork
2024-01-10 22:56 ` ✗ CI.BAT: failure " Patchwork
2024-01-11 20:30 ` Michal Wajdeczko
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=Za3qnkhVxR1FXyTK@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=michal.wajdeczko@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