From patchwork Tue Oct 9 04:27:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeykumar Sankaran X-Patchwork-Id: 10631841 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 07C4216B1 for ; Tue, 9 Oct 2018 04:28:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED93029A28 for ; Tue, 9 Oct 2018 04:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E197829A36; Tue, 9 Oct 2018 04:28:08 +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 5F26529A28 for ; Tue, 9 Oct 2018 04:28:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725927AbeJILnF (ORCPT ); Tue, 9 Oct 2018 07:43:05 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:59340 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725828AbeJILnF (ORCPT ); Tue, 9 Oct 2018 07:43:05 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 269A560D5E; Tue, 9 Oct 2018 04:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539059286; bh=PPLtKKU1wsZzPdKsGClYuvF3HD7Q6GUktQljm9pqjYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YnBj5lORdHsxKsrPoExzpW/QGkqratfStsFqww580VIACczb8EfvYdxWvcRPhdt05 ofX7LPRzsTa1h46kXT4gs/XkeSGL4dCwgECPKX7eCSgPH6e9e5UF0dO+x5R8CCxlcC 4bLrP527890kEbhzkfr1U1So/9wBDuaQTL+YrVHk= 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 EF89F60D74; Tue, 9 Oct 2018 04:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539059279; bh=PPLtKKU1wsZzPdKsGClYuvF3HD7Q6GUktQljm9pqjYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KFtp7O5L0CnCkoCNUP2550+P8NJhYOrqhl31VjsNK0UIH5089X+sUkTWPFvd4bu9M ThzVeCvzWl/reV2kkx7tdiQRS5HI06MDVZCcD+Olf5pUPApm09kORoLjHiyhYywDur Lp2MPZYx2YsNhvcjUIWdDiiTxyiqhKP/HNnbfGGo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org EF89F60D74 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 08/25] drm/msm/dpu: release reservation using crtc state Date: Mon, 8 Oct 2018 21:27:25 -0700 Message-Id: <1539059262-8326-9-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 Use the hw block pointers stored in crtc state to release them back to RM resource pool. This change is made to uncouple RM reservation from encoder_id. Separate change is submitted to clean up RM of encoder id tagging. Signed-off-by: Jeykumar Sankaran --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 +- drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c | 69 +++++++++++++++++++++++------ drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h | 6 +-- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 17dbbc3..a8fd14e 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -1223,7 +1223,7 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n"); - dpu_rm_release(&dpu_kms->rm, drm_enc); + dpu_rm_release(&dpu_kms->rm, drm_enc->crtc->state); } static enum dpu_intf dpu_encoder_get_intf(struct dpu_mdss_cfg *catalog, diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c index 5703b11..619b596 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.c @@ -625,27 +625,70 @@ static int _dpu_rm_populate_requirements( return 0; } -static void _dpu_rm_release_reservation(struct dpu_rm *rm, uint32_t enc_id) +static int _dpu_rm_release_hw(struct dpu_rm *rm, enum dpu_hw_blk_type type, + int id) { struct dpu_rm_hw_blk *blk; - enum dpu_hw_blk_type type; - for (type = 0; type < DPU_HW_BLK_MAX; type++) { - list_for_each_entry(blk, &rm->hw_blks[type], list) { - if (blk->enc_id == enc_id) { - blk->enc_id = 0; - DPU_DEBUG("rel enc %d %d %d\n", enc_id, - blk->type, blk->id); - } + list_for_each_entry(blk, &rm->hw_blks[type], list) { + if (blk->hw->id == id) { + blk->enc_id = 0; + return 0; } } + + DRM_DEBUG_KMS("failed to find hw id(%d) of type(%d) for releasing\n", + id, type); + + return -EINVAL; } -void dpu_rm_release(struct dpu_rm *rm, struct drm_encoder *enc) +static void _dpu_rm_release_reservation(struct dpu_rm *rm, + struct dpu_crtc_state *dpu_cstate) { + int i; + + for (i = 0; i < dpu_cstate->num_mixers; i++) { + struct dpu_crtc_mixer *mixer = &dpu_cstate->mixers[i]; + + if (!mixer->hw_lm) + continue; + + if (!_dpu_rm_release_hw(rm, DPU_HW_BLK_LM, + mixer->hw_lm->base.id)) + mixer->hw_lm = NULL; + + if (!_dpu_rm_release_hw(rm, DPU_HW_BLK_PINGPONG, + mixer->hw_pp->base.id)) + mixer->hw_pp = NULL; + } + + for (i = 0; i < dpu_cstate->num_ctls; i++) { + if (!dpu_cstate->hw_ctls[i]) + continue; + + if (!_dpu_rm_release_hw(rm, DPU_HW_BLK_CTL, + dpu_cstate->hw_ctls[i]->base.id)) + dpu_cstate->hw_ctls[i] = NULL; + } + + for (i = 0; i < dpu_cstate->num_intfs; i++) { + if (!dpu_cstate->hw_intfs[i]) + continue; + + if (!_dpu_rm_release_hw(rm, DPU_HW_BLK_INTF, + dpu_cstate->hw_intfs[i]->base.id)) + dpu_cstate->hw_intfs[i] = NULL; + } +} + +void dpu_rm_release(struct dpu_rm *rm, struct drm_crtc_state *crtc_state) +{ + struct dpu_crtc_state *dpu_cstate = to_dpu_crtc_state(crtc_state); + mutex_lock(&rm->rm_lock); - _dpu_rm_release_reservation(rm, enc->base.id); + _dpu_rm_release_reservation(rm, dpu_cstate); mutex_unlock(&rm->rm_lock); } @@ -679,12 +722,12 @@ int dpu_rm_reserve( ret = _dpu_rm_make_reservation(rm, enc, dpu_cstate, &reqs); if (ret) { DPU_ERROR("failed to reserve hw resources: %d\n", ret); - _dpu_rm_release_reservation(rm, enc->base.id); + _dpu_rm_release_reservation(rm, dpu_cstate); } else if (test_only) { /* test_only: test the reservation and then undo */ DPU_DEBUG("test_only: discard test [enc: %d]\n", enc->base.id); - _dpu_rm_release_reservation(rm, enc->base.id); + _dpu_rm_release_reservation(rm, dpu_cstate); } end: diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h index eb6a6ac..e48e8f2 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_rm.h @@ -95,13 +95,13 @@ int dpu_rm_reserve(struct dpu_rm *rm, bool test_only); /** - * dpu_rm_reserve - Given the encoder for the display chain, release any + * dpu_rm_release - Given the encoder for the display chain, release any * HW blocks previously reserved for that use case. * @rm: DPU Resource Manager handle - * @enc: DRM Encoder handle + * @crtc_state: atomic DRM state handle * @Return: 0 on Success otherwise -ERROR */ -void dpu_rm_release(struct dpu_rm *rm, struct drm_encoder *enc); +void dpu_rm_release(struct dpu_rm *rm, struct drm_crtc_state *crtc_state); /** * dpu_rm_get_mdp - Retrieve HW block for MDP TOP.