Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp632135pxv; Thu, 15 Jul 2021 12:01:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7+s2R6Ym3CyxbHi+TSyvF9S4HPwyP8N8bMxzlJwa2qHlWz2gh/YZ118fgRKkkBPzuGU+/ X-Received: by 2002:a17:907:c26:: with SMTP id ga38mr6989748ejc.38.1626375701536; Thu, 15 Jul 2021 12:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375701; cv=none; d=google.com; s=arc-20160816; b=dJ1+F73yRv9Smn7/vsODjPK1Oc3Ejv5zqRnRwxK5iwbd8YbHlK+L0+to2gihWBy51U oSIoskVTMBAmp5lLSSRjWW8SoeBmajCMCVmVnFsvls3IOhbApXsO6mhmq8u3iKL/8NG2 /1O3Gq3NYEh6rtmppJi5p/qajLAptGxTWfi9egSc/qrmfOTMGS9xA6XVIuJdTjmaxfB1 BJeOr9OyahnafdnjnncQ3qjg/f6+YuAOZSQT71w9HQgMbpBZuu9ZQeXP6tPA2Jp2o0hj A0jWOJpapf+xVX4ZhBAxWfw29ooW6tIdsh7xR+wwWoM93AQYeMjQtF4UFOalQdIb6VZd G2pw== 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=J0Ej3IILM7wgVGEheQ6v3qG6RkS7z66eerjd+zKHIdQ=; b=vScqm6JG5vGbRRz3ONZKFHoutYPtpg5177jhLGlC6io43e/Xlvu9PaXOU3QHb0e9T9 u+0WOGRx1dOX9eu1Kwm1C9sFHkqoZu/OCmMzmpxjRASG1e9tl/eS7Uj0YzRJeZlp/57o PYx8hqDeqg/mcsEIWzTtGFiT8f0+0YGFda4/bv4ts50zCJDLM93xgJmLrgxqHfVi3NLJ mE/WVNjArFnG6iIqfrtuV92E5KtaWQFJLW2butlQVSwEv8kb5izYUerffsTLXLIj0wTC RTg4QtDfauCt4AAXcNlEUGH4YPfRMPyUiS1qaGTwXtFtx8vMGnkwedXr9BYD8XqAif5Z l5YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GjJEu5O0; 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 n1si7450564ejx.353.2021.07.15.12.01.17; Thu, 15 Jul 2021 12:01:41 -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=GjJEu5O0; 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 S243290AbhGOTBy (ORCPT + 99 others); Thu, 15 Jul 2021 15:01:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:58696 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241445AbhGOSyZ (ORCPT ); Thu, 15 Jul 2021 14:54:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE7BD613CF; Thu, 15 Jul 2021 18:51:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375090; bh=E1NXYw1yelaXlfpaQVT4j+Mkq7KtqvVHZqmCSpSwalY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GjJEu5O0AO9KDKYdoh0Rqag1kao05LHHvE0yCmzxSp5OdSrk32krgSofiovfEOyEH yDmzY9M5OQ8qDsJmz2imP1gmOnKuZpD/G3/NBvrEiVfnWNxX1+8dkIFyr3iFF2fKze KGMm3aDOcKE15UWZ4Q+6VSZvncYC4e6P1vx9l1uc= 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.10 156/215] drm/dp: Handle zeroed port counts in drm_dp_read_downstream_info() Date: Thu, 15 Jul 2021 20:38:48 +0200 Message-Id: <20210715182627.085216274@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 @@ -602,7 +602,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;