lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1418226513-14105-14-git-send-email-a.hajda@samsung.com>
Date:	Wed, 10 Dec 2014 16:48:31 +0100
From:	Andrzej Hajda <a.hajda@...sung.com>
To:	linux-kernel@...r.kernel.org (open list)
Cc:	Andrzej Hajda <a.hajda@...sung.com>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Mike Turquette <mturquette@...aro.org>,
	Russell King <linux@....linux.org.uk>,
	Linus Walleij <linus.walleij@...aro.org>,
	Alexandre Courbot <gnurou@...il.com>,
	Thierry Reding <thierry.reding@...il.com>,
	Inki Dae <inki.dae@...sung.com>,
	Kishon Vijay Abraham I <kishon@...com>,
	Liam Girdwood <lgirdwood@...il.com>,
	Mark Brown <broonie@...nel.org>,
	Grant Likely <grant.likely@...aro.org>,
	Rob Herring <robh+dt@...nel.org>,
	linux-arm-kernel@...ts.infradead.org (moderated list:ARM/CLKDEV SUPPORT),
	linux-gpio@...r.kernel.org (open list:GPIO SUBSYSTEM),
	dri-devel@...ts.freedesktop.org (open list:DRM PANEL DRIVERS),
	linux-samsung-soc@...r.kernel.org (moderated list:ARM/S5P EXYNOS AR...),
	devicetree@...r.kernel.org (open list:OPEN FIRMWARE AND...),
	boris.brezillon@...e-electrons.com
Subject: [RFC 13/15] drm/exynos/dpi: convert to restrack API

exynos_dpi implements drm encoder and connector. Currently its probe
was defered if the associated panel was not yet present. It is inefficient
behavior - it could start normally with connector status set to disconnected
and notify drm about status change when panel appears/disapeears.
Unfortunately drm_panel API does not provide such notifications.
restrack solves the issue above.
After converting to restrack driver have following advantages:
- correctly handles removal of resources,
- do not need to defer probing, so as a result the whole drm system
  initialization will not be postponed to late initcall, unless other
  components delays it,
- it starts/stops tracking panel presence only when necessary.

Signed-off-by: Andrzej Hajda <a.hajda@...sung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_dpi.c  | 80 +++++++++++++++++++++++---------
 drivers/gpu/drm/exynos/exynos_drm_fimd.c |  7 +++
 2 files changed, 64 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
index 91a29e1..75ee578 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c
@@ -13,9 +13,9 @@
 #include <drm/drmP.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_panel.h>
-
 #include <linux/of_graph.h>
 #include <linux/regulator/consumer.h>
+#include <linux/restrack.h>
 
 #include <video/of_videomode.h>
 #include <video/videomode.h>
