dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH v1] drm/tegra: vic: Defer firmware loading until it is really needed
@ 2018-12-10 12:03 Dmitry Osipenko
  0 siblings, 0 replies; only message in thread
From: Dmitry Osipenko @ 2018-12-10 12:03 UTC (permalink / raw)
  To: Marcel Ziswiler, Mikko Perttunen, Thierry Reding; +Cc: linux-tegra, dri-devel

DRM driver fails to load if VIC firmware is missing, let's defer the
firmware loading until it is really needed. This eliminates the need
to have initrd with the firmware if DRM driver is compiled as built-in.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/gpu/drm/tegra/vic.c | 43 +++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c
index d47983deb1cf..efb75f290ff0 100644
--- a/drivers/gpu/drm/tegra/vic.c
+++ b/drivers/gpu/drm/tegra/vic.c
@@ -96,6 +96,34 @@ static int vic_runtime_suspend(struct device *dev)
 	return 0;
 }
 
+static int vic_load_firmware(struct vic *vic)
+{
+	struct host1x_client *client = &vic->client.base;
+	struct drm_device *dev = dev_get_drvdata(client->parent);
+	struct tegra_drm *tegra = dev->dev_private;
+	int err;
+
+	if (vic->falcon.data)
+		return 0;
+
+	vic->falcon.data = tegra;
+
+	err = falcon_read_firmware(&vic->falcon, vic->config->firmware);
+	if (err < 0)
+		goto err_cleanup;
+
+	err = falcon_load_firmware(&vic->falcon);
+	if (err < 0)
+		goto err_cleanup;
+
+	return 0;
+
+err_cleanup:
+	vic->falcon.data = NULL;
+
+	return err;
+}
+
 static int vic_boot(struct vic *vic)
 {
 	u32 fce_ucode_size, fce_bin_data_offset;
@@ -105,6 +133,10 @@ static int vic_boot(struct vic *vic)
 	if (vic->booted)
 		return 0;
 
+	err = vic_load_firmware(vic);
+	if (err < 0)
+		return err;
+
 	/* setup clockgating registers */
 	vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) |
 			CG_IDLE_CG_EN |
@@ -181,13 +213,6 @@ static int vic_init(struct host1x_client *client)
 		vic->domain = tegra->domain;
 	}
 
-	if (!vic->falcon.data) {
-		vic->falcon.data = tegra;
-		err = falcon_load_firmware(&vic->falcon);
-		if (err < 0)
-			goto detach;
-	}
-
 	vic->channel = host1x_channel_request(client->dev);
 	if (!vic->channel) {
 		err = -ENOMEM;
@@ -372,10 +397,6 @@ static int vic_probe(struct platform_device *pdev)
 	if (err < 0)
 		return err;
 
-	err = falcon_read_firmware(&vic->falcon, vic->config->firmware);
-	if (err < 0)
-		goto exit_falcon;
-
 	platform_set_drvdata(pdev, vic);
 
 	INIT_LIST_HEAD(&vic->client.base.list);
-- 
2.19.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-12-10 12:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-10 12:03 [RFC PATCH v1] drm/tegra: vic: Defer firmware loading until it is really needed Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox