Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp657862pxv; Thu, 15 Jul 2021 12:41:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt5MYBRHzwg+8yr15/G7UuX9E/i1wnmuOrIcbW3ZNmEkkDJhiY6pJTxVZWwhUlMbouaOhT X-Received: by 2002:a05:6402:6c8:: with SMTP id n8mr9256606edy.180.1626378069586; Thu, 15 Jul 2021 12:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626378069; cv=none; d=google.com; s=arc-20160816; b=Ngops35tAmF2meQ+/8Jp7c50lnERRcIEXncha3/vcuf63LM57pB7vc3yL8AVtpSuVo yCrUJCHi1tv14WyCME2ek30dmdK9UqMKO46/fFUP14Tn9cZBajfsyaFgT4RyevI+8lXI J5ZlJtHXQpYpqqAPY69cO7pFcRBs4YYgoZ0nZKigrzZpsFZt/TTNRccVWMxavs5tkh4S HwlPvhOXx79Ilfan3+9OWhnCWdqlM825PEhkz2pjrP0zpSOwkUBZqSq3Jho7khbiql89 3ZEnAtqto2naJ/RZoo8ossxrngBLQUlISP6eTT5R3AdGU+9CuiogBbVfrbl9Yt0xkvm/ dPGw== 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=ZaNYA0bA6Cn9j1ozPfBidJzjDda/wHM28KGPV+rd/kw=; b=erExaKlmEtxIeTJYBrHYv0wjVJIUgyDpIWZ/Z/BPf0QEIR3UaR5HEGhltV1JWxf81b xK2slX8zPFTdHIzmym1Ue+irhhummxr48XdbBnz6pD3yS5vKzjxXpwM22I0vv1SwvTz4 4KpM3uT1jx3RERakvYVpGy37fO9nhxaY/8PawdUyX2I6iEDINwtuBiDbxNJotna/LcnC bMTV2fYwoSN9L1hC7X0CEnDzduLzBT1aYJ5ag4rSSfqS51Z44uZkZDYhNJiq1kaRGcmS Zk55NQcPyPps3sNX6pyujZPfNkjVfa+gB+QAio+ZydtcPQROVzERtNmoueil6Kndk5WX otjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hcxzWaND; 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 d12si10023017ejj.130.2021.07.15.12.40.47; Thu, 15 Jul 2021 12:41:09 -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=hcxzWaND; 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 S242219AbhGOTlJ (ORCPT + 99 others); Thu, 15 Jul 2021 15:41:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:51362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244652AbhGOTPB (ORCPT ); Thu, 15 Jul 2021 15:15:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D030461413; Thu, 15 Jul 2021 19:11:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626376262; bh=g5KchM9DXxcv9S6mGCD25XdSLy+DyVBq9Kh+7G1R5mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcxzWaNDwpt7rNFYloK44bLuTpY6sBdPCRAfjT35MpItS4yde/gwgy0L6zuaMuyOZ EaJIYSXG9QZATtEwPAquxyB2A3qdL6vlX451umNa5R3qRtzgRIU1UEsZGFTtKaGgCq i4XBBeAFT/2D8KDivp4DT0RJVMaPES66elxVgJhY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lyude Paul , =?UTF-8?q?J=C3=A9r=C3=B4me=20de=20Bretagne?= , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Subject: [PATCH 5.13 195/266] drm/dp: Handle zeroed port counts in drm_dp_read_downstream_info() Date: Thu, 15 Jul 2021 20:39:10 +0200 Message-Id: <20210715182645.081719708@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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: Lyude Paul commit 205bb69a90363541a634a662a599fddb95956524 upstream. While the DP specification isn't entirely clear on if this should be allowed or not, some branch devices report having downstream ports present while also reporting a downstream port count of 0. So to avoid breaking those devices, we need to handle this in drm_dp_read_downstream_info(). So, to do this we assume there's no downstream port info when the downstream port count is 0. Signed-off-by: Lyude Paul Tested-by: Jérôme de Bretagne Bugzilla: https://gitlab.freedesktop.org/drm/intel/-/issues/3416 Fixes: 3d3721ccb18a ("drm/i915/dp: Extract drm_dp_read_downstream_info()") Cc: # v5.10+ Reviewed-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20210430223428.10514-1-lyude@redhat.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_dp_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -679,7 +679,14 @@ int drm_dp_read_downstream_info(struct d !(dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT)) return 0; + /* Some branches advertise having 0 downstream ports, despite also advertising they have a + * downstream port present. The DP spec isn't clear on if this is allowed or not, but since + * some branches do it we need to handle it regardless. + */ len = drm_dp_downstream_port_count(dpcd); + if (!len) + return 0; + if (dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DETAILED_CAP_INFO_AVAILABLE) len *= 4;