Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3460220pxb; Mon, 25 Jan 2021 17:30:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqB67xvNT28z/CqmDbLKG1RtymgFFYOJC1f5mRoNQp1T7aPztDnKYrUwxD2hGe6Jgl9E1f X-Received: by 2002:a05:6402:558:: with SMTP id i24mr2689044edx.141.1611624652204; Mon, 25 Jan 2021 17:30:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611624652; cv=none; d=google.com; s=arc-20160816; b=kXuQBOpQW/w/N+KSw32J8CGS6dR6j8F9t0jStXWHDHhJ86eCGU+JLyDX8Uh2t6u7Lq lLxrA3Q64hTZTkynqEWr/rwu8yz6o3MfF9ODsjq/frVLFTeuoT25DTTM278/hC+tl6sA a8AI5GeaoHEmJ7RkRC2ao0AklEgqO+gJnKb+KVYHMql7YB3N49Y5MGLpYb3TeOJJ/usk U6xpfxBmQm5eNuY5QiyTk2cgY6AODAU6nuJ8GnGLkM2h3dyIpwhXWi6Kq2301ZQ7XYon XZTaBHMjN8obB06eHUuFJAPKm8KyDJp4aO4oXvHRP/nfQvlZjuIQuEvDcwSO5YLSTFYG A8uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=4Ug0Sgxznve6GvUt+Yo3iUtClJ+NVFLVPNbOa+xh5OQ=; b=pejFSCmiR1tfgKRQ1KyMX/MIMCf0nVvG6bnqCuhqL5GrgdyDq5OFtY9IbHUF/o6jS4 wmsfM8IABISn5U+O+fSGRkGgYkE6gSn14A7dEQxIo2+GoyR+bOUHtBBuNJILyTETfLPY blmk61VB+AwYTo6soa3kHQImFcW1bTUA/k9mWuzOYXTrw417xxJ1d0HynmVJU3ljI6EV mmFwILaSzjVAW3mobuHNTk5qEqVbEid6xgkdRPLMOZKJ5GjNgaBwEk2iQcmTC/SEkwdj Dmjhpwie+g8CaJq2Ap4NcsDM7V44YYMbUv7JzLwi1JXpCLHVXElguGNAJm9zQPzaFvv+ D2/Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x12si6514966ejf.85.2021.01.25.17.30.27; Mon, 25 Jan 2021 17:30:52 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728116AbhAYMcg (ORCPT + 99 others); Mon, 25 Jan 2021 07:32:36 -0500 Received: from mga11.intel.com ([192.55.52.93]:6423 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbhAYMUm (ORCPT ); Mon, 25 Jan 2021 07:20:42 -0500 IronPort-SDR: UUM+SgqLDM/RUWR/Mu/NYg87hsq6LpWFnhS+5ja+f9myNoNZeOlJleCKi6RcJ0/q4krQHk8GEp YKMVSHePH6EA== X-IronPort-AV: E=McAfee;i="6000,8403,9874"; a="176204571" X-IronPort-AV: E=Sophos;i="5.79,373,1602572400"; d="scan'208";a="176204571" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2021 04:18:24 -0800 IronPort-SDR: oxSq+bW0tCqWU7I2UIGAZLet7pukoh2GDoYW+hDR7viC1W6Qv3oq8Ajr6Sxkxtvbu6MNER9gNl KhfYLaN582aw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,373,1602572400"; d="scan'208";a="361471544" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga008.fm.intel.com with SMTP; 25 Jan 2021 04:18:20 -0800 Received: by stinkbox (sSMTP sendmail emulation); Mon, 25 Jan 2021 14:18:20 +0200 Date: Mon, 25 Jan 2021 14:18:20 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Jani Nikula Cc: Koba Ko , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Lyude Paul , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] drm/dp_mst: Align mst link rate with soure rate Message-ID: References: <20210113014105.28110-1-koba.ko@canonical.com> <20210113014105.28110-2-koba.ko@canonical.com> <8735z5t5qz.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8735z5t5qz.fsf@intel.com> X-Patchwork-Hint: comment Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 13, 2021 at 01:51:00PM +0200, Jani Nikula wrote: > On Wed, 13 Jan 2021, Koba Ko wrote: > > After read the link rate from MST hub, align with > > maximum source rate. > > > > Signed-off-by: Koba Ko > > --- > > drivers/gpu/drm/drm_dp_mst_topology.c | 8 ++++++++ > > drivers/gpu/drm/i915/display/intel_dp.c | 7 +++++++ > > include/drm/drm_dp_helper.h | 8 ++++++++ > > include/drm/drm_dp_mst_helper.h | 4 ++++ > > 4 files changed, 27 insertions(+) > > > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c > > index 6982ecbf30b5..e7ceae97be85 100644 > > --- a/drivers/gpu/drm/drm_dp_mst_topology.c > > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c > > @@ -3672,6 +3672,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms > > { > > int ret = 0; > > struct drm_dp_mst_branch *mstb = NULL; > > + unsigned int max_link_rate_tbl[MAX_DRM_DP_MAX_RATE + 1] = { > > + DP_LINK_BW_1_62, DP_LINK_BW_2_7, DP_LINK_BW_5_4, > > + DP_LINK_BW_8_1, DP_LINK_RATE_TABLE > > + }; > > Please no. Read on for why. > > > > > mutex_lock(&mgr->payload_lock); > > mutex_lock(&mgr->lock); > > @@ -3693,6 +3697,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms > > goto out_unlock; > > } > > > > + if (mgr->max_source_rate < MAX_DRM_DP_MAX_RATE) > > + mgr->dpcd[1] = max_link_rate_tbl[mgr->max_source_rate]; > > Make ->max_source_rate the actual physical rate in kHz, and use > drm_dp_link_rate_to_bw_code() here. > > > + > > mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1], > > mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK); > > if (mgr->pbn_div == 0) { > > @@ -5422,6 +5429,7 @@ int drm_dp_mst_topology_mgr_init(struct drm_dp_mst_topology_mgr *mgr, > > mgr->aux = aux; > > mgr->max_dpcd_transaction_bytes = max_dpcd_transaction_bytes; > > mgr->max_payloads = max_payloads; > > + mgr->max_source_rate = MAX_DRM_DP_MAX_RATE; > > mgr->conn_base_id = conn_base_id; > > if (max_payloads + 1 > sizeof(mgr->payload_mask) * 8 || > > max_payloads + 1 > sizeof(mgr->vcpi_mask) * 8) > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c > > index 469e765a1b7b..a89b4c823123 100644 > > --- a/drivers/gpu/drm/i915/display/intel_dp.c > > +++ b/drivers/gpu/drm/i915/display/intel_dp.c > > @@ -5392,6 +5392,13 @@ intel_dp_configure_mst(struct intel_dp *intel_dp) > > intel_dp->is_mst = sink_can_mst && > > i915->params.enable_dp_mst; > > > > + if (intel_dp_source_supports_hbr3(intel_dp)) > > + intel_dp->mst_mgr.max_source_rate = DRM_DP_MAX_RATE_HBR3; > > + else if (intel_dp_source_supports_hbr2(intel_dp)) > > + intel_dp->mst_mgr.max_source_rate = DRM_DP_MAX_RATE_HBR2; > > + else > > + intel_dp->mst_mgr.max_source_rate = DRM_DP_MAX_RATE_HBR; > > Whenever this file references a "rate", it's the rate in kHz. This is > confusing. Use the rate in kHz. > > Also, please look at how intel_dp_source_supports_hbr* are implemented; > we already have all the supported source rates cached in intel_dp. > > The max source rate is: > > intel_dp->source_rates[intel_dp->num_source_rates - 1]. > > No need to do the if ladder here at all. If you like, you can add a > helper: > > int intel_dp_max_source_rate(struct intel_dp *intel_dp) > { > return intel_dp->source_rates[intel_dp->num_source_rates - 1]; > } Using the max source rate isn't super great either. A bit better than the current mess though. The correct fix would be to let the driver provide the actually used link_rate+lane_count to the MST code during atomic_check(), instead of trying to guess what the driver is going to use. -- Ville Syrj?l? Intel