From patchwork Thu Jul 15 18:38:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 478207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 055F3C636C9 for ; Thu, 15 Jul 2021 18:52:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED313613CA for ; Thu, 15 Jul 2021 18:52:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240601AbhGOSz0 (ORCPT ); Thu, 15 Jul 2021 14:55:26 -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_de_Bretagne?= , =?utf-8?b?VmlsbGUgU3lyasOkbMOk?= 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 Precedence: bulk List-ID: X-Mailing-List: stable@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;