Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp710320pxv; Thu, 15 Jul 2021 14:07:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5GAenPn2gDR2zWiuPqsGh1+yoyZbuzaI+3FViOSe/i4Na1080V5l+46aWIW4A9dypxNd+ X-Received: by 2002:a17:906:6d54:: with SMTP id a20mr7738432ejt.322.1626383259185; Thu, 15 Jul 2021 14:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383259; cv=none; d=google.com; s=arc-20160816; b=mkIilLr9HeHJ3rOhv4sYkdc/MxnA2ybRZ2M2h7Lw9cBSvZQfe/vUFaStwWiIukQFZt 9EIf9l/E2ATbLnMYp14vGr7X6cU1qgGv/bPNC0XVYo4NNbqAN05v6CM4eRWLvdm1CyPb mZt/9spmO6xlmTf7dst0mGpc2r3z7+dOMBx4dETPnSz04Qgvw1LkOLjUqOcCMqym3ONc KczuDM637kUFdMMripnnUdLcb08+NOv7DDDnK+zElaotFwoJ99B1WVjUGjECzOblCfWJ 1LFf25n64iNMjafTG+Fer7VCxjszX/OzJs4Junzi2s5XJEsGtjop2kBqPCabO8K7ngXb RSDg== 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=Hfan3laFcUN/AeATiqIGHmcRyEu7F15E2XhG9kArXfEbAzHalzq428oz/xAWzn5wB2 wfSfB4j2yQhO6XsLdECvGTG9Iwg1FmV5Ye7s4msSDlQDr7yNRImDi/2VOY14DhGF4ANw 6J7K2WI9Havt0dHJL9uih14cxtwQTZ/ioskJugX42A5gS1HROm1sPAR5BkLN9WnFBxQJ g1s9+cahlCrGsuLbUmwvnKvqyU4JtyxSl1ndzOIfVRmcbfJicF8G+yjfdPTPGuXNpUMj i/nL/m89zmY8YnykZmAmK5ljVpwp0x4VqMmXNTCy6BESR6bvF4d6UBWc7O/pykzjlpJm Yj5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PpL3GVWV; 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 u6si2191789edy.75.2021.07.15.14.07.16; Thu, 15 Jul 2021 14:07:39 -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=PpL3GVWV; 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 S245129AbhGOTTU (ORCPT + 99 others); Thu, 15 Jul 2021 15:19:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:39498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243677AbhGOTEi (ORCPT ); Thu, 15 Jul 2021 15:04:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A1BA6140A; Thu, 15 Jul 2021 19:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375633; bh=g5KchM9DXxcv9S6mGCD25XdSLy+DyVBq9Kh+7G1R5mI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpL3GVWV3mRRraartscZAtj6dugmzkJDRf2Zq2ag8I0iOaHS97BGYENwckwH5Hu/2 Xvx9l81VKysiWGkj1iBQ1gf6W8FN7o/HSd0hVaatlVHs0MWdeSbY1NWI8g5MAsdaz0 MkRYNWw0XlH48Mu0xU3AKPNX9qQht9zhZHfCU5eI= 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.12 171/242] drm/dp: Handle zeroed port counts in drm_dp_read_downstream_info() Date: Thu, 15 Jul 2021 20:38:53 +0200 Message-Id: <20210715182623.324295260@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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;