From 8dd5deed118752d0460f1d7b3274e3ef69eb7733 Mon Sep 17 00:00:00 2001 From: Amine Najahi Date: Wed, 11 Mar 2020 11:04:22 -0400 Subject: [PATCH] drm: msm: sde: reserve LM in pairs for 4LM topologies Reserve LM in the sequence of primary-peer and then primary-peer again until all required LM are reserved. Searching sequence will not change for single/dual LM reservation. For single LM reservation it will return right after the first primary LM is found. For dual LM reservation it will return after the first primary-peer pair is found. The logic can also work for triple/quad or any number of LM reservetion and make sure that all the reserved LMs are in pairs except the last one if total LM number is odd. Change-Id: Ia28bb64fedeb43430039775051943d751259a3d2 Signed-off-by: Amine Najahi Signed-off-by: satbir singh Signed-off-by: Xiaowen Wu --- msm/sde/sde_rm.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/msm/sde/sde_rm.c b/msm/sde/sde_rm.c index 4fd6c34d25..0cd0697201 100644 --- a/msm/sde/sde_rm.c +++ b/msm/sde/sde_rm.c @@ -1071,6 +1071,7 @@ static int _sde_rm_reserve_lms( struct sde_rm_hw_blk *ds[MAX_BLOCKS]; struct sde_rm_hw_blk *pp[MAX_BLOCKS]; struct sde_rm_hw_iter iter_i, iter_j; + u32 lm_mask = 0; int lm_count = 0; int i, rc = 0; @@ -1083,13 +1084,13 @@ static int _sde_rm_reserve_lms( sde_rm_init_hw_iter(&iter_i, 0, SDE_HW_BLK_LM); while (lm_count != reqs->topology->num_lm && _sde_rm_get_hw_locked(rm, &iter_i)) { - memset(&lm, 0, sizeof(lm)); - memset(&dspp, 0, sizeof(dspp)); - memset(&ds, 0, sizeof(ds)); - memset(&pp, 0, sizeof(pp)); + if (lm_mask & (1 << iter_i.blk->id)) + continue; - lm_count = 0; lm[lm_count] = iter_i.blk; + dspp[lm_count] = NULL; + ds[lm_count] = NULL; + pp[lm_count] = NULL; SDE_DEBUG("blk id = %d, _lm_ids[%d] = %d\n", iter_i.blk->id, @@ -1105,32 +1106,48 @@ static int _sde_rm_reserve_lms( &pp[lm_count], NULL)) continue; + lm_mask |= (1 << iter_i.blk->id); ++lm_count; + /* Return if peer is not needed */ + if (lm_count == reqs->topology->num_lm) + break; + /* Valid primary mixer found, find matching peers */ sde_rm_init_hw_iter(&iter_j, 0, SDE_HW_BLK_LM); - while (lm_count != reqs->topology->num_lm && - _sde_rm_get_hw_locked(rm, &iter_j)) { - if (iter_i.blk == iter_j.blk) + while (_sde_rm_get_hw_locked(rm, &iter_j)) { + if (lm_mask & (1 << iter_j.blk->id)) continue; + lm[lm_count] = iter_j.blk; + dspp[lm_count] = NULL; + ds[lm_count] = NULL; + pp[lm_count] = NULL; + if (!_sde_rm_check_lm_and_get_connected_blks( rm, rsvp, reqs, iter_j.blk, &dspp[lm_count], &ds[lm_count], &pp[lm_count], iter_i.blk)) continue; - lm[lm_count] = iter_j.blk; SDE_DEBUG("blk id = %d, _lm_ids[%d] = %d\n", - iter_i.blk->id, + iter_j.blk->id, lm_count, _lm_ids ? _lm_ids[lm_count] : -1); if (_lm_ids && (lm[lm_count])->id != _lm_ids[lm_count]) continue; + lm_mask |= (1 << iter_j.blk->id); ++lm_count; + break; + } + + /* Rollback primary LM if peer is not found */ + if (!iter_j.hw) { + lm_mask &= ~(1 << iter_i.blk->id); + --lm_count; } } @@ -1139,10 +1156,7 @@ static int _sde_rm_reserve_lms( return -ENAVAIL; } - for (i = 0; i < ARRAY_SIZE(lm); i++) { - if (!lm[i]) - break; - + for (i = 0; i < lm_count; i++) { lm[i]->rsvp_nxt = rsvp; pp[i]->rsvp_nxt = rsvp; if (dspp[i])