From nobody Mon Apr 6 09:10:40 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7407E30AD15 for ; Fri, 20 Mar 2026 15:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774021087; cv=none; b=QO5MVWVGleqIbiDzMyQhD+DtioyF1itNOzx8UrJsl39jHKskg5+n1DTew5iB6Md0KAh3C6uGp1BkFdB40hhmzvhePZ1w0xa4glajJ0aRaXENIVOy8Zi//kX7zueNEXlZQV1bbkQU6mhMng0chM/giJcKbS3wlPzaz9TrcbUIdYk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774021087; c=relaxed/simple; bh=4pE+jrwy4jUT3ssAt5lqIp6H+URkNBaRTvhbX8ZdWQE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uZs7Wi1azIPpbNBYxUqOokQBrX8hd5jiQnvE5beso2LH63j8rA+fc5V9RImDIclMRCf855ZLBT7Hgnbl5fv5prUNiOTgsNCOYeBu0cBXTcVMTcNLAnhSHTASEKR+iTY2zRiw/4gleb4c9FjAoCZRMKAjCaueSknFdKAO/FfrwB0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=b/xIDQTE; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b/xIDQTE" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4852afd42ceso15829985e9.2 for ; Fri, 20 Mar 2026 08:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774021083; x=1774625883; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LC8/Krjsz/8eMfvmK5q2jyfb9Doz50BbBIjca4omGxs=; b=b/xIDQTE0xkpk12ISv/NvwKtScoVtr9Z39tMr2RZyLuVVXhnZO9Ri6gMDXaZ/qxbnt hRI87uZV4u4VluqNxhTgFitPWnKEczCHQi+7+kdNYg56meyQotZbrY9vnv7seiUdFqBg L2LWdxteWPKvNPhXP5BiieY2wCoOEeS7usIL2VzqjbV2Ocr9tCur4NydWN74y/DpRGRI rkAmrDaeGDs8D5i+ZtyUQLtbICOLJ5EtC1+4qiBssU3E7ZT7avvpMEYeSIWghUBcA0W9 +Kl03mlcWPLWDaKlIi5eRukYyJhrq1/DKZ6pXJtfaDqlq/pr7GPb++zCHC8KyjSbQ7OR pFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774021083; x=1774625883; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LC8/Krjsz/8eMfvmK5q2jyfb9Doz50BbBIjca4omGxs=; b=MhyT49idzsj9tg11MuZl/Apqkjta5+VfwtAFNFYMwsJB58zPLG9y1jV/+5CnnSUS9a rvSKwyGAQYkyBLGo1O+Z4WpBkiBbyb3Qv8AQTsMW5tDr2whJSAmQAQUIf8Ib8EXCltlk dyW0pVRaXh94wQvw5bUcuAbn4V5dqRc/xEtdUxr17AReX4dcwwoZptyKuhkhhcvuFQgc fBiPP4izbr6MXxrpgE2hzTAElPfb8X5wrX/OS9+sHDHkv+Z8qoPQB7Hiqkef3FuA4qyt ZhImHGmmHlbjfbfpfehAwG6nkZcWGjxsDgz945bdlTk3cwyW7Ix9Vb9vN0DkRKz1u4I0 2j7w== X-Forwarded-Encrypted: i=1; AJvYcCXPSBb3Q0txww2R0tjDHFQ3Y9eLLVx5Mda+eQbITWGQCz5DovWHr4YUU5itW+TDT7LeJxKegp1uIR8StOk=@vger.kernel.org X-Gm-Message-State: AOJu0Yzxh+QlGkjSyWubfI6/TBw/S/kP1q9Y8rJnuWukLj/a3KgsiNDF P3wVRit7n3g+T9na0PZETasyC2FriuMpEcMCf6mxnEcpocm7t4Rb2vHi X-Gm-Gg: ATEYQzz6fd5WZlskCZFlrjYy5Z9bPWkKlGGK4kTz/jVIENR6akNWTcKmg57W1+BdXfs 3zlHrH9maomrMXzWf2a2YR+tUjVyKhoKDruz2sxdny4STEaA95m4BCdZOHpYIxcgLMxGQgqVEs2 Qrajc1axTLBQq3B9P3n8oMDsVPHNc4pRR1pgkcJaqrh9Ec6CRFsG4PyPbv2WzVgGjbjR8H11Qgn o/U+D1Su4d2Dww70SebAFjwBcks67efNT4A2eJ4y0wm7PrLCQ4h1oSupgN066qMODW561yiNmeS jQcznyKS8lJDugGSFVJxNUnCQqr19Q0SRlv9pPLnSz7c6xuGqg4kdGFPSsG/v4eNufJj8tO/4Qf e0Ct1n84NEbL5/PHYdZizSCqhO9B4ltgHtr4hBDPEV6Tf3YHMNUs+B9CGrwYqmWi/mYnpRF4vf9 xk8KA2edx2FtN0TdV1fOY= X-Received: by 2002:a05:600c:8508:b0:485:3b00:f92e with SMTP id 5b1f17b1804b1-486fedab7dbmr51111835e9.2.1774021082580; Fri, 20 Mar 2026 08:38:02 -0700 (PDT) Received: from luca-vm.lan ([154.61.61.58]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486ff19d387sm18532675e9.17.2026.03.20.08.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 08:38:01 -0700 (PDT) From: Luca Leonardo Scorcia To: dri-devel@lists.freedesktop.org Cc: Luca Leonardo Scorcia , AngeloGioacchino Del Regno , CK Hu , Chun-Kuang Hu , Philipp Zabel , David Airlie , Simona Vetter , Matthias Brugger , Alexandre Mergnat , linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 RESEND] drm/mediatek: dsi: Store driver data before invoking mipi_dsi_host_register Date: Fri, 20 Mar 2026 15:37:37 +0000 Message-ID: <20260320153753.25450-1-l.scorcia@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The call to mipi_dsi_host_register triggers a callback to mtk_dsi_bind, which uses dev_get_drvdata to retrieve the mtk_dsi struct, so this structure needs to be stored inside the driver data before invoking it. As drvdata is currently uninitialized it leads to a crash when registering the DSI DRM encoder right after acquiring the mode_config.idr_mutex, blocking all subsequent DRM operations. Fixes the following crash during mediatek-drm probe (tested on Xiaomi Smart Clock x04g): Unable to handle kernel NULL pointer dereference at virtual address 0000000000000040 [...] Modules linked in: mediatek_drm(+) drm_display_helper cec drm_client_lib drm_dma_helper drm_kms_helper panel_simple [...] Call trace: drm_mode_object_add+0x58/0x98 (P) __drm_encoder_init+0x48/0x140 drm_encoder_init+0x6c/0xa0 drm_simple_encoder_init+0x20/0x34 [drm_kms_helper] mtk_dsi_bind+0x34/0x13c [mediatek_drm] component_bind_all+0x120/0x280 mtk_drm_bind+0x284/0x67c [mediatek_drm] try_to_bring_up_aggregate_device+0x23c/0x320 __component_add+0xa4/0x198 component_add+0x14/0x20 mtk_dsi_host_attach+0x78/0x100 [mediatek_drm] mipi_dsi_attach+0x2c/0x50 panel_simple_dsi_probe+0x4c/0x9c [panel_simple] mipi_dsi_drv_probe+0x1c/0x28 really_probe+0xc0/0x3dc __driver_probe_device+0x80/0x160 driver_probe_device+0x40/0x120 __device_attach_driver+0xbc/0x17c bus_for_each_drv+0x88/0xf0 __device_attach+0x9c/0x1cc device_initial_probe+0x54/0x60 bus_probe_device+0x34/0xa0 device_add+0x5b0/0x800 mipi_dsi_device_register_full+0xdc/0x16c mipi_dsi_host_register+0xc4/0x17c mtk_dsi_probe+0x10c/0x260 [mediatek_drm] platform_probe+0x5c/0xa4 really_probe+0xc0/0x3dc __driver_probe_device+0x80/0x160 driver_probe_device+0x40/0x120 __driver_attach+0xc8/0x1f8 bus_for_each_dev+0x7c/0xe0 driver_attach+0x24/0x30 bus_add_driver+0x11c/0x240 driver_register+0x68/0x130 __platform_register_drivers+0x64/0x160 mtk_drm_init+0x24/0x1000 [mediatek_drm] do_one_initcall+0x60/0x1d0 do_init_module+0x54/0x240 load_module+0x1838/0x1dc0 init_module_from_file+0xd8/0xf0 __arm64_sys_finit_module+0x1b4/0x428 invoke_syscall.constprop.0+0x48/0xc8 do_el0_svc+0x3c/0xb8 el0_svc+0x34/0xe8 el0t_64_sync_handler+0xa0/0xe4 el0t_64_sync+0x198/0x19c Code: 52800022 941004ab 2a0003f3 37f80040 (29005a80) Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: CK Hu ---[ end trace 0000000000000000 ]--- Fixes: e4732b590a77 ("drm/mediatek: dsi: Register DSI host after acquiring = clocks and PHY") Signed-off-by: Luca Leonardo Scorcia Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: CK Hu --- v3: Also initialize irq_wait_queue before calling platform_set_drvdata v2: Added Fixes tag drivers/gpu/drm/mediatek/mtk_dsi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/= mtk_dsi.c index d7726091819c..acee2227275b 100644 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c @@ -1232,6 +1232,11 @@ static int mtk_dsi_probe(struct platform_device *pde= v) =20 dsi->host.ops =3D &mtk_dsi_ops; dsi->host.dev =3D dev; + + init_waitqueue_head(&dsi->irq_wait_queue); + + platform_set_drvdata(pdev, dsi); + ret =3D mipi_dsi_host_register(&dsi->host); if (ret < 0) return dev_err_probe(dev, ret, "Failed to register DSI host\n"); @@ -1243,10 +1248,6 @@ static int mtk_dsi_probe(struct platform_device *pde= v) return dev_err_probe(&pdev->dev, ret, "Failed to request DSI irq\n"); } =20 - init_waitqueue_head(&dsi->irq_wait_queue); - - platform_set_drvdata(pdev, dsi); - dsi->bridge.of_node =3D dev->of_node; dsi->bridge.type =3D DRM_MODE_CONNECTOR_DSI; =20 --=20 2.43.0