Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp740886pxy; Fri, 30 Apr 2021 15:35:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3LllsEPdyhHVrIwUR1Y3sdISBTS995677bpaKRVxPDMHZesF6bHD5bKiuHBBxJ2im2m3 X-Received: by 2002:a17:90a:d78c:: with SMTP id z12mr16955869pju.106.1619822138093; Fri, 30 Apr 2021 15:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619822138; cv=none; d=google.com; s=arc-20160816; b=vWYbS6r+LPouqR5ZYSGy78Fx2p23TEP/5R/1/jNCvElZ+I3zxFyWEeeHrDYjPVG+AN Roey8cqAub1jtCrHeinyLvQyibh2R14MrO6YRSO9bQlzRyX+uI4eJMoHBaaX7/9WSQ2t aH/f7in7RY6/daF7jY2/q/1iIETAwSVjSnIQgS0mMTEX5hdbjLpmmPseh+olO4sViSS+ JdAB2tho+9dCcCBF3/RAAJVb2dB7G1x/l3BT58uNOdaj8XfxT2ot8anahMf6lNW5XGse q6aZQqiw0WxpUJX21uQqh9repPv6ri0QUxoCbpZ5qvCIE4VkEHl9myOVRFq/0hc35U02 2rmQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=pLPFkif6Bc1G5AuiGH/FaebyEZLmCnW8ksg8zeS6jOM=; b=p1uVpeQDnutNLNQToSoaDBn4MsONFIFXb5opFEbVlo5d8eEVJOrADE0ZGn2zCQMqUS CHX+eYrIz2RoSj/AUWPA2XQfoEYtqNqdTb1ds+Ww+IJYmfPd5/fe4no35J1efjwomoYr HmhpFmCX6gtR3nQHkiS6bozpi99uFwKUUqr17i+yWSWnPGciU1eD7Xc1iQqxmjiMV1gf L9+BvQE+jorWntWIDe+NIataug3fB9XP1o/ySPVTrJuHYxIlVmRGJI44JAqaZHvmdwR9 Y0E1i7SF6XDxyxqWh5qF1jOZHIlOVrBhjL7gnt+CpspsOLmh6Gt2Mjb93KHiqG4M8tIo OJAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Oa7FPiIf; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i198si4865056pgd.575.2021.04.30.15.35.25; Fri, 30 Apr 2021 15:35:38 -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=@redhat.com header.s=mimecast20190719 header.b=Oa7FPiIf; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231656AbhD3Wfk (ORCPT + 99 others); Fri, 30 Apr 2021 18:35:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48299 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231668AbhD3Wfj (ORCPT ); Fri, 30 Apr 2021 18:35:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619822090; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pLPFkif6Bc1G5AuiGH/FaebyEZLmCnW8ksg8zeS6jOM=; b=Oa7FPiIf7knU5n0YohJOXs9YQgusRa0rTzDQGn5wJwQY497EdyGK2SueLtlELhr0la8vep p6WcJOWKwczNm2DNKuK5tDrZmCYH+Ih8fyiTZso0k9EqI3MOddUoq8NiziUQ79cAMARy/h hMvg+8Lg/6oUl7ArZLo3MQZ0KGo5nGw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-39-Vh_UcPDqPU2gws_TFRposg-1; Fri, 30 Apr 2021 18:34:46 -0400 X-MC-Unique: Vh_UcPDqPU2gws_TFRposg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8BD7B501F3; Fri, 30 Apr 2021 22:34:44 +0000 (UTC) Received: from Whitewolf.redhat.com (ovpn-112-36.rdu2.redhat.com [10.10.112.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00F415D755; Fri, 30 Apr 2021 22:34:42 +0000 (UTC) From: Lyude Paul To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: =?UTF-8?q?J=C3=A9r=C3=B4me=20de=20Bretagne?= , stable@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Sean Paul , Jani Nikula , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] drm/dp: Handle zeroed port counts in drm_dp_read_downstream_info() Date: Fri, 30 Apr 2021 18:34:27 -0400 Message-Id: <20210430223428.10514-1-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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+ --- drivers/gpu/drm/drm_dp_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c index cb56d74e9d38..27c8c5bdf7d9 100644 --- a/drivers/gpu/drm/drm_dp_helper.c +++ b/drivers/gpu/drm/drm_dp_helper.c @@ -682,7 +682,14 @@ int drm_dp_read_downstream_info(struct drm_dp_aux *aux, !(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; -- 2.30.2