[PATCH 3/3] drm/i915/guc: Use new IDA for MLRC GuC IDs
Michal Wajdeczko
michal.wajdeczko at intel.com
Tue Oct 31 22:53:09 UTC 2023
WIP
Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
---
drivers/gpu/drm/i915/gt/uc/intel_guc.h | 6 +-
.../gpu/drm/i915/gt/uc/intel_guc_submission.c | 63 ++++++-------------
2 files changed, 20 insertions(+), 49 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc.h b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
index 2b6dfe62c8f2..1fb1aa19a75f 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc.h
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc.h
@@ -111,7 +111,7 @@ struct intel_guc {
*/
spinlock_t lock;
/**
- * @guc_ids: used to allocate new guc_ids, single-lrc
+ * @guc_ids: used to allocate new guc_ids
*/
struct ida guc_ids;
/**
@@ -119,10 +119,6 @@ struct intel_guc {
* to reduce this number while testing.
*/
int num_guc_ids;
- /**
- * @guc_ids_bitmap: used to allocate new guc_ids, multi-lrc
- */
- unsigned long *guc_ids_bitmap;
/**
* @guc_id_list: list of intel_context with valid guc_ids but no
* refs
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index d37698bd6b91..43446a56e58f 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -150,17 +150,6 @@ guc_create_parallel(struct intel_engine_cs **engines,
#define GUC_REQUEST_SIZE 64 /* bytes */
-/*
- * We reserve 1/16 of the guc_ids for multi-lrc as these need to be contiguous
- * per the GuC submission interface. A different allocation algorithm is used
- * (bitmap vs. ida) between multi-lrc and single-lrc hence the reason to
- * partition the guc_id space. We believe the number of multi-lrc contexts in
- * use should be low and 1/16 should be sufficient. Minimum of 32 guc_ids for
- * multi-lrc.
- */
-#define NUMBER_MULTI_LRC_GUC_ID(guc) \
- ((guc)->submission_state.num_guc_ids / 16)
-
/*
* Below is a set of functions which control the GuC scheduling state which
* require a lock.
@@ -2045,21 +2034,12 @@ int intel_guc_submission_init(struct intel_guc *guc)
if (ret)
goto destroy_pool;
- guc->submission_state.guc_ids_bitmap =
- bitmap_zalloc(NUMBER_MULTI_LRC_GUC_ID(guc), GFP_KERNEL);
- if (!guc->submission_state.guc_ids_bitmap) {
- ret = -ENOMEM;
- goto destroy_tlb;
- }
-
guc->timestamp.ping_delay = (POLL_TIME_CLKS / gt->clock_frequency + 1) * HZ;
guc->timestamp.shift = gpm_timestamp_shift(gt);
guc->submission_initialized = true;
return 0;
-destroy_tlb:
- fini_tlb_lookup(guc);
destroy_pool:
guc_lrc_desc_pool_destroy_v69(guc);
return ret;
@@ -2073,7 +2053,7 @@ void intel_guc_submission_fini(struct intel_guc *guc)
guc_flush_destroyed_contexts(guc);
guc_lrc_desc_pool_destroy_v69(guc);
i915_sched_engine_put(guc->sched_engine);
- bitmap_free(guc->submission_state.guc_ids_bitmap);
+ ida_destroy(&guc->submission_state.guc_ids);
fini_tlb_lookup(guc);
guc->submission_initialized = false;
}
@@ -2144,26 +2124,23 @@ static void guc_submit_request(struct i915_request *rq)
static int new_guc_id(struct intel_guc *guc, struct intel_context *ce)
{
+ unsigned int num_ids = 1;
int ret;
GEM_BUG_ON(intel_context_is_child(ce));
if (intel_context_is_parent(ce))
- ret = bitmap_find_free_region(guc->submission_state.guc_ids_bitmap,
- NUMBER_MULTI_LRC_GUC_ID(guc),
- order_base_2(ce->parallel.number_children
- + 1));
- else
- ret = ida_simple_get(&guc->submission_state.guc_ids,
- NUMBER_MULTI_LRC_GUC_ID(guc),
- guc->submission_state.num_guc_ids,
- GFP_KERNEL | __GFP_RETRY_MAYFAIL |
- __GFP_NOWARN);
+ num_ids <<= order_base_2(ce->parallel.number_children + 1);
+
+ ret = ida_alloc_group_range(&guc->submission_state.guc_ids,
+ 0, guc->submission_state.num_guc_ids - 1,
+ num_ids - 1,
+ GFP_KERNEL | __GFP_RETRY_MAYFAIL |
+ __GFP_NOWARN);
if (unlikely(ret < 0))
return ret;
- if (!intel_context_is_parent(ce))
- ++guc->submission_state.guc_ids_in_use;
+ guc->submission_state.guc_ids_in_use += num_ids;
ce->guc_id.id = ret;
return 0;
@@ -2174,16 +2151,14 @@ static void __release_guc_id(struct intel_guc *guc, struct intel_context *ce)
GEM_BUG_ON(intel_context_is_child(ce));
if (!context_guc_id_invalid(ce)) {
- if (intel_context_is_parent(ce)) {
- bitmap_release_region(guc->submission_state.guc_ids_bitmap,
- ce->guc_id.id,
- order_base_2(ce->parallel.number_children
- + 1));
- } else {
- --guc->submission_state.guc_ids_in_use;
- ida_simple_remove(&guc->submission_state.guc_ids,
- ce->guc_id.id);
- }
+ unsigned int num_ids = 1;
+
+ if (intel_context_is_parent(ce))
+ num_ids <<= order_base_2(ce->parallel.number_children + 1);
+
+ ida_free_group(&guc->submission_state.guc_ids, ce->guc_id.id, num_ids - 1);
+ guc->submission_state.guc_ids_in_use -= num_ids;
+
clr_ctx_id_mapping(guc, ce->guc_id.id);
set_context_guc_id_invalid(ce);
}
@@ -4639,7 +4614,7 @@ static bool __guc_submission_selected(struct intel_guc *guc)
int intel_guc_sched_disable_gucid_threshold_max(struct intel_guc *guc)
{
- return guc->submission_state.num_guc_ids - NUMBER_MULTI_LRC_GUC_ID(guc);
+ return guc->submission_state.num_guc_ids;
}
/*
--
2.25.1
More information about the Intel-gfx-trybot
mailing list