accel/ivpu: Limit SSIDs to 128 on all generations
Karol Wachowski
maintainerPATCH 1/1 accel/ivpu: Limit SSIDs to 128 on all generations
Some generations support only 128 SSIDs, while the KMD configured 256 CD table entries and allowed user contexts up to SSID 130. Align the limit across all generations.
Limit the CD table to 128 entries and the user SSID range to 2-127, so root can create 126 contexts and non-root users 64. Also fix the off by one SSID bounds checks against the CD table size.
--- drivers/accel/ivpu/ivpu_drv.c | 2 +- drivers/accel/ivpu/ivpu_drv.h | 3 ++- drivers/accel/ivpu/ivpu_mmu.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-)
drivers/accel/ivpu/ivpu_drv.c +1 -1
@@ -127,7 +127,7 @@ static struct ivpu_user_limits *ivpu_user_limits_alloc(struct ivpu_device *vdev, limits->max_ctx_count =ivpu_get_context_count (vdev); limits->max_db_count =ivpu_get_doorbell_count (vdev); }else { - limits->max_ctx_count =ivpu_get_context_count (vdev) /2 ; + limits->max_ctx_count =IVPU_NON_ROOT_USER_MAX_CONTEXTS ; limits->max_db_count =ivpu_get_doorbell_count (vdev) /2 ; }
drivers/accel/ivpu/ivpu_drv.h +2 -1
@@ -38,7 +38,8 @@/* SSID 1 is used by the VPU to represent reserved context */ #define IVPU_RESERVED_CONTEXT_MMU_SSID 1#define IVPU_USER_CONTEXT_MIN_SSID 2 -#define IVPU_USER_CONTEXT_MAX_SSID (IVPU_USER_CONTEXT_MIN_SSID + 128) +#define IVPU_USER_CONTEXT_MAX_SSID 127 +#define IVPU_NON_ROOT_USER_MAX_CONTEXTS 64#define IVPU_MIN_DB 1#define IVPU_MAX_DB 255
drivers/accel/ivpu/ivpu_mmu.c +3 -3
@@ -65,7 +65,7 @@#define IVPU_MMU_IDR5_REF_FPGA 0x00800075#define IVPU_MMU_CDTAB_ENT_SIZE 64 -#define IVPU_MMU_CDTAB_ENT_COUNT_LOG2 8/* 256 entries */ +#define IVPU_MMU_CDTAB_ENT_COUNT_LOG2 7/* 128 entries */ #define IVPU_MMU_CDTAB_ENT_COUNT ((u32)1 << IVPU_MMU_CDTAB_ENT_COUNT_LOG2)#define IVPU_MMU_STREAM_ID0 0
@@ -700,7 +700,7 @@ static int ivpu_mmu_cdtab_entry_set(struct ivpu_device *vdev, u32 ssid, u64 cd_du64 cd[4 ];int ret =0 ; -if (ssid >IVPU_MMU_CDTAB_ENT_COUNT ) +if (ssid >=IVPU_MMU_CDTAB_ENT_COUNT )return -EINVAL ; entry = cdtab->base + (ssid *IVPU_MMU_CDTAB_ENT_SIZE );
@@ -918,7 +918,7 @@ int ivpu_mmu_disable_ssid_events(struct ivpu_device *vdev, u32 ssid)u64 *entry;u64 val; -if (ssid >IVPU_MMU_CDTAB_ENT_COUNT ) +if (ssid >=IVPU_MMU_CDTAB_ENT_COUNT )return -EINVAL ;mutex_lock (&mmu->lock);
Signature · 1 line
2.43.0
Quoted 3 lines · Karol Wachowski
Some generations support only 128 SSIDs, while the KMD configured 256 CD table entries and allowed user contexts up to SSID 130. Align the limit across all generations.
When I read this, I have the question, why limit to 128 for all generations when I assume some generations support more than 128. Would that not be a handicap for users on the gen(s) which can utilize more? It seems like the justification for applying this lowest common denominator across everything is not quite clear to an outsider.
Quoted 5 lines
Limit the CD table to 128 entries and the user SSID range to 2-127, so root can create 126 contexts and non-root users 64. Also fix the off by one SSID bounds checks against the CD table size.
Signed-off-by Karol Wachowski <[email protected]>
Wachowski, Karol
maintainerQuoted 10 lines · Jeff Hugo
Quoted 3 lines · Karol Wachowski
Some generations support only 128 SSIDs, while the KMD configured 256 CD table entries and allowed user contexts up to SSID 130. Align the limit across all generations.
When I read this, I have the question, why limit to 128 for all generations when I assume some generations support more than 128. Would that not be a handicap for users on the gen(s) which can utilize more? It seems like the justification for applying this lowest common denominator across everything is not quite clear to an outsider.
Quoted 3 lines
Limit the CD table to 128 entries and the user SSID range to 2-127, so root can create 126 contexts and non-root users 64. Also fix the off by one SSID bounds checks against the CD table size.
Hi,
The commit message could have been clearer. Before this patch the driver allowed 128 user contexts (MIN_SSID + 128). Now the limit is 128 SSIDs in total, which leaves 126 user contexts.
So the real cost is 2 contexts for root. Non-root stays at 64.
In return the SSID range, the CD table size and the bounds checks all match. Testing gets simpler, because we can check exact limits instead of loose minimums. The userspace interface also becomes consistent, with the same limits everywhere.
I'll add this to the commit message in v2.
Thanks,
Karol
Quoted 3 lines
Quoted 2 lines
Signed-off-by Karol Wachowski <[email protected]>