From patchwork Tue Oct 9 04:27:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeykumar Sankaran X-Patchwork-Id: 10631913 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 D65E616B1 for ; Tue, 9 Oct 2018 04:29:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C67AA29A4D for ; Tue, 9 Oct 2018 04:29:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA8C729A52; Tue, 9 Oct 2018 04:29:59 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7412229A4D for ; Tue, 9 Oct 2018 04:29:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E096F6E15B; Tue, 9 Oct 2018 04:28:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3FCD86E1EE; Tue, 9 Oct 2018 04:28:54 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D5A7660D2E; Tue, 9 Oct 2018 04:28:16 +0000 (UTC) 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 67FDC60DDF; Tue, 9 Oct 2018 04:28:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 67FDC60DDF From: Jeykumar Sankaran To: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 18/25] drm/msm/dpu: merge RM interface reservation helpers Date: Mon, 8 Oct 2018 21:27:35 -0700 Message-Id: <1539059262-8326-19-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> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: hoegsberg@google.com, seanpaul@chromium.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP we don't have enough reasons why the HW block looping's cannot happen in the same function. So merge them. Signed-off-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 63 ++++++++++++++-------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c index a79456c..bb59250 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c @@ -435,52 +435,39 @@ static int _dpu_rm_reserve_ctls( return 0; } -static struct dpu_rm_hw_blk *_dpu_rm_reserve_intf( - struct dpu_rm *rm, - uint32_t id, - enum dpu_hw_blk_type type) -{ - 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 */ - list_for_each_entry(iter, blk_list, list) { - if (iter->hw->id != id || iter->in_use) - continue; - - trace_dpu_rm_reserve_intf(iter->hw->id, DPU_HW_BLK_INTF); - - break; - } - - /* Shouldn't happen since intfs are fixed at probe */ - if (!iter) { - DPU_ERROR("couldn't find type %d id %d\n", type, id); - return NULL; - } - - return iter; -} - -static int _dpu_rm_reserve_intf_related_hw( +static int _dpu_rm_reserve_intfs( struct dpu_rm *rm, struct dpu_crtc_state *dpu_cstate, struct dpu_encoder_hw_resources *hw_res) { - struct dpu_rm_hw_blk *blk; + struct dpu_rm_hw_blk *iter; + struct list_head *blk_list = &rm->hw_blks[DPU_HW_BLK_INTF]; int i, num_intfs = 0; for (i = 0; i < ARRAY_SIZE(hw_res->intfs); i++) { + struct dpu_rm_hw_blk *intf_blk = NULL; + if (hw_res->intfs[i] == INTF_MODE_NONE) continue; - blk = _dpu_rm_reserve_intf(rm, i + INTF_0, - DPU_HW_BLK_INTF); - if (!blk) - return -ENAVAIL; + list_for_each_entry(iter, blk_list, list) { + if (iter->in_use) + continue; + + if (iter->hw->id == (INTF_0 + i)) { + intf_blk = iter; + break; + } + } + + if (!intf_blk) + return -EINVAL; - blk->in_use = true; - dpu_cstate->hw_intfs[num_intfs++] = to_dpu_hw_intf(blk->hw); + intf_blk->in_use = true; + dpu_cstate->hw_intfs[num_intfs++] = + to_dpu_hw_intf(intf_blk->hw); + + trace_dpu_rm_reserve_intf(intf_blk->hw->id, DPU_HW_BLK_INTF); } dpu_cstate->num_intfs = num_intfs; @@ -507,9 +494,11 @@ static int _dpu_rm_make_reservation( return ret; } - ret = _dpu_rm_reserve_intf_related_hw(rm, dpu_cstate, &reqs->hw_res); - if (ret) + ret = _dpu_rm_reserve_intfs(rm, dpu_cstate, &reqs->hw_res); + if (ret) { + DPU_ERROR("unable to find appropriate INTF\n"); return ret; + } return ret; }