From nobody Wed Oct 8 17:29:51 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7751121B185 for ; Thu, 26 Jun 2025 10:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750932321; cv=none; b=X5yyt1xMzPk0fMEeaXyeUDIVFGPFPfhTf1cjnmcrovR/pEhoaBPqHzOn8Q+BfjHciUah+Oi1jVjR5ZNYAhc+I5fImD7SXVsxY9n+G4V+w2Hv+GX19up7jDQ6HagDmHMePJvXDiIh31aMpVLG03rqlM+M1IMRjX9ddZVQv28+8Ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750932321; c=relaxed/simple; bh=jbRXkk0hjIDPPWjYuxAm63dXMqfFIrrPdpEYXFXsa9M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uPI7AtllCscQFtKXWCLfDlmncUujw26MNN1ybMSxKSonN/1R+np7rCMFtyn2hTsBb6hvN1FqNVux92YW3Vj7tmKeARrffAbeJMKMO0S8axFBDN11xyTbq4i8ZUXSIiuAKeATExJSEjiec6CLwzn0uSgDahExRXj7PGmFhxqRTQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ohmjphWj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ohmjphWj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD2EBC4CEEB; Thu, 26 Jun 2025 10:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750932320; bh=jbRXkk0hjIDPPWjYuxAm63dXMqfFIrrPdpEYXFXsa9M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ohmjphWj3P1xuIYPxYPqL2IeLt3i+DXuplSSTbggaXEOo6ePZSfAjyik2cjBI+wxy TlSkYkSE2ArTDXSI7S1F7aUx1Rsig/BpliW0h1Bm8PVczxt4/GNh8YaGxJS8EFRlFT 6l4tqmgLfNBCifHA9O9FAiL7IXJynhZm7LJBWsIg+hD8AxOPKq3idjvkRNY/vUpUwW NhOUsZ1Ke+DAP/C+17S+DnFtAot0aKWH+xC87HJTMl8S0ZnNHoKlS5E9+SbmSOQYlC FlEgnZ7LZkJpsJOSLLINHdGhjMI01oewwPx3a6ZVHc6GDJKzYnnqop+4C5iAoSbvYe 67dY96OU64qbw== From: Maxime Ripard Date: Thu, 26 Jun 2025 12:05:02 +0200 Subject: [PATCH v2 4/5] drm/panel: panel-simple: Add function to look panel data up Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250626-drm-panel-simple-fixes-v2-4-5afcaa608bdc@kernel.org> References: <20250626-drm-panel-simple-fixes-v2-0-5afcaa608bdc@kernel.org> In-Reply-To: <20250626-drm-panel-simple-fixes-v2-0-5afcaa608bdc@kernel.org> To: Neil Armstrong , Jessica Zhang , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Simona Vetter , Luca Ceresoli , Anusha Srivatsa , Francesco Dolcini Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Maxime Ripard X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6328; i=mripard@kernel.org; h=from:subject:message-id; bh=jbRXkk0hjIDPPWjYuxAm63dXMqfFIrrPdpEYXFXsa9M=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDBmx0oHMz1tLHVMLJ/nJlb0NZfNTVwhdIcdwJE2ywH0n9 4Zm31sdU1kYhDkZZMUUWZ7IhJ1e3r64ysF+5Q+YOaxMIEMYuDgFYCLz2Rnro28u9r5ZKX8za5f9 lUNZ743fd614b6t6J2jvQf/I8zZnk+/siHE97qXo9kb3fFkRx7R4xjp7zdoXvde2PAp+PScu0sX I+tWasijHH4frtmqzaa16fOLuJ1c+nurQzw+3SCYo3X7zQRkA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Commit de04bb0089a9 ("drm/panel/panel-simple: Use the new allocation in place of devm_kzalloc()") moved the call to drm_panel_init into the devm_drm_panel_alloc(), which needs a connector type to initialize properly. In the panel-dpi compatible case, the passed panel_desc structure is an empty one used as a discriminant, and the connector type it contains isn't actually initialized. It is initialized through a call to panel_dpi_probe() later in the function, which used to be before the call to drm_panel_init() that got merged into devm_drm_panel_alloc(). So, we do need a proper panel_desc pointer before the call to devm_drm_panel_alloc() now. All cases associate their panel_desc with the panel compatible and use of_device_get_match_data, except for the panel-dpi compatible. In that case, we're expected to call panel_dpi_probe, which will allocate and initialize the panel_desc for us. Let's create such a helper function that would be called first in the driver and will lookup the desc by compatible, or allocate one if relevant. Reported-by: Francesco Dolcini Closes: https://lore.kernel.org/all/20250612081834.GA248237@francesco-nb/ Fixes: de04bb0089a9 ("drm/panel/panel-simple: Use the new allocation in pla= ce of devm_kzalloc()") Signed-off-by: Maxime Ripard Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/panel/panel-simple.c | 82 +++++++++++++++++++++-----------= ---- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/p= anel-simple.c index e70ee2d4a538caaae673507b93e02b444a2e1640..4c831af86414aba6a6b44dbc602= 0c0268dbd78b7 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -24,10 +24,11 @@ #include #include #include #include #include +#include #include #include #include #include =20 @@ -134,10 +135,18 @@ struct panel_desc { =20 /** @connector_type: LVDS, eDP, DSI, DPI, etc. */ int connector_type; }; =20 +struct panel_desc_dsi { + struct panel_desc desc; + + unsigned long flags; + enum mipi_dsi_pixel_format format; + unsigned int lanes; +}; + struct panel_simple { struct drm_panel base; =20 ktime_t unprepared_time; =20 @@ -565,19 +574,53 @@ static int panel_simple_override_nondefault_lvds_data= mapping(struct device *dev, } =20 return 0; } =20 -static struct panel_simple *panel_simple_probe(struct device *dev, const s= truct panel_desc *desc) +static const struct panel_desc *panel_simple_get_desc(struct device *dev) { + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI) && + dev_is_mipi_dsi(dev)) { + const struct panel_desc_dsi *dsi_desc; + + dsi_desc =3D of_device_get_match_data(dev); + if (!dsi_desc) + return ERR_PTR(-ENODEV); + + return &dsi_desc->desc; + } + + if (dev_is_platform(dev)) { + const struct panel_desc *desc; + + desc =3D of_device_get_match_data(dev); + if (!desc) + return ERR_PTR(-ENODEV); + + if (desc =3D=3D &panel_dpi) + return panel_dpi_probe(dev); + + return desc; + } + + return ERR_PTR(-ENODEV); +} + +static struct panel_simple *panel_simple_probe(struct device *dev) +{ + const struct panel_desc *desc; struct panel_simple *panel; struct display_timing dt; struct device_node *ddc; int connector_type; u32 bus_flags; int err; =20 + desc =3D panel_simple_get_desc(dev); + if (IS_ERR(desc)) + return ERR_CAST(desc); + panel =3D devm_drm_panel_alloc(dev, struct panel_simple, base, &panel_simple_funcs, desc->connector_type); if (IS_ERR(panel)) return ERR_CAST(panel); =20 @@ -606,23 +649,13 @@ static struct panel_simple *panel_simple_probe(struct= device *dev, const struct =20 if (!panel->ddc) return ERR_PTR(-EPROBE_DEFER); } =20 - if (desc =3D=3D &panel_dpi) { - /* Handle the generic panel-dpi binding */ - desc =3D panel_dpi_probe(dev); - if (IS_ERR(desc)) { - err =3D PTR_ERR(desc); - goto free_ddc; - } - - panel->desc =3D desc; - } else { - if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) - panel_simple_parse_panel_timing_node(dev, panel, &dt); - } + if ((desc !=3D &panel_dpi) && + !of_get_display_timing(dev->of_node, "panel-timing", &dt)) + panel_simple_parse_panel_timing_node(dev, panel, &dt); =20 if (desc->connector_type =3D=3D DRM_MODE_CONNECTOR_LVDS) { /* Optional data-mapping property for overriding bus format */ err =3D panel_simple_override_nondefault_lvds_datamapping(dev, panel); if (err) @@ -5374,18 +5407,13 @@ static const struct of_device_id platform_of_match[= ] =3D { }; MODULE_DEVICE_TABLE(of, platform_of_match); =20 static int panel_simple_platform_probe(struct platform_device *pdev) { - const struct panel_desc *desc; struct panel_simple *panel; =20 - desc =3D of_device_get_match_data(&pdev->dev); - if (!desc) - return -ENODEV; - - panel =3D panel_simple_probe(&pdev->dev, desc); + panel =3D panel_simple_probe(&pdev->dev); if (IS_ERR(panel)) return PTR_ERR(panel); =20 return 0; } @@ -5415,18 +5443,10 @@ static struct platform_driver panel_simple_platform= _driver =3D { .probe =3D panel_simple_platform_probe, .remove =3D panel_simple_platform_remove, .shutdown =3D panel_simple_platform_shutdown, }; =20 -struct panel_desc_dsi { - struct panel_desc desc; - - unsigned long flags; - enum mipi_dsi_pixel_format format; - unsigned int lanes; -}; - static const struct drm_display_mode auo_b080uan01_mode =3D { .clock =3D 154500, .hdisplay =3D 1200, .hsync_start =3D 1200 + 62, .hsync_end =3D 1200 + 62 + 4, @@ -5659,15 +5679,11 @@ static int panel_simple_dsi_probe(struct mipi_dsi_d= evice *dsi) { const struct panel_desc_dsi *desc; struct panel_simple *panel; int err; =20 - desc =3D of_device_get_match_data(&dsi->dev); - if (!desc) - return -ENODEV; - - panel =3D panel_simple_probe(&dsi->dev, &desc->desc); + panel =3D panel_simple_probe(&dsi->dev); if (IS_ERR(panel)) return PTR_ERR(panel); =20 desc =3D container_of(panel->desc, struct panel_desc_dsi, desc); dsi->mode_flags =3D desc->flags; --=20 2.49.0