From patchwork Mon Oct 28 10:25:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3601 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 583F13F338 for ; Mon, 28 Oct 2024 11:26:28 +0100 (CET) Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5cbadbef8edsf2549907a12.3 for ; Mon, 28 Oct 2024 03:26:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1730111188; cv=pass; d=google.com; s=arc-20240605; b=N8pkt8n6iwbCuufxb4RJwnE97XtZTiXQbgt+ba6rkozYQ+b6PQhQ56B6Bg8A2fzpbr V7+93y2HsE0Mq9IVsp0bJg8EM4DxJU3hKjJ9l4TqgtZSlz8kA7viNf7xLI9j3mzbabGd nD+DUkpsBoMuHa+0SZ1VXP+jrqEEdRT3vm0N/8D28SQ5i1h114nRRbx1QJbNZaGJ6IDD POegtTQS01MXE3A6AgZkOwDc3qHnGFWLUZhaAIyaxQEfKeSqxb/TOD5Y0qnavTZOE1xv nn5o/o4iw5tdJcVHySRIA7L8VSXWy9+sWknaE5IZDQlgrfjJePrwe7uLZutbmyS+zmL2 fQaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=s5psUVIwEkKPoOs2WXFQuCbOoez2cCmpIDuJawxdo8E=; fh=gbbU+cqaF5KoKLbchg3Yw9ZoyqEpYlQZ7m1nd9x5QSI=; b=ZcCX+crBfQBuWlD5Hkask+qFRgszToXp1gCWCQOVLo+fL0QY7snglamPZdAQWb1gXY /1ZvkxQDN4ouIiX4F0wkn7HoIAARlnqnrU039J7I077BB1rm8zcfYzAxHDSisT8FY5ZE mmmH0T2Y7w4I7Zz6MplsbD9Vp3icnxNXZOfjCDkiWkCmPRfoPHOsJRwVCpM+aMY/ey0e wqku6qnH8m7Z4fwXMh+d+EDFONRbqiM7IDRS3VcE6GaXDiYpeQQWXQYv31wkUXmsMF5e uH7bQfN1UjXQ5u+MZwHQGfCgv0cOZhojtCykb6HxjaHsrS+9dxrIQJa1CxMGYMY4pPaR l+RA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Stibil46; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1730111188; x=1730715988; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=s5psUVIwEkKPoOs2WXFQuCbOoez2cCmpIDuJawxdo8E=; b=e2+krSZJLRShorfgVVUNFNJXQFi4u0rULGqQp4ngELqETFtHzLdFr4NZICWKZEXkIX 6nod7yWXscA5JrZE+ssr+c+F2p1uwtxRl0PVUkQdFiXu7G80sLDJQPfG57skwVBA2AMQ oSEPP2k1hlEAjOAMaH/9ejyP3QBNnabsIsVfk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730111188; x=1730715988; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=s5psUVIwEkKPoOs2WXFQuCbOoez2cCmpIDuJawxdo8E=; b=VpzM7jrXriFz2aRVV6HJWUJ844b/Xzq+3VZcbzy6cDrv5tXJ22EOgL6jtJ2TgIZ/KB nhr6YTxhpWic55LA/rOUvQokEHVi22Ns0PPexPT5wJ0EM7ySr1MZ0TMrKtQ4wsgMaQwW gq/SpoiCoI+b95GgxyQhNLyms7ktkoUCriSlip/wjyuTF3DX2mkBwGtJvT2XduA730E9 FYQR14R5iUaR5zk+036S3KOdDj/jsfDgdPG+rY5vIazNhi5M2R6kUuw2Ch6twCHpZXo9 CDhXQg/MTrBYRpSnARPIFoSJiIR4H5q0MEQ57jI0RJaBgEm0YtgjPjxLUpfC/BzNjCpg GWuw== X-Forwarded-Encrypted: i=2; AJvYcCXLtmrSj8baRC3hKJ/2oBgEqGVGwFm92sKyfMtp/P/RQV5aWB5vV0Aavkp6EQBeEGrJVHV7KWgRoRvpbpmo@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YwL9Jo0LH+42kvPs+gXpU7wGZmzeaEzPLbxD0IO6GsTVH+0oq4K ZlERp6y48lLYD4LwJjp+hy1iVjOj4JpMarE69pTFVqaYUS4CZjiVgJnxXqv/xrZ0PA== X-Google-Smtp-Source: AGHT+IGPGFDmoccP+LShvG+XMzY/lZwGsa6x6n3kAqoECVvf4qbgSIVvRMiayBsjYxy2kNxt2NhSCQ== X-Received: by 2002:a05:6402:5209:b0:5c9:59e6:e908 with SMTP id 4fb4d7f45d1cf-5cbbf89216amr6538806a12.6.1730111187853; Mon, 28 Oct 2024 03:26:27 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:34d1:b0:5c8:acf3:1296 with SMTP id 4fb4d7f45d1cf-5cb999fd8dfls3195a12.2.-pod-prod-03-eu; Mon, 28 Oct 2024 03:26:26 -0700 (PDT) X-Received: by 2002:a17:907:7f16:b0:a9a:67a8:4c0b with SMTP id a640c23a62f3a-a9de619a3c6mr753707366b.60.1730111186295; Mon, 28 Oct 2024 03:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1730111186; cv=none; d=google.com; s=arc-20240605; b=e8zHizdFSNjJqRJN3AlcGocx4fmtWD5Txgd8efbcZk1pcVTI0tGpUhJO1VIfYgQOBn uc9Ec1IBho9VsBwAbboJR5UyRuVHWlLBf67JXwYYFqA/b638A0mEH0J1haYe4GttVPZg R/fg9lbroBPBzkW336OmpfYIOnZRWVZXhBuK6t67c7zZMfLZ/HoJElI9/YQ8o935Zt16 /vhW3NvbjxLPzH7DX/5o5i8QBE77n5N0v35K8eZxK3Wz2SaaqpP2TMcMXMqq7LoZhoAJ 7SxWHOZi9BcjX/rOOqjC7qJ16aNR/jgPf+l/k49X2k/cRcQR3qoKEjCbL0CL8zDqjWTi H9/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=aIDm7KBT1s0AbOc3yV3TQ9ohvs8sUqIvua5HhBI5V8A=; fh=M2fpjXzppMk52WT6IfI31fWa7zFBF4cOzrbdwbKYzY8=; b=PGhc7N89mu5RQqQr+F+ZPYUpy/0qEM1fTKcRJH1UZHPZ9zGgTLmVKyLjubS2TBMZKH smhOxK0JF60ulI/IyW5qHW0qCwPDRid2CNoy/zdlOOINjKeP850FKG27FiEHY5Cg8jG8 9/KtzZJ9l4DNeZ9NtLyNPvfHKWERp8HdjJhkOCVSQ9biVLJHE+U/B4ebv7Z7uzPB0EIr aIxsxpM7K+Jjebut9PrzpKxwLvyeEz2P6VmlQxCgjye+n+Oe5TzrDJhP6I7DmIZKef+8 y0w+ZsbzyvyYVOEq1L9vc5uW4BDjlh+W0VUrF+gYxwqCHdKYIoGMfEKqPTsIw+yaLo9R xFcQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Stibil46; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id a640c23a62f3a-a9b1f067995sor199352266b.11.2024.10.28.03.26.26 for (Google Transport Security); Mon, 28 Oct 2024 03:26:26 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a17:906:da8a:b0:a99:425c:c653 with SMTP id a640c23a62f3a-a9de5ce24f6mr866426966b.22.1730111185881; Mon, 28 Oct 2024 03:26:25 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.41.121]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9b1f297b04sm363613966b.134.2024.10.28.03.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2024 03:26:25 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, Dario Binacchi , David Airlie , Fabio Estevam , Maarten Lankhorst , Marek Vasut , Maxime Ripard , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Simona Vetter , Stefan Agner , Thomas Zimmermann , dri-devel@lists.freedesktop.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 10/10] drm/mxsfb: stop controller and drain FIFOs if already initialized Date: Mon, 28 Oct 2024 11:25:33 +0100 Message-ID: <20241028102559.1451383-11-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> References: <20241028102559.1451383-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Stibil46; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com; dara=pass header.i=@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , You can't re-program the controller if it is still running. This may lead to shifted pictures, so stop the controller and drain its FIFOs in case it's already properly setup. This patch is crucial when supporting the simple framebuffer, as the controller has already been initialized by the bootloader. Signed-off-by: Dario Binacchi --- drivers/gpu/drm/mxsfb/mxsfb_drv.c | 3 +++ drivers/gpu/drm/mxsfb/mxsfb_drv.h | 1 + drivers/gpu/drm/mxsfb/mxsfb_kms.c | 14 +++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c b/drivers/gpu/drm/mxsfb/mxsfb_drv.c index cb5ce4e81fc7..38c94cdc8f6c 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -221,6 +222,8 @@ static int mxsfb_load(struct drm_device *drm, if (!mxsfb) return -ENOMEM; + mxsfb->enabled = + of_property_read_bool(drm->dev->of_node, "fsl,boot-on"); mxsfb->drm = drm; drm->dev_private = mxsfb; mxsfb->devdata = devdata; diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.h b/drivers/gpu/drm/mxsfb/mxsfb_drv.h index d160d921b25f..0f9ae4ce450c 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_drv.h +++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.h @@ -47,6 +47,7 @@ struct mxsfb_drm_private { struct drm_bridge *bridge; bool crc_active; + bool enabled; }; static inline struct mxsfb_drm_private * diff --git a/drivers/gpu/drm/mxsfb/mxsfb_kms.c b/drivers/gpu/drm/mxsfb/mxsfb_kms.c index 7ed2516b6de0..d064a2bb65df 100644 --- a/drivers/gpu/drm/mxsfb/mxsfb_kms.c +++ b/drivers/gpu/drm/mxsfb/mxsfb_kms.c @@ -202,9 +202,11 @@ static void mxsfb_enable_controller(struct mxsfb_drm_private *mxsfb) writel(reg, mxsfb->base + LCDC_CTRL1); writel(CTRL_RUN, mxsfb->base + LCDC_CTRL + REG_SET); + + mxsfb->enabled = true; } -static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) +static void _mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) { u32 reg; @@ -221,6 +223,13 @@ static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) reg &= ~VDCTRL4_SYNC_SIGNALS_ON; writel(reg, mxsfb->base + LCDC_VDCTRL4); + mxsfb->enabled = false; +} + +static void mxsfb_disable_controller(struct mxsfb_drm_private *mxsfb) +{ + _mxsfb_disable_controller(mxsfb); + clk_disable_unprepare(mxsfb->clk); if (mxsfb->clk_disp_axi) clk_disable_unprepare(mxsfb->clk_disp_axi); @@ -354,6 +363,9 @@ static void mxsfb_crtc_atomic_enable(struct drm_crtc *crtc, u32 bus_format = 0; dma_addr_t dma_addr; + if (mxsfb->enabled) + _mxsfb_disable_controller(mxsfb); + pm_runtime_get_sync(drm->dev); mxsfb_enable_axi_clk(mxsfb);