Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp740016imm; Thu, 13 Sep 2018 07:05:17 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb8TLmmduohk7osIpsiqndrR6O76GEp1EY7V749WK7WM816CGw5g5Kl3ffmfwF4ioZKazWW X-Received: by 2002:a17:902:b68d:: with SMTP id c13-v6mr7452285pls.139.1536847517732; Thu, 13 Sep 2018 07:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847517; cv=none; d=google.com; s=arc-20160816; b=xvbz1rNGm1nbxH77TXIvrcijXaQA22T8u3zo+MmA5UPT3/jSgILSlo8A7jmJ2XCWFC ognaODmSVxMcotP79XXnQNXTmV7O6lpHyA2X97VUHGz7wRLpw3/oQ7Q7b+BSa017i/Tc RKGj7v32nLq3/6msDXSukejiO9QwMBFOmB+Jb9UIAGv2QXOSqRlU3eG7P6EIwwj15gi/ DPDxML8miNPHEOGp3WfgmW66D/JioGjL75Wz4Paw8oUNm79RI/5oHyge7u5iGvKwhW+T +bQeuBcXPS3qZtmES5k/c/5l9I6UW+dsRYFXrDAdz8WMrmTt/fPgHH/CQt8b4tXYIWhT bLxg== 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; bh=EbYy10Uxjc2BURlXz0goIDLlJEUHH5cxH+uRtoVdwos=; b=yY9T1orCxP+5oZoyEu6SMPYbe5v592fDMNyJj9KFnV3be62NoasJsrL9zlop8OIv95 n6fQhRNmJ+vERhl7GFKWmpGQtyyZqYm9/8pF3QwAbJpZrIt5lpby8K8OkUuIXA5ZYzjp Q4FSu7JD4Jxsb+rMrX320PvGSxP2UeRaqJKMzvMWD04Y5JmXKHsnQ5rbPlcqNM71uo3D Na29k3Tnocu9d4oPRdWoso+VlcOCOtOkRwCuATTQ7udKFAD25RkDuO0uQhUCGQ7jNV2S pO6DKAOxqWxmgTfevvXTr4Kb+lk+OYHg+4TDVesPfX33Io400lru/CYFhFri9HDqfTPQ G+PQ== ARC-Authentication-Results: i=1; mx.google.com; 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 p61-v6si4152301plb.55.2018.09.13.07.04.58; Thu, 13 Sep 2018 07:05:17 -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; 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 S1731728AbeIMTOP (ORCPT + 99 others); Thu, 13 Sep 2018 15:14:15 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35400 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbeIMTOP (ORCPT ); Thu, 13 Sep 2018 15:14:15 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 748D4D35; Thu, 13 Sep 2018 14:04:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikita Lipski , Harry Wentland , Leo Li , Alex Deucher Subject: [PATCH 4.18 173/197] drm/amd/display: Check if clock source in use before disabling Date: Thu, 13 Sep 2018 15:32:02 +0200 Message-Id: <20180913131848.483211012@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikita Lipski commit ad8960a6cb06c446d0a391ce095f6f28edf36aff upstream. [why] We are disabling clock source while other pipes are still using it, because we don't verify the number of pipes that share it. [how] - Adding a function in resources to return the number of pipes sharing the clock source. - Checking that no one is sharing the clock source before disabling Signed-off-by: Mikita Lipski Reviewed-by: Harry Wentland Acked-by: Leo Li Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 46 ++++++++---- drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 4 - drivers/gpu/drm/amd/display/dc/inc/resource.h | 5 + 3 files changed, 40 insertions(+), 15 deletions(-) --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -268,24 +268,30 @@ bool resource_construct( return true; } +static int find_matching_clock_source( + const struct resource_pool *pool, + struct clock_source *clock_source) +{ + int i; + + for (i = 0; i < pool->clk_src_count; i++) { + if (pool->clock_sources[i] == clock_source) + return i; + } + return -1; +} void resource_unreference_clock_source( struct resource_context *res_ctx, const struct resource_pool *pool, struct clock_source *clock_source) { - int i; - - for (i = 0; i < pool->clk_src_count; i++) { - if (pool->clock_sources[i] != clock_source) - continue; + int i = find_matching_clock_source(pool, clock_source); + if (i > -1) res_ctx->clock_source_ref_count[i]--; - break; - } - if (pool->dp_clock_source == clock_source) res_ctx->dp_clock_source_ref_count--; } @@ -295,19 +301,31 @@ void resource_reference_clock_source( const struct resource_pool *pool, struct clock_source *clock_source) { - int i; - for (i = 0; i < pool->clk_src_count; i++) { - if (pool->clock_sources[i] != clock_source) - continue; + int i = find_matching_clock_source(pool, clock_source); + if (i > -1) res_ctx->clock_source_ref_count[i]++; - break; - } if (pool->dp_clock_source == clock_source) res_ctx->dp_clock_source_ref_count++; } +int resource_get_clock_source_reference( + struct resource_context *res_ctx, + const struct resource_pool *pool, + struct clock_source *clock_source) +{ + int i = find_matching_clock_source(pool, clock_source); + + if (i > -1) + return res_ctx->clock_source_ref_count[i]; + + if (pool->dp_clock_source == clock_source) + return res_ctx->dp_clock_source_ref_count; + + return -1; +} + bool resource_are_streams_timing_synchronizable( struct dc_stream_state *stream1, struct dc_stream_state *stream2) --- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c @@ -1939,7 +1939,9 @@ static void dce110_reset_hw_ctx_wrap( pipe_ctx_old->plane_res.mi->funcs->free_mem_input( pipe_ctx_old->plane_res.mi, dc->current_state->stream_count); - if (old_clk) + if (old_clk && 0 == resource_get_clock_source_reference(&context->res_ctx, + dc->res_pool, + old_clk)) old_clk->funcs->cs_power_down(old_clk); dc->hwss.disable_plane(dc, pipe_ctx_old); --- a/drivers/gpu/drm/amd/display/dc/inc/resource.h +++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h @@ -102,6 +102,11 @@ void resource_reference_clock_source( const struct resource_pool *pool, struct clock_source *clock_source); +int resource_get_clock_source_reference( + struct resource_context *res_ctx, + const struct resource_pool *pool, + struct clock_source *clock_source); + bool resource_are_streams_timing_synchronizable( struct dc_stream_state *stream1, struct dc_stream_state *stream2);