From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 10/13] drm/i915/dsb: Allow the caller to pass in the DSB buffer size
Date: Fri, 16 Dec 2022 02:38:07 +0200 [thread overview]
Message-ID: <20221216003810.13338-11-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20221216003810.13338-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
The caller should more or less know how many DSB commands it
wants to emit into the command buffer, so allow it to specify
the size of the command buffer rather than having the low level
DSB code guess it.
Technically we can emit as many as 134+1033 (for adl+ degamma +
10bit gamma) register writes but thanks to the DSB indexed register
write command we get significant space savings so the current size
estimate of 8KiB (~1024 DSB commands) is sufficient for now.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/i915/display/intel_color.c | 2 +-
drivers/gpu/drm/i915/display/intel_dsb.c | 42 +++++++++++++---------
drivers/gpu/drm/i915/display/intel_dsb.h | 3 +-
3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index 76603357252d..8d97c299e657 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -1380,7 +1380,7 @@ void intel_color_prepare_commit(struct intel_crtc_state *crtc_state)
/* FIXME DSB has issues loading LUTs, disable it for now */
return;
- crtc_state->dsb = intel_dsb_prepare(crtc);
+ crtc_state->dsb = intel_dsb_prepare(crtc, 1024);
}
void intel_color_cleanup_commit(struct intel_crtc_state *crtc_state)
diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
index 636c57767f97..7c593ec84d41 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.c
+++ b/drivers/gpu/drm/i915/display/intel_dsb.c
@@ -30,21 +30,24 @@ struct intel_dsb {
struct intel_crtc *crtc;
/*
- * free_pos will point the first free entry position
- * and help in calculating tail of command buffer.
+ * maximum number of dwords the buffer will hold.
*/
- int free_pos;
+ unsigned int size;
/*
- * ins_start_offset will help to store start address of the dsb
+ * free_pos will point the first free dword and
+ * help in calculating tail of command buffer.
+ */
+ unsigned int free_pos;
+
+ /*
+ * ins_start_offset will help to store start dword of the dsb
* instuction and help in identifying the batch of auto-increment
* register.
*/
- u32 ins_start_offset;
+ unsigned int ins_start_offset;
};
-#define DSB_BUF_SIZE (2 * PAGE_SIZE)
-
/**
* DOC: DSB
*
@@ -76,7 +79,7 @@ static bool assert_dsb_has_room(struct intel_dsb *dsb)
struct drm_i915_private *i915 = to_i915(crtc->base.dev);
/* each instruction is 2 dwords */
- return !drm_WARN(&i915->drm, ALIGN(dsb->free_pos, 2) > DSB_BUF_SIZE / 4 - 2,
+ return !drm_WARN(&i915->drm, dsb->free_pos > dsb->size - 2,
"DSB buffer overflow\n");
}
@@ -168,7 +171,7 @@ void intel_dsb_reg_write(struct intel_dsb *dsb,
if (intel_dsb_prev_ins_is_mmio_write(dsb, reg)) {
u32 prev_val = buf[dsb->ins_start_offset + 0];
- buf[dsb->ins_start_offset + 0] = 1; /* size */
+ buf[dsb->ins_start_offset + 0] = 1; /* count */
buf[dsb->ins_start_offset + 1] =
(DSB_OPCODE_INDEXED_WRITE << DSB_OPCODE_SHIFT) |
i915_mmio_reg_offset(reg);
@@ -178,7 +181,7 @@ void intel_dsb_reg_write(struct intel_dsb *dsb,
}
buf[dsb->free_pos++] = val;
- /* Update the size. */
+ /* Update the count */
buf[dsb->ins_start_offset]++;
/* if number of data words is odd, then the last dword should be 0.*/
@@ -250,6 +253,7 @@ void intel_dsb_commit(struct intel_dsb *dsb)
/**
* intel_dsb_prepare() - Allocate, pin and map the DSB command buffer.
* @crtc: the CRTC
+ * @max_cmds: number of commands we need to fit into command buffer
*
* This function prepare the command buffer which is used to store dsb
* instructions with data.
@@ -257,25 +261,30 @@ void intel_dsb_commit(struct intel_dsb *dsb)
* Returns:
* DSB context, NULL on failure
*/
-struct intel_dsb *intel_dsb_prepare(struct intel_crtc *crtc)
+struct intel_dsb *intel_dsb_prepare(struct intel_crtc *crtc,
+ unsigned int max_cmds)
{
struct drm_i915_private *i915 = to_i915(crtc->base.dev);
- struct intel_dsb *dsb;
struct drm_i915_gem_object *obj;
- struct i915_vma *vma;
- u32 *buf;
intel_wakeref_t wakeref;
+ struct intel_dsb *dsb;
+ struct i915_vma *vma;
+ unsigned int size;
+ u32 *buf;
if (!HAS_DSB(i915))
return NULL;
- dsb = kmalloc(sizeof(*dsb), GFP_KERNEL);
+ dsb = kzalloc(sizeof(*dsb), GFP_KERNEL);
if (!dsb)
goto out;
wakeref = intel_runtime_pm_get(&i915->runtime_pm);
- obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
+ /* ~1 qword per instruction, full cachelines */
+ size = ALIGN(max_cmds * 8, CACHELINE_BYTES);
+
+ obj = i915_gem_object_create_internal(i915, PAGE_ALIGN(size));
if (IS_ERR(obj))
goto out_put_rpm;
@@ -297,6 +306,7 @@ struct intel_dsb *intel_dsb_prepare(struct intel_crtc *crtc)
dsb->vma = vma;
dsb->crtc = crtc;
dsb->cmd_buf = buf;
+ dsb->size = size / 4; /* in dwords */
dsb->free_pos = 0;
dsb->ins_start_offset = 0;
diff --git a/drivers/gpu/drm/i915/display/intel_dsb.h b/drivers/gpu/drm/i915/display/intel_dsb.h
index 25d774049cc2..05c221b6d0a4 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.h
+++ b/drivers/gpu/drm/i915/display/intel_dsb.h
@@ -13,7 +13,8 @@
struct intel_crtc;
struct intel_dsb;
-struct intel_dsb *intel_dsb_prepare(struct intel_crtc *crtc);
+struct intel_dsb *intel_dsb_prepare(struct intel_crtc *crtc,
+ unsigned int max_cmds);
void intel_dsb_cleanup(struct intel_dsb *dsb);
void intel_dsb_reg_write(struct intel_dsb *dsb,
i915_reg_t reg, u32 val);
--
2.37.4
next prev parent reply other threads:[~2022-12-16 0:38 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 0:37 [Intel-gfx] [PATCH 00/13] drm/i915/dsb: DSB fixes/cleanups Ville Syrjala
2022-12-16 0:37 ` [Intel-gfx] [PATCH 01/13] drm/i915/dsb: Stop with the RMW Ville Syrjala
2023-01-04 7:59 ` Manna, Animesh
2022-12-16 0:37 ` [Intel-gfx] [PATCH 02/13] drm/i915/dsb: Inline DSB_CTRL writes into intel_dsb_commit() Ville Syrjala
2023-01-04 8:40 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 03/13] drm/i915/dsb: Align DSB register writes to 8 bytes Ville Syrjala
2023-01-04 9:08 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 04/13] drm/i915/dsb: Fix DSB command buffer size checks Ville Syrjala
2023-01-04 6:57 ` Manna, Animesh
2023-01-04 7:11 ` Manna, Animesh
2023-01-04 10:52 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 05/13] drm/i915/dsb: Extract assert_dsb_has_room() Ville Syrjala
2023-01-04 11:36 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 06/13] drm/i915/dsb: Extract intel_dsb_emit() Ville Syrjala
2023-01-04 11:41 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 07/13] drm/i915/dsb: Improve the indexed reg write checks Ville Syrjala
2023-01-04 12:13 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 08/13] drm/i915/dsb: Handle the indexed vs. not inside the DSB code Ville Syrjala
2023-01-05 14:43 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 09/13] drm/i915/dsb: Introduce intel_dsb_align_tail() Ville Syrjala
2023-01-05 14:46 ` Manna, Animesh
2022-12-16 0:38 ` Ville Syrjala [this message]
2023-01-05 15:19 ` [Intel-gfx] [PATCH 10/13] drm/i915/dsb: Allow the caller to pass in the DSB buffer size Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 11/13] drm/i915/dsb: Add mode DSB opcodes Ville Syrjala
2023-01-05 15:22 ` Manna, Animesh
2023-01-09 9:47 ` Jani Nikula
2023-01-11 12:43 ` Manna, Animesh
2022-12-16 0:38 ` [Intel-gfx] [PATCH 12/13] drm/i915/dsb: Define more DSB registers Ville Syrjala
2023-01-11 15:59 ` Manna, Animesh
2023-01-13 14:37 ` Ville Syrjälä
2022-12-16 0:38 ` [Intel-gfx] [PATCH 13/13] drm/i915/dsb: Pimp debug/error prints Ville Syrjala
2022-12-16 0:57 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/dsb: DSB fixes/cleanups Patchwork
2022-12-16 0:57 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2022-12-16 1:31 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2022-12-16 15:54 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
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=20221216003810.13338-11-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/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