From patchwork Tue Oct 9 04:27:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeykumar Sankaran X-Patchwork-Id: 10631881 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0EA4E112B for ; Tue, 9 Oct 2018 04:28:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3E9729A4D for ; Tue, 9 Oct 2018 04:28:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E886729A52; Tue, 9 Oct 2018 04:28:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E939929A4D for ; Tue, 9 Oct 2018 04:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbeJILnv (ORCPT ); Tue, 9 Oct 2018 07:43:51 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:33400 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbeJILnu (ORCPT ); Tue, 9 Oct 2018 07:43:50 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 14E9160C80; Tue, 9 Oct 2018 04:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539059332; bh=D8mYPrtBKVxrgthNInGQklTng6V/fEPgHEMiwqg+0ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PrklG8nM9Bt6wmXcFnMiRAVHyk5hA/YWWCdxMui5pNTay3F5Aw24nPoxUBiciGE2W kyKhbWVEVECEqMaAafb2MhE1g6HrYime55dRk27akN7YbWBypLTkQby1Pmjgq0X6Rx IQgDmkGEeBOW9fSEtqcp2Erg0xSyGA1yaxWDS/4I= Received: from jeykumar-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jsanka@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4B8CD60DCE; Tue, 9 Oct 2018 04:28:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539059292; bh=D8mYPrtBKVxrgthNInGQklTng6V/fEPgHEMiwqg+0ZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MdDQDRIqiP54R3EiJf+bRKxhUQ6HnOr3NHMgCOLKmuG1dxZHkCCGLXJpIZInjowdY JlSR6j12AUkXr0sRq65pgp7Uos6bvpdy48jvNawPR1w9+B20v+rjIu/hvRgA5j4xcr VmjdfXjfodirSzo+1GNZANGSEgdPvsHsATqSqFWg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4B8CD60DCE Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jsanka@codeaurora.org From: Jeykumar Sankaran To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Cc: Jeykumar Sankaran , seanpaul@chromium.org, robdclark@gmail.com, hoegsberg@google.com, jcrouse@codeaurora.org Subject: [PATCH 17/25] drm/msm/dpu: remove RM HW block list iterator Date: Mon, 8 Oct 2018 21:27:34 -0700 Message-Id: <1539059262-8326-18-git-send-email-jsanka@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539059262-8326-1-git-send-email-jsanka@codeaurora.org> References: <1539059262-8326-1-git-send-email-jsanka@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replacing with simpler linked list helper iterators. Signed-off-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 120 +++++++++++++-------------------- 1 file changed, 46 insertions(+), 74 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c index 1234991..a79456c 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c @@ -45,49 +45,6 @@ struct dpu_rm_hw_blk { struct dpu_hw_blk *hw; }; -/** - * struct dpu_rm_hw_iter - iterator for use with dpu_rm - * @blk: dpu_rm internal block representation. Clients ignore. Used as iterator. - * @type: Hardware Block Type client wishes to search for. - */ -struct dpu_rm_hw_iter { - struct dpu_rm_hw_blk *blk; - enum dpu_hw_blk_type type; -}; - -static void _dpu_rm_init_hw_iter( - struct dpu_rm_hw_iter *iter, - enum dpu_hw_blk_type type) -{ - memset(iter, 0, sizeof(*iter)); - iter->type = type; -} - -static bool _dpu_rm_get_hw_locked(struct dpu_rm *rm, struct dpu_rm_hw_iter *i) -{ - struct list_head *blk_list; - - if (!rm || !i || i->type >= DPU_HW_BLK_MAX) { - DPU_ERROR("invalid rm\n"); - return false; - } - - blk_list = &rm->hw_blks[i->type]; - - if (i->blk && (&i->blk->list == blk_list)) { - DPU_DEBUG("attempt resume iteration past last\n"); - return false; - } - - i->blk = list_prepare_entry(i->blk, blk_list, list); - - list_for_each_entry_continue(i->blk, blk_list, list) - if (!i->blk->in_use) - return true; - - return false; -} - static void _dpu_rm_hw_destroy(enum dpu_hw_blk_type type, void *hw) { switch (type) { @@ -301,7 +258,8 @@ static bool _dpu_rm_check_lm_and_get_connected_blks( struct dpu_rm_hw_blk *primary_lm) { const struct dpu_lm_cfg *lm_cfg = to_dpu_hw_mixer(lm->hw)->cap; - struct dpu_rm_hw_iter iter; + struct dpu_rm_hw_blk *iter; + struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_PINGPONG]; *pp = NULL; @@ -320,10 +278,12 @@ static bool _dpu_rm_check_lm_and_get_connected_blks( } } - _dpu_rm_init_hw_iter(&iter, DPU_HW_BLK_PINGPONG); - while (_dpu_rm_get_hw_locked(rm, &iter)) { - if (iter.blk->hw->id == lm_cfg->pingpong) { - *pp = iter.blk; + list_for_each_entry(iter, blk_list, list) { + if (iter->in_use) + continue; + + if (iter->hw->id == lm_cfg->pingpong) { + *pp = iter; break; } } @@ -343,7 +303,8 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, { struct dpu_rm_hw_blk *lm[MAX_BLOCKS]; struct dpu_rm_hw_blk *pp[MAX_BLOCKS]; - struct dpu_rm_hw_iter iter_i, iter_j; + struct dpu_rm_hw_blk *iter_i, *iter_j; + struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_LM]; int lm_count = 0; int i, rc = 0; @@ -353,14 +314,18 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, } /* Find a primary mixer */ - _dpu_rm_init_hw_iter(&iter_i, DPU_HW_BLK_LM); - while (lm_count != reqs->topology.num_lm && - _dpu_rm_get_hw_locked(rm, &iter_i)) { + list_for_each_entry(iter_i, blk_list, list) { + if (iter_i->in_use) + continue; + + if (lm_count == reqs->topology.num_lm) + break; + memset(&lm, 0, sizeof(lm)); memset(&pp, 0, sizeof(pp)); lm_count = 0; - lm[lm_count] = iter_i.blk; + lm[lm_count] = iter_i; if (!_dpu_rm_check_lm_and_get_connected_blks( rm, reqs, lm[lm_count], @@ -370,19 +335,22 @@ static int _dpu_rm_reserve_lms(struct dpu_rm *rm, ++lm_count; /* Valid primary mixer found, find matching peers */ - _dpu_rm_init_hw_iter(&iter_j, DPU_HW_BLK_LM); + list_for_each_entry(iter_j, blk_list, list) { + if (iter_j->in_use) + continue; - while (lm_count != reqs->topology.num_lm && - _dpu_rm_get_hw_locked(rm, &iter_j)) { - if (iter_i.blk == iter_j.blk) + if (lm_count == reqs->topology.num_lm) + break; + + if (iter_i == iter_j) continue; if (!_dpu_rm_check_lm_and_get_connected_blks( - rm, reqs, iter_j.blk, - &pp[lm_count], iter_i.blk)) + rm, reqs, iter_j, + &pp[lm_count], iter_i)) continue; - lm[lm_count] = iter_j.blk; + lm[lm_count] = iter_j; ++lm_count; } } @@ -417,7 +385,9 @@ static int _dpu_rm_reserve_ctls( const struct msm_display_topology *top) { struct dpu_rm_hw_blk *ctls[MAX_BLOCKS]; - struct dpu_rm_hw_iter iter; + struct dpu_rm_hw_blk *iter; + struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_CTL]; + int i = 0, num_ctls = 0; bool needs_split_display = false; @@ -428,21 +398,23 @@ static int _dpu_rm_reserve_ctls( needs_split_display = _dpu_rm_needs_split_display(top); - _dpu_rm_init_hw_iter(&iter, DPU_HW_BLK_CTL); - while (_dpu_rm_get_hw_locked(rm, &iter)) { - const struct dpu_hw_ctl *ctl = to_dpu_hw_ctl(iter.blk->hw); + list_for_each_entry(iter, blk_list, list) { + const struct dpu_hw_ctl *ctl = to_dpu_hw_ctl(iter->hw); unsigned long features = ctl->caps->features; bool has_split_display; + if (iter->in_use) + continue; + has_split_display = BIT(DPU_CTL_SPLIT_DISPLAY) & features; - DPU_DEBUG("ctl %d caps 0x%lX\n", iter.blk->hw->id, features); + DPU_DEBUG("ctl %d caps 0x%lX\n", iter->hw->id, features); if (needs_split_display != has_split_display) continue; - ctls[i] = iter.blk; - DPU_DEBUG("ctl %d match\n", iter.blk->hw->id); + ctls[i] = iter; + DPU_DEBUG("ctl %d match\n", iter->hw->id); if (++i == num_ctls) break; @@ -468,26 +440,26 @@ static struct dpu_rm_hw_blk *_dpu_rm_reserve_intf( uint32_t id, enum dpu_hw_blk_type type) { - struct dpu_rm_hw_iter iter; + struct dpu_rm_hw_blk *iter; + struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_INTF]; /* Find the block entry in the rm, and note the reservation */ - _dpu_rm_init_hw_iter(&iter, type); - while (_dpu_rm_get_hw_locked(rm, &iter)) { - if (iter.blk->hw->id != id) + list_for_each_entry(iter, blk_list, list) { + if (iter->hw->id != id || iter->in_use) continue; - trace_dpu_rm_reserve_intf(iter.blk->hw->id, DPU_HW_BLK_INTF); + trace_dpu_rm_reserve_intf(iter->hw->id, DPU_HW_BLK_INTF); break; } /* Shouldn't happen since intfs are fixed at probe */ - if (!iter.blk) { + if (!iter) { DPU_ERROR("couldn't find type %d id %d\n", type, id); return NULL; } - return iter.blk; + return iter; } static int _dpu_rm_reserve_intf_related_hw(