From patchwork Fri Sep 8 07:50:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 9943331 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED1A56035D for ; Fri, 8 Sep 2017 07:50:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D59432853A for ; Fri, 8 Sep 2017 07:50:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA71628563; Fri, 8 Sep 2017 07:50:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 554542853A for ; Fri, 8 Sep 2017 07:50:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63C8D6E083; Fri, 8 Sep 2017 07:50:23 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from wens.csie.org (mirror2.csie.ntu.edu.tw [140.112.30.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98B9B6EAAE for ; Fri, 8 Sep 2017 07:50:22 +0000 (UTC) Received: by wens.csie.org (Postfix, from userid 1000) id 76E785FFE1; Fri, 8 Sep 2017 15:50:19 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , David Airlie Subject: [PATCH 3/8] drm/sun4i: tcon: Check for multiple paths between TCONs and backends Date: Fri, 8 Sep 2017 15:50:11 +0800 Message-Id: <20170908075016.18657-4-wens@csie.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170908075016.18657-1-wens@csie.org> References: <20170908075016.18657-1-wens@csie.org> Cc: devicetree@vger.kernel.org, Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The patch b317fa3ba11a ("drm/sun4i: tcon: Find matching display backend by device node matching") assumed a one-to-one mapping between TCONs and backends. This turned out wrong, as we found muxing controls in the TCON of the A31, and undocumented usage of the backend output selector of the A20. Make sun4i_tcon_find_engine() bail out if the current node has multiple input connections. Fixes: b317fa3ba11a ("drm/sun4i: tcon: Find matching display backend by device node matching") Signed-off-by: Chen-Yu Tsai --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index eb32676d5b01..065654dbfb2c 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -473,6 +473,20 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv, if (!port) return ERR_PTR(-EINVAL); + /* + * This only works if there is only one path from the TCON + * to any display engine. Otherwise the probe order of the + * TCONs and display engines is not guaranteed. They may + * either bind to the wrong one, or worse, bind to the same + * one if additional checks are not done. + * + * Bail out if there are multiple input connections. + */ + if (of_get_available_child_count(port) != 1) { + of_node_put(port); + return ERR_PTR(-EINVAL); + } + for_each_available_child_of_node(port, ep) { remote = of_graph_get_remote_port_parent(ep); if (!remote)