From nobody Wed Nov 27 16:58:58 2024 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4A50156242 for ; Wed, 9 Oct 2024 08:50:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728463847; cv=none; b=UbovleGAMFDn3SNLnYFWqC+9oMtY27gIX6erAmWWDHDYYu8Gw0c36GEoHmkWgBa2+4T9OJw5L0Wgdvs9O5Jk75VyLhf4dEhFWsrHCxj0eq4KMTWQAknZSz6mSSIgQZzqZgyIXi0Fbwc2uv+XASoJHp5Rnr9EY4iHeS2z3V5xTiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728463847; c=relaxed/simple; bh=KJa8UFj1F4L8nQh4hIiMMrUpybEXZ51VO2/k9KJv3XQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EU8jjeSDWfSGAPeXkwlh/ebLx23tchvalbYNKnm9IB9zbZN+JCPj2XsUAz2ojrpfGzOz4hqCEJnU5QUWxYlHE4Um6LNHI6pDTUv2rwiTfBV0KAPnbkkcUDx0NRmd1mlWZGhlu7Q4hk8RT9JWSes46q4gNFOia9Vgd2+WmMFiq4Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=nZqJrlOP; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="nZqJrlOP" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-7d4fa972cbeso4843097a12.2 for ; Wed, 09 Oct 2024 01:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728463845; x=1729068645; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gFxoZp5lvl8L75KXTXnmIeC5GQOmgq4jA/ny4+kC/hI=; b=nZqJrlOP4quDRS9EsEEFnZiFAHihOIUy5SnQDPzae19Bgf+Jlx/1WYcaqa+qfbGy1T pcnI5LJeDcAgFbZsYrCcmjLA7O6Nm3rmXxL8AnWfJiFGyVH0AqKfKui+SPda0Lce+kgK 1bVLxafnNpYUHbfhxpYWKUVjPo87jh28FVkHna3IQMKZtk4rXzOXJ3/w9wc3ALoAi+91 1DThl2BNR4kJI/y3RGc/2S27fkcNLezdbMP5bPLRbx8JSArY140PjAqMAZgUpEOsEOC8 tF7cqaSZo72/UxNlwnX6ndHlTUg8WSf7I/731CVq6wNpkzxBa0MufHR0l5ZRwpoMaFyy hDeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728463845; x=1729068645; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gFxoZp5lvl8L75KXTXnmIeC5GQOmgq4jA/ny4+kC/hI=; b=HW+G3Cb7CepYU8Zxvh6cWklLuMHZIhQbyE8xudO/9X/FmkxuTUu70nVkRjoVfKqtXc JhqD9ew5hPZWU/kIuNSmyeZW5DiAOBjKM/FmLtvRW28coZVCMuCWLy9vdy2UGZnBGl3k 97HVD6xuiOzAVmoqNomPIypsU3ofNjMLzHDrnERQ43tuOMOzenFTtjOoLbvKeZddQKVt 43kNhDTI0CkDiUgq5tWjgi4wRklc0VKqJty5qPOO0r0mjNz8LKHyDnepM60KcYAYzcSX ej/6NyoMaU7pQsTsE1DK0ETtKDicL//Gh1t7TrxOZM2xW+cc7nVr3M1ZH12DFTwyzUB3 vnXQ== X-Forwarded-Encrypted: i=1; AJvYcCXluiv+5Uqekp/CQWsvGctoX4j0Dwyd3C4+RckDAGmfum8VUhcoX/tqBsRoFAyAj9YNY7YvchgK5PJryOE=@vger.kernel.org X-Gm-Message-State: AOJu0Yzbh+4rI46OI0Cs6BtkzeAcSogJc8+CwQi8G6aPCg1cuLYMUGLw Mfdco7pq9OddNwkHkwKdXNwLzwuDVi26x39lSmxLLU2KnnxNX95iYnaNFm+io5s= X-Google-Smtp-Source: AGHT+IER5m8hOoH/Wws+QEssyk0f1aSKzdwJ8U1bUR/9WTE+/Czt6Ufxweg/byCCtqaNnoKEwDNiVQ== X-Received: by 2002:a17:90a:f0d1:b0:2e2:abab:c450 with SMTP id 98e67ed59e1d1-2e2ababc590mr1412105a91.11.1728463844828; Wed, 09 Oct 2024 01:50:44 -0700 (PDT) Received: from [127.0.1.1] ([112.65.12.217]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e2abad236esm898157a91.10.2024.10.09.01.50.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 01:50:44 -0700 (PDT) From: Jun Nie Date: Wed, 09 Oct 2024 16:50:17 +0800 Subject: [PATCH v2 04/14] drm/msm/dpu: switch RM to use crtc_id rather than enc_id for allocation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241009-sm8650-v6-11-hmd-pocf-mdss-quad-upstream-21-v2-4-76d4f5d413bf@linaro.org> References: <20241009-sm8650-v6-11-hmd-pocf-mdss-quad-upstream-21-v2-0-76d4f5d413bf@linaro.org> In-Reply-To: <20241009-sm8650-v6-11-hmd-pocf-mdss-quad-upstream-21-v2-0-76d4f5d413bf@linaro.org> To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jun Nie X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728463820; l=25681; i=jun.nie@linaro.org; s=20240403; h=from:subject:message-id; bh=KJa8UFj1F4L8nQh4hIiMMrUpybEXZ51VO2/k9KJv3XQ=; b=Ii9UtPVf6NHG4/sGXzCHJ9n8R3KY/21OqwzXDuPHQEe48KWIvavFH4PFOBQg5RFXaGv6BEMxC LZpHhkxlsxtDUn35atXgn0Bscm1l+J0WFIhkSL0++unKwMxl03gSN/w X-Developer-Key: i=jun.nie@linaro.org; a=ed25519; pk=MNiBt/faLPvo+iJoP1hodyY2x6ozVXL8QMptmsKg3cc= Up to now the driver has been using encoder to allocate hardware resources. Switch it to use CRTC id so that mixer number can be known in dpu_plane_virtual_assign_resources() via CRTC id for sspp alloation. Because the mixer allocation is done in drm_atomic_helper_check_modeset() as part of CRTC operation. While the sspp assignment is in drm_atomic_helper_check_planes() call tree. So CRTC is more central than encoder. Siwtching the id achieves above goal. Co-developed-by: Dmitry Baryshkov Signed-off-by: Dmitry Baryshkov Signed-off-by: Jun Nie --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 18 +-- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h | 12 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 189 ++++++++++++++----------= ---- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 19 ++- 4 files changed, 116 insertions(+), 122 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/= msm/disp/dpu1/dpu_encoder.c index e8400b494687c..bd2509985c4d0 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -687,11 +687,11 @@ static int dpu_encoder_virt_atomic_check( * Dont allocate when active is false. */ if (drm_atomic_crtc_needs_modeset(crtc_state)) { - dpu_rm_release(global_state, drm_enc); + dpu_rm_release(global_state, crtc_state->crtc); =20 if (!crtc_state->active_changed || crtc_state->enable) ret =3D dpu_rm_reserve(&dpu_kms->rm, global_state, - drm_enc, crtc_state, topology); + crtc_state->crtc, topology); } =20 trace_dpu_enc_atomic_check_flags(DRMID(drm_enc), adj_mode->flags); @@ -1125,14 +1125,14 @@ static void dpu_encoder_virt_atomic_mode_set(struct= drm_encoder *drm_enc, =20 /* Query resource that have been reserved in atomic check step. */ num_pp =3D dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state, - drm_enc->base.id, DPU_HW_BLK_PINGPONG, hw_pp, + drm_enc->crtc, DPU_HW_BLK_PINGPONG, hw_pp, ARRAY_SIZE(hw_pp)); num_ctl =3D dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state, - drm_enc->base.id, DPU_HW_BLK_CTL, hw_ctl, ARRAY_SIZE(hw_ctl)); + drm_enc->crtc, DPU_HW_BLK_CTL, hw_ctl, ARRAY_SIZE(hw_ctl)); num_lm =3D dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state, - drm_enc->base.id, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm)); + drm_enc->crtc, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm)); dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state, - drm_enc->base.id, DPU_HW_BLK_DSPP, hw_dspp, + drm_enc->crtc, DPU_HW_BLK_DSPP, hw_dspp, ARRAY_SIZE(hw_dspp)); =20 for (i =3D 0; i < MAX_CHANNELS_PER_ENC; i++) @@ -1140,7 +1140,7 @@ static void dpu_encoder_virt_atomic_mode_set(struct d= rm_encoder *drm_enc, : NULL; =20 num_dsc =3D dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state, - drm_enc->base.id, DPU_HW_BLK_DSC, + drm_enc->crtc, DPU_HW_BLK_DSC, hw_dsc, ARRAY_SIZE(hw_dsc)); for (i =3D 0; i < num_dsc; i++) { dpu_enc->hw_dsc[i] =3D to_dpu_hw_dsc(hw_dsc[i]); @@ -1154,7 +1154,7 @@ static void dpu_encoder_virt_atomic_mode_set(struct d= rm_encoder *drm_enc, struct dpu_hw_blk *hw_cdm =3D NULL; =20 dpu_rm_get_assigned_resources(&dpu_kms->rm, global_state, - drm_enc->base.id, DPU_HW_BLK_CDM, + drm_enc->crtc, DPU_HW_BLK_CDM, &hw_cdm, 1); dpu_enc->cur_master->hw_cdm =3D hw_cdm ? to_dpu_hw_cdm(hw_cdm) : NULL; } @@ -2030,7 +2030,7 @@ static void dpu_encoder_helper_reset_mixers(struct dp= u_encoder_phys *phys_enc) global_state =3D dpu_kms_get_existing_global_state(phys_enc->dpu_kms); =20 num_lm =3D dpu_rm_get_assigned_resources(&phys_enc->dpu_kms->rm, global_s= tate, - phys_enc->parent->base.id, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm)); + phys_enc->parent->crtc, DPU_HW_BLK_LM, hw_lm, ARRAY_SIZE(hw_lm)); =20 for (i =3D 0; i < num_lm; i++) { hw_mixer[i] =3D to_dpu_hw_mixer(hw_lm[i]); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h b/drivers/gpu/drm/msm/= disp/dpu1/dpu_kms.h index 1952576600575..4f0fa1596b414 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.h @@ -134,12 +134,12 @@ struct dpu_global_state { =20 struct dpu_rm *rm; =20 - uint32_t pingpong_to_enc_id[PINGPONG_MAX - PINGPONG_0]; - uint32_t mixer_to_enc_id[LM_MAX - LM_0]; - uint32_t ctl_to_enc_id[CTL_MAX - CTL_0]; - uint32_t dspp_to_enc_id[DSPP_MAX - DSPP_0]; - uint32_t dsc_to_enc_id[DSC_MAX - DSC_0]; - uint32_t cdm_to_enc_id; + uint32_t pingpong_to_crtc_id[PINGPONG_MAX - PINGPONG_0]; + uint32_t mixer_to_crtc_id[LM_MAX - LM_0]; + uint32_t ctl_to_crtc_id[CTL_MAX - CTL_0]; + uint32_t dspp_to_crtc_id[DSPP_MAX - DSPP_0]; + uint32_t dsc_to_crtc_id[DSC_MAX - DSC_0]; + uint32_t cdm_to_crtc_id; =20 uint32_t sspp_to_crtc_id[SSPP_MAX - SSPP_NONE]; }; diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/d= isp/dpu1/dpu_rm.c index 5c9bb64df7930..a6e1eb888f6c8 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c @@ -21,9 +21,9 @@ =20 =20 static inline bool reserved_by_other(uint32_t *res_map, int idx, - uint32_t enc_id) + uint32_t crtc_id) { - return res_map[idx] && res_map[idx] !=3D enc_id; + return res_map[idx] && res_map[idx] !=3D crtc_id; } =20 /** @@ -225,7 +225,7 @@ static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int p= rimary_idx) * pingpong * @rm: dpu resource manager handle * @global_state: resources shared across multiple kms objects - * @enc_id: encoder id requesting for allocation + * @crtc_id: crtc id requesting for allocation * @lm_idx: index of proposed layer mixer in rm->mixer_blks[], function ch= ecks * if lm, and all other hardwired blocks connected to the lm (pp) is * available and appropriate @@ -239,14 +239,14 @@ static int _dpu_rm_get_lm_peer(struct dpu_rm *rm, int= primary_idx) */ static bool _dpu_rm_check_lm_and_get_connected_blks(struct dpu_rm *rm, struct dpu_global_state *global_state, - uint32_t enc_id, int lm_idx, int *pp_idx, int *dspp_idx, + uint32_t crtc_id, int lm_idx, int *pp_idx, int *dspp_idx, struct dpu_rm_requirements *reqs) { const struct dpu_lm_cfg *lm_cfg; int idx; =20 /* Already reserved? */ - if (reserved_by_other(global_state->mixer_to_enc_id, lm_idx, enc_id)) { + if (reserved_by_other(global_state->mixer_to_crtc_id, lm_idx, crtc_id)) { DPU_DEBUG("lm %d already reserved\n", lm_idx + LM_0); return false; } @@ -258,7 +258,7 @@ static bool _dpu_rm_check_lm_and_get_connected_blks(str= uct dpu_rm *rm, return false; } =20 - if (reserved_by_other(global_state->pingpong_to_enc_id, idx, enc_id)) { + if (reserved_by_other(global_state->pingpong_to_crtc_id, idx, crtc_id)) { DPU_DEBUG("lm %d pp %d already reserved\n", lm_cfg->id, lm_cfg->pingpong); return false; @@ -274,7 +274,7 @@ static bool _dpu_rm_check_lm_and_get_connected_blks(str= uct dpu_rm *rm, return false; } =20 - if (reserved_by_other(global_state->dspp_to_enc_id, idx, enc_id)) { + if (reserved_by_other(global_state->dspp_to_crtc_id, idx, crtc_id)) { DPU_DEBUG("lm %d dspp %d already reserved\n", lm_cfg->id, lm_cfg->dspp); return false; @@ -286,7 +286,7 @@ static bool _dpu_rm_check_lm_and_get_connected_blks(str= uct dpu_rm *rm, =20 static int _dpu_rm_reserve_lms(struct dpu_rm *rm, struct dpu_global_state *global_state, - uint32_t enc_id, + uint32_t crtc_id, struct dpu_rm_requirements *reqs) =20 { @@ -314,7 +314,7 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, lm_idx[lm_count] =3D i; =20 if (!_dpu_rm_check_lm_and_get_connected_blks(rm, global_state, - enc_id, i, &pp_idx[lm_count], + crtc_id, i, &pp_idx[lm_count], &dspp_idx[lm_count], reqs)) { continue; } @@ -333,7 +333,7 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, continue; =20 if (!_dpu_rm_check_lm_and_get_connected_blks(rm, - global_state, enc_id, j, + global_state, crtc_id, j, &pp_idx[lm_count], &dspp_idx[lm_count], reqs)) { continue; @@ -350,13 +350,16 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, } =20 for (i =3D 0; i < lm_count; i++) { - global_state->mixer_to_enc_id[lm_idx[i]] =3D enc_id; - global_state->pingpong_to_enc_id[pp_idx[i]] =3D enc_id; - global_state->dspp_to_enc_id[dspp_idx[i]] =3D - reqs->topology.num_dspp ? enc_id : 0; + global_state->mixer_to_crtc_id[lm_idx[i]] =3D crtc_id; + global_state->pingpong_to_crtc_id[pp_idx[i]] =3D crtc_id; + global_state->dspp_to_crtc_id[dspp_idx[i]] =3D + reqs->topology.num_dspp ? crtc_id : 0; =20 - trace_dpu_rm_reserve_lms(lm_idx[i] + LM_0, enc_id, + trace_dpu_rm_reserve_lms(lm_idx[i] + LM_0, crtc_id, pp_idx[i] + PINGPONG_0); + + DPU_DEBUG("reserve lm[%d]:%d, pp_idx[%d]:%d, dspp[%d]:%d for crtc_id %d\= n", + i, lm_idx[i], i, pp_idx[i], i, dspp_idx[i], crtc_id); } =20 return 0; @@ -365,7 +368,7 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, static int _dpu_rm_reserve_ctls( struct dpu_rm *rm, struct dpu_global_state *global_state, - uint32_t enc_id, + uint32_t crtc_id, const struct msm_display_topology *top) { int ctl_idx[MAX_BLOCKS]; @@ -389,7 +392,7 @@ static int _dpu_rm_reserve_ctls( =20 if (!rm->ctl_blks[j]) continue; - if (reserved_by_other(global_state->ctl_to_enc_id, j, enc_id)) + if (reserved_by_other(global_state->ctl_to_crtc_id, j, crtc_id)) continue; =20 ctl =3D to_dpu_hw_ctl(rm->ctl_blks[j]); @@ -413,8 +416,8 @@ static int _dpu_rm_reserve_ctls( return -ENAVAIL; =20 for (i =3D 0; i < ARRAY_SIZE(ctl_idx) && i < num_ctls; i++) { - global_state->ctl_to_enc_id[ctl_idx[i]] =3D enc_id; - trace_dpu_rm_reserve_ctls(i + CTL_0, enc_id); + global_state->ctl_to_crtc_id[ctl_idx[i]] =3D crtc_id; + trace_dpu_rm_reserve_ctls(i + CTL_0, crtc_id); } =20 return 0; @@ -422,12 +425,12 @@ static int _dpu_rm_reserve_ctls( =20 static int _dpu_rm_pingpong_next_index(struct dpu_global_state *global_sta= te, int start, - uint32_t enc_id) + uint32_t crtc_id) { int i; =20 for (i =3D start; i < (PINGPONG_MAX - PINGPONG_0); i++) { - if (global_state->pingpong_to_enc_id[i] =3D=3D enc_id) + if (global_state->pingpong_to_crtc_id[i] =3D=3D crtc_id) return i; } =20 @@ -448,7 +451,7 @@ static int _dpu_rm_pingpong_dsc_check(int dsc_idx, int = pp_idx) =20 static int _dpu_rm_dsc_alloc(struct dpu_rm *rm, struct dpu_global_state *global_state, - uint32_t enc_id, + uint32_t crtc_id, const struct msm_display_topology *top) { int num_dsc =3D 0; @@ -461,10 +464,10 @@ static int _dpu_rm_dsc_alloc(struct dpu_rm *rm, if (!rm->dsc_blks[dsc_idx]) continue; =20 - if (reserved_by_other(global_state->dsc_to_enc_id, dsc_idx, enc_id)) + if (reserved_by_other(global_state->dsc_to_crtc_id, dsc_idx, crtc_id)) continue; =20 - pp_idx =3D _dpu_rm_pingpong_next_index(global_state, pp_idx, enc_id); + pp_idx =3D _dpu_rm_pingpong_next_index(global_state, pp_idx, crtc_id); if (pp_idx < 0) return -ENAVAIL; =20 @@ -472,7 +475,7 @@ static int _dpu_rm_dsc_alloc(struct dpu_rm *rm, if (ret) return -ENAVAIL; =20 - global_state->dsc_to_enc_id[dsc_idx] =3D enc_id; + global_state->dsc_to_crtc_id[dsc_idx] =3D crtc_id; num_dsc++; pp_idx++; } @@ -488,7 +491,7 @@ static int _dpu_rm_dsc_alloc(struct dpu_rm *rm, =20 static int _dpu_rm_dsc_alloc_pair(struct dpu_rm *rm, struct dpu_global_state *global_state, - uint32_t enc_id, + uint32_t crtc_id, const struct msm_display_topology *top) { int num_dsc =3D 0; @@ -503,11 +506,11 @@ static int _dpu_rm_dsc_alloc_pair(struct dpu_rm *rm, continue; =20 /* consective dsc index to be paired */ - if (reserved_by_other(global_state->dsc_to_enc_id, dsc_idx, enc_id) || - reserved_by_other(global_state->dsc_to_enc_id, dsc_idx + 1, enc_id)) + if (reserved_by_other(global_state->dsc_to_crtc_id, dsc_idx, crtc_id) || + reserved_by_other(global_state->dsc_to_crtc_id, dsc_idx + 1, crtc_id= )) continue; =20 - pp_idx =3D _dpu_rm_pingpong_next_index(global_state, pp_idx, enc_id); + pp_idx =3D _dpu_rm_pingpong_next_index(global_state, pp_idx, crtc_id); if (pp_idx < 0) return -ENAVAIL; =20 @@ -517,7 +520,7 @@ static int _dpu_rm_dsc_alloc_pair(struct dpu_rm *rm, continue; } =20 - pp_idx =3D _dpu_rm_pingpong_next_index(global_state, pp_idx + 1, enc_id); + pp_idx =3D _dpu_rm_pingpong_next_index(global_state, pp_idx + 1, crtc_id= ); if (pp_idx < 0) return -ENAVAIL; =20 @@ -527,8 +530,8 @@ static int _dpu_rm_dsc_alloc_pair(struct dpu_rm *rm, continue; } =20 - global_state->dsc_to_enc_id[dsc_idx] =3D enc_id; - global_state->dsc_to_enc_id[dsc_idx + 1] =3D enc_id; + global_state->dsc_to_crtc_id[dsc_idx] =3D crtc_id; + global_state->dsc_to_crtc_id[dsc_idx + 1] =3D crtc_id; num_dsc +=3D 2; pp_idx++; /* start for next pair */ } @@ -544,11 +547,9 @@ static int _dpu_rm_dsc_alloc_pair(struct dpu_rm *rm, =20 static int _dpu_rm_reserve_dsc(struct dpu_rm *rm, struct dpu_global_state *global_state, - struct drm_encoder *enc, + uint32_t crtc_id, const struct msm_display_topology *top) { - uint32_t enc_id =3D enc->base.id; - if (!top->num_dsc || !top->num_intf) return 0; =20 @@ -558,22 +559,22 @@ static int _dpu_rm_reserve_dsc(struct dpu_rm *rm, * 2) DSC pair starts from even index, such as index(0,1), (2,3), etc * 3) even PINGPONG connects to even DSC * 4) odd PINGPONG connects to odd DSC - * 5) pair: encoder +--> pp_idx_0 --> dsc_idx_0 + * 5) pair: crtc +--> pp_idx_0 --> dsc_idx_0 * +--> pp_idx_1 --> dsc_idx_1 */ =20 /* num_dsc should be either 1, 2 or 4 */ if (top->num_dsc > top->num_intf) /* merge mode */ - return _dpu_rm_dsc_alloc_pair(rm, global_state, enc_id, top); + return _dpu_rm_dsc_alloc_pair(rm, global_state, crtc_id, top); else - return _dpu_rm_dsc_alloc(rm, global_state, enc_id, top); + return _dpu_rm_dsc_alloc(rm, global_state, crtc_id, top); =20 return 0; } =20 static int _dpu_rm_reserve_cdm(struct dpu_rm *rm, struct dpu_global_state *global_state, - struct drm_encoder *enc) + uint32_t crtc_id) { /* try allocating only one CDM block */ if (!rm->cdm_blk) { @@ -581,12 +582,12 @@ static int _dpu_rm_reserve_cdm(struct dpu_rm *rm, return -EIO; } =20 - if (global_state->cdm_to_enc_id) { + if (global_state->cdm_to_crtc_id) { DPU_ERROR("CDM_0 is already allocated\n"); return -EIO; } =20 - global_state->cdm_to_enc_id =3D enc->base.id; + global_state->cdm_to_crtc_id =3D crtc_id; =20 return 0; } @@ -594,30 +595,30 @@ static int _dpu_rm_reserve_cdm(struct dpu_rm *rm, static int _dpu_rm_make_reservation( struct dpu_rm *rm, struct dpu_global_state *global_state, - struct drm_encoder *enc, + uint32_t crtc_id, struct dpu_rm_requirements *reqs) { int ret; =20 - ret =3D _dpu_rm_reserve_lms(rm, global_state, enc->base.id, reqs); + ret =3D _dpu_rm_reserve_lms(rm, global_state, crtc_id, reqs); if (ret) { DPU_ERROR("unable to find appropriate mixers\n"); return ret; } =20 - ret =3D _dpu_rm_reserve_ctls(rm, global_state, enc->base.id, + ret =3D _dpu_rm_reserve_ctls(rm, global_state, crtc_id, &reqs->topology); if (ret) { DPU_ERROR("unable to find appropriate CTL\n"); return ret; } =20 - ret =3D _dpu_rm_reserve_dsc(rm, global_state, enc, &reqs->topology); + ret =3D _dpu_rm_reserve_dsc(rm, global_state, crtc_id, &reqs->topology); if (ret) return ret; =20 if (reqs->topology.needs_cdm) { - ret =3D _dpu_rm_reserve_cdm(rm, global_state, enc); + ret =3D _dpu_rm_reserve_cdm(rm, global_state, crtc_id); if (ret) { DPU_ERROR("unable to find CDM blk\n"); return ret; @@ -628,7 +629,7 @@ static int _dpu_rm_make_reservation( } =20 static int _dpu_rm_populate_requirements( - struct drm_encoder *enc, + struct drm_crtc *crtc, struct dpu_rm_requirements *reqs, struct msm_display_topology req_topology) { @@ -642,66 +643,59 @@ static int _dpu_rm_populate_requirements( } =20 static void _dpu_rm_clear_mapping(uint32_t *res_mapping, int cnt, - uint32_t enc_id) + uint32_t crtc_id) { int i; =20 for (i =3D 0; i < cnt; i++) { - if (res_mapping[i] =3D=3D enc_id) + if (res_mapping[i] =3D=3D crtc_id) res_mapping[i] =3D 0; } } =20 void dpu_rm_release(struct dpu_global_state *global_state, - struct drm_encoder *enc) + struct drm_crtc *crtc) { - _dpu_rm_clear_mapping(global_state->pingpong_to_enc_id, - ARRAY_SIZE(global_state->pingpong_to_enc_id), enc->base.id); - _dpu_rm_clear_mapping(global_state->mixer_to_enc_id, - ARRAY_SIZE(global_state->mixer_to_enc_id), enc->base.id); - _dpu_rm_clear_mapping(global_state->ctl_to_enc_id, - ARRAY_SIZE(global_state->ctl_to_enc_id), enc->base.id); - _dpu_rm_clear_mapping(global_state->dsc_to_enc_id, - ARRAY_SIZE(global_state->dsc_to_enc_id), enc->base.id); - _dpu_rm_clear_mapping(global_state->dspp_to_enc_id, - ARRAY_SIZE(global_state->dspp_to_enc_id), enc->base.id); - _dpu_rm_clear_mapping(&global_state->cdm_to_enc_id, 1, enc->base.id); + uint32_t crtc_id =3D crtc->base.id; + + _dpu_rm_clear_mapping(global_state->pingpong_to_crtc_id, + ARRAY_SIZE(global_state->pingpong_to_crtc_id), crtc_id); + _dpu_rm_clear_mapping(global_state->mixer_to_crtc_id, + ARRAY_SIZE(global_state->mixer_to_crtc_id), crtc_id); + _dpu_rm_clear_mapping(global_state->ctl_to_crtc_id, + ARRAY_SIZE(global_state->ctl_to_crtc_id), crtc_id); + _dpu_rm_clear_mapping(global_state->dsc_to_crtc_id, + ARRAY_SIZE(global_state->dsc_to_crtc_id), crtc_id); + _dpu_rm_clear_mapping(global_state->dspp_to_crtc_id, + ARRAY_SIZE(global_state->dspp_to_crtc_id), crtc_id); } =20 int dpu_rm_reserve( struct dpu_rm *rm, struct dpu_global_state *global_state, - struct drm_encoder *enc, - struct drm_crtc_state *crtc_state, + struct drm_crtc *crtc, struct msm_display_topology topology) { struct dpu_rm_requirements reqs; int ret; =20 - /* Check if this is just a page-flip */ - if (!drm_atomic_crtc_needs_modeset(crtc_state)) - return 0; - if (IS_ERR(global_state)) { DPU_ERROR("failed to global state\n"); return PTR_ERR(global_state); } =20 - DRM_DEBUG_KMS("reserving hw for enc %d crtc %d\n", - enc->base.id, crtc_state->crtc->base.id); + DRM_DEBUG_KMS("reserving hw for crtc %d\n", crtc->base.id); =20 - ret =3D _dpu_rm_populate_requirements(enc, &reqs, topology); + ret =3D _dpu_rm_populate_requirements(crtc, &reqs, topology); if (ret) { DPU_ERROR("failed to populate hw requirements\n"); return ret; } =20 - ret =3D _dpu_rm_make_reservation(rm, global_state, enc, &reqs); + ret =3D _dpu_rm_make_reservation(rm, global_state, crtc->base.id, &reqs); if (ret) DPU_ERROR("failed to reserve hw resources: %d\n", ret); =20 - - return ret; } =20 @@ -798,42 +792,43 @@ static char *dpu_hw_blk_type_name[] =3D { }; =20 int dpu_rm_get_assigned_resources(struct dpu_rm *rm, - struct dpu_global_state *global_state, uint32_t enc_id, + struct dpu_global_state *global_state, struct drm_crtc *crtc, enum dpu_hw_blk_type type, struct dpu_hw_blk **blks, int blks_size) { + uint32_t crtc_id =3D crtc->base.id; struct dpu_hw_blk **hw_blks; - uint32_t *hw_to_enc_id; + uint32_t *hw_to_crtc_id; int i, num_blks, max_blks; =20 switch (type) { case DPU_HW_BLK_PINGPONG: hw_blks =3D rm->pingpong_blks; - hw_to_enc_id =3D global_state->pingpong_to_enc_id; + hw_to_crtc_id =3D global_state->pingpong_to_crtc_id; max_blks =3D ARRAY_SIZE(rm->pingpong_blks); break; case DPU_HW_BLK_LM: hw_blks =3D rm->mixer_blks; - hw_to_enc_id =3D global_state->mixer_to_enc_id; + hw_to_crtc_id =3D global_state->mixer_to_crtc_id; max_blks =3D ARRAY_SIZE(rm->mixer_blks); break; case DPU_HW_BLK_CTL: hw_blks =3D rm->ctl_blks; - hw_to_enc_id =3D global_state->ctl_to_enc_id; + hw_to_crtc_id =3D global_state->ctl_to_crtc_id; max_blks =3D ARRAY_SIZE(rm->ctl_blks); break; case DPU_HW_BLK_DSPP: hw_blks =3D rm->dspp_blks; - hw_to_enc_id =3D global_state->dspp_to_enc_id; + hw_to_crtc_id =3D global_state->dspp_to_crtc_id; max_blks =3D ARRAY_SIZE(rm->dspp_blks); break; case DPU_HW_BLK_DSC: hw_blks =3D rm->dsc_blks; - hw_to_enc_id =3D global_state->dsc_to_enc_id; + hw_to_crtc_id =3D global_state->dsc_to_crtc_id; max_blks =3D ARRAY_SIZE(rm->dsc_blks); break; case DPU_HW_BLK_CDM: hw_blks =3D &rm->cdm_blk; - hw_to_enc_id =3D &global_state->cdm_to_enc_id; + hw_to_crtc_id =3D &global_state->cdm_to_crtc_id; max_blks =3D 1; break; default: @@ -843,17 +838,17 @@ int dpu_rm_get_assigned_resources(struct dpu_rm *rm, =20 num_blks =3D 0; for (i =3D 0; i < max_blks; i++) { - if (hw_to_enc_id[i] !=3D enc_id) + if (hw_to_crtc_id[i] !=3D crtc_id) continue; =20 if (num_blks =3D=3D blks_size) { - DPU_ERROR("More than %d %s assigned to enc %d\n", - blks_size, dpu_hw_blk_type_name[type], enc_id); + DPU_ERROR("More than %d resources assigned to crtc %d\n", + blks_size, crtc_id); break; } if (!hw_blks[i]) { - DPU_ERROR("%s unavailable to assign to enc %d\n", - dpu_hw_blk_type_name[type], enc_id); + DPU_ERROR("%s unavailable to assign to crtc %d\n", + dpu_hw_blk_type_name[type], crtc_id); break; } blks[num_blks++] =3D hw_blks[i]; @@ -883,38 +878,38 @@ void dpu_rm_print_state(struct drm_printer *p, =20 drm_puts(p, "resource mapping:\n"); drm_puts(p, "\tpingpong=3D"); - for (i =3D 0; i < ARRAY_SIZE(global_state->pingpong_to_enc_id); i++) + for (i =3D 0; i < ARRAY_SIZE(global_state->pingpong_to_crtc_id); i++) dpu_rm_print_state_helper(p, rm->pingpong_blks[i], - global_state->pingpong_to_enc_id[i]); + global_state->pingpong_to_crtc_id[i]); drm_puts(p, "\n"); =20 drm_puts(p, "\tmixer=3D"); - for (i =3D 0; i < ARRAY_SIZE(global_state->mixer_to_enc_id); i++) + for (i =3D 0; i < ARRAY_SIZE(global_state->mixer_to_crtc_id); i++) dpu_rm_print_state_helper(p, rm->mixer_blks[i], - global_state->mixer_to_enc_id[i]); + global_state->mixer_to_crtc_id[i]); drm_puts(p, "\n"); =20 drm_puts(p, "\tctl=3D"); - for (i =3D 0; i < ARRAY_SIZE(global_state->ctl_to_enc_id); i++) + for (i =3D 0; i < ARRAY_SIZE(global_state->ctl_to_crtc_id); i++) dpu_rm_print_state_helper(p, rm->ctl_blks[i], - global_state->ctl_to_enc_id[i]); + global_state->ctl_to_crtc_id[i]); drm_puts(p, "\n"); =20 drm_puts(p, "\tdspp=3D"); - for (i =3D 0; i < ARRAY_SIZE(global_state->dspp_to_enc_id); i++) + for (i =3D 0; i < ARRAY_SIZE(global_state->dspp_to_crtc_id); i++) dpu_rm_print_state_helper(p, rm->dspp_blks[i], - global_state->dspp_to_enc_id[i]); + global_state->dspp_to_crtc_id[i]); drm_puts(p, "\n"); =20 drm_puts(p, "\tdsc=3D"); - for (i =3D 0; i < ARRAY_SIZE(global_state->dsc_to_enc_id); i++) + for (i =3D 0; i < ARRAY_SIZE(global_state->dsc_to_crtc_id); i++) dpu_rm_print_state_helper(p, rm->dsc_blks[i], - global_state->dsc_to_enc_id[i]); + global_state->dsc_to_crtc_id[i]); drm_puts(p, "\n"); =20 drm_puts(p, "\tcdm=3D"); dpu_rm_print_state_helper(p, rm->cdm_blk, - global_state->cdm_to_enc_id); + global_state->cdm_to_crtc_id); drm_puts(p, "\n"); =20 drm_puts(p, "\tsspp=3D"); diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/d= isp/dpu1/dpu_rm.h index c51c5a9255ce6..720e2c64effbf 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h @@ -68,26 +68,25 @@ int dpu_rm_init(struct drm_device *dev, * HW blocks can then be accessed through dpu_rm_get_* functions. * HW Reservations should be released via dpu_rm_release_hw. * @rm: DPU Resource Manager handle - * @drm_enc: DRM Encoder handle - * @crtc_state: Proposed Atomic DRM CRTC State handle + * @crtc: DRM CRTC handle * @topology: Pointer to topology info for the display * @Return: 0 on Success otherwise -ERROR */ -int dpu_rm_reserve(struct dpu_rm *rm, +int dpu_rm_reserve( + struct dpu_rm *rm, struct dpu_global_state *global_state, - struct drm_encoder *drm_enc, - struct drm_crtc_state *crtc_state, + struct drm_crtc *crtc, struct msm_display_topology topology); =20 /** - * dpu_rm_reserve - Given the encoder for the display chain, release any + * dpu_rm_reserve - Given the crtc for the display chain, release any * HW blocks previously reserved for that use case. * @rm: DPU Resource Manager handle - * @enc: DRM Encoder handle + * @crtc: DRM CRTC handle * @Return: 0 on Success otherwise -ERROR */ void dpu_rm_release(struct dpu_global_state *global_state, - struct drm_encoder *enc); + struct drm_crtc *crtc); =20 /** * dpu_rm_reserve_sspp - Reserve the required SSPP for the provided CRTC @@ -111,10 +110,10 @@ void dpu_rm_release_all_sspp(struct dpu_global_state = *global_state, struct drm_crtc *crtc); =20 /** - * Get hw resources of the given type that are assigned to this encoder. + * Get hw resources of the given type that are assigned to this crtc. */ int dpu_rm_get_assigned_resources(struct dpu_rm *rm, - struct dpu_global_state *global_state, uint32_t enc_id, + struct dpu_global_state *global_state, struct drm_crtc *crtc, enum dpu_hw_blk_type type, struct dpu_hw_blk **blks, int blks_size); =20 /** --=20 2.34.1