freedreno: Remap high/norm/low priorities
authorRob Clark <robdclark@chromium.org>
Tue, 13 Sep 2022 18:14:46 +0000 (11:14 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 14 Sep 2022 02:06:27 +0000 (02:06 +0000)
At the gallium level, we only have three priorities.  But if kernel
supports preemption we'll have 3*nr_rings priority levels.  We'd prefer
to have the priorities that userspace picks be distributed over the
entire range of priorities so that preemption can work.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18584>

src/gallium/drivers/freedreno/freedreno_context.c
src/gallium/drivers/freedreno/freedreno_screen.c
src/gallium/drivers/freedreno/freedreno_screen.h

index 15e0934..1330b09 100644 (file)
@@ -591,15 +591,15 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 {
    struct fd_screen *screen = fd_screen(pscreen);
    struct pipe_context *pctx;
-   unsigned prio = 1;
+   unsigned prio = screen->prio_norm;
 
    /* lower numerical value == higher priority: */
    if (FD_DBG(HIPRIO))
-      prio = 0;
+      prio = screen->prio_high;
    else if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
-      prio = 0;
+      prio = screen->prio_high;
    else if (flags & PIPE_CONTEXT_LOW_PRIORITY)
-      prio = 2;
+      prio = screen->prio_low;
 
    /* Some of the stats will get printed out at context destroy, so
     * make sure they are collected:
index 0893ca9..602a018 100644 (file)
@@ -1037,6 +1037,21 @@ fd_screen_create(struct fd_device *dev, struct renderonly *ro,
    } else {
       /* # of rings equates to number of unique priority values: */
       screen->priority_mask = (1 << val) - 1;
+
+      /* Lowest numerical value (ie. zero) is highest priority: */
+      screen->prio_high = 0;
+
+      /* Highest numerical value is lowest priority: */
+      screen->prio_low = val - 1;
+
+      /* Pick midpoint for normal priority.. note that whatever the
+       * range of possible priorities, since we divide by 2 the
+       * result will either be an integer or an integer plus 0.5,
+       * in which case it will round down to an integer, so int
+       * division will give us an appropriate result in either
+       * case:
+       */
+      screen->prio_norm = val / 2;
    }
 
    if (fd_device_version(dev) >= FD_VERSION_ROBUSTNESS)
index a97f256..b389112 100644 (file)
@@ -89,6 +89,7 @@ struct fd_screen {
    uint32_t ram_size;
    uint32_t max_rts; /* max # of render targets */
    uint32_t priority_mask;
+   unsigned prio_low, prio_norm, prio_high;  /* remap low/norm/high priority to kernel priority */
    bool has_timestamp;
    bool has_robustness;
    bool has_syncobj;