gpu: host1x: Stop CDMA before suspending
authorMikko Perttunen <mperttunen@nvidia.com>
Fri, 1 Sep 2023 11:15:08 +0000 (14:15 +0300)
committerThierry Reding <treding@nvidia.com>
Wed, 11 Oct 2023 20:52:44 +0000 (22:52 +0200)
Before going into suspend, wait all CDMA to go idle and stop it.
This will ensure no channel is still active while we enter
suspend, and ensures the driver doesn't think that CDMA is still
active when coming back from suspend (as HW state has been reset).

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230901111510.663401-2-cyndis@kapsi.fi
drivers/gpu/host1x/channel.c
drivers/gpu/host1x/channel.h
drivers/gpu/host1x/dev.c

index 79501c9575321cdf9bb12ee63a8bec553663bab2..08077afe4cde26796456b22e41bd044d962bbfe3 100644 (file)
@@ -81,6 +81,25 @@ void host1x_channel_stop(struct host1x_channel *channel)
 }
 EXPORT_SYMBOL(host1x_channel_stop);
 
+/**
+ * host1x_channel_stop_all() - disable CDMA on allocated channels
+ * @host: host1x instance
+ *
+ * Stop CDMA on allocated channels
+ */
+void host1x_channel_stop_all(struct host1x *host)
+{
+       struct host1x_channel_list *chlist = &host->channel_list;
+       int bit;
+
+       mutex_lock(&chlist->lock);
+
+       for_each_set_bit(bit, chlist->allocated_channels, host->info->nb_channels)
+               host1x_channel_stop(&chlist->channels[bit]);
+
+       mutex_unlock(&chlist->lock);
+}
+
 static void release_channel(struct kref *kref)
 {
        struct host1x_channel *channel =
index b23a8071fbd02e1eabd965af67afb01b6f60df9e..d7aede204d83d6105e48371dbd97de1b286404be 100644 (file)
@@ -40,5 +40,6 @@ int host1x_channel_list_init(struct host1x_channel_list *chlist,
 void host1x_channel_list_free(struct host1x_channel_list *chlist);
 struct host1x_channel *host1x_channel_get_index(struct host1x *host,
                                                unsigned int index);
+void host1x_channel_stop_all(struct host1x *host);
 
 #endif
index 7c6699aed7d2ae48401f6614203a95062d8ebbb7..6501bee9e8c1a3e4e2a61af4f3b7bbbe8693d998 100644 (file)
@@ -655,6 +655,7 @@ static int __maybe_unused host1x_runtime_suspend(struct device *dev)
        struct host1x *host = dev_get_drvdata(dev);
        int err;
 
+       host1x_channel_stop_all(host);
        host1x_intr_stop(host);
        host1x_syncpt_save(host);