Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2497502pxj; Mon, 10 May 2021 04:32:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQCMJ1ErWxR5kOfbYFkRjWimpnrMyUgZvRjQa1EVas03OOLCPS16T2jSjQyP7b1AHc31d0 X-Received: by 2002:a05:6e02:e81:: with SMTP id t1mr4378726ilj.228.1620646366812; Mon, 10 May 2021 04:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620646366; cv=none; d=google.com; s=arc-20160816; b=Oabjkg4HcmOKEnPQNauGIZli7oh7yKdK0RM/FLs2QopaaB8L7vQBAhlxJKGCebFOO7 PPYGK1+SLUW55W7MW8fm7wcKCjWvARJWN5TvbqZHbqkPT7sK/rJHKC3QBHKIptmWe7av glDqdX481OjH8GQcW3JrXAixtTgKqUjixm+OraPYq6kQKHGiZUJrFfeKPSJ/KFdkSGCr 2fjA+wWqAissSCLihv8AEICts9tsXuZ/alRWEQCEL+U27as7fbrDkQTc0gVX38WRgjuq 0Yht+F6STgSNJgBsdI1Rc7qk6PAIGaGKYUAtcKArIBLIbCVeTNdiQt7WtH/q1fnS7jks I3Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7vLfxAGe03j9WAdmWulb2rssjgi+B8Vsd4ek4JfNwKs=; b=Apl0QNzTvVM+K1xTC9C4GZ+/2Q5HFNg594gaVwQ4fouEpaQTacGV01lNv7dzzxRDXu uyObE+NHVy6G3/cyJSh0z8X5bncwjdeqVW4+B1WUIkpxQy3uvfoyY8fus9ppwjskUDgP rV+3T5y3GVg74ynTv+GqSHKSqET8jezTFE4Wbz3rgq4kwg7D+fZsvFhkGn4EbHDNvVxx uT4m1dDApn0m9YZERPoMM9gy1m8+MFz3E4Ypc0ZJM1IE5wkkB5cGkPHLtG6xzzUDJwYv ZqIUUHCdHIGccZo/rE/QWNC+08DgjKASq5SidYym5kl+F2AaP/HSYQG25pS7+bTFrJpw jvPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XkNYxB88; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l24si14352192ioh.105.2021.05.10.04.32.33; Mon, 10 May 2021 04:32:46 -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=@linuxfoundation.org header.s=korg header.b=XkNYxB88; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236017AbhEJLae (ORCPT + 99 others); Mon, 10 May 2021 07:30:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:52812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234817AbhEJK5I (ORCPT ); Mon, 10 May 2021 06:57:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 449AF6162D; Mon, 10 May 2021 10:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643770; bh=9PNRs/NqtnqsZodPRpjt5A1cV1aiyd4RkqOemCQ4w8c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XkNYxB88IK6GVMjmN96fln6Ghkixs3sthBS7KUwTFnok5waVG0+szYe265Ole1OqW Lch3D3JUi9udzLXBbZDWqzdEsYaP3Q7POhHYO2N7VdJo5f91PXrtW3w5SdfZG4YwUW avSWcG/VV4upQhyg+Sb7MqQ7b42JGucWVmwYgm0g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Kazlauskas , Eric Yang , Qingqing Zhuo , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.11 134/342] drm/amd/display: Fix MPC OGAM power on/off sequence Date: Mon, 10 May 2021 12:18:44 +0200 Message-Id: <20210510102014.503058966@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102010.096403571@linuxfoundation.org> References: <20210510102010.096403571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicholas Kazlauskas [ Upstream commit 737b2b536a30a467c405d75f2287e17828838a13 ] [Why] Color corruption can occur on bootup into a login manager that applies a non-linear gamma LUT because the LUT may not actually be powered on before writing. It's cleared on the next full pipe reprogramming as we switch to LUTB from LUTA and the pipe accessing the LUT has taken it out of light sleep mode. [How] The MPCC_OGAM_MEM_PWR_FORCE register does not force the current power mode when set to 0. It only forces when set light sleep, deep sleep or shutdown. The register to actually force power on and ignore sleep modes is MPCC_OGAM_MEM_PWR_DIS - a value of 0 will enable power requests and a value of 1 will disable them. When PWR_FORCE!=0 is combined with PWR_DIS=0 then MPCC OGAM memory is forced into the state specified by the force bits. If PWR_FORCE is 0 then it respects the mode specified by MPCC_OGAM_MEM_LOW_PWR_MODE if the RAM LUT is not in use. We set that bit to shutdown on low power, but otherwise it inherits from bootup defaults. So for the fix: 1. Update the sequence to "force" power on when needed We can use MPCC_OGAM_MEM_PWR_DIS for this to turn on the memory even when the block is in bypass and pending to be enabled for the next frame. We need this for both low power enabled or disabled. If we don't set this then we can run into issues when we first program the LUT from bootup. 2. Don't apply FORCE_SEL Once we enable power requests with DIS=0 we run into the issue of the RAM being forced into light sleep and being unusable for display output. Leave this 0 like we used to for DCN20. 3. Rely on MPCC OGAM init to determine light sleep/deep sleep MPC low power debug mode isn't enabled on any ASIC currently but we'll respect the setting determined during init if it is. Lightly tested as working with IGT tests and desktop color adjustment. 4. Change the MPC resource default for DCN30 It was interleaving the dcn20 and dcn30 versions before depending on the sequence. 5. REG_WAIT for it to be on whenever we're powering up the memory Otherwise we can write register values too early and we'll get corruption. Signed-off-by: Nicholas Kazlauskas Reviewed-by: Eric Yang Acked-by: Qingqing Zhuo Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c index 3e6f76096119..a7598356f37d 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c +++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_mpc.c @@ -143,16 +143,18 @@ static void mpc3_power_on_ogam_lut( { struct dcn30_mpc *mpc30 = TO_DCN30_MPC(mpc); - if (mpc->ctx->dc->debug.enable_mem_low_power.bits.mpc) { - // Force power on - REG_UPDATE(MPCC_MEM_PWR_CTRL[mpcc_id], MPCC_OGAM_MEM_PWR_DIS, power_on == true ? 1:0); - // Wait for confirmation when powering on - if (power_on) - REG_WAIT(MPCC_MEM_PWR_CTRL[mpcc_id], MPCC_OGAM_MEM_PWR_STATE, 0, 10, 10); - } else { - REG_SET(MPCC_MEM_PWR_CTRL[mpcc_id], 0, - MPCC_OGAM_MEM_PWR_FORCE, power_on == true ? 0 : 1); - } + /* + * Powering on: force memory active so the LUT can be updated. + * Powering off: allow entering memory low power mode + * + * Memory low power mode is controlled during MPC OGAM LUT init. + */ + REG_UPDATE(MPCC_MEM_PWR_CTRL[mpcc_id], + MPCC_OGAM_MEM_PWR_DIS, power_on != 0); + + /* Wait for memory to be powered on - we won't be able to write to it otherwise. */ + if (power_on) + REG_WAIT(MPCC_MEM_PWR_CTRL[mpcc_id], MPCC_OGAM_MEM_PWR_STATE, 0, 10, 10); } static void mpc3_configure_ogam_lut( @@ -1427,7 +1429,7 @@ const struct mpc_funcs dcn30_mpc_funcs = { .acquire_rmu = mpcc3_acquire_rmu, .program_3dlut = mpc3_program_3dlut, .release_rmu = mpcc3_release_rmu, - .power_on_mpc_mem_pwr = mpc20_power_on_ogam_lut, + .power_on_mpc_mem_pwr = mpc3_power_on_ogam_lut, .get_mpc_out_mux = mpc1_get_mpc_out_mux, }; -- 2.30.2