On 29-07-21, 23:23, Dmitry Baryshkov wrote: > On 15/07/2021 09:51, Vinod Koul wrote: > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c > > index fd2d104f0a91..4da6d72b7996 100644 > > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c > > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c > > @@ -11,6 +11,7 @@ > > #include "dpu_hw_intf.h" > > #include "dpu_hw_dspp.h" > > #include "dpu_hw_merge3d.h" > > +#include "dpu_hw_dsc.h" > > #include "dpu_encoder.h" > > #include "dpu_trace.h" > > @@ -75,6 +76,14 @@ int dpu_rm_destroy(struct dpu_rm *rm) > > dpu_hw_intf_destroy(hw); > > } > > } > > + for (i = 0; i < ARRAY_SIZE(rm->dsc_blks); i++) { > > + struct dpu_hw_dsc *hw; > > + > > + if (rm->intf_blks[i]) { > > rm->dsc_blks[i] Thanks for spotting, fixed! > > > + hw = to_dpu_hw_dsc(rm->dsc_blks[i]); > > + dpu_hw_dsc_destroy(hw); > > + } > > + } > > return 0; > > } > > @@ -221,6 +230,19 @@ int dpu_rm_init(struct dpu_rm *rm, > > rm->dspp_blks[dspp->id - DSPP_0] = &hw->base; > > } > > + for (i = 0; i < cat->dsc_count; i++) { > > + struct dpu_hw_dsc *hw; > > + const struct dpu_dsc_cfg *dsc = &cat->dsc[i]; > > + > > + hw = dpu_hw_dsc_init(dsc->id, mmio, cat); > > + if (IS_ERR_OR_NULL(hw)) { > > + rc = PTR_ERR(hw); > > + DPU_ERROR("failed dsc object creation: err %d\n", rc); > > + goto fail; > > + } > > + rm->dsc_blks[dsc->id - DSC_0] = &hw->base; > > + } > > + > > return 0; > > fail: > > @@ -476,6 +498,9 @@ static int _dpu_rm_reserve_intf( > > } > > global_state->intf_to_enc_id[idx] = enc_id; > > + > > + global_state->dsc_to_enc_id[0] = enc_id; > > + global_state->dsc_to_enc_id[1] = enc_id; > > This is not correct. At least this should be guarded with an if, checking > that DSC is requested. Also we'd need to check that DSC 0 and 1 are not > allocated. Correct, so I have done few changes here and for DSC block reservation.. - Calling dpu_rm_get_assigned_resources() for DSC only when DSC is required from dpu encoder - moved the above code to dsc helper: _dpu_rm_reserve_dsc() as suggested by Abhinav as well - Check if DSC is supported and then check if DSC 0|1 are not allocated and then assign as above -- ~Vinod