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/csf/mali_kbase_csf.h | 252 +++++++++++++++++++-------------------------------
1 files changed, 97 insertions(+), 155 deletions(-)
diff --git a/kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf.h b/kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf.h
index e3bd436..dd947dc 100644
--- a/kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf.h
+++ b/kernel/drivers/gpu/arm/bifrost/csf/mali_kbase_csf.h
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
*
- * (C) COPYRIGHT 2018-2021 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2018-2023 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_csf_scheduler.h"
#include "mali_kbase_csf_firmware.h"
#include "mali_kbase_csf_protected_memory.h"
+#include "mali_kbase_hwaccess_time.h"
/* Indicate invalid CS h/w interface
*/
@@ -39,132 +40,18 @@
*/
#define KBASEP_USER_DB_NR_INVALID ((s8)-1)
-#define FIRMWARE_PING_INTERVAL_MS (4000) /* 4 seconds */
+/* Number of pages used for GPU command queue's User input & output data */
+#define KBASEP_NUM_CS_USER_IO_PAGES (2)
-#define FIRMWARE_IDLE_HYSTERESIS_TIME_MS (10) /* Default 10 milliseconds */
-
-/**
- * enum kbase_csf_event_callback_action - return type for CSF event callbacks.
- *
- * @KBASE_CSF_EVENT_CALLBACK_FIRST: Never set explicitly.
- * It doesn't correspond to any action or type of event callback.
- *
- * @KBASE_CSF_EVENT_CALLBACK_KEEP: The callback will remain registered.
- *
- * @KBASE_CSF_EVENT_CALLBACK_REMOVE: The callback will be removed
- * immediately upon return.
- *
- * @KBASE_CSF_EVENT_CALLBACK_LAST: Never set explicitly.
- * It doesn't correspond to any action or type of event callback.
+/* Indicates an invalid value for the scan out sequence number, used to
+ * signify there is no group that has protected mode execution pending.
*/
-enum kbase_csf_event_callback_action {
- KBASE_CSF_EVENT_CALLBACK_FIRST = 0,
- KBASE_CSF_EVENT_CALLBACK_KEEP,
- KBASE_CSF_EVENT_CALLBACK_REMOVE,
- KBASE_CSF_EVENT_CALLBACK_LAST,
-};
+#define KBASEP_TICK_PROTM_PEND_SCAN_SEQ_NR_INVALID (U32_MAX)
-/**
- * kbase_csf_event_callback_action - type for callback functions to be
- * called upon CSF events.
- *
- * This is the type of callback functions that can be registered
- * for CSF events. These function calls shall be triggered by any call
- * to kbase_csf_event_signal.
- *
- * @param: Generic parameter to pass to the callback function.
- *
- * Return: KBASE_CSF_EVENT_CALLBACK_KEEP if the callback should remain
- * registered, or KBASE_CSF_EVENT_CALLBACK_REMOVE if it should be removed.
- */
-typedef enum kbase_csf_event_callback_action kbase_csf_event_callback(void *param);
+#define FIRMWARE_IDLE_HYSTERESIS_TIME_USEC (10000) /* Default 10 milliseconds */
-/**
- * kbase_csf_event_wait_add - Add a CSF event callback
- *
- * This function adds an event callback to the list of CSF event callbacks
- * belonging to a given Kbase context, to be triggered when a CSF event is
- * signalled by kbase_csf_event_signal.
- *
- * @kctx: The Kbase context the @callback should be registered to.
- * @callback: The callback function to register.
- * @param: Custom parameter to be passed to the @callback function.
- *
- * Return: 0 on success, or negative on failure.
- */
-int kbase_csf_event_wait_add(struct kbase_context *kctx,
- kbase_csf_event_callback *callback, void *param);
-
-/**
- * kbase_csf_event_wait_remove - Remove a CSF event callback
- *
- * This function removes an event callback from the list of CSF event callbacks
- * belonging to a given Kbase context.
- *
- * @kctx: The kbase context the @callback should be removed from.
- * @callback: The callback function to remove.
- * @param: Custom parameter that would have been passed to the @p callback
- * function.
- */
-void kbase_csf_event_wait_remove(struct kbase_context *kctx,
- kbase_csf_event_callback *callback, void *param);
-
-/**
- * kbase_csf_event_wait_remove_all - Removes all CSF event callbacks
- *
- * This function empties the list of CSF event callbacks belonging to a given
- * Kbase context.
- *
- * @kctx: The kbase context for which CSF event callbacks have to be removed.
- */
-void kbase_csf_event_wait_remove_all(struct kbase_context *kctx);
-
-/**
- * kbase_csf_read_error - Read CS fatal error
- *
- * This function takes the CS fatal error from context's ordered
- * error_list, copies its contents to @event_data.
- *
- * @kctx: The kbase context to read fatal error from
- * @event_data: Caller-provided buffer to copy the fatal error to
- *
- * Return: true if fatal error is read successfully.
- */
-bool kbase_csf_read_error(struct kbase_context *kctx,
- struct base_csf_notification *event_data);
-
-/**
- * kbase_csf_error_pending - Check whether fatal error is pending
- *
- * @kctx: The kbase context to check fatal error upon.
- *
- * Return: true if fatal error is pending.
- */
-bool kbase_csf_error_pending(struct kbase_context *kctx);
-
-/**
- * kbase_csf_event_signal - Signal a CSF event
- *
- * This function triggers all the CSF event callbacks that are registered to
- * a given Kbase context, and also signals the event handling thread of
- * userspace driver waiting for the CSF event.
- *
- * @kctx: The kbase context whose CSF event callbacks shall be triggered.
- * @notify_gpu: Flag to indicate if CSF firmware should be notified of the
- * signaling of event that happened on the Driver side, either
- * the signal came from userspace or from kcpu queues.
- */
-void kbase_csf_event_signal(struct kbase_context *kctx, bool notify_gpu);
-
-static inline void kbase_csf_event_signal_notify_gpu(struct kbase_context *kctx)
-{
- kbase_csf_event_signal(kctx, true);
-}
-
-static inline void kbase_csf_event_signal_cpu_only(struct kbase_context *kctx)
-{
- kbase_csf_event_signal(kctx, false);
-}
+/* Idle hysteresis time can be scaled down when GPU sleep feature is used */
+#define FIRMWARE_IDLE_HYSTERESIS_GPU_SLEEP_SCALER (5)
/**
* kbase_csf_ctx_init - Initialize the CSF interface for a GPU address space.
@@ -179,11 +66,11 @@
* kbase_csf_ctx_handle_fault - Terminate queue groups & notify fault upon
* GPU bus fault, MMU page fault or similar.
*
- * This function terminates all GPU command queue groups in the context and
- * notifies the event notification thread of the fault.
- *
* @kctx: Pointer to faulty kbase context.
* @fault: Pointer to the fault.
+ *
+ * This function terminates all GPU command queue groups in the context and
+ * notifies the event notification thread of the fault.
*/
void kbase_csf_ctx_handle_fault(struct kbase_context *kctx,
struct kbase_fault *fault);
@@ -191,10 +78,10 @@
/**
* kbase_csf_ctx_term - Terminate the CSF interface for a GPU address space.
*
+ * @kctx: Pointer to the kbase context which is being terminated.
+ *
* This function terminates any remaining CSGs and CSs which weren't destroyed
* before context termination.
- *
- * @kctx: Pointer to the kbase context which is being terminated.
*/
void kbase_csf_ctx_term(struct kbase_context *kctx);
@@ -240,16 +127,35 @@
struct kbase_ioctl_cs_queue_terminate *term);
/**
+ * kbase_csf_free_command_stream_user_pages() - Free the resources allocated
+ * for a queue at the time of bind.
+ *
+ * @kctx: Address of the kbase context within which the queue was created.
+ * @queue: Pointer to the queue to be unlinked.
+ *
+ * This function will free the pair of physical pages allocated for a GPU
+ * command queue, and also release the hardware doorbell page, that were mapped
+ * into the process address space to enable direct submission of commands to
+ * the hardware. Also releases the reference taken on the queue when the mapping
+ * was created.
+ *
+ * If an explicit or implicit unbind was missed by the userspace then the
+ * mapping will persist. On process exit kernel itself will remove the mapping.
+ */
+void kbase_csf_free_command_stream_user_pages(struct kbase_context *kctx,
+ struct kbase_queue *queue);
+
+/**
* kbase_csf_alloc_command_stream_user_pages - Allocate resources for a
* GPU command queue.
- *
- * This function allocates a pair of User mode input/output pages for a
- * GPU command queue and maps them in the shared interface segment of MCU
- * firmware address space. Also reserves a hardware doorbell page for the queue.
*
* @kctx: Pointer to the kbase context within which the resources
* for the queue are being allocated.
* @queue: Pointer to the queue for which to allocate resources.
+ *
+ * This function allocates a pair of User mode input/output pages for a
+ * GPU command queue and maps them in the shared interface segment of MCU
+ * firmware address space. Also reserves a hardware doorbell page for the queue.
*
* Return: 0 on success, or negative on failure.
*/
@@ -275,8 +181,9 @@
* are any.
*
* @queue: Pointer to queue to be unbound.
+ * @process_exit: Flag to indicate if process exit is happening.
*/
-void kbase_csf_queue_unbind(struct kbase_queue *queue);
+void kbase_csf_queue_unbind(struct kbase_queue *queue, bool process_exit);
/**
* kbase_csf_queue_unbind_stopped - Unbind a GPU command queue in the case
@@ -291,9 +198,9 @@
/**
* kbase_csf_queue_kick - Schedule a GPU command queue on the firmware
*
- * @kctx: The kbase context.
- * @kick: Pointer to the struct which specifies the queue
- * that needs to be scheduled.
+ * @kctx: The kbase context.
+ * @kick: Pointer to the struct which specifies the queue
+ * that needs to be scheduled.
*
* Return: 0 on success, or negative on failure.
*/
@@ -301,14 +208,28 @@
struct kbase_ioctl_cs_queue_kick *kick);
/**
+ * kbase_csf_queue_group_handle_is_valid - Find the queue group corresponding
+ * to the indicated handle.
+ *
+ * @kctx: The kbase context under which the queue group exists.
+ * @group_handle: Handle for the group which uniquely identifies it within
+ * the context with which it was created.
+ *
+ * This function is used to find the queue group when passed a handle.
+ *
+ * Return: Pointer to a queue group on success, NULL on failure
+ */
+struct kbase_queue_group *kbase_csf_find_queue_group(struct kbase_context *kctx, u8 group_handle);
+
+/**
* kbase_csf_queue_group_handle_is_valid - Find if the given queue group handle
* is valid.
- *
- * This function is used to determine if the queue group handle is valid.
*
* @kctx: The kbase context under which the queue group exists.
* @group_handle: Handle for the group which uniquely identifies it within
* the context with which it was created.
+ *
+ * This function is used to determine if the queue group handle is valid.
*
* Return: 0 on success, or negative on failure.
*/
@@ -353,10 +274,9 @@
*/
void kbase_csf_term_descheduled_queue_group(struct kbase_queue_group *group);
+#if IS_ENABLED(CONFIG_MALI_VECTOR_DUMP) || MALI_UNIT_TEST
/**
* kbase_csf_queue_group_suspend - Suspend a GPU command queue group
- *
- * This function is used to suspend a queue group and copy the suspend buffer.
*
* @kctx: The kbase context for which the queue group is to be
* suspended.
@@ -365,11 +285,14 @@
* @group_handle: Handle for the group which uniquely identifies it within
* the context within which it was created.
*
+ * This function is used to suspend a queue group and copy the suspend buffer.
+ *
* Return: 0 on success or negative value if failed to suspend
* queue group and copy suspend buffer contents.
*/
int kbase_csf_queue_group_suspend(struct kbase_context *kctx,
struct kbase_suspend_copy_buffer *sus_buf, u8 group_handle);
+#endif
/**
* kbase_csf_add_group_fatal_error - Report a fatal group error to userspace
@@ -394,11 +317,11 @@
* the update of userspace mapping of HW
* doorbell page.
*
+ * @kbdev: Instance of a GPU platform device that implements a CSF interface.
+ *
* The function creates a file and allocates a dummy page to facilitate the
* update of userspace mapping to point to the dummy page instead of the real
* HW doorbell page after the suspend of queue group.
- *
- * @kbdev: Instance of a GPU platform device that implements a CSF interface.
*
* Return: 0 on success, or negative on failure.
*/
@@ -417,13 +340,13 @@
* instead of the User register page after
* the GPU power down.
*
+ * @kbdev: Instance of a GPU platform device that implements a CSF interface.
+ *
* The function allocates a dummy page which is used to replace the User
* register page in the userspace mapping after the power down of GPU.
* On the power up of GPU, the mapping is updated to point to the real
* User register page. The mapping is used to allow access to LATEST_FLUSH
* register from userspace.
- *
- * @kbdev: Instance of a GPU platform device that implements a CSF interface.
*
* Return: 0 on success, or negative on failure.
*/
@@ -431,7 +354,7 @@
/**
* kbase_csf_free_dummy_user_reg_page - Free the dummy page that was used
- * used to replace the User register page
+ * to replace the User register page
*
* @kbdev: Instance of a GPU platform device that implements a CSF interface.
*/
@@ -440,10 +363,10 @@
/**
* kbase_csf_ring_csg_doorbell - ring the doorbell for a CSG interface.
*
- * The function kicks a notification on the CSG interface to firmware.
- *
* @kbdev: Instance of a GPU platform device that implements a CSF interface.
* @slot: Index of CSG interface for ringing the door-bell.
+ *
+ * The function kicks a notification on the CSG interface to firmware.
*/
void kbase_csf_ring_csg_doorbell(struct kbase_device *kbdev, int slot);
@@ -451,10 +374,10 @@
* kbase_csf_ring_csg_slots_doorbell - ring the doorbell for a set of CSG
* interfaces.
*
- * The function kicks a notification on a set of CSG interfaces to firmware.
- *
* @kbdev: Instance of a GPU platform device that implements a CSF interface.
* @slot_bitmap: bitmap for the given slots, slot-0 on bit-0, etc.
+ *
+ * The function kicks a notification on a set of CSG interfaces to firmware.
*/
void kbase_csf_ring_csg_slots_doorbell(struct kbase_device *kbdev,
u32 slot_bitmap);
@@ -462,9 +385,6 @@
/**
* kbase_csf_ring_cs_kernel_doorbell - ring the kernel doorbell for a CSI
* assigned to a GPU queue
- *
- * The function sends a doorbell interrupt notification to the firmware for
- * a CSI assigned to a GPU queue.
*
* @kbdev: Instance of a GPU platform device that implements a CSF interface.
* @csi_index: ID of the CSI assigned to the GPU queue.
@@ -476,6 +396,9 @@
* The flag is supposed be false only when the input page
* for bound GPU queues is programmed at the time of
* starting/resuming the group on a CSG slot.
+ *
+ * The function sends a doorbell interrupt notification to the firmware for
+ * a CSI assigned to a GPU queue.
*/
void kbase_csf_ring_cs_kernel_doorbell(struct kbase_device *kbdev,
int csi_index, int csg_nr,
@@ -485,11 +408,11 @@
* kbase_csf_ring_cs_user_doorbell - ring the user doorbell allocated for a
* queue.
*
- * The function kicks a notification to the firmware on the doorbell assigned
- * to the queue.
- *
* @kbdev: Instance of a GPU platform device that implements a CSF interface.
* @queue: Pointer to the queue for ringing the door-bell.
+ *
+ * The function kicks a notification to the firmware on the doorbell assigned
+ * to the queue.
*/
void kbase_csf_ring_cs_user_doorbell(struct kbase_device *kbdev,
struct kbase_queue *queue);
@@ -560,5 +483,24 @@
return kbasep_csf_queue_group_priority_to_relative[priority];
}
+/**
+ * kbase_csf_ktrace_gpu_cycle_cnt - Wrapper to retreive the GPU cycle counter
+ * value for Ktrace purpose.
+ *
+ * @kbdev: Instance of a GPU platform device that implements a CSF interface.
+ *
+ * This function is just a wrapper to retreive the GPU cycle counter value, to
+ * avoid any overhead on Release builds where Ktrace is disabled by default.
+ *
+ * Return: Snapshot of the GPU cycle count register.
+ */
+static inline u64 kbase_csf_ktrace_gpu_cycle_cnt(struct kbase_device *kbdev)
+{
+#if KBASE_KTRACE_ENABLE
+ return kbase_backend_get_cycle_cnt(kbdev);
+#else
+ return 0;
+#endif
+}
#endif /* _KBASE_CSF_H_ */
--
Gitblit v1.6.2