From 1543e317f1da31b75942316931e8f491a8920811 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Thu, 04 Jan 2024 10:08:02 +0000
Subject: [PATCH] disable FB
---
kernel/drivers/gpu/arm/bifrost/mali_kbase_vinstr.c | 113 ++++++++++++++++++++++++--------------------------------
1 files changed, 48 insertions(+), 65 deletions(-)
diff --git a/kernel/drivers/gpu/arm/bifrost/mali_kbase_vinstr.c b/kernel/drivers/gpu/arm/bifrost/mali_kbase_vinstr.c
index 38de7f6..d770913 100644
--- a/kernel/drivers/gpu/arm/bifrost/mali_kbase_vinstr.c
+++ b/kernel/drivers/gpu/arm/bifrost/mali_kbase_vinstr.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
/*
*
- * (C) COPYRIGHT 2011-2021 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2011-2022 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
@@ -20,10 +20,11 @@
*/
#include "mali_kbase_vinstr.h"
-#include "mali_kbase_hwcnt_virtualizer.h"
-#include "mali_kbase_hwcnt_types.h"
+#include "hwcnt/mali_kbase_hwcnt_virtualizer.h"
+#include "hwcnt/mali_kbase_hwcnt_types.h"
#include <uapi/gpu/arm/bifrost/mali_kbase_hwcnt_reader.h>
-#include "mali_kbase_hwcnt_gpu.h"
+#include "hwcnt/mali_kbase_hwcnt_gpu.h"
+#include "hwcnt/mali_kbase_hwcnt_gpu_narrow.h"
#include <uapi/gpu/arm/bifrost/mali_kbase_ioctl.h>
#include "mali_malisw.h"
#include "mali_kbase_debug.h"
@@ -37,7 +38,13 @@
#include <linux/mutex.h>
#include <linux/poll.h>
#include <linux/slab.h>
+#include <linux/version_compat_defs.h>
#include <linux/workqueue.h>
+
+/* Explicitly include epoll header for old kernels. Not required from 4.16. */
+#if KERNEL_VERSION(4, 16, 0) > LINUX_VERSION_CODE
+#include <uapi/linux/eventpoll.h>
+#endif
/* Hwcnt reader API version */
#define HWCNT_READER_API 1
@@ -55,8 +62,8 @@
* @metadata: Hardware counter metadata provided by virtualizer.
* @metadata_user: API compatible hardware counter metadata provided by vinstr.
* For compatibility with the user driver interface, this
- * contains a "truncated" version of the HWCNT metadata limited
- * to 64 entries per block. NULL when not required.
+ * contains a narrowed version of the HWCNT metadata limited
+ * to 64 entries per block of 32 bits each.
* @lock: Lock protecting all vinstr state.
* @suspend_count: Suspend reference count. If non-zero, timer and worker are
* prevented from being re-scheduled.
@@ -68,7 +75,7 @@
struct kbase_vinstr_context {
struct kbase_hwcnt_virtualizer *hvirt;
const struct kbase_hwcnt_metadata *metadata;
- const struct kbase_hwcnt_metadata *metadata_user;
+ const struct kbase_hwcnt_metadata_narrow *metadata_user;
struct mutex lock;
size_t suspend_count;
size_t client_count;
@@ -89,8 +96,8 @@
* occur. If 0, not a periodic client.
* @enable_map: Counters enable map.
* @tmp_buf: Temporary buffer to use before handing dump to client.
- * @dump_bufs: Array of dump buffers allocated by this client.
- * @dump_bufs_meta: Metadata of dump buffers.
+ * @dump_bufs: Array of narrow dump buffers allocated by this client.
+ * @dump_bufs_meta: Metadata of hwcnt reader client buffers.
* @meta_idx: Index of metadata being accessed by userspace.
* @read_idx: Index of buffer read by userspace.
* @write_idx: Index of buffer being written by dump worker.
@@ -104,7 +111,7 @@
u32 dump_interval_ns;
struct kbase_hwcnt_enable_map enable_map;
struct kbase_hwcnt_dump_buffer tmp_buf;
- struct kbase_hwcnt_dump_buffer_array dump_bufs;
+ struct kbase_hwcnt_dump_buffer_narrow_array dump_bufs;
struct kbase_hwcnt_reader_metadata *dump_bufs_meta;
atomic_t meta_idx;
atomic_t read_idx;
@@ -112,9 +119,7 @@
wait_queue_head_t waitq;
};
-static unsigned int kbasep_vinstr_hwcnt_reader_poll(
- struct file *filp,
- poll_table *wait);
+static __poll_t kbasep_vinstr_hwcnt_reader_poll(struct file *filp, poll_table *wait);
static long kbasep_vinstr_hwcnt_reader_ioctl(
struct file *filp,
@@ -190,7 +195,7 @@
unsigned int write_idx;
unsigned int read_idx;
struct kbase_hwcnt_dump_buffer *tmp_buf;
- struct kbase_hwcnt_dump_buffer *dump_buf;
+ struct kbase_hwcnt_dump_buffer_narrow *dump_buf;
struct kbase_hwcnt_reader_metadata *meta;
u8 clk_cnt;
@@ -223,17 +228,11 @@
* variant will explicitly zero any non-enabled counters to ensure
* nothing except exactly what the user asked for is made visible.
*
- * If the metadata in vinstr (vctx->metadata_user) is not NULL, it means
- * vinstr has the truncated metadata, so do a narrow copy since
- * virtualizer has a bigger buffer but user only needs part of it.
- * otherwise we do a full copy.
+ * A narrow copy is required since virtualizer has a bigger buffer
+ * but user only needs part of it.
*/
- if (vcli->vctx->metadata_user)
- kbase_hwcnt_dump_buffer_copy_strict_narrow(dump_buf, tmp_buf,
- &vcli->enable_map);
- else
- kbase_hwcnt_dump_buffer_copy_strict(dump_buf, tmp_buf,
- &vcli->enable_map);
+ kbase_hwcnt_dump_buffer_copy_strict_narrow(dump_buf, tmp_buf,
+ &vcli->enable_map);
clk_cnt = vcli->vctx->metadata->clk_cnt;
@@ -362,6 +361,8 @@
* kbasep_vinstr_dump_timer() - Dump timer that schedules the dump worker for
* execution as soon as possible.
* @timer: Timer structure.
+ *
+ * Return: HRTIMER_NORESTART always.
*/
static enum hrtimer_restart kbasep_vinstr_dump_timer(struct hrtimer *timer)
{
@@ -388,7 +389,7 @@
kbase_hwcnt_virtualizer_client_destroy(vcli->hvcli);
kfree(vcli->dump_bufs_meta);
- kbase_hwcnt_dump_buffer_array_free(&vcli->dump_bufs);
+ kbase_hwcnt_dump_buffer_narrow_array_free(&vcli->dump_bufs);
kbase_hwcnt_dump_buffer_free(&vcli->tmp_buf);
kbase_hwcnt_enable_map_free(&vcli->enable_map);
kfree(vcli);
@@ -446,20 +447,11 @@
/* Enable all the available clk_enable_map. */
vcli->enable_map.clk_enable_map = (1ull << vctx->metadata->clk_cnt) - 1;
- if (vctx->metadata_user)
- /* Use vinstr's truncated metadata to alloc dump buffers which
- * interact with clients.
- */
- errcode =
- kbase_hwcnt_dump_buffer_array_alloc(vctx->metadata_user,
- setup->buffer_count,
- &vcli->dump_bufs);
- else
- /* Use metadata from virtualizer to allocate dump buffers if
- * vinstr doesn't have the truncated metadata.
- */
- errcode = kbase_hwcnt_dump_buffer_array_alloc(
- vctx->metadata, setup->buffer_count, &vcli->dump_bufs);
+ /* Use vinstr's narrowed metadata to alloc narrow dump buffers which
+ * interact with clients.
+ */
+ errcode = kbase_hwcnt_dump_buffer_narrow_array_alloc(
+ vctx->metadata_user, setup->buffer_count, &vcli->dump_bufs);
if (errcode)
goto error;
@@ -504,9 +496,8 @@
vctx->hvirt = hvirt;
vctx->metadata = metadata;
- vctx->metadata_user = NULL;
- errcode = kbase_hwcnt_gpu_metadata_create_truncate_64(
- &vctx->metadata_user, metadata);
+ errcode = kbase_hwcnt_gpu_metadata_narrow_create(&vctx->metadata_user,
+ metadata);
if (errcode)
goto err_metadata_create;
@@ -530,8 +521,6 @@
if (!vctx)
return;
- cancel_work_sync(&vctx->dump_work);
-
/* Non-zero client count implies client leak */
if (WARN_ON(vctx->client_count != 0)) {
struct kbase_vinstr_client *pos, *n;
@@ -543,8 +532,8 @@
}
}
- if (vctx->metadata_user)
- kbase_hwcnt_metadata_destroy(vctx->metadata_user);
+ cancel_work_sync(&vctx->dump_work);
+ kbase_hwcnt_gpu_metadata_narrow_destroy(vctx->metadata_user);
WARN_ON(vctx->client_count != 0);
kfree(vctx);
@@ -930,12 +919,13 @@
}
/**
- * The hwcnt reader's ioctl command - get API version.
+ * kbasep_vinstr_hwcnt_reader_ioctl_get_api_version() - get API version ioctl
+ * command.
* @cli: The non-NULL pointer to the client
* @arg: Command's argument.
* @size: Size of arg.
*
- * @return 0 on success, else error code.
+ * Return: 0 on success, else error code.
*/
static long kbasep_vinstr_hwcnt_reader_ioctl_get_api_version(
struct kbase_vinstr_client *cli, unsigned long arg, size_t size)
@@ -1006,14 +996,8 @@
cli, (u32 __user *)arg);
break;
case _IOC_NR(KBASE_HWCNT_READER_GET_BUFFER_SIZE):
- if (cli->vctx->metadata_user)
- rcode = put_user(
- (u32)cli->vctx->metadata_user->dump_buf_bytes,
- (u32 __user *)arg);
- else
- rcode = put_user(
- (u32)cli->vctx->metadata->dump_buf_bytes,
- (u32 __user *)arg);
+ rcode = put_user((u32)cli->vctx->metadata_user->dump_buf_bytes,
+ (u32 __user *)arg);
break;
case _IOC_NR(KBASE_HWCNT_READER_DUMP):
rcode = kbasep_vinstr_hwcnt_reader_ioctl_dump(cli);
@@ -1055,26 +1039,25 @@
* @filp: Non-NULL pointer to file structure.
* @wait: Non-NULL pointer to poll table.
*
- * Return: POLLIN if data can be read without blocking, 0 if data can not be
- * read without blocking, else error code.
+ * Return: EPOLLIN | EPOLLRDNORM if data can be read without blocking, 0 if
+ * data can not be read without blocking, else EPOLLHUP | EPOLLERR.
*/
-static unsigned int kbasep_vinstr_hwcnt_reader_poll(
- struct file *filp,
- poll_table *wait)
+static __poll_t kbasep_vinstr_hwcnt_reader_poll(struct file *filp, poll_table *wait)
{
struct kbase_vinstr_client *cli;
if (!filp || !wait)
- return -EINVAL;
+ return EPOLLHUP | EPOLLERR;
cli = filp->private_data;
if (!cli)
- return -EINVAL;
+ return EPOLLHUP | EPOLLERR;
poll_wait(filp, &cli->waitq, wait);
if (kbasep_vinstr_hwcnt_reader_buffer_ready(cli))
- return POLLIN;
- return 0;
+ return EPOLLIN | EPOLLRDNORM;
+
+ return (__poll_t)0;
}
/**
--
Gitblit v1.6.2