Received: by 10.223.185.111 with SMTP id b44csp867737wrg; Fri, 9 Mar 2018 15:35:00 -0800 (PST) X-Google-Smtp-Source: AG47ELsYML9EH8D5FDiVUi5vXV+V++UpU0MB/dPubnFQzSnHuWN6iUulPPhVbysG1KMjz3SCV15t X-Received: by 2002:a17:902:12e:: with SMTP id 43-v6mr198102plb.77.1520638500392; Fri, 09 Mar 2018 15:35:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520638500; cv=none; d=google.com; s=arc-20160816; b=uP8oZ/jiF5Wb2TowyDVqFLD/NqiDVEU5MT0B5Emdp8NmB+I6qiBoxbTotMpz9C528+ v2Y2Sn54ntXDyiw/+ncXAdydxqSx892X0thz45buT555tlfC3l4s/QpjpQUuZuNDBU6P Yf1YWBQtqbiUfLke+guR5M/25xSB9sLlPMbyrtWICa43lhFt4y+NmRQBrpb7My1RJcQa 2fEva37B8OsTvjSGvRxpJeUrn892RjlZSFxs/DX6xkmeBItOZctxVxfbcVhMNgT7OTiH pNMOqjZvczlzSvSvRlWUcId1kSBMQQHaXyZeH+yJOhah/LNJoBw+ys4DE4wuz2rx7Drd jAXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=FiEd6d+KseWLVFh8JI1l9dZIjZSTrNjopDIk0FIY9Nc=; b=DfW26FSc4Ie5UKhBNK1GP9i5/LpfSw+R9tt/EpQz99red9JbAj/Ro8ikRKyuFMu53m /2ntm0sZ/Y/EL6zYDK9OjgxYM6tr/KDorFS5IoAlqWEF3jKzlX3wfC8s8AxDvnjFgP/t bHcElHUWCPrgzkoTJcRolgq4SWglJoZtHPRlOG1D90pKORLyJezHKK4u89Sdsiq8ynt6 0CF2wDYHMtCcJmItYtSszgGnUAb9Jnqynaai0qyYr6G2MjfjVs/e8vwmZYwuAOEoSs9l NDxPtHUv8FmJpURdLg6klE6wvCEFjx6MV6JFp+fcakzrqwdGJNxhUQTYZNjiPh6RSZF9 zZ+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u193si1434715pgc.352.2018.03.09.15.34.45; Fri, 09 Mar 2018 15:35:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932717AbeCIXdB (ORCPT + 99 others); Fri, 9 Mar 2018 18:33:01 -0500 Received: from anholt.net ([50.246.234.109]:38324 "EHLO anholt.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932508AbeCIXdA (ORCPT ); Fri, 9 Mar 2018 18:33:00 -0500 Received: from localhost (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 8F2D010A1502; Fri, 9 Mar 2018 15:32:59 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at anholt.net Received: from anholt.net ([127.0.0.1]) by localhost (kingsolver.anholt.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5KoZv7R7furw; Fri, 9 Mar 2018 15:32:57 -0800 (PST) Received: from eliezer.anholt.net (localhost [127.0.0.1]) by anholt.net (Postfix) with ESMTP id 794E610A0222; Fri, 9 Mar 2018 15:32:57 -0800 (PST) Received: by eliezer.anholt.net (Postfix, from userid 1000) id CD61A2FE2D48; Fri, 9 Mar 2018 15:32:56 -0800 (PST) From: Eric Anholt To: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, Eric Anholt , Boris Brezillon Subject: [PATCH] drm/vc4: Fix oops dereferencing DPI's connector since panel_bridge. Date: Fri, 9 Mar 2018 15:32:56 -0800 Message-Id: <20180309233256.1667-1-eric@anholt.net> X-Mailer: git-send-email 2.16.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the cleanup, I didn't notice that we needed to dereference the connector for the bus_format. Fix the regression by looking up the first (and only) connector attached to us, and assume that its bus_format is what we want. Some day it would be good to have that part of display_info attached to the bridge, instead. Signed-off-by: Eric Anholt Fixes: 7b1298e05310 ("drm/vc4: Switch DPI to using the panel-bridge helper.") Cc: Boris Brezillon --- drivers/gpu/drm/vc4/vc4_dpi.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dpi.c b/drivers/gpu/drm/vc4/vc4_dpi.c index 72c9dbd81d7f..88783e143cc2 100644 --- a/drivers/gpu/drm/vc4/vc4_dpi.c +++ b/drivers/gpu/drm/vc4/vc4_dpi.c @@ -96,7 +96,6 @@ struct vc4_dpi { struct platform_device *pdev; struct drm_encoder *encoder; - struct drm_connector *connector; void __iomem *regs; @@ -164,14 +163,31 @@ static void vc4_dpi_encoder_disable(struct drm_encoder *encoder) static void vc4_dpi_encoder_enable(struct drm_encoder *encoder) { + struct drm_device *dev = encoder->dev; struct drm_display_mode *mode = &encoder->crtc->mode; struct vc4_dpi_encoder *vc4_encoder = to_vc4_dpi_encoder(encoder); struct vc4_dpi *dpi = vc4_encoder->dpi; + struct drm_connector_list_iter conn_iter; + struct drm_connector *connector = NULL, *connector_scan; u32 dpi_c = DPI_ENABLE | DPI_OUTPUT_ENABLE_MODE; int ret; - if (dpi->connector->display_info.num_bus_formats) { - u32 bus_format = dpi->connector->display_info.bus_formats[0]; + /* Look up the connector attached to DPI so we can get the + * bus_format. Ideally the bridge would tell us the + * bus_format we want, but it doesn't yet, so assume that it's + * uniform throughout the bridge chain. + */ + drm_connector_list_iter_begin(dev, &conn_iter); + drm_for_each_connector_iter(connector_scan, &conn_iter) { + if (connector_scan->encoder == encoder) { + connector = connector_scan; + break; + } + } + drm_connector_list_iter_end(&conn_iter); + + if (connector && connector->display_info.num_bus_formats) { + u32 bus_format = connector->display_info.bus_formats[0]; switch (bus_format) { case MEDIA_BUS_FMT_RGB888_1X24: @@ -199,6 +215,9 @@ static void vc4_dpi_encoder_enable(struct drm_encoder *encoder) DRM_ERROR("Unknown media bus format %d\n", bus_format); break; } + } else { + /* Default to 24bit if no connector found. */ + dpi_c |= VC4_SET_FIELD(DPI_FORMAT_24BIT_888_RGB, DPI_FORMAT); } if (mode->flags & DRM_MODE_FLAG_NHSYNC) @@ -264,7 +283,7 @@ static int vc4_dpi_init_bridge(struct vc4_dpi *dpi) return ret; } - if (panel) + if (panel) bridge = drm_panel_bridge_add(panel, DRM_MODE_CONNECTOR_DPI); return drm_bridge_attach(dpi->encoder, bridge, NULL); -- 2.16.2