@@ -34,7 +34,6 @@ enum {
 struct exynos_dpi {
 	struct exynos_drm_display display;
 	struct device *dev;
-	struct device_node *panel_node;
 
 	struct drm_panel *panel;
 	struct drm_connector connector;
@@ -42,10 +41,13 @@ struct exynos_dpi {
 
 	struct videomode *vm;
 	int dpms_mode;
+	struct restrack_ctx *rtrack;
 };
 
 #define connector_to_dpi(c) container_of(c, struct exynos_dpi, connector)
 
+struct exynos_drm_display *fimd_dev_to_display(struct device *dev);
+
 static inline struct exynos_dpi *display_to_dpi(struct exynos_drm_display *d)
 {
 	return container_of(d, struct exynos_dpi, display);
@@ -56,14 +58,18 @@ exynos_dpi_detect(struct drm_connector *connector, bool force)
 {
 	struct exynos_dpi *ctx = connector_to_dpi(connector);
 
-	if (ctx->panel && !ctx->panel->connector)
-		drm_panel_attach(ctx->panel, &ctx->connector);
+	if (!ctx->vm && IS_ERR(ctx->panel))
+		return connector_status_disconnected;
 
 	return connector_status_connected;
 }
 
 static void exynos_dpi_connector_destroy(struct drm_connector *connector)
 {
+	struct exynos_dpi *ctx = connector_to_dpi(connector);
+
+	if (!IS_ERR(ctx->rtrack))
+		restrack_unregister(ctx->rtrack);
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
 }
@@ -94,7 +100,7 @@ static int exynos_dpi_get_modes(struct drm_connector *connector)
 		return 1;
 	}
 
-	if (ctx->panel)
+	if (!IS_ERR(ctx->panel))
 		return ctx->panel->funcs->get_modes(ctx->panel);
 
 	return 0;
@@ -113,6 +119,38 @@ static struct drm_connector_helper_funcs exynos_dpi_connector_helper_funcs = {
 	.best_encoder = exynos_dpi_best_encoder,
 };
 
+static void exynos_dpi_dpms(struct exynos_drm_display *display, int mode);
+
+void exynos_dpi_notifier(struct device *dev, int ret)
+{
+	struct exynos_drm_display *display = fimd_dev_to_display(dev);
+	struct exynos_dpi *ctx = display_to_dpi(display);
+	struct drm_connector *connector = &ctx->connector;
+	struct drm_device *drm_dev = connector->dev;
+	bool poll_enabled = drm_dev->mode_config.poll_enabled;
+
+	mutex_lock(&drm_dev->mode_config.mutex);
+
+	if (ret == 0) {
+		drm_panel_attach(ctx->panel, connector);
+	} else if (ret == -EPROBE_DEFER) {
+		exynos_dpi_dpms(&ctx->display, DRM_MODE_DPMS_OFF);
+		drm_panel_detach(ctx->panel);
+		ctx->panel = ERR_PTR(-EPROBE_DEFER);
+	} else {
+		dev_err(dev, "restrack error %d\n", ret);
+		poll_enabled = false;
+	}
+
+	if (poll_enabled)
+		connector->status = exynos_dpi_detect(connector, true);
+
+	mutex_unlock(&drm_dev->mode_config.mutex);
+
+	if (poll_enabled)
+		drm_kms_helper_hotplug_event(drm_dev);
+}
+
 static int exynos_dpi_create_connector(struct exynos_drm_display *display,
 				       struct drm_encoder *encoder)
 {
@@ -136,12 +174,23 @@ static int exynos_dpi_create_connector(struct exynos_drm_display *display,
 	drm_connector_register(connector);
 	drm_mode_connector_attach_encoder(connector, encoder);
 
+	if (ctx->vm)
+		return 0;
+
+	ctx->rtrack = restrack_register(ctx->dev, exynos_dpi_notifier,
+		drm_panel_restrack_desc(&ctx->panel, NULL, FIMD_PORT_RGB)
+	);
+
+	if (IS_ERR(ctx->rtrack))
+		DRM_ERROR("error installing panel tracker: %ld\n",
+			  PTR_ERR(ctx->rtrack));
+
 	return 0;
 }
 
 static void exynos_dpi_poweron(struct exynos_dpi *ctx)
 {
-	if (ctx->panel) {
+	if (!IS_ERR(ctx->panel)) {
 		drm_panel_prepare(ctx->panel);
 		drm_panel_enable(ctx->panel);
 	}
@@ -149,7 +198,7 @@ static void exynos_dpi_poweron(struct exynos_dpi *ctx)
 
 static void exynos_dpi_poweroff(struct exynos_dpi *ctx)
 {
-	if (ctx->panel) {
+	if (!IS_ERR(ctx->panel)) {
 		drm_panel_disable(ctx->panel);
 		drm_panel_unprepare(ctx->panel);
 	}
@@ -217,10 +266,9 @@ static int exynos_dpi_parse_dt(struct exynos_dpi *ctx)
 		if (ep.port != FIMD_PORT_RGB)
 			continue;
 
-		ctx->panel_node = of_graph_get_remote_port_parent(np);
 		of_node_put(np);
 
-		return ctx->panel_node ? 0 : -EINVAL;
+		return 0;
 	}
 
 	return -EINVAL;
@@ -252,15 +300,6 @@ struct exynos_drm_display *exynos_dpi_probe(struct device *dev)
 		goto err_del_component;
 	}
 
-	if (ctx->panel_node) {
-		ctx->panel = of_drm_find_panel(ctx->panel_node);
-		if (!ctx->panel) {
-			exynos_drm_component_del(dev,
-						EXYNOS_DEVICE_TYPE_CONNECTOR);
-			return ERR_PTR(-EPROBE_DEFER);
-		}
-	}
-
 	return &ctx->display;
 
 err_del_component:
@@ -273,11 +312,6 @@ int exynos_dpi_remove(struct exynos_drm_display *display)
 {
 	struct exynos_dpi *ctx = display_to_dpi(display);
 
-	exynos_dpi_dpms(&ctx->display, DRM_MODE_DPMS_OFF);
-
-	if (ctx->panel)
-		drm_panel_detach(ctx->panel);
-
 	exynos_drm_component_del(ctx->dev, EXYNOS_DEVICE_TYPE_CONNECTOR);
 
 	return 0;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index e5810d1..05cf4e2 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -190,6 +190,13 @@ static inline struct fimd_context *mgr_to_fimd(struct exynos_drm_manager *mgr)
 	return container_of(mgr, struct fimd_context, manager);
 }
 
+struct exynos_drm_display *fimd_dev_to_display(struct device *dev)
+{
+	struct fimd_context *ctx = dev_get_drvdata(dev);
+
+	return ctx->display;
+}
+
 static const struct of_device_id fimd_driver_dt_match[] = {
 	{ .compatible = "samsung,s3c6400-fimd",
 	  .data = &s3c64xx_fimd_driver_data },
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