| From 680b5220ff8660d9992c84c755c5f48a83bc3659 Mon Sep 17 00:00:00 2001 |
| From: Kalyan Thota <quic_kalyant@quicinc.com> |
| Date: Fri, 27 Jan 2023 02:14:47 -0800 |
| Subject: [PATCH] BACKPORT: FROMGIT: drm/msm/disp/dpu1: add support for dspp |
| sub block flush in sc7280 |
| |
| Flush mechanism for DSPP blocks has changed in sc7280 family, it |
| allows individual sub blocks to be flushed in coordination with |
| master flush control. |
| |
| Representation: master_flush && (PCC_flush | IGC_flush .. etc ) |
| |
| This change adds necessary support for the above design. |
| |
| Changes in v1: |
| - Few nits (Doug, Dmitry) |
| - Restrict sub-block flush programming to dpu_hw_ctl file (Dmitry) |
| |
| Changes in v2: |
| - Move the address offset to flush macro (Dmitry) |
| - Separate ops for the sub block flush (Dmitry) |
| |
| Changes in v3: |
| - Reuse the DPU_DSPP_xx enum instead of a new one (Dmitry) |
| |
| Changes in v4: |
| - Use shorter version for unsigned int (Stephen) |
| |
| Changes in v5: |
| - Spurious patch please ignore. |
| |
| Changes in v6: |
| - Add SOB tag (Doug, Dmitry) |
| |
| Changes in v7: |
| - Cache flush mask per dspp (Dmitry) |
| - Few nits (Marijn) |
| |
| Changes in v8: |
| - Few nits (Marijn) |
| |
| Changes in v9: |
| - Use DSPP enum while accessing flush mask to make it readable (Dmitry) |
| - Few nits (Dmitry) |
| |
| Changes in v10: |
| - Fix white spaces in a separate patch (Dmitry) |
| |
| Changes in v11: |
| - Define a macro for dspp flush selection (Marijn) |
| - Few nits (Marijn) |
| |
| Changes in v12: |
| - Minor comments (reorder macros and a condition) (Marijn) |
| |
| Signed-off-by: Kalyan Thota <quic_kalyant@quicinc.com> |
| Tested-by: Douglas Anderson <dianders@chromium.org> |
| Patchwork: https://patchwork.freedesktop.org/patch/520701/ |
| Link: https://lore.kernel.org/r/1674814487-2112-1-git-send-email-quic_kalyant@quicinc.com |
| Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> |
| (cherry picked from commit 83a58b20c9b340000d508181f9d4ecec1437a771 |
| https://gitlab.freedesktop.org/drm/msm.git msm-next) |
| |
| Conflicts: |
| drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |
| Triviail context conflict with commit e92a4ae1981b ("drm/msm/dpu: fix |
| blend setup for DMA4 and DMA5 layers"). That patch is a fix of another |
| patch that we don't have and picking the further patch causes more |
| conflicts. Since this context conflict is so trivial to resolve, just |
| accept a BACKPORT. |
| |
| BUG=b:227735600 |
| TEST=Night light on herobrine internal display should work |
| |
| Change-Id: I8a6ea53c2518f4fadd83f51c086e373c879a8003 |
| Signed-off-by: Douglas Anderson <dianders@chromium.org> |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3950113 |
| Reviewed-by: Rob Clark <robdclark@chromium.org> |
| (cherry picked from commit 6f5edff2ec91da820bb6868acf0f2f1dd8bbc861) |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/4408894 |
| Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> |
| Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> |
| --- |
| drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 2 +- |
| .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c | 5 +- |
| .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h | 4 ++ |
| drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 49 +++++++++++++++++-- |
| drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h | 5 +- |
| 5 files changed, 58 insertions(+), 7 deletions(-) |
| |
| diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c |
| index b1ec0c35947bb5013b2432b1aea5ab3fe10d6d6c..1bdf78cae12a37a1514538b93a86183dc7b023dd 100644 |
| --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c |
| +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c |
| @@ -768,7 +768,7 @@ static void _dpu_crtc_setup_cp_blocks(struct drm_crtc *crtc) |
| |
| /* stage config flush mask */ |
| ctl->ops.update_pending_flush_dspp(ctl, |
| - mixer[i].hw_dspp->idx); |
| + mixer[i].hw_dspp->idx, DPU_DSPP_PCC); |
| } |
| } |
| |
| diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c |
| index b39e72a72d58380784909f3da14cbf9f0c63ea2d..7b8a5a5cfec76f8222557404aae69772e03b7fae 100644 |
| --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c |
| +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c |
| @@ -66,7 +66,10 @@ |
| (PINGPONG_SDM845_MASK | BIT(DPU_PINGPONG_TE2)) |
| |
| #define CTL_SC7280_MASK \ |
| - (BIT(DPU_CTL_ACTIVE_CFG) | BIT(DPU_CTL_FETCH_ACTIVE) | BIT(DPU_CTL_VM_CFG)) |
| + (BIT(DPU_CTL_ACTIVE_CFG) | \ |
| + BIT(DPU_CTL_FETCH_ACTIVE) | \ |
| + BIT(DPU_CTL_VM_CFG) | \ |
| + BIT(DPU_CTL_DSPP_SUB_BLOCK_FLUSH)) |
| |
| #define CTL_SM8550_MASK \ |
| (CTL_SC7280_MASK | BIT(DPU_CTL_HAS_LAYER_EXT4)) |
| diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |
| index ae85b40e282b5710ecdbf303eabe0795d609646c..058d372a6bdacd191311d087276a3511ab689ddb 100644 |
| --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |
| +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.h |
| @@ -169,10 +169,12 @@ enum { |
| * DSPP sub-blocks |
| * @DPU_DSPP_PCC Panel color correction block |
| * @DPU_DSPP_GC Gamma correction block |
| + * @DPU_DSPP_IGC Inverse gamma correction block |
| */ |
| enum { |
| DPU_DSPP_PCC = 0x1, |
| DPU_DSPP_GC, |
| + DPU_DSPP_IGC, |
| DPU_DSPP_MAX |
| }; |
| |
| @@ -200,6 +202,7 @@ enum { |
| * @DPU_CTL_FETCH_ACTIVE: Active CTL for fetch HW (SSPPs) |
| * @DPU_CTL_VM_CFG: CTL config to support multiple VMs |
| * @DPU_CTL_HAS_LAYER_EXT4: CTL has the CTL_LAYER_EXT4 register |
| + * @DPU_CTL_DSPP_BLOCK_FLUSH: CTL config to support dspp sub-block flush |
| * @DPU_CTL_MAX |
| */ |
| enum { |
| @@ -208,6 +211,7 @@ enum { |
| DPU_CTL_FETCH_ACTIVE, |
| DPU_CTL_VM_CFG, |
| DPU_CTL_HAS_LAYER_EXT4, |
| + DPU_CTL_DSPP_SUB_BLOCK_FLUSH, |
| DPU_CTL_MAX |
| }; |
| |
| diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c |
| index 6c53ea560ffaa734ace47fb28798dc9c6168ae0e..bbdc95ce374a754cfa64c4d8603bb2ddd3bde0c1 100644 |
| --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c |
| +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c |
| @@ -26,15 +26,16 @@ |
| #define CTL_SW_RESET 0x030 |
| #define CTL_LAYER_EXTN_OFFSET 0x40 |
| #define CTL_MERGE_3D_ACTIVE 0x0E4 |
| +#define CTL_DSC_ACTIVE 0x0E8 |
| #define CTL_WB_ACTIVE 0x0EC |
| #define CTL_INTF_ACTIVE 0x0F4 |
| +#define CTL_FETCH_PIPE_ACTIVE 0x0FC |
| #define CTL_MERGE_3D_FLUSH 0x100 |
| -#define CTL_DSC_ACTIVE 0x0E8 |
| #define CTL_DSC_FLUSH 0x104 |
| #define CTL_WB_FLUSH 0x108 |
| #define CTL_INTF_FLUSH 0x110 |
| #define CTL_INTF_MASTER 0x134 |
| -#define CTL_FETCH_PIPE_ACTIVE 0x0FC |
| +#define CTL_DSPP_n_FLUSH(n) ((0x13C) + ((n) * 4)) |
| |
| #define CTL_MIXER_BORDER_OUT BIT(24) |
| #define CTL_FLUSH_MASK_CTL BIT(17) |
| @@ -44,6 +45,7 @@ |
| #define DSC_IDX 22 |
| #define INTF_IDX 31 |
| #define WB_IDX 16 |
| +#define DSPP_IDX 29 /* From DPU hw rev 7.x.x */ |
| #define CTL_INVALID_BIT 0xffff |
| #define CTL_DEFAULT_GROUP_ID 0xf |
| |
| @@ -115,6 +117,9 @@ static inline void dpu_hw_ctl_clear_pending_flush(struct dpu_hw_ctl *ctx) |
| trace_dpu_hw_ctl_clear_pending_flush(ctx->pending_flush_mask, |
| dpu_hw_ctl_get_flush_register(ctx)); |
| ctx->pending_flush_mask = 0x0; |
| + |
| + memset(ctx->pending_dspp_flush_mask, 0, |
| + sizeof(ctx->pending_dspp_flush_mask)); |
| } |
| |
| static inline void dpu_hw_ctl_update_pending_flush(struct dpu_hw_ctl *ctx, |
| @@ -132,6 +137,8 @@ static u32 dpu_hw_ctl_get_pending_flush(struct dpu_hw_ctl *ctx) |
| |
| static inline void dpu_hw_ctl_trigger_flush_v1(struct dpu_hw_ctl *ctx) |
| { |
| + int dspp; |
| + |
| if (ctx->pending_flush_mask & BIT(MERGE_3D_IDX)) |
| DPU_REG_WRITE(&ctx->hw, CTL_MERGE_3D_FLUSH, |
| ctx->pending_merge_3d_flush_mask); |
| @@ -142,6 +149,13 @@ static inline void dpu_hw_ctl_trigger_flush_v1(struct dpu_hw_ctl *ctx) |
| DPU_REG_WRITE(&ctx->hw, CTL_WB_FLUSH, |
| ctx->pending_wb_flush_mask); |
| |
| + if (ctx->pending_flush_mask & BIT(DSPP_IDX)) |
| + for (dspp = DSPP_0; dspp < DSPP_MAX; dspp++) { |
| + if (ctx->pending_dspp_flush_mask[dspp - DSPP_0]) |
| + DPU_REG_WRITE(&ctx->hw, |
| + CTL_DSPP_n_FLUSH(dspp - DSPP_0), |
| + ctx->pending_dspp_flush_mask[dspp - DSPP_0]); |
| + } |
| DPU_REG_WRITE(&ctx->hw, CTL_FLUSH, ctx->pending_flush_mask); |
| } |
| |
| @@ -289,7 +303,7 @@ static void dpu_hw_ctl_update_pending_flush_merge_3d_v1(struct dpu_hw_ctl *ctx, |
| } |
| |
| static void dpu_hw_ctl_update_pending_flush_dspp(struct dpu_hw_ctl *ctx, |
| - enum dpu_dspp dspp) |
| + enum dpu_dspp dspp, u32 dspp_sub_blk) |
| { |
| switch (dspp) { |
| case DSPP_0: |
| @@ -309,6 +323,29 @@ static void dpu_hw_ctl_update_pending_flush_dspp(struct dpu_hw_ctl *ctx, |
| } |
| } |
| |
| +static void dpu_hw_ctl_update_pending_flush_dspp_sub_blocks( |
| + struct dpu_hw_ctl *ctx, enum dpu_dspp dspp, u32 dspp_sub_blk) |
| +{ |
| + if (dspp >= DSPP_MAX) |
| + return; |
| + |
| + switch (dspp_sub_blk) { |
| + case DPU_DSPP_IGC: |
| + ctx->pending_dspp_flush_mask[dspp - DSPP_0] |= BIT(2); |
| + break; |
| + case DPU_DSPP_PCC: |
| + ctx->pending_dspp_flush_mask[dspp - DSPP_0] |= BIT(4); |
| + break; |
| + case DPU_DSPP_GC: |
| + ctx->pending_dspp_flush_mask[dspp - DSPP_0] |= BIT(5); |
| + break; |
| + default: |
| + return; |
| + } |
| + |
| + ctx->pending_flush_mask |= BIT(DSPP_IDX); |
| +} |
| + |
| static u32 dpu_hw_ctl_poll_reset_status(struct dpu_hw_ctl *ctx, u32 timeout_us) |
| { |
| struct dpu_hw_blk_reg_map *c = &ctx->hw; |
| @@ -630,7 +667,11 @@ static void _setup_ctl_ops(struct dpu_hw_ctl_ops *ops, |
| ops->setup_blendstage = dpu_hw_ctl_setup_blendstage; |
| ops->update_pending_flush_sspp = dpu_hw_ctl_update_pending_flush_sspp; |
| ops->update_pending_flush_mixer = dpu_hw_ctl_update_pending_flush_mixer; |
| - ops->update_pending_flush_dspp = dpu_hw_ctl_update_pending_flush_dspp; |
| + if (cap & BIT(DPU_CTL_DSPP_SUB_BLOCK_FLUSH)) |
| + ops->update_pending_flush_dspp = dpu_hw_ctl_update_pending_flush_dspp_sub_blocks; |
| + else |
| + ops->update_pending_flush_dspp = dpu_hw_ctl_update_pending_flush_dspp; |
| + |
| if (cap & BIT(DPU_CTL_FETCH_ACTIVE)) |
| ops->set_active_pipes = dpu_hw_ctl_set_fetch_pipe_active; |
| }; |
| diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h |
| index 96c012ec8467689527f736cc3454a0e104a2a57c..78611a8316974262756ec281d83ba0ebb36a5813 100644 |
| --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h |
| +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.h |
| @@ -152,9 +152,11 @@ struct dpu_hw_ctl_ops { |
| * No effect on hardware |
| * @ctx : ctl path ctx pointer |
| * @blk : DSPP block index |
| + * @dspp_sub_blk : DSPP sub-block index |
| */ |
| void (*update_pending_flush_dspp)(struct dpu_hw_ctl *ctx, |
| - enum dpu_dspp blk); |
| + enum dpu_dspp blk, u32 dspp_sub_blk); |
| + |
| /** |
| * Write the value of the pending_flush_mask to hardware |
| * @ctx : ctl path ctx pointer |
| @@ -242,6 +244,7 @@ struct dpu_hw_ctl { |
| u32 pending_intf_flush_mask; |
| u32 pending_wb_flush_mask; |
| u32 pending_merge_3d_flush_mask; |
| + u32 pending_dspp_flush_mask[DSPP_MAX - DSPP_0]; |
| |
| /* ops */ |
| struct dpu_hw_ctl_ops ops; |
| -- |
| 2.34.1 |
| |