Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1173729pxk; Mon, 31 Aug 2020 11:49:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjlO7Et0sTnbsYZQIFqU/Lw4CxryF3JYbeLJYPy2EiC3mSWk6LnN7BKZ2Gx/sH6lNV/oLQ X-Received: by 2002:a17:906:f1d5:: with SMTP id gx21mr2101589ejb.165.1598899789500; Mon, 31 Aug 2020 11:49:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598899789; cv=none; d=google.com; s=arc-20160816; b=d131/YgFcUAeGZkvS304wwmZy0x3O0xUEIwS4c/MvhUKkr9fZ/VqvqHzbcn+SJL9s2 7Rus0l9zzQNte+mhLXsNJUqraFWpeda5vHw58T6xbiuJFmriT4lY0tZARAvAlODBdWB1 t+X2c/DAsZ9lN52zsm8KtZRUTtrHiDC//qsXdCTIURLt2alFjqgn63V8ds2ZGiEzz2n0 1CcJJ5yzKcTgp3cbeObWf1eKVJPqUEl2Lq3q7hCGi+y2NKsw+mTwXBHmnJokWOIC+xKq AhYh8UeVbwFCAjPFATO+AVHOIJz3aaqW3X9TulDgX84w7MBz3PlogNzadbC9wAfX0oKw Pu0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Fz8IcMwlrk2uopEErPzF9oEoYJCZknFZESIvk7ODwD0=; b=a363wwBIh4VXxCPV7BQgHCwW9eeYJJiP9szt71p3xxnSCyGhA0IBUfT8ce4SDitN2l 05qz36TNM0xpNj9on+FnfN6wJpM3PtZ+e8LndHylR9cQ7CQoQrQz88EBx7algdweOpDH l7CZQPAE0JVaz2MWff83ZEgWPLRQg22BBz2s3hoGcK3ZaOzm3Ax8AdsO2q2zF7GJH0HS e9qePQ0U/JxOGAoFiK/7kUTExC9Yc8oQLrY3tQ+4uz8vinPC4ioqxCiub6j7CfNkZ+ct oObbekZ3XssERgFRgiPxhuTtBXu7AWgj1Jxsb2qHUucdiO+fpN3CkI8CW+olLaj4BjDT WBCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVgPlztI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si5573411edm.49.2020.08.31.11.49.24; Mon, 31 Aug 2020 11:49:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BVgPlztI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728450AbgHaP3t (ORCPT + 99 others); Mon, 31 Aug 2020 11:29:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:38266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728369AbgHaP3m (ORCPT ); Mon, 31 Aug 2020 11:29:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C3EFC2083E; Mon, 31 Aug 2020 15:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598887781; bh=DVKJ29QHAzz4qU2F/xNhd+abhHFEJS1721McD0/25Pw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BVgPlztInhS/+jPXxBfeOqZMRiFgW049evUwGOWfafa55BpXg8iU8k/2S8/dSNc2e c4GOYc6ejgRCPbgTTof7Gaczq6UGBqwPHUx9lSfUGqYbDBzEgWOAiqzTJQDWQ37T9P leFmjee1/ThUcFlAGaoaMdXPxXFGxOx8fuYKSbU4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kalyan Thota , Rob Clark , Sasha Levin , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.8 04/42] drm/msm/dpu: Fix reservation failures in modeset Date: Mon, 31 Aug 2020 11:28:56 -0400 Message-Id: <20200831152934.1023912-4-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831152934.1023912-1-sashal@kernel.org> References: <20200831152934.1023912-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kalyan Thota [ Upstream commit ccc862b957c6413b008fbe458034372847992d7f ] In TEST_ONLY commit, rm global_state will duplicate the object and request for new reservations, once they pass then the new state will be swapped with the old and will be available for the Atomic Commit. This patch fixes some of missing links in the resource reservation sequence mentioned above. 1) Creation of duplicate state in test_only commit (Rob) 2) Allocate and release the resources on every modeset. 3) Avoid allocation only when active is false. In a modeset operation, swap state happens well before disable. Hence clearing reservations in disable will cause failures in modeset enable. Allow reservations to be cleared/allocated before swap, such that only newly committed resources are pushed to HW. Changes in v1: - Move the rm release to atomic_check. - Ensure resource allocation and free happens when active is not changed i.e only when mode is changed.(Rob) Changes in v2: - Handle dpu_kms_get_global_state API failure as it may return EDEADLK (swboyd). Signed-off-by: Kalyan Thota Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c index 0946a86b37b28..c0cd936314e66 100644 --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c @@ -586,7 +586,10 @@ static int dpu_encoder_virt_atomic_check( dpu_kms = to_dpu_kms(priv->kms); mode = &crtc_state->mode; adj_mode = &crtc_state->adjusted_mode; - global_state = dpu_kms_get_existing_global_state(dpu_kms); + global_state = dpu_kms_get_global_state(crtc_state->state); + if (IS_ERR(global_state)) + return PTR_ERR(global_state); + trace_dpu_enc_atomic_check(DRMID(drm_enc)); /* @@ -621,12 +624,15 @@ static int dpu_encoder_virt_atomic_check( /* Reserve dynamic resources now. */ if (!ret) { /* - * Avoid reserving resources when mode set is pending. Topology - * info may not be available to complete reservation. + * Release and Allocate resources on every modeset + * Dont allocate when active is false. */ if (drm_atomic_crtc_needs_modeset(crtc_state)) { - ret = dpu_rm_reserve(&dpu_kms->rm, global_state, - drm_enc, crtc_state, topology); + dpu_rm_release(global_state, drm_enc); + + if (!crtc_state->active_changed || crtc_state->active) + ret = dpu_rm_reserve(&dpu_kms->rm, global_state, + drm_enc, crtc_state, topology); } } @@ -1175,7 +1181,6 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) struct dpu_encoder_virt *dpu_enc = NULL; struct msm_drm_private *priv; struct dpu_kms *dpu_kms; - struct dpu_global_state *global_state; int i = 0; if (!drm_enc) { @@ -1194,7 +1199,6 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) priv = drm_enc->dev->dev_private; dpu_kms = to_dpu_kms(priv->kms); - global_state = dpu_kms_get_existing_global_state(dpu_kms); trace_dpu_enc_disable(DRMID(drm_enc)); @@ -1224,8 +1228,6 @@ static void dpu_encoder_virt_disable(struct drm_encoder *drm_enc) DPU_DEBUG_ENC(dpu_enc, "encoder disabled\n"); - dpu_rm_release(global_state, drm_enc); - mutex_unlock(&dpu_enc->enc_lock); } -- 2.25.1