* [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation
@ 2022-10-09 18:48 Marijn Suijten
2022-10-09 18:48 ` [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations Marijn Suijten
` (10 more replies)
0 siblings, 11 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
Various removals of complex yet unnecessary math, fixing all uses of
drm_dsc_config::bits_per_pixel to deal with the fact that this field
includes four fractional bits, and finally making sure that
range_bpg_offset contains values 6-bits wide to prevent overflows in
drm_dsc_pps_payload_pack().
Altogether this series is responsible for solving _all_ Display Stream
Compression issues and artifacts on the Sony Tama (sdm845) Akatsuki
smartphone (2880x1440p).
Changes since v2:
- Generalize mux_word_size setting depending on bits_per_component;
- Migrate DSI's DSC calculations to drm_dsc_compute_rc_parameters(),
implicitly addressing existing math issues;
- Disallow any bits_per_component other than 8, until hardcoded values
are updated and tested to support such cases.
v2: https://lore.kernel.org/linux-arm-msm/20221005181657.784375-1-marijn.suijten@somainline.org/T/#u
Changes since v1:
- Propagate r-b's, except (obviously) in patches that were (heavily)
modified;
- Remove accidental debug code in dsi_cmd_dma_add;
- Move Range BPG Offset masking out of DCS PPS packing, back into the
DSI driver when it is assigned to drm_dsc_config (this series is now
strictly focusing on drm/msm again);
- Replace modulo-check resulting in conditional increment with
DIV_ROUND_UP;
- Remove repeated calculation of slice_chunk_size;
- Use u16 instead of int when handling bits_per_pixel;
- Use DRM_DEV_ERROR instead of pr_err in DSI code;
- Also remove redundant target_bpp_x16 variable.
v1: https://lore.kernel.org/linux-arm-msm/20221001190807.358691-1-marijn.suijten@somainline.org/T/#u
Marijn Suijten (10):
drm/msm/dsi: Remove useless math in DSC calculations
drm/msm/dsi: Remove repeated calculation of slice_per_intf
drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on
modulo
drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size
drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc
drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC
values
drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits
drm/msm/dpu1: Account for DSC's bits_per_pixel having 4 fractional
bits
drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent
bits
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 11 +-
drivers/gpu/drm/msm/dsi/dsi_host.c | 121 ++++++---------------
2 files changed, 37 insertions(+), 95 deletions(-)
--
2.38.0
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
@ 2022-10-09 18:48 ` Marijn Suijten
2022-10-09 18:52 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 02/10] drm/msm/dsi: Remove repeated calculation of slice_per_intf Marijn Suijten
` (9 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
Multiplying a value by 2 and adding 1 to it always results in a value
that is uneven, and that 1 gets truncated immediately when performing
integer division by 2 again. There is no "rounding" possible here.
After that target_bpp_x16 is used to store a multiplication of
bits_per_pixel by 16 which is only ever read to immediately be divided
by 16 again, and is elided in much the same way.
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 8e4bc586c262..70077d1f0f21 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1784,7 +1784,6 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
int hrd_delay;
int pre_num_extra_mux_bits, num_extra_mux_bits;
int slice_bits;
- int target_bpp_x16;
int data;
int final_value, final_scale;
int i;
@@ -1864,14 +1863,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
- /* bpp * 16 + 0.5 */
- data = dsc->bits_per_pixel * 16;
- data *= 2;
- data++;
- data /= 2;
- target_bpp_x16 = data;
-
- data = (dsc->initial_xmit_delay * target_bpp_x16) / 16;
+ data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
final_value = dsc->rc_model_size - data + num_extra_mux_bits;
dsc->final_offset = final_value;
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 02/10] drm/msm/dsi: Remove repeated calculation of slice_per_intf
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
2022-10-09 18:48 ` [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations Marijn Suijten
@ 2022-10-09 18:48 ` Marijn Suijten
2022-10-09 18:53 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 03/10] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo Marijn Suijten
` (8 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel,
Bjorn Andersson
slice_per_intf is already computed for intf_width, which holds the same
value as hdisplay.
Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 70077d1f0f21..c746ed5d61f9 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -842,7 +842,7 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, bool enable,
static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mode, u32 hdisplay)
{
struct drm_dsc_config *dsc = msm_host->dsc;
- u32 reg, intf_width, reg_ctrl, reg_ctrl2;
+ u32 reg, reg_ctrl, reg_ctrl2;
u32 slice_per_intf, total_bytes_per_intf;
u32 pkt_per_line;
u32 bytes_in_slice;
@@ -851,8 +851,7 @@ static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mod
/* first calculate dsc parameters and then program
* compress mode registers
*/
- intf_width = hdisplay;
- slice_per_intf = DIV_ROUND_UP(intf_width, dsc->slice_width);
+ slice_per_intf = DIV_ROUND_UP(hdisplay, dsc->slice_width);
/* If slice_per_pkt is greater than slice_per_intf
* then default to 1. This can happen during partial
@@ -861,7 +860,6 @@ static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mod
if (slice_per_intf > dsc->slice_count)
dsc->slice_count = 1;
- slice_per_intf = DIV_ROUND_UP(hdisplay, dsc->slice_width);
bytes_in_slice = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
dsc->slice_chunk_size = bytes_in_slice;
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 03/10] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
2022-10-09 18:48 ` [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations Marijn Suijten
2022-10-09 18:48 ` [PATCH v3 02/10] drm/msm/dsi: Remove repeated calculation of slice_per_intf Marijn Suijten
@ 2022-10-09 18:48 ` Marijn Suijten
2022-10-09 18:53 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 04/10] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size Marijn Suijten
` (7 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
This exact same math is used to compute bytes_in_slice above in
dsi_update_dsc_timing(), also used to fill slice_chunk_size.
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index c746ed5d61f9..48c966375ffa 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1829,9 +1829,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
* params are calculated
*/
groups_per_line = DIV_ROUND_UP(dsc->slice_width, 3);
- dsc->slice_chunk_size = dsc->slice_width * dsc->bits_per_pixel / 8;
- if ((dsc->slice_width * dsc->bits_per_pixel) % 8)
- dsc->slice_chunk_size++;
+ dsc->slice_chunk_size = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
/* rbs-min */
min_rate_buffer_size = dsc->rc_model_size - dsc->initial_offset +
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 04/10] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (2 preceding siblings ...)
2022-10-09 18:48 ` [PATCH v3 03/10] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo Marijn Suijten
@ 2022-10-09 18:48 ` Marijn Suijten
2022-10-09 18:54 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc Marijn Suijten
` (6 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
dsi_populate_dsc_params() is called prior to dsi_update_dsc_timing() and
already computes a value for slice_chunk_size, whose value doesn't need
to be recomputed and re-set here.
Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 48c966375ffa..f42794cdd4c1 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -845,7 +845,6 @@ static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mod
u32 reg, reg_ctrl, reg_ctrl2;
u32 slice_per_intf, total_bytes_per_intf;
u32 pkt_per_line;
- u32 bytes_in_slice;
u32 eol_byte_num;
/* first calculate dsc parameters and then program
@@ -860,11 +859,7 @@ static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mod
if (slice_per_intf > dsc->slice_count)
dsc->slice_count = 1;
- bytes_in_slice = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
-
- dsc->slice_chunk_size = bytes_in_slice;
-
- total_bytes_per_intf = bytes_in_slice * slice_per_intf;
+ total_bytes_per_intf = dsc->slice_chunk_size * slice_per_intf;
eol_byte_num = total_bytes_per_intf % 3;
pkt_per_line = slice_per_intf / dsc->slice_count;
@@ -890,7 +885,7 @@ static void dsi_update_dsc_timing(struct msm_dsi_host *msm_host, bool is_cmd_mod
reg_ctrl |= reg;
reg_ctrl2 &= ~DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH__MASK;
- reg_ctrl2 |= DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH(bytes_in_slice);
+ reg_ctrl2 |= DSI_COMMAND_COMPRESSION_MODE_CTRL2_STREAM0_SLICE_WIDTH(dsc->slice_chunk_size);
dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL, reg_ctrl);
dsi_write(msm_host, REG_DSI_COMMAND_COMPRESSION_MODE_CTRL2, reg_ctrl2);
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (3 preceding siblings ...)
2022-10-09 18:48 ` [PATCH v3 04/10] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size Marijn Suijten
@ 2022-10-09 18:48 ` Marijn Suijten
2022-10-09 18:55 ` Dmitry Baryshkov
2022-10-12 22:53 ` Abhinav Kumar
2022-10-09 18:48 ` [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters() Marijn Suijten
` (5 subsequent siblings)
10 siblings, 2 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
This field is currently unread but will come into effect when duplicated
code below is migrated to call drm_dsc_compute_rc_parameters(), which
uses the bpc-dependent value of the local variable mux_words_size in
much the same way.
The hardcoded constant seems to be a remnant from the `/* bpc 8 */`
comment right above, indicating that this group of field assignments is
applicable to bpc = 8 exclusively and should probably bail out on
different bpc values, until constants for other bpc values are added (or
the current ones are confirmed to be correct across multiple bpc's).
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index f42794cdd4c1..83cde4d62b68 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1808,6 +1808,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
if (dsc->bits_per_component == 12)
mux_words_size = 64;
+ dsc->mux_word_size = mux_words_size;
dsc->initial_xmit_delay = 512;
dsc->initial_scale_value = 32;
dsc->first_line_bpg_offset = 12;
@@ -1818,7 +1819,6 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
dsc->flatness_max_qp = 12;
dsc->rc_quant_incr_limit0 = 11;
dsc->rc_quant_incr_limit1 = 11;
- dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
/* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
* params are calculated
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (4 preceding siblings ...)
2022-10-09 18:48 ` [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc Marijn Suijten
@ 2022-10-09 18:48 ` Marijn Suijten
2022-10-09 18:56 ` Dmitry Baryshkov
2022-10-09 18:50 ` Marijn Suijten
` (4 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:48 UTC (permalink / raw)
To: phone-devel, Rob Clark, Abhinav Kumar, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Sean Paul, David Airlie, Daniel Vetter, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
As per the FIXME this code is entirely duplicate with what is already
provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
why this comment was put in place instead of resolved from the get-go.
Not only does it save on duplication, it would have also spared certain
issues.
For example, this code from downstream assumed dsc->bits_per_pixel to
contain an integer value, whereas the upstream drm_dsc_config struct has
it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
accounts for this feat, and the sole remaining use of
dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
in a separate patch.
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 64 +++---------------------------
1 file changed, 6 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 83cde4d62b68..68c39debc22f 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -21,6 +21,7 @@
#include <video/mipi_display.h>
+#include <drm/display/drm_dsc_helper.h>
#include <drm/drm_of.h>
#include "dsi.h"
@@ -1771,14 +1772,6 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
{
- int mux_words_size;
- int groups_per_line, groups_total;
- int min_rate_buffer_size;
- int hrd_delay;
- int pre_num_extra_mux_bits, num_extra_mux_bits;
- int slice_bits;
- int data;
- int final_value, final_scale;
int i;
dsc->rc_model_size = 8192;
@@ -1804,11 +1797,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
if (dsc->bits_per_pixel != 8)
dsc->initial_offset = 2048; /* bpp = 12 */
- mux_words_size = 48; /* bpc == 8/10 */
- if (dsc->bits_per_component == 12)
- mux_words_size = 64;
+ if (dsc->bits_per_component <= 10)
+ dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
+ else
+ dsc->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
- dsc->mux_word_size = mux_words_size;
dsc->initial_xmit_delay = 512;
dsc->initial_scale_value = 32;
dsc->first_line_bpg_offset = 12;
@@ -1820,52 +1813,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
dsc->rc_quant_incr_limit0 = 11;
dsc->rc_quant_incr_limit1 = 11;
- /* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
- * params are calculated
- */
- groups_per_line = DIV_ROUND_UP(dsc->slice_width, 3);
- dsc->slice_chunk_size = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
-
- /* rbs-min */
- min_rate_buffer_size = dsc->rc_model_size - dsc->initial_offset +
- dsc->initial_xmit_delay * dsc->bits_per_pixel +
- groups_per_line * dsc->first_line_bpg_offset;
-
- hrd_delay = DIV_ROUND_UP(min_rate_buffer_size, dsc->bits_per_pixel);
-
- dsc->initial_dec_delay = hrd_delay - dsc->initial_xmit_delay;
-
- dsc->initial_scale_value = 8 * dsc->rc_model_size /
- (dsc->rc_model_size - dsc->initial_offset);
-
- slice_bits = 8 * dsc->slice_chunk_size * dsc->slice_height;
-
- groups_total = groups_per_line * dsc->slice_height;
-
- data = dsc->first_line_bpg_offset * 2048;
-
- dsc->nfl_bpg_offset = DIV_ROUND_UP(data, (dsc->slice_height - 1));
-
- pre_num_extra_mux_bits = 3 * (mux_words_size + (4 * dsc->bits_per_component + 4) - 2);
-
- num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size -
- ((slice_bits - pre_num_extra_mux_bits) % mux_words_size));
-
- data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
- dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
-
- data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
- final_value = dsc->rc_model_size - data + num_extra_mux_bits;
- dsc->final_offset = final_value;
-
- final_scale = 8 * dsc->rc_model_size / (dsc->rc_model_size - final_value);
-
- data = (final_scale - 9) * (dsc->nfl_bpg_offset + dsc->slice_bpg_offset);
- dsc->scale_increment_interval = (2048 * dsc->final_offset) / data;
-
- dsc->scale_decrement_interval = groups_per_line / (dsc->initial_scale_value - 8);
-
- return 0;
+ return drm_dsc_compute_rc_parameters(dsc);
}
static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (5 preceding siblings ...)
2022-10-09 18:48 ` [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters() Marijn Suijten
@ 2022-10-09 18:50 ` Marijn Suijten
2022-10-09 18:58 ` Marijn Suijten
2022-10-12 23:03 ` [Freedreno] " Abhinav Kumar
2022-10-09 18:51 ` [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values Marijn Suijten
` (3 subsequent siblings)
10 siblings, 2 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:50 UTC (permalink / raw)
To: phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul,
David Airlie, Daniel Vetter, Vinod Koul, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
As per the FIXME this code is entirely duplicate with what is already
provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
why this comment was put in place instead of resolved from the get-go.
Not only does it save on duplication, it would have also spared certain
issues.
For example, this code from downstream assumed dsc->bits_per_pixel to
contain an integer value, whereas the upstream drm_dsc_config struct has
it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
accounts for this feat, and the sole remaining use of
dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
in a separate patch.
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 64 +++---------------------------
1 file changed, 6 insertions(+), 58 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 83cde4d62b68..68c39debc22f 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -21,6 +21,7 @@
#include <video/mipi_display.h>
+#include <drm/display/drm_dsc_helper.h>
#include <drm/drm_of.h>
#include "dsi.h"
@@ -1771,14 +1772,6 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
{
- int mux_words_size;
- int groups_per_line, groups_total;
- int min_rate_buffer_size;
- int hrd_delay;
- int pre_num_extra_mux_bits, num_extra_mux_bits;
- int slice_bits;
- int data;
- int final_value, final_scale;
int i;
dsc->rc_model_size = 8192;
@@ -1804,11 +1797,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
if (dsc->bits_per_pixel != 8)
dsc->initial_offset = 2048; /* bpp = 12 */
- mux_words_size = 48; /* bpc == 8/10 */
- if (dsc->bits_per_component == 12)
- mux_words_size = 64;
+ if (dsc->bits_per_component <= 10)
+ dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
+ else
+ dsc->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
- dsc->mux_word_size = mux_words_size;
dsc->initial_xmit_delay = 512;
dsc->initial_scale_value = 32;
dsc->first_line_bpg_offset = 12;
@@ -1820,52 +1813,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
dsc->rc_quant_incr_limit0 = 11;
dsc->rc_quant_incr_limit1 = 11;
- /* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
- * params are calculated
- */
- groups_per_line = DIV_ROUND_UP(dsc->slice_width, 3);
- dsc->slice_chunk_size = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
-
- /* rbs-min */
- min_rate_buffer_size = dsc->rc_model_size - dsc->initial_offset +
- dsc->initial_xmit_delay * dsc->bits_per_pixel +
- groups_per_line * dsc->first_line_bpg_offset;
-
- hrd_delay = DIV_ROUND_UP(min_rate_buffer_size, dsc->bits_per_pixel);
-
- dsc->initial_dec_delay = hrd_delay - dsc->initial_xmit_delay;
-
- dsc->initial_scale_value = 8 * dsc->rc_model_size /
- (dsc->rc_model_size - dsc->initial_offset);
-
- slice_bits = 8 * dsc->slice_chunk_size * dsc->slice_height;
-
- groups_total = groups_per_line * dsc->slice_height;
-
- data = dsc->first_line_bpg_offset * 2048;
-
- dsc->nfl_bpg_offset = DIV_ROUND_UP(data, (dsc->slice_height - 1));
-
- pre_num_extra_mux_bits = 3 * (mux_words_size + (4 * dsc->bits_per_component + 4) - 2);
-
- num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size -
- ((slice_bits - pre_num_extra_mux_bits) % mux_words_size));
-
- data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
- dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
-
- data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
- final_value = dsc->rc_model_size - data + num_extra_mux_bits;
- dsc->final_offset = final_value;
-
- final_scale = 8 * dsc->rc_model_size / (dsc->rc_model_size - final_value);
-
- data = (final_scale - 9) * (dsc->nfl_bpg_offset + dsc->slice_bpg_offset);
- dsc->scale_increment_interval = (2048 * dsc->final_offset) / data;
-
- dsc->scale_decrement_interval = groups_per_line / (dsc->initial_scale_value - 8);
-
- return 0;
+ return drm_dsc_compute_rc_parameters(dsc);
}
static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (6 preceding siblings ...)
2022-10-09 18:50 ` Marijn Suijten
@ 2022-10-09 18:51 ` Marijn Suijten
2022-10-09 18:57 ` Dmitry Baryshkov
2022-10-12 23:08 ` Abhinav Kumar
2022-10-09 18:53 ` [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
` (2 subsequent siblings)
10 siblings, 2 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:51 UTC (permalink / raw)
To: phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul,
David Airlie, Daniel Vetter, Vinod Koul, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
According to the `/* bpc 8 */` comment below only values for a
bits_per_component of 8 are currently hardcoded in place. This is
further confirmed by downstream sources [1] containing different
constants for other BPC values (and different initial_offset too,
with an extra dependency on bits_per_pixel). Prevent future mishaps by
explicitly disallowing any other bits_per_component value until the
right parameters are put in place and tested.
[1]: https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers/-/blob/DISPLAY.LA.2.0.r1-08000-WAIPIO.0/msm/sde_dsc_helper.c#L110-139
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 68c39debc22f..7e6b7e506ae8 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1774,6 +1774,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
{
int i;
+ if (dsc->bits_per_component != 8) {
+ DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n");
+ return -EOPNOTSUPP;
+ }
+
dsc->rc_model_size = 8192;
dsc->first_line_bpg_offset = 12;
dsc->rc_edge_factor = 6;
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* Re: [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations
2022-10-09 18:48 ` [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations Marijn Suijten
@ 2022-10-09 18:52 ` Dmitry Baryshkov
0 siblings, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:52 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Abhinav Kumar, Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 09/10/2022 21:48, Marijn Suijten wrote:
> Multiplying a value by 2 and adding 1 to it always results in a value
> that is uneven, and that 1 gets truncated immediately when performing
> integer division by 2 again. There is no "rounding" possible here.
>
> After that target_bpp_x16 is used to store a multiplication of
> bits_per_pixel by 16 which is only ever read to immediately be divided
> by 16 again, and is elided in much the same way.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 02/10] drm/msm/dsi: Remove repeated calculation of slice_per_intf
2022-10-09 18:48 ` [PATCH v3 02/10] drm/msm/dsi: Remove repeated calculation of slice_per_intf Marijn Suijten
@ 2022-10-09 18:53 ` Dmitry Baryshkov
0 siblings, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:53 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Abhinav Kumar, Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel,
Bjorn Andersson
On 09/10/2022 21:48, Marijn Suijten wrote:
> slice_per_intf is already computed for intf_width, which holds the same
> value as hdisplay.
>
> Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Reviewed-by: Vinod Koul <vkoul@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (7 preceding siblings ...)
2022-10-09 18:51 ` [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values Marijn Suijten
@ 2022-10-09 18:53 ` Marijn Suijten
2022-10-09 19:24 ` Dmitry Baryshkov
2022-10-12 23:25 ` Abhinav Kumar
2022-10-09 18:53 ` [PATCH v3 09/10] drm/msm/dpu1: " Marijn Suijten
2022-10-09 18:53 ` [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Marijn Suijten
10 siblings, 2 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:53 UTC (permalink / raw)
To: phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul,
David Airlie, Daniel Vetter, Vinod Koul, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
drm_dsc_config's bits_per_pixel field holds a fractional value with 4
bits, which all panel drivers should adhere to for
drm_dsc_pps_payload_pack() to generate a valid payload. All code in the
DSI driver here seems to assume that this field doesn't contain any
fractional bits, hence resulting in the wrong values being computed.
Since none of the calculations leave any room for fractional bits or
seem to indicate any possible area of support, disallow such values
altogether. calculate_rc_params() in intel_vdsc.c performs an identical
bitshift to get at this integer value.
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 7e6b7e506ae8..46032c576a59 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -34,7 +34,7 @@
#define DSI_RESET_TOGGLE_DELAY_MS 20
-static int dsi_populate_dsc_params(struct drm_dsc_config *dsc);
+static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc);
static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor)
{
@@ -909,6 +909,7 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
u32 va_end = va_start + mode->vdisplay;
u32 hdisplay = mode->hdisplay;
u32 wc;
+ int ret;
DBG("");
@@ -944,7 +945,9 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
/* we do the calculations for dsc parameters here so that
* panel can use these parameters
*/
- dsi_populate_dsc_params(dsc);
+ ret = dsi_populate_dsc_params(msm_host, dsc);
+ if (ret)
+ return;
/* Divide the display by 3 but keep back/font porch and
* pulse width same
@@ -1770,9 +1773,15 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
2, 0, 0, -2, -4, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12
};
-static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
+static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc)
{
int i;
+ u16 bpp = dsc->bits_per_pixel >> 4;
+
+ if (dsc->bits_per_pixel & 0xf) {
+ DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n");
+ return -EINVAL;
+ }
if (dsc->bits_per_component != 8) {
DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n");
@@ -1798,8 +1807,8 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i];
}
- dsc->initial_offset = 6144; /* Not bpp 12 */
- if (dsc->bits_per_pixel != 8)
+ dsc->initial_offset = 6144; /* Not bpp 12 */
+ if (bpp != 8)
dsc->initial_offset = 2048; /* bpp = 12 */
if (dsc->bits_per_component <= 10)
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 09/10] drm/msm/dpu1: Account for DSC's bits_per_pixel having 4 fractional bits
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (8 preceding siblings ...)
2022-10-09 18:53 ` [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
@ 2022-10-09 18:53 ` Marijn Suijten
2022-10-09 18:53 ` [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Marijn Suijten
10 siblings, 0 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:53 UTC (permalink / raw)
To: phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul,
David Airlie, Daniel Vetter, Vinod Koul, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
According to the comment this DPU register contains the bits per pixel
as a 6.4 fractional value, conveniently matching the contents of
bits_per_pixel in struct drm_dsc_config which also uses 4 fractional
bits. However, the downstream source this implementation was
copy-pasted from has its bpp field stored _without_ fractional part.
This makes the entire convoluted math obsolete as it is impossible to
pull those 4 fractional bits out of thin air, by somehow trying to reuse
the lowest 2 bits of a non-fractional bpp (lsb = bpp % 4??).
The rest of the code merely attempts to keep the integer part a multiple
of 4, which is rendered useless thanks to data |= dsc->bits_per_pixel <<
12; already filling up those bits anyway (but not on downstream).
Fixes: c110cfd1753e ("drm/msm/disp/dpu1: Add support for DSC")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Vinod Koul <vkoul@kernel.org>
---
drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c
index 46cc2afd2bb9..c63e6eef1ba6 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_dsc.c
@@ -47,7 +47,7 @@ static void dpu_hw_dsc_config(struct dpu_hw_dsc *hw_dsc,
u32 initial_lines)
{
struct dpu_hw_blk_reg_map *c = &hw_dsc->hw;
- u32 data, lsb, bpp;
+ u32 data;
u32 slice_last_group_size;
u32 det_thresh_flatness;
bool is_cmd_mode = !(mode & DSC_MODE_VIDEO);
@@ -61,14 +61,7 @@ static void dpu_hw_dsc_config(struct dpu_hw_dsc *hw_dsc,
data = (initial_lines << 20);
data |= ((slice_last_group_size - 1) << 18);
/* bpp is 6.4 format, 4 LSBs bits are for fractional part */
- data |= dsc->bits_per_pixel << 12;
- lsb = dsc->bits_per_pixel % 4;
- bpp = dsc->bits_per_pixel / 4;
- bpp *= 4;
- bpp <<= 4;
- bpp |= lsb;
-
- data |= bpp << 8;
+ data |= (dsc->bits_per_pixel << 8);
data |= (dsc->block_pred_enable << 7);
data |= (dsc->line_buf_depth << 3);
data |= (dsc->simple_422 << 2);
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
` (9 preceding siblings ...)
2022-10-09 18:53 ` [PATCH v3 09/10] drm/msm/dpu1: " Marijn Suijten
@ 2022-10-09 18:53 ` Marijn Suijten
2022-10-09 19:14 ` Dmitry Baryshkov
2022-10-12 23:26 ` Abhinav Kumar
10 siblings, 2 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:53 UTC (permalink / raw)
To: phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Marijn Suijten,
Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul,
David Airlie, Daniel Vetter, Vinod Koul, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
The bpg_offset array contains negative BPG offsets which fill the full 8
bits of a char thanks to two's complement: this however results in those
bits bleeding into the next field when the value is packed into DSC PPS
by the drm_dsc_helper function, which only expects range_bpg_offset to
contain 6-bit wide values. As a consequence random slices appear
corrupted on-screen (tested on a Sony Tama Akatsuki device with sdm845).
Use AND operators to limit these two's complement values to 6 bits,
similar to the AMD and i915 drivers.
Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 46032c576a59..c5c2d70ac27d 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -1804,7 +1804,11 @@ static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc
for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
dsc->rc_range_params[i].range_min_qp = min_qp[i];
dsc->rc_range_params[i].range_max_qp = max_qp[i];
- dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i];
+ /*
+ * Range BPG Offset contains two's-complement signed values that fill
+ * 8 bits, yet the registers and DCS PPS field are only 6 bits wide.
+ */
+ dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i] & DSC_RANGE_BPG_OFFSET_MASK;
}
dsc->initial_offset = 6144; /* Not bpp 12 */
--
2.38.0
^ permalink raw reply related [flat|nested] 34+ messages in thread
* Re: [PATCH v3 03/10] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo
2022-10-09 18:48 ` [PATCH v3 03/10] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo Marijn Suijten
@ 2022-10-09 18:53 ` Dmitry Baryshkov
0 siblings, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:53 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Abhinav Kumar, Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 09/10/2022 21:48, Marijn Suijten wrote:
> This exact same math is used to compute bytes_in_slice above in
> dsi_update_dsc_timing(), also used to fill slice_chunk_size.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 04/10] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size
2022-10-09 18:48 ` [PATCH v3 04/10] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size Marijn Suijten
@ 2022-10-09 18:54 ` Dmitry Baryshkov
0 siblings, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:54 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Abhinav Kumar, Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 09/10/2022 21:48, Marijn Suijten wrote:
> dsi_populate_dsc_params() is called prior to dsi_update_dsc_timing() and
> already computes a value for slice_chunk_size, whose value doesn't need
> to be recomputed and re-set here.
>
> Fixes: 08802f515c3c ("drm/msm/dsi: Add support for DSC configuration")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc
2022-10-09 18:48 ` [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc Marijn Suijten
@ 2022-10-09 18:55 ` Dmitry Baryshkov
2022-10-12 22:53 ` Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:55 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Abhinav Kumar, Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 09/10/2022 21:48, Marijn Suijten wrote:
> This field is currently unread but will come into effect when duplicated
> code below is migrated to call drm_dsc_compute_rc_parameters(), which
> uses the bpc-dependent value of the local variable mux_words_size in
> much the same way.
>
> The hardcoded constant seems to be a remnant from the `/* bpc 8 */`
> comment right above, indicating that this group of field assignments is
> applicable to bpc = 8 exclusively and should probably bail out on
> different bpc values, until constants for other bpc values are added (or
> the current ones are confirmed to be correct across multiple bpc's).
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-09 18:48 ` [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters() Marijn Suijten
@ 2022-10-09 18:56 ` Dmitry Baryshkov
0 siblings, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:56 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Abhinav Kumar, Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 09/10/2022 21:48, Marijn Suijten wrote:
> As per the FIXME this code is entirely duplicate with what is already
> provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
> why this comment was put in place instead of resolved from the get-go.
> Not only does it save on duplication, it would have also spared certain
> issues.
>
> For example, this code from downstream assumed dsc->bits_per_pixel to
> contain an integer value, whereas the upstream drm_dsc_config struct has
> it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
> accounts for this feat, and the sole remaining use of
> dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
> in a separate patch.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values
2022-10-09 18:51 ` [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values Marijn Suijten
@ 2022-10-09 18:57 ` Dmitry Baryshkov
2022-10-12 23:08 ` Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 18:57 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Abhinav Kumar, Sean Paul, David Airlie, Daniel Vetter, Vinod Koul,
Douglas Anderson, Vladimir Lypak, linux-arm-msm, dri-devel,
freedreno, linux-kernel
On 09/10/2022 21:51, Marijn Suijten wrote:
> According to the `/* bpc 8 */` comment below only values for a
> bits_per_component of 8 are currently hardcoded in place. This is
> further confirmed by downstream sources [1] containing different
> constants for other BPC values (and different initial_offset too,
> with an extra dependency on bits_per_pixel). Prevent future mishaps by
> explicitly disallowing any other bits_per_component value until the
> right parameters are put in place and tested.
>
> [1]: https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers/-/blob/DISPLAY.LA.2.0.r1-08000-WAIPIO.0/msm/sde_dsc_helper.c#L110-139
>
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-09 18:50 ` Marijn Suijten
@ 2022-10-09 18:58 ` Marijn Suijten
2022-10-12 23:03 ` [Freedreno] " Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-09 18:58 UTC (permalink / raw)
To: phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Abhinav Kumar, Dmitry Baryshkov, Sean Paul, David Airlie,
Daniel Vetter, Vinod Koul, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 2022-10-09 20:50:54, Marijn Suijten wrote:
Apologies. After attempting to recover from an unexpected interruption
_right as I was sending this series_, this patch got sent twice as it
only later appeared to also have made its way through in the first round
[1], together with the cover letter and first five patches.
[1]: https://lore.kernel.org/linux-arm-msm/20221009184824.457416-7-marijn.suijten@somainline.org/
- Marijn
> As per the FIXME this code is entirely duplicate with what is already
> provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
> why this comment was put in place instead of resolved from the get-go.
> Not only does it save on duplication, it would have also spared certain
> issues.
>
> For example, this code from downstream assumed dsc->bits_per_pixel to
> contain an integer value, whereas the upstream drm_dsc_config struct has
> it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
> accounts for this feat, and the sole remaining use of
> dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
> in a separate patch.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 64 +++---------------------------
> 1 file changed, 6 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 83cde4d62b68..68c39debc22f 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -21,6 +21,7 @@
>
> #include <video/mipi_display.h>
>
> +#include <drm/display/drm_dsc_helper.h>
> #include <drm/drm_of.h>
>
> #include "dsi.h"
> @@ -1771,14 +1772,6 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
>
> static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> {
> - int mux_words_size;
> - int groups_per_line, groups_total;
> - int min_rate_buffer_size;
> - int hrd_delay;
> - int pre_num_extra_mux_bits, num_extra_mux_bits;
> - int slice_bits;
> - int data;
> - int final_value, final_scale;
> int i;
>
> dsc->rc_model_size = 8192;
> @@ -1804,11 +1797,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> if (dsc->bits_per_pixel != 8)
> dsc->initial_offset = 2048; /* bpp = 12 */
>
> - mux_words_size = 48; /* bpc == 8/10 */
> - if (dsc->bits_per_component == 12)
> - mux_words_size = 64;
> + if (dsc->bits_per_component <= 10)
> + dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
> + else
> + dsc->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
>
> - dsc->mux_word_size = mux_words_size;
> dsc->initial_xmit_delay = 512;
> dsc->initial_scale_value = 32;
> dsc->first_line_bpg_offset = 12;
> @@ -1820,52 +1813,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> dsc->rc_quant_incr_limit0 = 11;
> dsc->rc_quant_incr_limit1 = 11;
>
> - /* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
> - * params are calculated
> - */
> - groups_per_line = DIV_ROUND_UP(dsc->slice_width, 3);
> - dsc->slice_chunk_size = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
> -
> - /* rbs-min */
> - min_rate_buffer_size = dsc->rc_model_size - dsc->initial_offset +
> - dsc->initial_xmit_delay * dsc->bits_per_pixel +
> - groups_per_line * dsc->first_line_bpg_offset;
> -
> - hrd_delay = DIV_ROUND_UP(min_rate_buffer_size, dsc->bits_per_pixel);
> -
> - dsc->initial_dec_delay = hrd_delay - dsc->initial_xmit_delay;
> -
> - dsc->initial_scale_value = 8 * dsc->rc_model_size /
> - (dsc->rc_model_size - dsc->initial_offset);
> -
> - slice_bits = 8 * dsc->slice_chunk_size * dsc->slice_height;
> -
> - groups_total = groups_per_line * dsc->slice_height;
> -
> - data = dsc->first_line_bpg_offset * 2048;
> -
> - dsc->nfl_bpg_offset = DIV_ROUND_UP(data, (dsc->slice_height - 1));
> -
> - pre_num_extra_mux_bits = 3 * (mux_words_size + (4 * dsc->bits_per_component + 4) - 2);
> -
> - num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size -
> - ((slice_bits - pre_num_extra_mux_bits) % mux_words_size));
> -
> - data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
> - dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
> -
> - data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
> - final_value = dsc->rc_model_size - data + num_extra_mux_bits;
> - dsc->final_offset = final_value;
> -
> - final_scale = 8 * dsc->rc_model_size / (dsc->rc_model_size - final_value);
> -
> - data = (final_scale - 9) * (dsc->nfl_bpg_offset + dsc->slice_bpg_offset);
> - dsc->scale_increment_interval = (2048 * dsc->final_offset) / data;
> -
> - dsc->scale_decrement_interval = groups_per_line / (dsc->initial_scale_value - 8);
> -
> - return 0;
> + return drm_dsc_compute_rc_parameters(dsc);
> }
>
> static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
> --
> 2.38.0
>
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits
2022-10-09 18:53 ` [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Marijn Suijten
@ 2022-10-09 19:14 ` Dmitry Baryshkov
2022-10-11 7:51 ` Marijn Suijten
2022-10-12 23:26 ` Abhinav Kumar
1 sibling, 1 reply; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 19:14 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Abhinav Kumar, Sean Paul, David Airlie, Daniel Vetter, Vinod Koul,
Douglas Anderson, Vladimir Lypak, linux-arm-msm, dri-devel,
freedreno, linux-kernel
On 09/10/2022 21:53, Marijn Suijten wrote:
> The bpg_offset array contains negative BPG offsets which fill the full 8
> bits of a char thanks to two's complement: this however results in those
> bits bleeding into the next field when the value is packed into DSC PPS
> by the drm_dsc_helper function, which only expects range_bpg_offset to
> contain 6-bit wide values. As a consequence random slices appear
> corrupted on-screen (tested on a Sony Tama Akatsuki device with sdm845).
>
> Use AND operators to limit these two's complement values to 6 bits,
> similar to the AMD and i915 drivers.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Side note: the DSC params tables are more or less common between amd,
i916 and msm drivers. It might be worth moving them to the DSC helpers
from the individual drivers. This would mean such masks handling can go
into the helper too.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits
2022-10-09 18:53 ` [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
@ 2022-10-09 19:24 ` Dmitry Baryshkov
2022-10-12 23:25 ` Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Dmitry Baryshkov @ 2022-10-09 19:24 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Abhinav Kumar, Sean Paul, David Airlie, Daniel Vetter, Vinod Koul,
Douglas Anderson, Vladimir Lypak, linux-arm-msm, dri-devel,
freedreno, linux-kernel
On 09/10/2022 21:53, Marijn Suijten wrote:
> drm_dsc_config's bits_per_pixel field holds a fractional value with 4
> bits, which all panel drivers should adhere to for
> drm_dsc_pps_payload_pack() to generate a valid payload. All code in the
> DSI driver here seems to assume that this field doesn't contain any
> fractional bits, hence resulting in the wrong values being computed.
> Since none of the calculations leave any room for fractional bits or
> seem to indicate any possible area of support, disallow such values
> altogether. calculate_rc_params() in intel_vdsc.c performs an identical
> bitshift to get at this integer value.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits
2022-10-09 19:14 ` Dmitry Baryshkov
@ 2022-10-11 7:51 ` Marijn Suijten
0 siblings, 0 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-11 7:51 UTC (permalink / raw)
To: Dmitry Baryshkov
Cc: phone-devel, ~postmarketos/upstreaming,
AngeloGioacchino Del Regno, Konrad Dybcio, Martin Botka,
Jami Kettunen, Rob Clark, Abhinav Kumar, Sean Paul, David Airlie,
Daniel Vetter, Vinod Koul, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 2022-10-09 22:14:16, Dmitry Baryshkov wrote:
> On 09/10/2022 21:53, Marijn Suijten wrote:
> > The bpg_offset array contains negative BPG offsets which fill the full 8
> > bits of a char thanks to two's complement: this however results in those
> > bits bleeding into the next field when the value is packed into DSC PPS
> > by the drm_dsc_helper function, which only expects range_bpg_offset to
> > contain 6-bit wide values. As a consequence random slices appear
> > corrupted on-screen (tested on a Sony Tama Akatsuki device with sdm845).
> >
> > Use AND operators to limit these two's complement values to 6 bits,
> > similar to the AMD and i915 drivers.
> >
> > Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> > Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
>
>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>
> Side note: the DSC params tables are more or less common between amd,
> i916 and msm drivers. It might be worth moving them to the DSC helpers
> from the individual drivers. This would mean such masks handling can go
> into the helper too.
I'll queue this up in my list and perhaps tackle it in the next round of
DSC fixes, assuming things don't get too big.
If there are no more reviews I'll respin v4 with your review picked up
and patch 7/10 reworked or reordered to have access to the msm_host
pointer added in 8/10 (see kernel test robot mail).
- Marijn
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc
2022-10-09 18:48 ` [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc Marijn Suijten
2022-10-09 18:55 ` Dmitry Baryshkov
@ 2022-10-12 22:53 ` Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-12 22:53 UTC (permalink / raw)
To: Marijn Suijten, phone-devel, Rob Clark, Dmitry Baryshkov,
Vinod Koul
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Sean Paul,
David Airlie, Daniel Vetter, Douglas Anderson, Vladimir Lypak,
linux-arm-msm, dri-devel, freedreno, linux-kernel
On 10/9/2022 11:48 AM, Marijn Suijten wrote:
> This field is currently unread but will come into effect when duplicated
> code below is migrated to call drm_dsc_compute_rc_parameters(), which
> uses the bpc-dependent value of the local variable mux_words_size in
> much the same way.
>
> The hardcoded constant seems to be a remnant from the `/* bpc 8 */`
> comment right above, indicating that this group of field assignments is
> applicable to bpc = 8 exclusively and should probably bail out on
> different bpc values, until constants for other bpc values are added (or
> the current ones are confirmed to be correct across multiple bpc's).
>
Yes, this seems to hard-code it to 8bpc/10bpc. So your code-change is fine.
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index f42794cdd4c1..83cde4d62b68 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1808,6 +1808,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> if (dsc->bits_per_component == 12)
> mux_words_size = 64;
>
> + dsc->mux_word_size = mux_words_size;
> dsc->initial_xmit_delay = 512;
> dsc->initial_scale_value = 32;
> dsc->first_line_bpg_offset = 12;
> @@ -1818,7 +1819,6 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> dsc->flatness_max_qp = 12;
> dsc->rc_quant_incr_limit0 = 11;
> dsc->rc_quant_incr_limit1 = 11;
> - dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
>
> /* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
> * params are calculated
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [Freedreno] [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-09 18:50 ` Marijn Suijten
2022-10-09 18:58 ` Marijn Suijten
@ 2022-10-12 23:03 ` Abhinav Kumar
2022-10-13 9:36 ` Marijn Suijten
1 sibling, 1 reply; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-12 23:03 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: Vinod Koul, Jami Kettunen, David Airlie, linux-arm-msm,
Vladimir Lypak, Konrad Dybcio, dri-devel, Douglas Anderson,
Rob Clark, Martin Botka, ~postmarketos/upstreaming, Daniel Vetter,
AngeloGioacchino Del Regno, Dmitry Baryshkov, freedreno,
Sean Paul, linux-kernel
On 10/9/2022 11:50 AM, Marijn Suijten wrote:
> As per the FIXME this code is entirely duplicate with what is already
> provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
> why this comment was put in place instead of resolved from the get-go.
> Not only does it save on duplication, it would have also spared certain
> issues.
>
> For example, this code from downstream assumed dsc->bits_per_pixel to
> contain an integer value, whereas the upstream drm_dsc_config struct has
> it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
> accounts for this feat, and the sole remaining use of
> dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
> in a separate patch.
>
This is a nice cleanup! Thanks for doing this. I would actually like to
move towards the drm_dsc_compute_rc_parameters() API.
But I would like to hold back this change till Vinod clarifies because
Vinod had mentioned that with drm_dsc_compute_rc_parameters() he was
seeing a mismatch in the computation of two values.
slice_bpg_offset and the final_offset.
The difference between the upstream drm_dsc_compute_rc_parameters() and
dsi_populate_dsc_params() causing this was not clear to me from his
explanation earlier.
So this was left as a to-do item.
I would like this to be re-tested on pixel3 and check if this works for
vinod. If not, i think its the right time to debug why and not delay
this more.
Thanks
Abhinav
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 64 +++---------------------------
> 1 file changed, 6 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 83cde4d62b68..68c39debc22f 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -21,6 +21,7 @@
>
> #include <video/mipi_display.h>
>
> +#include <drm/display/drm_dsc_helper.h>
> #include <drm/drm_of.h>
>
> #include "dsi.h"
> @@ -1771,14 +1772,6 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
>
> static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> {
> - int mux_words_size;
> - int groups_per_line, groups_total;
> - int min_rate_buffer_size;
> - int hrd_delay;
> - int pre_num_extra_mux_bits, num_extra_mux_bits;
> - int slice_bits;
> - int data;
> - int final_value, final_scale;
> int i;
>
> dsc->rc_model_size = 8192;
> @@ -1804,11 +1797,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> if (dsc->bits_per_pixel != 8)
> dsc->initial_offset = 2048; /* bpp = 12 */
>
> - mux_words_size = 48; /* bpc == 8/10 */
> - if (dsc->bits_per_component == 12)
> - mux_words_size = 64;
> + if (dsc->bits_per_component <= 10)
> + dsc->mux_word_size = DSC_MUX_WORD_SIZE_8_10_BPC;
> + else
> + dsc->mux_word_size = DSC_MUX_WORD_SIZE_12_BPC;
>
> - dsc->mux_word_size = mux_words_size;
> dsc->initial_xmit_delay = 512;
> dsc->initial_scale_value = 32;
> dsc->first_line_bpg_offset = 12;
> @@ -1820,52 +1813,7 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> dsc->rc_quant_incr_limit0 = 11;
> dsc->rc_quant_incr_limit1 = 11;
>
> - /* FIXME: need to call drm_dsc_compute_rc_parameters() so that rest of
> - * params are calculated
> - */
> - groups_per_line = DIV_ROUND_UP(dsc->slice_width, 3);
> - dsc->slice_chunk_size = DIV_ROUND_UP(dsc->slice_width * dsc->bits_per_pixel, 8);
> -
> - /* rbs-min */
> - min_rate_buffer_size = dsc->rc_model_size - dsc->initial_offset +
> - dsc->initial_xmit_delay * dsc->bits_per_pixel +
> - groups_per_line * dsc->first_line_bpg_offset;
> -
> - hrd_delay = DIV_ROUND_UP(min_rate_buffer_size, dsc->bits_per_pixel);
> -
> - dsc->initial_dec_delay = hrd_delay - dsc->initial_xmit_delay;
> -
> - dsc->initial_scale_value = 8 * dsc->rc_model_size /
> - (dsc->rc_model_size - dsc->initial_offset);
> -
> - slice_bits = 8 * dsc->slice_chunk_size * dsc->slice_height;
> -
> - groups_total = groups_per_line * dsc->slice_height;
> -
> - data = dsc->first_line_bpg_offset * 2048;
> -
> - dsc->nfl_bpg_offset = DIV_ROUND_UP(data, (dsc->slice_height - 1));
> -
> - pre_num_extra_mux_bits = 3 * (mux_words_size + (4 * dsc->bits_per_component + 4) - 2);
> -
> - num_extra_mux_bits = pre_num_extra_mux_bits - (mux_words_size -
> - ((slice_bits - pre_num_extra_mux_bits) % mux_words_size));
> -
> - data = 2048 * (dsc->rc_model_size - dsc->initial_offset + num_extra_mux_bits);
> - dsc->slice_bpg_offset = DIV_ROUND_UP(data, groups_total);
> -
> - data = dsc->initial_xmit_delay * dsc->bits_per_pixel;
> - final_value = dsc->rc_model_size - data + num_extra_mux_bits;
> - dsc->final_offset = final_value;
> -
> - final_scale = 8 * dsc->rc_model_size / (dsc->rc_model_size - final_value);
> -
> - data = (final_scale - 9) * (dsc->nfl_bpg_offset + dsc->slice_bpg_offset);
> - dsc->scale_increment_interval = (2048 * dsc->final_offset) / data;
> -
> - dsc->scale_decrement_interval = groups_per_line / (dsc->initial_scale_value - 8);
> -
> - return 0;
> + return drm_dsc_compute_rc_parameters(dsc);
> }
>
> static int dsi_host_parse_dt(struct msm_dsi_host *msm_host)
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values
2022-10-09 18:51 ` [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values Marijn Suijten
2022-10-09 18:57 ` Dmitry Baryshkov
@ 2022-10-12 23:08 ` Abhinav Kumar
2022-10-13 9:27 ` Marijn Suijten
1 sibling, 1 reply; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-12 23:08 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
Vinod Koul, Douglas Anderson, Vladimir Lypak, linux-arm-msm,
dri-devel, freedreno, linux-kernel
On 10/9/2022 11:51 AM, Marijn Suijten wrote:
> According to the `/* bpc 8 */` comment below only values for a
> bits_per_component of 8 are currently hardcoded in place. This is
> further confirmed by downstream sources [1] containing different
> constants for other BPC values (and different initial_offset too,
> with an extra dependency on bits_per_pixel). Prevent future mishaps by
> explicitly disallowing any other bits_per_component value until the
> right parameters are put in place and tested.
>
> [1]: https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers/-/blob/DISPLAY.LA.2.0.r1-08000-WAIPIO.0/msm/sde_dsc_helper.c#L110-139
>
Seems like a valid kbot error.
https://patchwork.freedesktop.org/patch/506359/#comment_912830
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 68c39debc22f..7e6b7e506ae8 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1774,6 +1774,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> {
> int i;
>
> + if (dsc->bits_per_component != 8) {
> + DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n");
> + return -EOPNOTSUPP;
> + }
> +
> dsc->rc_model_size = 8192;
> dsc->first_line_bpg_offset = 12;
> dsc->rc_edge_factor = 6;
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits
2022-10-09 18:53 ` [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
2022-10-09 19:24 ` Dmitry Baryshkov
@ 2022-10-12 23:25 ` Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-12 23:25 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
Vinod Koul, Douglas Anderson, Vladimir Lypak, linux-arm-msm,
dri-devel, freedreno, linux-kernel
On 10/9/2022 11:53 AM, Marijn Suijten wrote:
> drm_dsc_config's bits_per_pixel field holds a fractional value with 4
> bits, which all panel drivers should adhere to for
> drm_dsc_pps_payload_pack() to generate a valid payload. All code in the
> DSI driver here seems to assume that this field doesn't contain any
> fractional bits, hence resulting in the wrong values being computed.
> Since none of the calculations leave any room for fractional bits or
> seem to indicate any possible area of support, disallow such values
> altogether. calculate_rc_params() in intel_vdsc.c performs an identical
> bitshift to get at this integer value.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 7e6b7e506ae8..46032c576a59 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -34,7 +34,7 @@
>
> #define DSI_RESET_TOGGLE_DELAY_MS 20
>
> -static int dsi_populate_dsc_params(struct drm_dsc_config *dsc);
> +static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc);
>
> static int dsi_get_version(const void __iomem *base, u32 *major, u32 *minor)
> {
> @@ -909,6 +909,7 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
> u32 va_end = va_start + mode->vdisplay;
> u32 hdisplay = mode->hdisplay;
> u32 wc;
> + int ret;
>
> DBG("");
>
> @@ -944,7 +945,9 @@ static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_bonded_dsi)
> /* we do the calculations for dsc parameters here so that
> * panel can use these parameters
> */
> - dsi_populate_dsc_params(dsc);
> + ret = dsi_populate_dsc_params(msm_host, dsc);
> + if (ret)
> + return;
>
> /* Divide the display by 3 but keep back/font porch and
> * pulse width same
> @@ -1770,9 +1773,15 @@ static char bpg_offset[DSC_NUM_BUF_RANGES] = {
> 2, 0, 0, -2, -4, -6, -8, -8, -8, -10, -10, -12, -12, -12, -12
> };
>
> -static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> +static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc_config *dsc)
> {
> int i;
> + u16 bpp = dsc->bits_per_pixel >> 4;
> +
> + if (dsc->bits_per_pixel & 0xf) {
> + DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support fractional bits_per_pixel\n");
> + return -EINVAL;
> + }
>
> if (dsc->bits_per_component != 8) {
> DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n");
> @@ -1798,8 +1807,8 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i];
> }
>
> - dsc->initial_offset = 6144; /* Not bpp 12 */
> - if (dsc->bits_per_pixel != 8)
> + dsc->initial_offset = 6144; /* Not bpp 12 */
> + if (bpp != 8)
> dsc->initial_offset = 2048; /* bpp = 12 */
>
> if (dsc->bits_per_component <= 10)
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits
2022-10-09 18:53 ` [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Marijn Suijten
2022-10-09 19:14 ` Dmitry Baryshkov
@ 2022-10-12 23:26 ` Abhinav Kumar
1 sibling, 0 replies; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-12 23:26 UTC (permalink / raw)
To: Marijn Suijten, phone-devel
Cc: ~postmarketos/upstreaming, AngeloGioacchino Del Regno,
Konrad Dybcio, Martin Botka, Jami Kettunen, Rob Clark,
Dmitry Baryshkov, Sean Paul, David Airlie, Daniel Vetter,
Vinod Koul, Douglas Anderson, Vladimir Lypak, linux-arm-msm,
dri-devel, freedreno, linux-kernel
On 10/9/2022 11:53 AM, Marijn Suijten wrote:
> The bpg_offset array contains negative BPG offsets which fill the full 8
> bits of a char thanks to two's complement: this however results in those
> bits bleeding into the next field when the value is packed into DSC PPS
> by the drm_dsc_helper function, which only expects range_bpg_offset to
> contain 6-bit wide values. As a consequence random slices appear
> corrupted on-screen (tested on a Sony Tama Akatsuki device with sdm845).
>
> Use AND operators to limit these two's complement values to 6 bits,
> similar to the AMD and i915 drivers.
>
> Fixes: b9080324d6ca ("drm/msm/dsi: add support for dsc data")
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
> drivers/gpu/drm/msm/dsi/dsi_host.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> index 46032c576a59..c5c2d70ac27d 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> @@ -1804,7 +1804,11 @@ static int dsi_populate_dsc_params(struct msm_dsi_host *msm_host, struct drm_dsc
> for (i = 0; i < DSC_NUM_BUF_RANGES; i++) {
> dsc->rc_range_params[i].range_min_qp = min_qp[i];
> dsc->rc_range_params[i].range_max_qp = max_qp[i];
> - dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i];
> + /*
> + * Range BPG Offset contains two's-complement signed values that fill
> + * 8 bits, yet the registers and DCS PPS field are only 6 bits wide.
> + */
> + dsc->rc_range_params[i].range_bpg_offset = bpg_offset[i] & DSC_RANGE_BPG_OFFSET_MASK;
> }
>
> dsc->initial_offset = 6144; /* Not bpp 12 */
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values
2022-10-12 23:08 ` Abhinav Kumar
@ 2022-10-13 9:27 ` Marijn Suijten
0 siblings, 0 replies; 34+ messages in thread
From: Marijn Suijten @ 2022-10-13 9:27 UTC (permalink / raw)
To: Abhinav Kumar
Cc: phone-devel, ~postmarketos/upstreaming,
AngeloGioacchino Del Regno, Konrad Dybcio, Martin Botka,
Jami Kettunen, Rob Clark, Dmitry Baryshkov, Sean Paul,
David Airlie, Daniel Vetter, Vinod Koul, Douglas Anderson,
Vladimir Lypak, linux-arm-msm, dri-devel, freedreno, linux-kernel
On 2022-10-12 16:08:07, Abhinav Kumar wrote:
>
>
> On 10/9/2022 11:51 AM, Marijn Suijten wrote:
> > According to the `/* bpc 8 */` comment below only values for a
> > bits_per_component of 8 are currently hardcoded in place. This is
> > further confirmed by downstream sources [1] containing different
> > constants for other BPC values (and different initial_offset too,
> > with an extra dependency on bits_per_pixel). Prevent future mishaps by
> > explicitly disallowing any other bits_per_component value until the
> > right parameters are put in place and tested.
> >
> > [1]: https://git.codelinaro.org/clo/la/platform/vendor/opensource/display-drivers/-/blob/DISPLAY.LA.2.0.r1-08000-WAIPIO.0/msm/sde_dsc_helper.c#L110-139
> >
>
> Seems like a valid kbot error.
>
> https://patchwork.freedesktop.org/patch/506359/#comment_912830
It is correct, and I suggested in [1] to either reorder this patch 7/10
after 8/10, or pull back the msm_host pointer argument into this patch.
[1]: https://lore.kernel.org/linux-arm-msm/20221011075119.tvn5j5jm6aqnhqv2@SoMainline.org/
- Marijn
> > Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
> > ---
> > drivers/gpu/drm/msm/dsi/dsi_host.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
> > index 68c39debc22f..7e6b7e506ae8 100644
> > --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
> > +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
> > @@ -1774,6 +1774,11 @@ static int dsi_populate_dsc_params(struct drm_dsc_config *dsc)
> > {
> > int i;
> >
> > + if (dsc->bits_per_component != 8) {
> > + DRM_DEV_ERROR(&msm_host->pdev->dev, "DSI does not support bits_per_component != 8 yet\n");
> > + return -EOPNOTSUPP;
> > + }
> > +
> > dsc->rc_model_size = 8192;
> > dsc->first_line_bpg_offset = 12;
> > dsc->rc_edge_factor = 6;
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [Freedreno] [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-12 23:03 ` [Freedreno] " Abhinav Kumar
@ 2022-10-13 9:36 ` Marijn Suijten
2022-10-13 16:02 ` Abhinav Kumar
0 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-13 9:36 UTC (permalink / raw)
To: Abhinav Kumar
Cc: phone-devel, Vinod Koul, Jami Kettunen, David Airlie,
linux-arm-msm, Vladimir Lypak, Konrad Dybcio, dri-devel,
Douglas Anderson, Rob Clark, Martin Botka,
~postmarketos/upstreaming, Daniel Vetter,
AngeloGioacchino Del Regno, Dmitry Baryshkov, freedreno,
Sean Paul, linux-kernel
On 2022-10-12 16:03:06, Abhinav Kumar wrote:
>
>
> On 10/9/2022 11:50 AM, Marijn Suijten wrote:
> > As per the FIXME this code is entirely duplicate with what is already
> > provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
> > why this comment was put in place instead of resolved from the get-go.
> > Not only does it save on duplication, it would have also spared certain
> > issues.
> >
> > For example, this code from downstream assumed dsc->bits_per_pixel to
> > contain an integer value, whereas the upstream drm_dsc_config struct has
> > it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
> > accounts for this feat, and the sole remaining use of
> > dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
> > in a separate patch.
> >
>
> This is a nice cleanup! Thanks for doing this. I would actually like to
> move towards the drm_dsc_compute_rc_parameters() API.
>
> But I would like to hold back this change till Vinod clarifies because
> Vinod had mentioned that with drm_dsc_compute_rc_parameters() he was
> seeing a mismatch in the computation of two values.
>
> slice_bpg_offset and the final_offset.
Unsurprisingly so because final_offset, and slice_bpg_offset through
initial_offset depend directly on bits_per_pixel. The main takeaway of
this series is that Vinod was interpreting this field as integer instead
of containing 4 fractional bits. If he updates his the panel driver [1]
to set bits_per_pixel = 8 << 4 instead of just 8 to account for this,
the values should check out once again.
[1]: https://git.linaro.org/people/vinod.koul/kernel.git/commit/?h=topic/pixel3_5.18-rc1&id=1d7d98ad564f1ec69e7525e07418918d90f247a1
Once Vinod (or someone else in the posession of a Pixel 3) confirms
this, I can respin this series and more explicitly explain why the FIXME
was put in place, instead of being resolved outright?
- Marijn
>
> The difference between the upstream drm_dsc_compute_rc_parameters() and
> dsi_populate_dsc_params() causing this was not clear to me from his
> explanation earlier.
>
> So this was left as a to-do item.
>
> I would like this to be re-tested on pixel3 and check if this works for
> vinod. If not, i think its the right time to debug why and not delay
> this more.
>
> Thanks
>
> Abhinav
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [Freedreno] [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-13 9:36 ` Marijn Suijten
@ 2022-10-13 16:02 ` Abhinav Kumar
2022-10-17 8:59 ` Marijn Suijten
0 siblings, 1 reply; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-13 16:02 UTC (permalink / raw)
To: Marijn Suijten
Cc: phone-devel, Vinod Koul, Jami Kettunen, David Airlie,
linux-arm-msm, Vladimir Lypak, Konrad Dybcio, dri-devel,
Douglas Anderson, Rob Clark, Martin Botka,
~postmarketos/upstreaming, Daniel Vetter,
AngeloGioacchino Del Regno, Dmitry Baryshkov, freedreno,
Sean Paul, linux-kernel
On 10/13/2022 2:36 AM, Marijn Suijten wrote:
> On 2022-10-12 16:03:06, Abhinav Kumar wrote:
>>
>>
>> On 10/9/2022 11:50 AM, Marijn Suijten wrote:
>>> As per the FIXME this code is entirely duplicate with what is already
>>> provided inside drm_dsc_compute_rc_parameters(), and it is yet unknown
>>> why this comment was put in place instead of resolved from the get-go.
>>> Not only does it save on duplication, it would have also spared certain
>>> issues.
>>>
>>> For example, this code from downstream assumed dsc->bits_per_pixel to
>>> contain an integer value, whereas the upstream drm_dsc_config struct has
>>> it with 4 fractional bits. drm_dsc_compute_rc_parameters() already
>>> accounts for this feat, and the sole remaining use of
>>> dsc->bits_per_pixel inside dsi_populate_dsc_params() will be addressed
>>> in a separate patch.
>>>
>>
>> This is a nice cleanup! Thanks for doing this. I would actually like to
>> move towards the drm_dsc_compute_rc_parameters() API.
>>
>> But I would like to hold back this change till Vinod clarifies because
>> Vinod had mentioned that with drm_dsc_compute_rc_parameters() he was
>> seeing a mismatch in the computation of two values.
>>
>> slice_bpg_offset and the final_offset.
>
> Unsurprisingly so because final_offset, and slice_bpg_offset through
> initial_offset depend directly on bits_per_pixel. The main takeaway of
> this series is that Vinod was interpreting this field as integer instead
> of containing 4 fractional bits. If he updates his the panel driver [1]
> to set bits_per_pixel = 8 << 4 instead of just 8 to account for this,
> the values should check out once again.
>
> [1]: https://git.linaro.org/people/vinod.koul/kernel.git/commit/?h=topic/pixel3_5.18-rc1&id=1d7d98ad564f1ec69e7525e07418918d90f247a1
>
> Once Vinod (or someone else in the posession of a Pixel 3) confirms
> this, I can respin this series and more explicitly explain why the FIXME
> was put in place, instead of being resolved outright?
>
> - Marijn
Makes perfect sense to me.
Will just wait for Vinod's tested-by.
>
>>
>> The difference between the upstream drm_dsc_compute_rc_parameters() and
>> dsi_populate_dsc_params() causing this was not clear to me from his
>> explanation earlier.
>>
>> So this was left as a to-do item.
>>
>> I would like this to be re-tested on pixel3 and check if this works for
>> vinod. If not, i think its the right time to debug why and not delay
>> this more.
>>
>> Thanks
>>
>> Abhinav
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [Freedreno] [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-13 16:02 ` Abhinav Kumar
@ 2022-10-17 8:59 ` Marijn Suijten
2022-10-17 13:37 ` Caleb Connolly
0 siblings, 1 reply; 34+ messages in thread
From: Marijn Suijten @ 2022-10-17 8:59 UTC (permalink / raw)
To: Abhinav Kumar
Cc: phone-devel, Vinod Koul, Jami Kettunen, David Airlie,
linux-arm-msm, Vladimir Lypak, Konrad Dybcio, dri-devel,
Douglas Anderson, Rob Clark, Martin Botka,
~postmarketos/upstreaming, Daniel Vetter,
AngeloGioacchino Del Regno, Dmitry Baryshkov, freedreno,
Sean Paul, linux-kernel, Newbyte, Caleb Connolly
On 2022-10-13 09:02:44, Abhinav Kumar wrote:
> On 10/13/2022 2:36 AM, Marijn Suijten wrote:
> > On 2022-10-12 16:03:06, Abhinav Kumar wrote:
> >> [..]
> >> But I would like to hold back this change till Vinod clarifies because
> >> Vinod had mentioned that with drm_dsc_compute_rc_parameters() he was
> >> seeing a mismatch in the computation of two values.
> >>
> >> slice_bpg_offset and the final_offset.
> >
> > Unsurprisingly so because final_offset, and slice_bpg_offset through
> > initial_offset depend directly on bits_per_pixel. The main takeaway of
> > this series is that Vinod was interpreting this field as integer instead
> > of containing 4 fractional bits. If he updates his the panel driver [1]
> > to set bits_per_pixel = 8 << 4 instead of just 8 to account for this,
> > the values should check out once again.
> >
> > [1]: https://git.linaro.org/people/vinod.koul/kernel.git/commit/?h=topic/pixel3_5.18-rc1&id=1d7d98ad564f1ec69e7525e07418918d90f247a1
> >
> > Once Vinod (or someone else in the posession of a Pixel 3) confirms
> > this, I can respin this series and more explicitly explain why the FIXME
> > was put in place, instead of being resolved outright?
> >
> > - Marijn
>
> Makes perfect sense to me.
>
> Will just wait for Vinod's tested-by.
Unfortunately Vinod doesn't have access to this device anymore, but
Caleb recently sent the support series including display driver for
Pixel 3 and is picking up the testing. User "Newbyte" from #linux-msm
promised to test on the LG G7 to have even more input samples.
- Marijn
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [Freedreno] [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-17 8:59 ` Marijn Suijten
@ 2022-10-17 13:37 ` Caleb Connolly
2022-10-17 16:28 ` Abhinav Kumar
0 siblings, 1 reply; 34+ messages in thread
From: Caleb Connolly @ 2022-10-17 13:37 UTC (permalink / raw)
To: Marijn Suijten, Abhinav Kumar
Cc: phone-devel, Vinod Koul, Jami Kettunen, David Airlie,
linux-arm-msm, Vladimir Lypak, Konrad Dybcio, dri-devel,
Douglas Anderson, Rob Clark, Martin Botka,
~postmarketos/upstreaming, Daniel Vetter,
AngeloGioacchino Del Regno, Dmitry Baryshkov, freedreno,
Sean Paul, linux-kernel, Newbyte
On 17/10/2022 09:59, Marijn Suijten wrote:
> On 2022-10-13 09:02:44, Abhinav Kumar wrote:
>> On 10/13/2022 2:36 AM, Marijn Suijten wrote:
>>> On 2022-10-12 16:03:06, Abhinav Kumar wrote:
>>>> [..]
>>>> But I would like to hold back this change till Vinod clarifies because
>>>> Vinod had mentioned that with drm_dsc_compute_rc_parameters() he was
>>>> seeing a mismatch in the computation of two values.
>>>>
>>>> slice_bpg_offset and the final_offset.
>>>
>>> Unsurprisingly so because final_offset, and slice_bpg_offset through
>>> initial_offset depend directly on bits_per_pixel. The main takeaway of
>>> this series is that Vinod was interpreting this field as integer instead
>>> of containing 4 fractional bits. If he updates his the panel driver [1]
>>> to set bits_per_pixel = 8 << 4 instead of just 8 to account for this,
>>> the values should check out once again.
>>>
>>> [1]: https://git.linaro.org/people/vinod.koul/kernel.git/commit/?h=topic/pixel3_5.18-rc1&id=1d7d98ad564f1ec69e7525e07418918d90f247a1
>>>
>>> Once Vinod (or someone else in the posession of a Pixel 3) confirms
>>> this, I can respin this series and more explicitly explain why the FIXME
>>> was put in place, instead of being resolved outright?
>>>
>>> - Marijn
>>
>> Makes perfect sense to me.
>>
>> Will just wait for Vinod's tested-by.
>
> Unfortunately Vinod doesn't have access to this device anymore, but
> Caleb recently sent the support series including display driver for
> Pixel 3 and is picking up the testing. User "Newbyte" from #linux-msm
> promised to test on the LG G7 to have even more input samples.
Hi,
I'm hoping to pick the Pixel 3 stuff back up at some point, but right now there
seem to be quite a few issues outside of DSC which make testing it a bit of a pain.
I gave Marijn's series [1] a go but wasn't able to get anything usable out of the
panel, however I doubt this is a DSC issue as I've always needed some hacks to
get the panel working - I've never had any success with it without skipping both
the initial panel reset and sending the PPS payload.
I think if Marijn has managed to initialise a panel properly then the lack of
Pixel 3 for validation shouldn't be a blocker to merge these fixes.
[1]:
https://lore.kernel.org/linux-arm-msm/20221009184824.457416-1-marijn.suijten@somainline.org/
>
> - Marijn
--
Kind Regards,
Caleb
^ permalink raw reply [flat|nested] 34+ messages in thread
* Re: [Freedreno] [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters()
2022-10-17 13:37 ` Caleb Connolly
@ 2022-10-17 16:28 ` Abhinav Kumar
0 siblings, 0 replies; 34+ messages in thread
From: Abhinav Kumar @ 2022-10-17 16:28 UTC (permalink / raw)
To: Caleb Connolly, Marijn Suijten
Cc: phone-devel, Vinod Koul, Jami Kettunen, David Airlie,
linux-arm-msm, Vladimir Lypak, Konrad Dybcio, dri-devel,
Douglas Anderson, Rob Clark, Martin Botka,
~postmarketos/upstreaming, Daniel Vetter,
AngeloGioacchino Del Regno, Dmitry Baryshkov, freedreno,
Sean Paul, linux-kernel, Newbyte
On 10/17/2022 6:37 AM, Caleb Connolly wrote:
>
>
> On 17/10/2022 09:59, Marijn Suijten wrote:
>> On 2022-10-13 09:02:44, Abhinav Kumar wrote:
>>> On 10/13/2022 2:36 AM, Marijn Suijten wrote:
>>>> On 2022-10-12 16:03:06, Abhinav Kumar wrote:
>>>>> [..]
>>>>> But I would like to hold back this change till Vinod clarifies because
>>>>> Vinod had mentioned that with drm_dsc_compute_rc_parameters() he was
>>>>> seeing a mismatch in the computation of two values.
>>>>>
>>>>> slice_bpg_offset and the final_offset.
>>>>
>>>> Unsurprisingly so because final_offset, and slice_bpg_offset through
>>>> initial_offset depend directly on bits_per_pixel. The main takeaway of
>>>> this series is that Vinod was interpreting this field as integer instead
>>>> of containing 4 fractional bits. If he updates his the panel driver [1]
>>>> to set bits_per_pixel = 8 << 4 instead of just 8 to account for this,
>>>> the values should check out once again.
>>>>
>>>> [1]: https://git.linaro.org/people/vinod.koul/kernel.git/commit/?h=topic/pixel3_5.18-rc1&id=1d7d98ad564f1ec69e7525e07418918d90f247a1
>>>>
>>>> Once Vinod (or someone else in the posession of a Pixel 3) confirms
>>>> this, I can respin this series and more explicitly explain why the FIXME
>>>> was put in place, instead of being resolved outright?
>>>>
>>>> - Marijn
>>>
>>> Makes perfect sense to me.
>>>
>>> Will just wait for Vinod's tested-by.
>>
>> Unfortunately Vinod doesn't have access to this device anymore, but
>> Caleb recently sent the support series including display driver for
>> Pixel 3 and is picking up the testing. User "Newbyte" from #linux-msm
>> promised to test on the LG G7 to have even more input samples.
>
> Hi,
>
> I'm hoping to pick the Pixel 3 stuff back up at some point, but right now there
> seem to be quite a few issues outside of DSC which make testing it a bit of a pain.
>
> I gave Marijn's series [1] a go but wasn't able to get anything usable out of the
> panel, however I doubt this is a DSC issue as I've always needed some hacks to
> get the panel working - I've never had any success with it without skipping both
> the initial panel reset and sending the PPS payload.
>
> I think if Marijn has managed to initialise a panel properly then the lack of
> Pixel 3 for validation shouldn't be a blocker to merge these fixes.
>
> [1]:
> https://lore.kernel.org/linux-arm-msm/20221009184824.457416-1-marijn.suijten@somainline.org/
>
>>
>> - Marijn
Alright, the onus is then on Vinod/ users of pixel3 to report/debug
whatever issues arise out of this computation.
Patch itself LGTM, hence
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
>
> --
> Kind Regards,
> Caleb
>
^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2022-10-17 16:29 UTC | newest]
Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-09 18:48 [PATCH v3 00/10] drm/msm: Fix math issues in MSM DSC implementation Marijn Suijten
2022-10-09 18:48 ` [PATCH v3 01/10] drm/msm/dsi: Remove useless math in DSC calculations Marijn Suijten
2022-10-09 18:52 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 02/10] drm/msm/dsi: Remove repeated calculation of slice_per_intf Marijn Suijten
2022-10-09 18:53 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 03/10] drm/msm/dsi: Use DIV_ROUND_UP instead of conditional increment on modulo Marijn Suijten
2022-10-09 18:53 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 04/10] drm/msm/dsi: Reuse earlier computed dsc->slice_chunk_size Marijn Suijten
2022-10-09 18:54 ` Dmitry Baryshkov
2022-10-09 18:48 ` [PATCH v3 05/10] drm/msm/dsi: Appropriately set dsc->mux_word_size based on bpc Marijn Suijten
2022-10-09 18:55 ` Dmitry Baryshkov
2022-10-12 22:53 ` Abhinav Kumar
2022-10-09 18:48 ` [PATCH v3 06/10] drm/msm/dsi: Migrate to drm_dsc_compute_rc_parameters() Marijn Suijten
2022-10-09 18:56 ` Dmitry Baryshkov
2022-10-09 18:50 ` Marijn Suijten
2022-10-09 18:58 ` Marijn Suijten
2022-10-12 23:03 ` [Freedreno] " Abhinav Kumar
2022-10-13 9:36 ` Marijn Suijten
2022-10-13 16:02 ` Abhinav Kumar
2022-10-17 8:59 ` Marijn Suijten
2022-10-17 13:37 ` Caleb Connolly
2022-10-17 16:28 ` Abhinav Kumar
2022-10-09 18:51 ` [PATCH v3 07/10] drm/msm/dsi: Disallow 8 BPC DSC configuration for alternative BPC values Marijn Suijten
2022-10-09 18:57 ` Dmitry Baryshkov
2022-10-12 23:08 ` Abhinav Kumar
2022-10-13 9:27 ` Marijn Suijten
2022-10-09 18:53 ` [PATCH v3 08/10] drm/msm/dsi: Account for DSC's bits_per_pixel having 4 fractional bits Marijn Suijten
2022-10-09 19:24 ` Dmitry Baryshkov
2022-10-12 23:25 ` Abhinav Kumar
2022-10-09 18:53 ` [PATCH v3 09/10] drm/msm/dpu1: " Marijn Suijten
2022-10-09 18:53 ` [PATCH v3 10/10] drm/msm/dsi: Prevent signed BPG offsets from bleeding into adjacent bits Marijn Suijten
2022-10-09 19:14 ` Dmitry Baryshkov
2022-10-11 7:51 ` Marijn Suijten
2022-10-12 23:26 ` Abhinav Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).