Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp3266799rwo; Mon, 24 Jul 2023 08:34:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlGp0VDOAfbvkkgkIou/0/Lnqt9Cg26EhJbntGs39Qp7E/QiTORRa/LP8eQbHu15AOzB9hBq X-Received: by 2002:a17:906:3154:b0:993:f9d4:eab3 with SMTP id e20-20020a170906315400b00993f9d4eab3mr10432050eje.18.1690212888635; Mon, 24 Jul 2023 08:34:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690212888; cv=none; d=google.com; s=arc-20160816; b=UQ81jc88OoOIELBNLdP/bpzr16s6YoscZOojI7SKQwWiQV5HyO0DEPgGwDLPyROu0a 6/u1dhp32SHPaEFmSX9D2DSag9IH/oiMEUVC37AA47erZSGuLx65FYJstbFbyY9MMpg7 Shj9e3VBu2eGCc1aw+TG6Iy6/eFd0LBCCGMI4kxaajeTl3ZJxBgcC3AdWOPmXd5tMwnQ xxhi4Gttu0MHNJunOBC86VL0QLw8oF2CQb3I7BULicTkD62GOoQTtNYXebIGb1Qlqn3O m1n1oL0+frpUC4GIv7Hu4UUYmfPTwBfeooFknzu5xzAMvH64kgzukETVl6DO1Yiy4P9D NNMw== 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=+Oq42VHLt9WI5LMY6xBEFPI3JfgTSegkWwKVtR1Zjh4=; fh=im19aUDH8qo8T8oZv8+k/OW9GT4UEjaWNCfbPI1bsYI=; b=bJDGixQ7BosVhw4avh21sI75K0lmZUuME95XQZeFVMsWkVEOKlH2op7uGXup17qJVL arCrb7UW8FVg9iJ1MQdd0t5Im24FTgkEL9eXPaargtZ5SIhdhEWZJmUU7uStAYbKXcOb 4vfpoz4CXBfTlkjRpZhU4auG4A/c2osKuqzyK5wUPsk+0M7VqvmyfCVJ56t6RuB/nlXq ND4yOQDHk3OzG3u8qlfQ93c4fkEBLWIo7aNYZfSXH1xj6ySn1w6NT5+5txej2edUtAQ4 LDrih3iHmmZEkEQWbUvyUnBTFWevvP6hDCcm4dNFZiDh/n/4dHOjTGD2cHOLKyU8ctLg zJ7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fris.de header.s=dkim header.b=tjjWmyPL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fris.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id re16-20020a170906d8d000b0098d373fa9e4si6450531ejb.1007.2023.07.24.08.34.24; Mon, 24 Jul 2023 08:34:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fris.de header.s=dkim header.b=tjjWmyPL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fris.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbjGXPOs (ORCPT + 99 others); Mon, 24 Jul 2023 11:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjGXPOq (ORCPT ); Mon, 24 Jul 2023 11:14:46 -0400 X-Greylist: delayed 350 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 24 Jul 2023 08:14:39 PDT Received: from mail.fris.de (mail.fris.de [116.203.77.234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E45D9133 for ; Mon, 24 Jul 2023 08:14:39 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 7DE21C00F4; Mon, 24 Jul 2023 17:08:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1690211307; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=+Oq42VHLt9WI5LMY6xBEFPI3JfgTSegkWwKVtR1Zjh4=; b=tjjWmyPLkeRE7G950imIX1wsfh9Mijw+PuJebrWHS6rh2+VuRM+89tQ39Nucm7QN6njm8v 6+GVI7LPNZI5WlevhtLPivM0PpGgJhuK1QfAyV4k/55/SeRgbgaaZCjkV6rLPVmzuOpUgH czr0LcoU5qIQqmg8nvc/pKS/Q7AcFu/oBC0lXonlyP2yCHbE/VOnuNjTVewMWcxTr7lF3/ tgy2p6v9WTcc0kvOWgQ/sxo5/NPy0Dq2wVN/tETIcBxQmQ6wtz/gLC7TISIcotq8LnIelb 3R/NWaxPvUGaioyt11Ih1Rj88GNgUOYBgegmMv3eoCgW975x6x3hRSHtcq2wrQ== From: Frieder Schrempf To: Andrzej Hajda , Daniel Vetter , David Airlie , dri-devel@lists.freedesktop.org, Frieder Schrempf , Inki Dae , Jagan Teki , linux-kernel@vger.kernel.org, Marek Szyprowski , Neil Armstrong , Robert Foss Cc: Tim Harvey , Adam Ford , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Marek Vasut Subject: [PATCH] drm: bridge: samsung-dsim: Fix init during host transfer Date: Mon, 24 Jul 2023 17:08:03 +0200 Message-ID: <20230724150812.553044-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frieder Schrempf In case the downstream bridge or panel uses DSI transfers before the DSI host was actually initialized through samsung_dsim_atomic_enable() which clears the stop state (LP11) mode, all transfers will fail. This happens with downstream bridges that are controlled by DSI commands such as the tc358762. As documented in [1] DSI hosts are expected to allow transfers outside the normal bridge enable/disable flow. To fix this make sure that stop state is cleared in samsung_dsim_host_transfer() which restores the previous behavior. We also factor out the common code to enable/disable stop state to samsung_dsim_set_stop_state(). [1] https://docs.kernel.org/gpu/drm-kms-helpers.html#mipi-dsi-bridge-operation Fixes: 0c14d3130654 ("drm: bridge: samsung-dsim: Fix i.MX8M enable flow to meet spec") Reported-by: Tim Harvey Signed-off-by: Frieder Schrempf --- Hi Tim, could you please give this patch a try and report back if it fixes your problem? Thanks! --- drivers/gpu/drm/bridge/samsung-dsim.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c index 043b8109e64a..92ea60e0fbf1 100644 --- a/drivers/gpu/drm/bridge/samsung-dsim.c +++ b/drivers/gpu/drm/bridge/samsung-dsim.c @@ -1386,6 +1386,18 @@ static void samsung_dsim_disable_irq(struct samsung_dsim *dsi) disable_irq(dsi->irq); } +static void samsung_dsim_set_stop_state(struct samsung_dsim *dsi, bool enable) +{ + u32 reg = samsung_dsim_read(dsi, DSIM_ESCMODE_REG); + + if (enable) + reg &= ~DSIM_FORCE_STOP_STATE; + else + reg |= DSIM_FORCE_STOP_STATE; + + samsung_dsim_write(dsi, DSIM_ESCMODE_REG, reg); +} + static int samsung_dsim_init(struct samsung_dsim *dsi) { const struct samsung_dsim_driver_data *driver_data = dsi->driver_data; @@ -1445,15 +1457,12 @@ static void samsung_dsim_atomic_enable(struct drm_bridge *bridge, struct drm_bridge_state *old_bridge_state) { struct samsung_dsim *dsi = bridge_to_dsi(bridge); - u32 reg; if (samsung_dsim_hw_is_exynos(dsi->plat_data->hw_type)) { samsung_dsim_set_display_mode(dsi); samsung_dsim_set_display_enable(dsi, true); } else { - reg = samsung_dsim_read(dsi, DSIM_ESCMODE_REG); - reg &= ~DSIM_FORCE_STOP_STATE; - samsung_dsim_write(dsi, DSIM_ESCMODE_REG, reg); + samsung_dsim_set_stop_state(dsi, false); } dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE; @@ -1463,16 +1472,12 @@ static void samsung_dsim_atomic_disable(struct drm_bridge *bridge, struct drm_bridge_state *old_bridge_state) { struct samsung_dsim *dsi = bridge_to_dsi(bridge); - u32 reg; if (!(dsi->state & DSIM_STATE_ENABLED)) return; - if (!samsung_dsim_hw_is_exynos(dsi->plat_data->hw_type)) { - reg = samsung_dsim_read(dsi, DSIM_ESCMODE_REG); - reg |= DSIM_FORCE_STOP_STATE; - samsung_dsim_write(dsi, DSIM_ESCMODE_REG, reg); - } + if (!samsung_dsim_hw_is_exynos(dsi->plat_data->hw_type)) + samsung_dsim_set_stop_state(dsi, true); dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; } @@ -1775,6 +1780,8 @@ static ssize_t samsung_dsim_host_transfer(struct mipi_dsi_host *host, if (ret) return ret; + samsung_dsim_set_stop_state(dsi, false); + ret = mipi_dsi_create_packet(&xfer.packet, msg); if (ret < 0) return ret; -- 2.41.0