Received: by 10.213.65.68 with SMTP id h4csp2865818imn; Mon, 2 Apr 2018 15:50:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ajEAvTtow0KnPBfadfwv9WEzyDCQzu4NWcyecUh0DzZzvRvXKJ2J2CsAF0OtNC//bf/Qh X-Received: by 2002:a17:902:1006:: with SMTP id b6-v6mr11630745pla.252.1522709445963; Mon, 02 Apr 2018 15:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522709445; cv=none; d=google.com; s=arc-20160816; b=O70Wjei+k7J8hLKzbLQBWpkqc9yBlv4r9siaqQxEPQQlukP0LLcEpwzlgazy8R/qKv eOosPhJxN7Y4roYXDzsNOXXnWPSVpZZcdT7tYbjQAzC0k0Bjv0pwDg6hAsHwsKEv/6Ek Cd5gLPC/M9ULXc+RHBj5zC3Nbf6xHFmEHKgRVqCS1vvJhnTC5l0YYTeuPZrMCnj/woOD 3Omed9JmZNBqGNESc8loQzGt5SQ2iaRZ9UM7H9MTby442kKRITvXXXXFUQ8Vr05AQWlQ JfBGQcS0ZjdxjEMqf5Z7Y5lA+e46HUI7m597J5qeDEoc5k11xqls9nG3cxdvny5iYDNd Of9A== 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 :arc-authentication-results; bh=JoMF+Hn7tcrNl/T2zYaVRttvtPGrsBcLrmtQuKMJJ8Q=; b=wOaeuKT/gdNnQtQQTIXQOWHmilirXlHWkoLgu8NZ/Jmo+4Dw0ESqL2t2d8LqBNL4TD B/CzHrB7HAAigLkF5RZroCCyBkhkV6uQN5keJRxcEJ9EIjv7GMSDA47hGfQU8DvZUs6k ijQGxQtQGI1Zy5+zX1AyBG3/MUXUmIwLESkPexAam8eVGyrMkGrMSZwNSlOSZsynuKsg uDn/sHVw6Ed6fMh7d1b3jCHZMVCrzxVb5mo+GcRVqfTL9vgCNTjEeuk3lzAHKwjv4eRR W4lz4b+BkEPOFR9GEHHEF31I7fwDQKU4+mDeMEk7erwsld/4yvs1CJQRsxAgNWNFB3/M vmIw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l23si883263pgn.696.2018.04.02.15.50.32; Mon, 02 Apr 2018 15:50:45 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754712AbeDBWsc (ORCPT + 99 others); Mon, 2 Apr 2018 18:48:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754670AbeDBWs3 (ORCPT ); Mon, 2 Apr 2018 18:48:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC6F484250; Mon, 2 Apr 2018 22:48:28 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-55.bss.redhat.com [10.20.1.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FB2F10FFE72; Mon, 2 Apr 2018 22:48:28 +0000 (UTC) From: Lyude Paul To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Manasi Navare , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , linux-kernel@vger.kernel.org Subject: [PATCH v5 07/10] drm/i915: Only use one link bw config for MST topologies Date: Mon, 2 Apr 2018 18:47:43 -0400 Message-Id: <20180402224800.16080-8-lyude@redhat.com> In-Reply-To: <20180402224800.16080-1-lyude@redhat.com> References: <20180402224800.16080-1-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Apr 2018 22:48:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 02 Apr 2018 22:48:29 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lyude@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a DP MST link needs retraining, sometimes the hub will detect that the current link bw config is impossible and will update it's RX caps in the DPCD to reflect the new maximum link rate. Currently, we make the assumption that the RX caps in the dpcd will never change like this. This means if the sink changes it's RX caps after we've already set up an MST link and we attempt to add or remove another sink from the topology, we could put ourselves into an invalid state where we've tried to configure different sinks on the same MST topology with different link rates. We could also run into this situation if a sink reports a higher link rate after suspend, usually from us having trained it with a fallback bw configuration before suspending. So: keep the link rate consistent by subclassing drm_dp_mst_topology_state, and tracking it there. For the time being, we only allow the link rate to change when the entire topology has been disconnected. V4: - Track link rate/lane count in the atomic topology state instead of in intel_dp. Signed-off-by: Lyude Paul Cc: Manasi Navare Cc: Ville Syrjälä --- drivers/gpu/drm/i915/intel_dp_mst.c | 77 +++++++++++++++++++++++++++++-------- drivers/gpu/drm/i915/intel_drv.h | 7 ++++ 2 files changed, 68 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp_mst.c b/drivers/gpu/drm/i915/intel_dp_mst.c index e308962cde05..d3040dd06859 100644 --- a/drivers/gpu/drm/i915/intel_dp_mst.c +++ b/drivers/gpu/drm/i915/intel_dp_mst.c @@ -41,8 +41,9 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, struct intel_connector *connector = to_intel_connector(conn_state->connector); struct drm_atomic_state *state = pipe_config->base.state; + struct intel_dp_mst_topology_state *mst_state; int bpp; - int lane_count, slots; + int slots; const struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode; int mst_pbn; bool reduce_m_n = drm_dp_has_quirk(&intel_dp->desc, @@ -55,18 +56,22 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, DRM_DEBUG_KMS("Setting pipe bpp to %d\n", bpp); } + + mst_state = to_intel_dp_mst_topology_state( + drm_atomic_dp_mst_get_topology_state(state, &intel_dp->mst_mgr)); /* * for MST we always configure max link bw - the spec doesn't * seem to suggest we should do otherwise. */ - lane_count = intel_dp_max_lane_count(intel_dp); - - pipe_config->lane_count = lane_count; + if (!mst_state->link_rate || !mst_state->lane_count) { + mst_state->link_rate = intel_dp_max_link_rate(intel_dp); + mst_state->lane_count = intel_dp_max_lane_count(intel_dp); + } + pipe_config->lane_count = mst_state->lane_count; + pipe_config->port_clock = mst_state->link_rate; pipe_config->pipe_bpp = bpp; - pipe_config->port_clock = intel_dp_max_link_rate(intel_dp); - if (drm_dp_mst_port_has_audio(&intel_dp->mst_mgr, connector->port)) pipe_config->has_audio = true; @@ -80,7 +85,7 @@ static bool intel_dp_mst_compute_config(struct intel_encoder *encoder, return false; } - intel_link_compute_m_n(bpp, lane_count, + intel_link_compute_m_n(bpp, mst_state->lane_count, adjusted_mode->crtc_clock, pipe_config->port_clock, &pipe_config->dp_m_n, @@ -524,11 +529,55 @@ static void intel_dp_mst_hotplug(struct drm_dp_mst_topology_mgr *mgr) drm_kms_helper_hotplug_event(dev); } +static void intel_mst_reset_state(struct drm_dp_mst_topology_state *state) +{ + struct intel_dp_mst_topology_state *intel_mst_state = + to_intel_dp_mst_topology_state(state); + + intel_mst_state->link_rate = 0; + intel_mst_state->lane_count = 0; +} + static const struct drm_dp_mst_topology_cbs mst_cbs = { .add_connector = intel_dp_add_mst_connector, .register_connector = intel_dp_register_mst_connector, .destroy_connector = intel_dp_destroy_mst_connector, .hotplug = intel_dp_mst_hotplug, + .reset_state = intel_mst_reset_state, +}; + +static struct drm_private_state * +intel_dp_mst_duplicate_state(struct drm_private_obj *obj) +{ + struct intel_dp_mst_topology_state *state; + + state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL); + if (!state) + return NULL; + + __drm_atomic_dp_mst_duplicate_topology_state( + to_dp_mst_topology_mgr(obj), &state->base); + + return &state->base.base; +} + +static void +intel_dp_mst_destroy_state(struct drm_private_obj *obj, + struct drm_private_state *state) +{ + struct drm_dp_mst_topology_state *mst_state = + to_dp_mst_topology_state(state); + struct intel_dp_mst_topology_state *intel_mst_state = + to_intel_dp_mst_topology_state(mst_state); + + __drm_atomic_dp_mst_destroy_topology_state(mst_state); + + kfree(intel_mst_state); +} + +static const struct drm_private_state_funcs mst_state_funcs = { + .atomic_duplicate_state = intel_dp_mst_duplicate_state, + .atomic_destroy_state = intel_dp_mst_destroy_state, }; static struct intel_dp_mst_encoder * @@ -581,21 +630,16 @@ intel_dp_create_fake_mst_encoders(struct intel_digital_port *intel_dig_port) return true; } -static const struct drm_private_state_funcs mst_state_funcs = { - .atomic_destroy_state = drm_atomic_dp_mst_destroy_topology_state, - .atomic_duplicate_state = drm_atomic_dp_mst_duplicate_topology_state, -}; - int intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_base_id) { struct intel_dp *intel_dp = &intel_dig_port->dp; - struct drm_dp_mst_topology_state *mst_state; + struct intel_dp_mst_topology_state *intel_mst_state; struct drm_device *dev = intel_dig_port->base.base.dev; int ret; - mst_state = kzalloc(sizeof(*mst_state), GFP_KERNEL); - if (!mst_state) + intel_mst_state = kzalloc(sizeof(*intel_mst_state), GFP_KERNEL); + if (!intel_mst_state) return -ENOMEM; intel_dp->can_mst = true; @@ -604,7 +648,8 @@ intel_dp_mst_encoder_init(struct intel_digital_port *intel_dig_port, int conn_ba /* create encoders */ intel_dp_create_fake_mst_encoders(intel_dig_port); - ret = drm_dp_mst_topology_mgr_init(&intel_dp->mst_mgr, mst_state, dev, + ret = drm_dp_mst_topology_mgr_init(&intel_dp->mst_mgr, + &intel_mst_state->base, dev, &intel_dp->aux, 16, 3, conn_base_id); if (ret) { intel_dp->can_mst = false; diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index f3e87c5e3fde..84cedd7d6720 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h @@ -981,6 +981,12 @@ struct cxsr_latency { u16 cursor_hpll_disable; }; +struct intel_dp_mst_topology_state { + struct drm_dp_mst_topology_state base; + int link_rate; + int lane_count; +}; + #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base) #define to_intel_crtc(x) container_of(x, struct intel_crtc, base) #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base) @@ -989,6 +995,7 @@ struct cxsr_latency { #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base) #define to_intel_plane(x) container_of(x, struct intel_plane, base) #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base) +#define to_intel_dp_mst_topology_state(x) container_of(x, struct intel_dp_mst_topology_state, base); #define intel_fb_obj(x) (x ? to_intel_framebuffer(x)->obj : NULL) struct intel_hdmi { -- 2.14.3