summaryrefslogtreecommitdiff
path: root/mali_kbase/tl
diff options
context:
space:
mode:
authorKevin DuBois <kevindubois@google.com>2022-11-02 21:39:17 +0000
committerKevin DuBois <kevindubois@google.com>2022-11-02 22:39:21 +0000
commit34e635317dc2a91076ac341df3867ac3bdb31ef1 (patch)
treecf1c0e597ce1e7dcd9b276ff4d51be60c7fdca58 /mali_kbase/tl
parent6dcd9736cbf84712dd7073dab4aea256e30517c2 (diff)
downloadgpu-34e635317dc2a91076ac341df3867ac3bdb31ef1.tar.gz
Revert "Merge r38p1 from upstream into partner/android13-gs-pixel-5.10-tm-qpr2"
This reverts commit 6dcd9736cbf84712dd7073dab4aea256e30517c2. Reason for revert: UMD taking too long to merge Bug: 228779790 Change-Id: I08b861ba3cfc8b025f653ef86b0a5ec643e5b13d
Diffstat (limited to 'mali_kbase/tl')
-rw-r--r--mali_kbase/tl/mali_kbase_timeline.c166
-rw-r--r--mali_kbase/tl/mali_kbase_timeline.h8
-rw-r--r--mali_kbase/tl/mali_kbase_timeline_io.c136
-rw-r--r--mali_kbase/tl/mali_kbase_timeline_priv.h27
-rw-r--r--mali_kbase/tl/mali_kbase_tracepoints.c4
-rw-r--r--mali_kbase/tl/mali_kbase_tracepoints.h4
6 files changed, 134 insertions, 211 deletions
diff --git a/mali_kbase/tl/mali_kbase_timeline.c b/mali_kbase/tl/mali_kbase_timeline.c
index 09de3f0..d656c03 100644
--- a/mali_kbase/tl/mali_kbase_timeline.c
+++ b/mali_kbase/tl/mali_kbase_timeline.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
/*
*
- * (C) COPYRIGHT 2015-2022 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2015-2021 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -26,6 +26,7 @@
#include <mali_kbase.h>
#include <mali_kbase_jm.h>
+#include <linux/anon_inodes.h>
#include <linux/atomic.h>
#include <linux/file.h>
#include <linux/mutex.h>
@@ -34,7 +35,7 @@
#include <linux/stringify.h>
#include <linux/timer.h>
#include <linux/wait.h>
-#include <linux/delay.h>
+
/* The period of autoflush checker execution in milliseconds. */
#define AUTOFLUSH_INTERVAL 1000 /* ms */
@@ -183,109 +184,90 @@ static void kbase_tlstream_current_devfreq_target(struct kbase_device *kbdev)
}
#endif /* CONFIG_MALI_DEVFREQ */
-int kbase_timeline_acquire(struct kbase_device *kbdev, u32 flags)
+int kbase_timeline_io_acquire(struct kbase_device *kbdev, u32 flags)
{
- int err = 0;
+ int ret = 0;
u32 timeline_flags = TLSTREAM_ENABLED | flags;
- struct kbase_timeline *timeline;
- int rcode;
-
- if (WARN_ON(!kbdev) || WARN_ON(flags & ~BASE_TLSTREAM_FLAGS_MASK))
- return -EINVAL;
-
- timeline = kbdev->timeline;
- if (WARN_ON(!timeline))
- return -EFAULT;
+ struct kbase_timeline *timeline = kbdev->timeline;
- if (atomic_cmpxchg(timeline->timeline_flags, 0, timeline_flags))
- return -EBUSY;
+ if (!atomic_cmpxchg(timeline->timeline_flags, 0, timeline_flags)) {
+ int rcode;
#if MALI_USE_CSF
- if (flags & BASE_TLSTREAM_ENABLE_CSFFW_TRACEPOINTS) {
- err = kbase_csf_tl_reader_start(&timeline->csf_tl_reader, kbdev);
- if (err) {
- atomic_set(timeline->timeline_flags, 0);
- return err;
+ if (flags & BASE_TLSTREAM_ENABLE_CSFFW_TRACEPOINTS) {
+ ret = kbase_csf_tl_reader_start(
+ &timeline->csf_tl_reader, kbdev);
+ if (ret) {
+ atomic_set(timeline->timeline_flags, 0);
+ return ret;
+ }
}
- }
#endif
+ ret = anon_inode_getfd(
+ "[mali_tlstream]",
+ &kbasep_tlstream_fops,
+ timeline,
+ O_RDONLY | O_CLOEXEC);
+ if (ret < 0) {
+ atomic_set(timeline->timeline_flags, 0);
+#if MALI_USE_CSF
+ kbase_csf_tl_reader_stop(&timeline->csf_tl_reader);
+#endif
+ return ret;
+ }
- /* Reset and initialize header streams. */
- kbase_tlstream_reset(&timeline->streams[TL_STREAM_TYPE_OBJ_SUMMARY]);
+ /* Reset and initialize header streams. */
+ kbase_tlstream_reset(
+ &timeline->streams[TL_STREAM_TYPE_OBJ_SUMMARY]);
- timeline->obj_header_btc = obj_desc_header_size;
- timeline->aux_header_btc = aux_desc_header_size;
+ timeline->obj_header_btc = obj_desc_header_size;
+ timeline->aux_header_btc = aux_desc_header_size;
#if !MALI_USE_CSF
- /* If job dumping is enabled, readjust the software event's
- * timeout as the default value of 3 seconds is often
- * insufficient.
- */
- if (flags & BASE_TLSTREAM_JOB_DUMPING_ENABLED) {
- dev_info(kbdev->dev,
- "Job dumping is enabled, readjusting the software event's timeout\n");
- atomic_set(&kbdev->js_data.soft_job_timeout_ms, 1800000);
- }
+ /* If job dumping is enabled, readjust the software event's
+ * timeout as the default value of 3 seconds is often
+ * insufficient.
+ */
+ if (flags & BASE_TLSTREAM_JOB_DUMPING_ENABLED) {
+ dev_info(kbdev->dev,
+ "Job dumping is enabled, readjusting the software event's timeout\n");
+ atomic_set(&kbdev->js_data.soft_job_timeout_ms,
+ 1800000);
+ }
#endif /* !MALI_USE_CSF */
- /* Summary stream was cleared during acquire.
- * Create static timeline objects that will be
- * read by client.
- */
- kbase_create_timeline_objects(kbdev);
+ /* Summary stream was cleared during acquire.
+ * Create static timeline objects that will be
+ * read by client.
+ */
+ kbase_create_timeline_objects(kbdev);
#ifdef CONFIG_MALI_DEVFREQ
- /* Devfreq target tracepoints are only fired when the target
- * changes, so we won't know the current target unless we
- * send it now.
- */
- kbase_tlstream_current_devfreq_target(kbdev);
+ /* Devfreq target tracepoints are only fired when the target
+ * changes, so we won't know the current target unless we
+ * send it now.
+ */
+ kbase_tlstream_current_devfreq_target(kbdev);
#endif /* CONFIG_MALI_DEVFREQ */
- /* Start the autoflush timer.
- * We must do this after creating timeline objects to ensure we
- * don't auto-flush the streams which will be reset during the
- * summarization process.
- */
- atomic_set(&timeline->autoflush_timer_active, 1);
- rcode = mod_timer(&timeline->autoflush_timer,
- jiffies + msecs_to_jiffies(AUTOFLUSH_INTERVAL));
- CSTD_UNUSED(rcode);
-
- timeline->last_acquire_time = ktime_get_raw();
-
- return err;
-}
-
-void kbase_timeline_release(struct kbase_timeline *timeline)
-{
- ktime_t elapsed_time;
- s64 elapsed_time_ms, time_to_sleep;
-
- if (WARN_ON(!timeline) || WARN_ON(!atomic_read(timeline->timeline_flags)))
- return;
-
- /* Get the amount of time passed since the timeline was acquired and ensure
- * we sleep for long enough such that it has been at least
- * TIMELINE_HYSTERESIS_TIMEOUT_MS amount of time between acquire and release.
- * This prevents userspace from spamming acquire and release too quickly.
- */
- elapsed_time = ktime_sub(ktime_get_raw(), timeline->last_acquire_time);
- elapsed_time_ms = ktime_to_ms(elapsed_time);
- time_to_sleep = (elapsed_time_ms < 0 ? TIMELINE_HYSTERESIS_TIMEOUT_MS :
- TIMELINE_HYSTERESIS_TIMEOUT_MS - elapsed_time_ms);
- if (time_to_sleep > 0)
- msleep_interruptible(time_to_sleep);
-
-#if MALI_USE_CSF
- kbase_csf_tl_reader_stop(&timeline->csf_tl_reader);
-#endif
+ /* Start the autoflush timer.
+ * We must do this after creating timeline objects to ensure we
+ * don't auto-flush the streams which will be reset during the
+ * summarization process.
+ */
+ atomic_set(&timeline->autoflush_timer_active, 1);
+ rcode = mod_timer(&timeline->autoflush_timer,
+ jiffies +
+ msecs_to_jiffies(AUTOFLUSH_INTERVAL));
+ CSTD_UNUSED(rcode);
+ } else {
+ ret = -EBUSY;
+ }
- /* Stop autoflush timer before releasing access to streams. */
- atomic_set(&timeline->autoflush_timer_active, 0);
- del_timer_sync(&timeline->autoflush_timer);
+ if (ret >= 0)
+ timeline->last_acquire_time = ktime_get();
- atomic_set(timeline->timeline_flags, 0);
+ return ret;
}
int kbase_timeline_streams_flush(struct kbase_timeline *timeline)
@@ -293,17 +275,11 @@ int kbase_timeline_streams_flush(struct kbase_timeline *timeline)
enum tl_stream_type stype;
bool has_bytes = false;
size_t nbytes = 0;
-
- if (WARN_ON(!timeline))
- return -EINVAL;
-
#if MALI_USE_CSF
- {
- int ret = kbase_csf_tl_reader_flush_buffer(&timeline->csf_tl_reader);
+ int ret = kbase_csf_tl_reader_flush_buffer(&timeline->csf_tl_reader);
- if (ret > 0)
- has_bytes = true;
- }
+ if (ret > 0)
+ has_bytes = true;
#endif
for (stype = 0; stype < TL_STREAM_TYPE_COUNT; stype++) {
diff --git a/mali_kbase/tl/mali_kbase_timeline.h b/mali_kbase/tl/mali_kbase_timeline.h
index 62be6c6..96a4b18 100644
--- a/mali_kbase/tl/mali_kbase_timeline.h
+++ b/mali_kbase/tl/mali_kbase_timeline.h
@@ -117,12 +117,4 @@ void kbase_timeline_post_kbase_context_destroy(struct kbase_context *kctx);
void kbase_timeline_stats(struct kbase_timeline *timeline, u32 *bytes_collected, u32 *bytes_generated);
#endif /* MALI_UNIT_TEST */
-/**
- * kbase_timeline_io_debugfs_init - Add a debugfs entry for reading timeline stream data
- *
- * @kbdev: An instance of the GPU platform device, allocated from the probe
- * method of the driver.
- */
-void kbase_timeline_io_debugfs_init(struct kbase_device *kbdev);
-
#endif /* _KBASE_TIMELINE_H */
diff --git a/mali_kbase/tl/mali_kbase_timeline_io.c b/mali_kbase/tl/mali_kbase_timeline_io.c
index 03178cc..3391e75 100644
--- a/mali_kbase/tl/mali_kbase_timeline_io.c
+++ b/mali_kbase/tl/mali_kbase_timeline_io.c
@@ -24,20 +24,27 @@
#include "mali_kbase_tracepoints.h"
#include "mali_kbase_timeline.h"
-#include <device/mali_kbase_device.h>
-
+#include <linux/delay.h>
#include <linux/poll.h>
-#include <linux/version_compat_defs.h>
-#include <linux/anon_inodes.h>
/* The timeline stream file operations functions. */
static ssize_t kbasep_timeline_io_read(struct file *filp, char __user *buffer,
size_t size, loff_t *f_pos);
-static __poll_t kbasep_timeline_io_poll(struct file *filp, poll_table *wait);
+static unsigned int kbasep_timeline_io_poll(struct file *filp,
+ poll_table *wait);
static int kbasep_timeline_io_release(struct inode *inode, struct file *filp);
static int kbasep_timeline_io_fsync(struct file *filp, loff_t start, loff_t end,
int datasync);
+/* The timeline stream file operations structure. */
+const struct file_operations kbasep_tlstream_fops = {
+ .owner = THIS_MODULE,
+ .release = kbasep_timeline_io_release,
+ .read = kbasep_timeline_io_read,
+ .poll = kbasep_timeline_io_poll,
+ .fsync = kbasep_timeline_io_fsync,
+};
+
/**
* kbasep_timeline_io_packet_pending - check timeline streams for pending
* packets
@@ -285,7 +292,7 @@ static ssize_t kbasep_timeline_io_read(struct file *filp, char __user *buffer,
*
* Return: POLLIN if data can be read without blocking, otherwise zero
*/
-static __poll_t kbasep_timeline_io_poll(struct file *filp, poll_table *wait)
+static unsigned int kbasep_timeline_io_poll(struct file *filp, poll_table *wait)
{
struct kbase_tlstream *stream;
unsigned int rb_idx;
@@ -295,90 +302,20 @@ static __poll_t kbasep_timeline_io_poll(struct file *filp, poll_table *wait)
KBASE_DEBUG_ASSERT(wait);
if (WARN_ON(!filp->private_data))
- return (__force __poll_t)-EFAULT;
+ return -EFAULT;
timeline = (struct kbase_timeline *)filp->private_data;
/* If there are header bytes to copy, read will not block */
if (kbasep_timeline_has_header_data(timeline))
- return (__force __poll_t)POLLIN;
+ return POLLIN;
poll_wait(filp, &timeline->event_queue, wait);
if (kbasep_timeline_io_packet_pending(timeline, &stream, &rb_idx))
- return (__force __poll_t)POLLIN;
+ return POLLIN;
return 0;
}
-int kbase_timeline_io_acquire(struct kbase_device *kbdev, u32 flags)
-{
- /* The timeline stream file operations structure. */
- static const struct file_operations kbasep_tlstream_fops = {
- .owner = THIS_MODULE,
- .release = kbasep_timeline_io_release,
- .read = kbasep_timeline_io_read,
- .poll = kbasep_timeline_io_poll,
- .fsync = kbasep_timeline_io_fsync,
- };
- int err;
-
- if (WARN_ON(!kbdev) || (flags & ~BASE_TLSTREAM_FLAGS_MASK))
- return -EINVAL;
-
- err = kbase_timeline_acquire(kbdev, flags);
- if (err)
- return err;
-
- err = anon_inode_getfd("[mali_tlstream]", &kbasep_tlstream_fops, kbdev->timeline,
- O_RDONLY | O_CLOEXEC);
- if (err < 0)
- kbase_timeline_release(kbdev->timeline);
-
- return err;
-}
-
-#if IS_ENABLED(CONFIG_DEBUG_FS)
-static int kbasep_timeline_io_open(struct inode *in, struct file *file)
-{
- struct kbase_device *const kbdev = in->i_private;
-
- if (WARN_ON(!kbdev))
- return -EFAULT;
-
- file->private_data = kbdev->timeline;
- return kbase_timeline_acquire(kbdev, BASE_TLSTREAM_FLAGS_MASK &
- ~BASE_TLSTREAM_JOB_DUMPING_ENABLED);
-}
-
-void kbase_timeline_io_debugfs_init(struct kbase_device *const kbdev)
-{
- static const struct file_operations kbasep_tlstream_debugfs_fops = {
- .owner = THIS_MODULE,
- .open = kbasep_timeline_io_open,
- .release = kbasep_timeline_io_release,
- .read = kbasep_timeline_io_read,
- .poll = kbasep_timeline_io_poll,
- .fsync = kbasep_timeline_io_fsync,
- };
- struct dentry *file;
-
- if (WARN_ON(!kbdev) || WARN_ON(IS_ERR_OR_NULL(kbdev->mali_debugfs_directory)))
- return;
-
- file = debugfs_create_file("tlstream", 0444, kbdev->mali_debugfs_directory, kbdev,
- &kbasep_tlstream_debugfs_fops);
-
- if (IS_ERR_OR_NULL(file))
- dev_warn(kbdev->dev, "Unable to create timeline debugfs entry");
-}
-#else
-/*
- * Stub function for when debugfs is disabled
- */
-void kbase_timeline_io_debugfs_init(struct kbase_device *const kbdev)
-{
-}
-#endif
-
/**
* kbasep_timeline_io_release - release timeline stream descriptor
* @inode: Pointer to inode structure
@@ -388,18 +325,55 @@ void kbase_timeline_io_debugfs_init(struct kbase_device *const kbdev)
*/
static int kbasep_timeline_io_release(struct inode *inode, struct file *filp)
{
+ struct kbase_timeline *timeline;
+ ktime_t elapsed_time;
+ s64 elapsed_time_ms, time_to_sleep;
+
+ KBASE_DEBUG_ASSERT(inode);
+ KBASE_DEBUG_ASSERT(filp);
+ KBASE_DEBUG_ASSERT(filp->private_data);
+
CSTD_UNUSED(inode);
- kbase_timeline_release(filp->private_data);
+ timeline = (struct kbase_timeline *)filp->private_data;
+
+ /* Get the amount of time passed since the timeline was acquired and ensure
+ * we sleep for long enough such that it has been at least
+ * TIMELINE_HYSTERESIS_TIMEOUT_MS amount of time between acquire and release.
+ * This prevents userspace from spamming acquire and release too quickly.
+ */
+ elapsed_time = ktime_sub(ktime_get(), timeline->last_acquire_time);
+ elapsed_time_ms = ktime_to_ms(elapsed_time);
+ time_to_sleep = MIN(TIMELINE_HYSTERESIS_TIMEOUT_MS,
+ TIMELINE_HYSTERESIS_TIMEOUT_MS - elapsed_time_ms);
+ if (time_to_sleep > 0)
+ msleep(time_to_sleep);
+
+#if MALI_USE_CSF
+ kbase_csf_tl_reader_stop(&timeline->csf_tl_reader);
+#endif
+
+ /* Stop autoflush timer before releasing access to streams. */
+ atomic_set(&timeline->autoflush_timer_active, 0);
+ del_timer_sync(&timeline->autoflush_timer);
+
+ atomic_set(timeline->timeline_flags, 0);
return 0;
}
static int kbasep_timeline_io_fsync(struct file *filp, loff_t start, loff_t end,
int datasync)
{
+ struct kbase_timeline *timeline;
+
CSTD_UNUSED(start);
CSTD_UNUSED(end);
CSTD_UNUSED(datasync);
- return kbase_timeline_streams_flush(filp->private_data);
+ if (WARN_ON(!filp->private_data))
+ return -EFAULT;
+
+ timeline = (struct kbase_timeline *)filp->private_data;
+
+ return kbase_timeline_streams_flush(timeline);
}
diff --git a/mali_kbase/tl/mali_kbase_timeline_priv.h b/mali_kbase/tl/mali_kbase_timeline_priv.h
index de30bcc..bf2c385 100644
--- a/mali_kbase/tl/mali_kbase_timeline_priv.h
+++ b/mali_kbase/tl/mali_kbase_timeline_priv.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
*
- * (C) COPYRIGHT 2019-2022 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2019-2021 ARM Limited. All rights reserved.
*
* This program is free software and is provided to you under the terms of the
* GNU General Public License version 2 as published by the Free Software
@@ -51,7 +51,7 @@
* @event_queue: Timeline stream event queue
* @bytes_collected: Number of bytes read by user
* @timeline_flags: Zero, if timeline is disabled. Timeline stream flags
- * otherwise. See kbase_timeline_acquire().
+ * otherwise. See kbase_timeline_io_acquire().
* @obj_header_btc: Remaining bytes to copy for the object stream header
* @aux_header_btc: Remaining bytes to copy for the aux stream header
* @last_acquire_time: The time at which timeline was last acquired.
@@ -77,27 +77,8 @@ struct kbase_timeline {
#endif
};
-void kbase_create_timeline_objects(struct kbase_device *kbdev);
-
-/**
- * kbase_timeline_acquire - acquire timeline for a userspace client.
- * @kbdev: An instance of the GPU platform device, allocated from the probe
- * method of the driver.
- * @flags: Timeline stream flags
- *
- * Each timeline instance can be acquired by only one userspace client at a time.
- *
- * Return: Zero on success, error number on failure (e.g. if already acquired).
- */
-int kbase_timeline_acquire(struct kbase_device *kbdev, u32 flags);
+extern const struct file_operations kbasep_tlstream_fops;
-/**
- * kbase_timeline_release - release timeline for a userspace client.
- * @timeline: Timeline instance to be stopped. It must be previously acquired
- * with kbase_timeline_acquire().
- *
- * Releasing the timeline instance allows it to be acquired by another userspace client.
- */
-void kbase_timeline_release(struct kbase_timeline *timeline);
+void kbase_create_timeline_objects(struct kbase_device *kbdev);
#endif /* _KBASE_TIMELINE_PRIV_H */
diff --git a/mali_kbase/tl/mali_kbase_tracepoints.c b/mali_kbase/tl/mali_kbase_tracepoints.c
index 3ac7850..6aae4e0 100644
--- a/mali_kbase/tl/mali_kbase_tracepoints.c
+++ b/mali_kbase/tl/mali_kbase_tracepoints.c
@@ -305,11 +305,11 @@ enum tl_msg_id_obj {
"@p", \
"atom") \
TRACEPOINT_DESC(KBASE_TL_JD_DONE_NO_LOCK_START, \
- "Within function kbase_jd_done_nolock", \
+ "Within function jd_done_nolock", \
"@p", \
"atom") \
TRACEPOINT_DESC(KBASE_TL_JD_DONE_NO_LOCK_END, \
- "Within function kbase_jd_done_nolock - end", \
+ "Within function jd_done_nolock - end", \
"@p", \
"atom") \
TRACEPOINT_DESC(KBASE_TL_JD_DONE_START, \
diff --git a/mali_kbase/tl/mali_kbase_tracepoints.h b/mali_kbase/tl/mali_kbase_tracepoints.h
index f01fc54..b15fe6a 100644
--- a/mali_kbase/tl/mali_kbase_tracepoints.h
+++ b/mali_kbase/tl/mali_kbase_tracepoints.h
@@ -1686,7 +1686,7 @@ struct kbase_tlstream;
} while (0)
/**
- * KBASE_TLSTREAM_TL_JD_DONE_NO_LOCK_START - Within function kbase_jd_done_nolock
+ * KBASE_TLSTREAM_TL_JD_DONE_NO_LOCK_START - Within function jd_done_nolock
*
* @kbdev: Kbase device
* @atom: Atom identifier
@@ -1705,7 +1705,7 @@ struct kbase_tlstream;
} while (0)
/**
- * KBASE_TLSTREAM_TL_JD_DONE_NO_LOCK_END - Within function kbase_jd_done_nolock - end
+ * KBASE_TLSTREAM_TL_JD_DONE_NO_LOCK_END - Within function jd_done_nolock - end
*
* @kbdev: Kbase device
* @atom: Atom identifier