dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: David Airlie <airlied@linux.ie>, James Jones <jajones@nvidia.com>,
	dri-devel@lists.freedesktop.org,
	Thomas Zimmermann <tzimmermann@suse.de>,
	linux-tegra@vger.kernel.org, Dmitry Osipenko <digetx@gmail.com>
Subject: [PATCH v2 08/10] gpu: host1x: Add early init and late exit callbacks
Date: Fri, 26 Mar 2021 15:51:37 +0100	[thread overview]
Message-ID: <20210326145139.467072-9-thierry.reding@gmail.com> (raw)
In-Reply-To: <20210326145139.467072-1-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

These callbacks can be used by client drivers to run code during early
init and during late exit. Early init callbacks are run prior to the
regular init callbacks while late exit callbacks run after the regular
exit callbacks.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/host1x/bus.c | 31 +++++++++++++++++++++++++++++++
 include/linux/host1x.h   |  2 ++
 2 files changed, 33 insertions(+)

diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 4c18874f7c4a..c9077cfbfef9 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -196,6 +196,17 @@ int host1x_device_init(struct host1x_device *device)
 
 	mutex_lock(&device->clients_lock);
 
+	list_for_each_entry(client, &device->clients, list) {
+		if (client->ops && client->ops->early_init) {
+			err = client->ops->early_init(client);
+			if (err < 0) {
+				dev_err(&device->dev, "failed to early initialize %s: %d\n",
+					dev_name(client->dev), err);
+				goto teardown_late;
+			}
+		}
+	}
+
 	list_for_each_entry(client, &device->clients, list) {
 		if (client->ops && client->ops->init) {
 			err = client->ops->init(client);
@@ -217,6 +228,14 @@ int host1x_device_init(struct host1x_device *device)
 		if (client->ops->exit)
 			client->ops->exit(client);
 
+	/* reset client to end of list for late teardown */
+	client = list_entry(&device->clients, struct host1x_client, list);
+
+teardown_late:
+	list_for_each_entry_continue_reverse(client, &device->clients, list)
+		if (client->ops->late_exit)
+			client->ops->late_exit(client);
+
 	mutex_unlock(&device->clients_lock);
 	return err;
 }
@@ -251,6 +270,18 @@ int host1x_device_exit(struct host1x_device *device)
 		}
 	}
 
+	list_for_each_entry_reverse(client, &device->clients, list) {
+		if (client->ops && client->ops->late_exit) {
+			err = client->ops->late_exit(client);
+			if (err < 0) {
+				dev_err(&device->dev, "failed to late cleanup %s: %d\n",
+					dev_name(client->dev), err);
+				mutex_unlock(&device->clients_lock);
+				return err;
+			}
+		}
+	}
+
 	mutex_unlock(&device->clients_lock);
 
 	return 0;
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index 5890f91dd286..74970681ecdb 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -31,8 +31,10 @@ u64 host1x_get_dma_mask(struct host1x *host1x);
  * @resume: host1x client resume code
  */
 struct host1x_client_ops {
+	int (*early_init)(struct host1x_client *client);
 	int (*init)(struct host1x_client *client);
 	int (*exit)(struct host1x_client *client);
+	int (*late_exit)(struct host1x_client *client);
 	int (*suspend)(struct host1x_client *client);
 	int (*resume)(struct host1x_client *client);
 };
-- 
2.30.2

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

  parent reply	other threads:[~2021-03-26 14:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-26 14:51 [PATCH v2 00/10] drm/tegra: Various improvements Thierry Reding
2021-03-26 14:51 ` [PATCH v2 01/10] drm/fourcc: Add macros to determine the modifier vendor Thierry Reding
2021-03-26 14:54   ` Simon Ser
2021-03-26 16:29     ` Thierry Reding
2021-04-27 18:40       ` Daniel Stone
2021-06-09 16:28         ` Daniel Stone
2021-06-10  8:58           ` Thierry Reding
2021-06-10 10:00             ` Daniel Stone
2021-03-26 14:51 ` [PATCH v2 02/10] drm/arm: malidp: Use fourcc_mod_is_vendor() helper Thierry Reding
2021-06-09 18:27   ` Daniel Vetter
2021-03-26 14:51 ` [PATCH v2 03/10] drm/tegra: dc: Inherit DMA mask Thierry Reding
2021-03-26 14:51 ` [PATCH v2 04/10] drm/tegra: dc: Parameterize maximum resolution Thierry Reding
2021-03-26 14:51 ` [PATCH v2 05/10] drm/tegra: dc: Implement hardware cursor on Tegra186 and later Thierry Reding
2021-03-26 15:58   ` Dmitry Osipenko
2021-03-26 14:51 ` [PATCH v2 06/10] drm/tegra: fb: Add diagnostics for framebuffer modifiers Thierry Reding
2021-03-26 14:51 ` [PATCH v2 07/10] drm/tegra: gem: Add a clarifying comment Thierry Reding
2021-03-26 14:51 ` Thierry Reding [this message]
2021-03-26 14:51 ` [PATCH v2 09/10] drm/tegra: Count number of display controllers at runtime Thierry Reding
2021-03-26 14:51 ` [PATCH v2 10/10] drm/tegra: Support sector layout on Tegra194 Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210326145139.467072-9-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=airlied@linux.ie \
    --cc=digetx@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jajones@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).