Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1000169yba; Thu, 4 Apr 2019 02:07:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWzhd317S5eUWG4+TgCZG/QRCuRq4icpyFxEsg4T3wKny0NTXJBB4y6ylol7Ikblr7j/3N X-Received: by 2002:a17:902:ba8b:: with SMTP id k11mr5339157pls.40.1554368828647; Thu, 04 Apr 2019 02:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368828; cv=none; d=google.com; s=arc-20160816; b=A9KMUW58ePuuW1F7CT/syPiQDSbsPSA+iX8mTDhZP7SFCGEs8GFNdNfm9RnL/pSVAv JQorBEjM18f0czAcfII3evubgVdFzhP/lmQmJiVl/GVgyocMwOgeBf/2fWVn0fB+oM4v nXl+0rtux+QxlM+HFQXVpt8iovkhg124DnwCR3I29831JKSMp88AVKC5LOl+vayQeUQp HbAavPe0IoAZaDCUDFW+4i1JJ4yGVrcSVC+kk5HYDUf1Sboc/en9Z8VHb9zE5r5k7QXR z0JAQVAF6KkzNoMb7S0ArdX0AqYS00vc4VkV3DgplBHUWLNnF5J6TjUeUeODI3Etzgwk Lqbg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x7OfjkHbUQG4k5ZbQ+Scroy0xI7AHjWNWycTq5ZYJmA=; b=pho1I0J557KXu/yMQHVBOTtZGp5xd0fAzNU/Jf8rUTOMavR2W1cKGoRdRsAxjt7szw 5iK0Swxee2Gg2KqTUvdka5qKR+xcdQAq+sUc79UQeZax088he4vJr7CE0jtuI0szl1eh 9NRd7nESZRS2URPRrIVsTmRKH2qzZmVfowHYJ+Ngshftl5YkjI4XbkdpFsetMb94oRtd 3VBqaq8NVyg9V/GyhRJAnSsM7jcVVt2POYorQVYHoZzDP/XPtzsNvwc/X31CkutIRltM lElEe+16g1N75mCNC2CDecG1lscB4Q7jibcdyNT5pE9BsQF2wFVJmtPW/mevJe8Xu7/y UptQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Eg7K/UoH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si16115316pgh.139.2019.04.04.02.06.53; Thu, 04 Apr 2019 02:07:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Eg7K/UoH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732294AbfDDJGV (ORCPT + 99 others); Thu, 4 Apr 2019 05:06:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:44730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732284AbfDDJGS (ORCPT ); Thu, 4 Apr 2019 05:06:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A61021872; Thu, 4 Apr 2019 09:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368777; bh=IhGawaN2KfIJ9n+wtWT+LKOfr+xZ1cvA65WGRUNO7js=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eg7K/UoH7lUz5s/s5Za9g+t2YRz6zUfHnWRKB1P7WquET7xKfcx4vMJ2G/Ft5W/N7 MKyZySaEiDRvG7NyE26oMrOq1qrGtJsvnGWVMYl9uqMfdrVcJvpDR0YkOZRmOoDu6P wM/NGQ5vCexewvBapLNXZNlXjUOBGAeh/x0cS4wA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Kazlauskas , Harry Wentland , Sun peng Li , Leo Li , Alex Deucher , Sasha Levin Subject: [PATCH 4.19 150/187] drm/amd/display: Enable vblank interrupt during CRC capture Date: Thu, 4 Apr 2019 10:48:07 +0200 Message-Id: <20190404084610.200427582@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 428da2bdb05d76c48d0bd8fbfa2e4c102685be08 ] [Why] In order to read CRC events when CRC capture is enabled the vblank interrput handler needs to be running for the CRTC. The handler is enabled while there is an active vblank reference. When running IGT tests there will often be no active vblank reference but the test expects to read a CRC value. This is valid usage (and works on i915 since they have a CRC interrupt handler) so the reference to the vblank should be grabbed while capture is active. This issue was found running: igt@kms_plane_multiple@atomic-pipe-b-tiling-none The pipe-b is the only one in the initial commit and was not previously active so no vblank reference is grabbed. The vblank interrupt is not enabled and the test times out. [How] Keep a reference to the vblank as long as CRC capture is enabled. If userspace never explicitly disables it then the reference is also dropped when removing the CRTC from the context (stream = NULL). Signed-off-by: Nicholas Kazlauskas Reviewed-by: Harry Wentland Reviewed-by: Sun peng Li Acked-by: Leo Li Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 ++++++- .../drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 42 +++++++++---------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index c57e85f08e23..2b8b892eb846 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4390,10 +4390,22 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev, */ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) { struct dm_crtc_state *dm_old_crtc_state = to_dm_crtc_state(old_crtc_state); + struct dm_crtc_state *dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc); - if (drm_atomic_crtc_needs_modeset(new_crtc_state) && dm_old_crtc_state->stream) + if (drm_atomic_crtc_needs_modeset(new_crtc_state) + && dm_old_crtc_state->stream) { + /* + * CRC capture was enabled but not disabled. + * Release the vblank reference. + */ + if (dm_new_crtc_state->crc_enabled) { + drm_crtc_vblank_put(crtc); + dm_new_crtc_state->crc_enabled = false; + } + manage_dm_interrupts(adev, acrtc, false); + } } /* Add check here for SoC's that support hardware cursor plane, to * unset legacy_cursor_update */ diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c index 6a6d977ddd7a..36a0bed9af07 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c @@ -51,6 +51,7 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name, { struct dm_crtc_state *crtc_state = to_dm_crtc_state(crtc->state); struct dc_stream_state *stream_state = crtc_state->stream; + bool enable; enum amdgpu_dm_pipe_crc_source source = dm_parse_crc_source(src_name); @@ -65,28 +66,27 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name, return -EINVAL; } + enable = (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO); + + if (!dc_stream_configure_crc(stream_state->ctx->dc, stream_state, + enable, enable)) + return -EINVAL; + /* When enabling CRC, we should also disable dithering. */ - if (source == AMDGPU_DM_PIPE_CRC_SOURCE_AUTO) { - if (dc_stream_configure_crc(stream_state->ctx->dc, - stream_state, - true, true)) { - crtc_state->crc_enabled = true; - dc_stream_set_dither_option(stream_state, - DITHER_OPTION_TRUN8); - } - else - return -EINVAL; - } else { - if (dc_stream_configure_crc(stream_state->ctx->dc, - stream_state, - false, false)) { - crtc_state->crc_enabled = false; - dc_stream_set_dither_option(stream_state, - DITHER_OPTION_DEFAULT); - } - else - return -EINVAL; - } + dc_stream_set_dither_option(stream_state, + enable ? DITHER_OPTION_TRUN8 + : DITHER_OPTION_DEFAULT); + + /* + * Reading the CRC requires the vblank interrupt handler to be + * enabled. Keep a reference until CRC capture stops. + */ + if (!crtc_state->crc_enabled && enable) + drm_crtc_vblank_get(crtc); + else if (crtc_state->crc_enabled && !enable) + drm_crtc_vblank_put(crtc); + + crtc_state->crc_enabled = enable; *values_cnt = 3; /* Reset crc_skipped on dm state */ -- 2.19.1