summaryrefslogtreecommitdiff
path: root/mali_kbase/arbiter
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2021-11-23 14:38:46 -0800
committerJesse Hall <jessehall@google.com>2021-11-23 14:38:46 -0800
commit0c596dc70431fa2c70021fa1685e3efc969a852d (patch)
tree8c6cfe8da5d3bea214e991cc4438988f65d9081e /mali_kbase/arbiter
parentbbbb1cf6bb211bb2094dd66656966277c326867f (diff)
downloadgpu-0c596dc70431fa2c70021fa1685e3efc969a852d.tar.gz
Mali Valhall Android DDK r34p0-00dev1
Provenance: 046d23c969 (collaborate/google/android/v_r34p0-00dev1) VX504X08X-BU-00000-r34p0-00dev1 - Valhall Android DDK VX504X08X-SW-99006-r34p0-00dev1 - Valhall Android Renderscript AOSP parts Documentation from VX504X08X-BU-00000 omitted. Signed-off-by: Jesse Hall <jessehall@google.com> Change-Id: I4ebbb3a3af709bd39f883eed3b35bf4657a95797
Diffstat (limited to 'mali_kbase/arbiter')
-rw-r--r--mali_kbase/arbiter/mali_kbase_arbiter_defs.h1
-rw-r--r--mali_kbase/arbiter/mali_kbase_arbiter_interface.h155
-rw-r--r--mali_kbase/arbiter/mali_kbase_arbiter_pm.c61
-rw-r--r--mali_kbase/arbiter/mali_kbase_arbiter_pm.h2
4 files changed, 107 insertions, 112 deletions
diff --git a/mali_kbase/arbiter/mali_kbase_arbiter_defs.h b/mali_kbase/arbiter/mali_kbase_arbiter_defs.h
index 570a82a..65cfc7b 100644
--- a/mali_kbase/arbiter/mali_kbase_arbiter_defs.h
+++ b/mali_kbase/arbiter/mali_kbase_arbiter_defs.h
@@ -20,7 +20,6 @@
*/
/**
- * @file
* Mali structures define to support arbitration feature
*/
diff --git a/mali_kbase/arbiter/mali_kbase_arbiter_interface.h b/mali_kbase/arbiter/mali_kbase_arbiter_interface.h
index c0137f7..3c60878 100644
--- a/mali_kbase/arbiter/mali_kbase_arbiter_interface.h
+++ b/mali_kbase/arbiter/mali_kbase_arbiter_interface.h
@@ -20,7 +20,6 @@
*/
/**
- * @file
* Defines the Mali arbiter interface
*/
@@ -61,58 +60,47 @@ struct arbiter_if_dev;
* the arbiter arbiter_if_vm_arb_ops callbacks below.
* For example vm_arb_gpu_stopped() may be called as a side effect of
* arb_vm_gpu_stop() being called here.
+ *
+ * @arb_vm_gpu_stop: Callback to ask VM to stop using GPU.
+ * dev: The arbif kernel module device.
+ *
+ * Informs KBase to stop using the GPU as soon as possible.
+ * Note: Once the driver is no longer using the GPU, a call
+ * to vm_arb_gpu_stopped is expected by the arbiter.
+ * @arb_vm_gpu_granted: Callback to indicate that GPU has been granted to VM.
+ * dev: The arbif kernel module device.
+ *
+ * Informs KBase that the GPU can now be used by the VM.
+ * @arb_vm_gpu_lost: Callback to indicate that VM has lost the GPU.
+ * dev: The arbif kernel module device.
+ *
+ * This is called if KBase takes too long to respond to the
+ * arbiter stop request.
+ * Once this is called, KBase will assume that access to the
+ * GPU has been lost and will fail all running jobs and
+ * reset its internal state.
+ * If successful, will respond with a vm_arb_gpu_stopped
+ * message.
+ * @arb_vm_max_config: Callback to send the max config info to the VM.
+ * dev: The arbif kernel module device.
+ * max_l2_slices: The maximum number of L2 slices.
+ * max_core_mask: The largest core mask.
+ *
+ * Informs KBase the maximum resources that can be
+ * allocated to the partition in use.
+ * @arb_vm_update_freq: Callback to notify that GPU clock frequency has been
+ * updated.
+ * dev: The arbif kernel module device.
+ * freq: GPU clock frequency value reported from arbiter
+ *
+ * Informs KBase that the GPU clock frequency has been updated.
*/
struct arbiter_if_arb_vm_ops {
- /**
- * arb_vm_gpu_stop() - Ask VM to stop using GPU
- * @dev: The arbif kernel module device.
- *
- * Informs KBase to stop using the GPU as soon as possible.
- * @Note: Once the driver is no longer using the GPU, a call to
- * vm_arb_gpu_stopped is expected by the arbiter.
- */
void (*arb_vm_gpu_stop)(struct device *dev);
-
- /**
- * arb_vm_gpu_granted() - GPU has been granted to VM
- * @dev: The arbif kernel module device.
- *
- * Informs KBase that the GPU can now be used by the VM.
- */
void (*arb_vm_gpu_granted)(struct device *dev);
-
- /**
- * arb_vm_gpu_lost() - VM has lost the GPU
- * @dev: The arbif kernel module device.
- *
- * This is called if KBase takes too long to respond to the arbiter
- * stop request.
- * Once this is called, KBase will assume that access to the GPU
- * has been lost and will fail all running jobs and reset its
- * internal state.
- * If successful, will respond with a vm_arb_gpu_stopped message.
- */
void (*arb_vm_gpu_lost)(struct device *dev);
-
- /**
- * arb_vm_max_config() - Send max config info to the VM
- * @dev: The arbif kernel module device.
- * @max_l2_slices: The maximum number of L2 slices.
- * @max_core_mask: The largest core mask.
- *
- * Informs KBase the maximum resources that can be allocated to the
- * partition in use.
- */
void (*arb_vm_max_config)(struct device *dev, uint32_t max_l2_slices,
uint32_t max_core_mask);
-
- /**
- * arb_vm_update_freq() - GPU clock frequency has been updated
- * @dev: The arbif kernel module device.
- * @freq: GPU clock frequency value reported from arbiter
- *
- * Informs KBase that the GPU clock frequency has been updated.
- */
void (*arb_vm_update_freq)(struct device *dev, uint32_t freq);
};
@@ -124,60 +112,45 @@ struct arbiter_if_arb_vm_ops {
*
* Note that we must not make any synchronous calls back in to the VM
* (via arbiter_if_arb_vm_ops above) in the context of these callbacks.
+ *
+ * @vm_arb_register_dev: Callback to register VM device driver callbacks.
+ * arbif_dev: The arbiter interface to register
+ * with for device callbacks
+ * dev: The device structure to supply in the callbacks.
+ * ops: The callbacks that the device driver supports
+ * (none are optional).
+ *
+ * Returns
+ * 0 - successful.
+ * -EINVAL - invalid argument.
+ * -EPROBE_DEFER - module dependencies are not yet
+ * available.
+ * @vm_arb_unregister_dev: Callback to unregister VM device driver callbacks.
+ * arbif_dev: The arbiter interface to unregistering
+ * from.
+ * @vm_arb_get_max_config: Callback to Request the max config from the Arbiter.
+ * arbif_dev: The arbiter interface to issue the
+ * request to.
+ * @vm_arb_gpu_request: Callback to ask the arbiter interface for GPU access.
+ * arbif_dev: The arbiter interface to issue the request
+ * to.
+ * @vm_arb_gpu_active: Callback to inform arbiter that driver has gone active.
+ * arbif_dev: The arbiter interface device to notify.
+ * @vm_arb_gpu_idle: Callback to inform the arbiter that driver has gone idle.
+ * arbif_dev: The arbiter interface device to notify.
+ * @vm_arb_gpu_stopped: Callback to inform arbiter that driver has stopped
+ * using the GPU
+ * arbif_dev: The arbiter interface device to notify.
+ * gpu_required: The GPU is still needed to do more work.
*/
struct arbiter_if_vm_arb_ops {
- /**
- * vm_arb_register_dev() - Register VM device driver callbacks.
- * @arbif_dev: The arbiter interface we are registering device callbacks
- * @dev: The device structure to supply in the callbacks.
- * @ops: The callbacks that the device driver supports
- * (none are optional).
- *
- * Return:
- * * 0 - successful.
- * * -EINVAL - invalid argument.
- * * -EPROBE_DEFER - module dependencies are not yet available.
- */
int (*vm_arb_register_dev)(struct arbiter_if_dev *arbif_dev,
struct device *dev, struct arbiter_if_arb_vm_ops *ops);
-
- /**
- * vm_arb_unregister_dev() - Unregister VM device driver callbacks.
- * @arbif_dev: The arbiter interface we are unregistering from.
- */
void (*vm_arb_unregister_dev)(struct arbiter_if_dev *arbif_dev);
-
- /**
- * vm_arb_gpu_get_max_config() - Request the max config from the
- * Arbiter.
- * @arbif_dev: The arbiter interface we want to issue the request.
- */
void (*vm_arb_get_max_config)(struct arbiter_if_dev *arbif_dev);
-
- /**
- * vm_arb_gpu_request() - Ask the arbiter interface for GPU access.
- * @arbif_dev: The arbiter interface we want to issue the request.
- */
void (*vm_arb_gpu_request)(struct arbiter_if_dev *arbif_dev);
-
- /**
- * vm_arb_gpu_active() - Inform arbiter that the driver has gone active
- * @arbif_dev: The arbiter interface device.
- */
void (*vm_arb_gpu_active)(struct arbiter_if_dev *arbif_dev);
-
- /**
- * vm_arb_gpu_idle() - Inform the arbiter that the driver has gone idle
- * @arbif_dev: The arbiter interface device.
- */
void (*vm_arb_gpu_idle)(struct arbiter_if_dev *arbif_dev);
-
- /**
- * vm_arb_gpu_stopped() - Inform the arbiter that the driver has stopped
- * using the GPU
- * @arbif_dev: The arbiter interface device.
- * @gpu_required: The GPU is still needed to do more work.
- */
void (*vm_arb_gpu_stopped)(struct arbiter_if_dev *arbif_dev,
u8 gpu_required);
};
diff --git a/mali_kbase/arbiter/mali_kbase_arbiter_pm.c b/mali_kbase/arbiter/mali_kbase_arbiter_pm.c
index 5c75686..62ff4fd 100644
--- a/mali_kbase/arbiter/mali_kbase_arbiter_pm.c
+++ b/mali_kbase/arbiter/mali_kbase_arbiter_pm.c
@@ -20,15 +20,12 @@
*/
/**
- * @file
* Mali arbiter power manager state machine and APIs
*/
#include <mali_kbase.h>
#include <mali_kbase_pm.h>
-#include <mali_kbase_hwaccess_jm.h>
#include <backend/gpu/mali_kbase_irq_internal.h>
-#include <mali_kbase_hwcnt_context.h>
#include <backend/gpu/mali_kbase_pm_internal.h>
#include <tl/mali_kbase_tracepoints.h>
#include <mali_kbase_gpuprops.h>
@@ -319,6 +316,7 @@ int kbase_arbiter_pm_early_init(struct kbase_device *kbdev)
if (kbdev->arb.arb_if) {
kbase_arbif_gpu_request(kbdev);
dev_dbg(kbdev->dev, "Waiting for initial GPU assignment...\n");
+
err = wait_event_timeout(arb_vm_state->vm_state_wait,
arb_vm_state->vm_state ==
KBASE_VM_STATE_INITIALIZING_WITH_GPU,
@@ -328,8 +326,9 @@ int kbase_arbiter_pm_early_init(struct kbase_device *kbdev)
dev_dbg(kbdev->dev,
"Kbase probe Deferred after waiting %d ms to receive GPU_GRANT\n",
gpu_req_timeout);
- err = -EPROBE_DEFER;
- goto arbif_eprobe_defer;
+
+ err = -ENODEV;
+ goto arbif_timeout;
}
dev_dbg(kbdev->dev,
@@ -337,9 +336,10 @@ int kbase_arbiter_pm_early_init(struct kbase_device *kbdev)
}
return 0;
-arbif_eprobe_defer:
+arbif_timeout:
kbase_arbiter_pm_early_term(kbdev);
return err;
+
arbif_init_fail:
destroy_workqueue(arb_vm_state->vm_arb_wq);
kfree(arb_vm_state);
@@ -619,6 +619,18 @@ static void kbase_arbiter_pm_vm_gpu_stop(struct kbase_device *kbdev)
case KBASE_VM_STATE_SUSPEND_PENDING:
/* Suspend finishes with a stop so nothing else to do */
break;
+ case KBASE_VM_STATE_INITIALIZING:
+ case KBASE_VM_STATE_STOPPED_GPU_REQUESTED:
+ /*
+ * Case stop() is received when in a GPU REQUESTED state, it
+ * means that the granted() was missed so the GPU needs to be
+ * requested again.
+ */
+ dev_dbg(kbdev->dev,
+ "GPU stop while already stopped with GPU requested");
+ kbase_arbif_gpu_stopped(kbdev, true);
+ start_request_timer(kbdev);
+ break;
default:
dev_warn(kbdev->dev, "GPU_STOP when not expected - state %s\n",
kbase_arbiter_pm_vm_state_str(arb_vm_state->vm_state));
@@ -656,9 +668,20 @@ static void kbase_gpu_lost(struct kbase_device *kbdev)
break;
case KBASE_VM_STATE_SUSPENDED:
case KBASE_VM_STATE_STOPPED:
- case KBASE_VM_STATE_STOPPED_GPU_REQUESTED:
dev_dbg(kbdev->dev, "GPU lost while already stopped");
break;
+ case KBASE_VM_STATE_INITIALIZING:
+ case KBASE_VM_STATE_STOPPED_GPU_REQUESTED:
+ /*
+ * Case lost() is received when in a GPU REQUESTED state, it
+ * means that the granted() and stop() were missed so the GPU
+ * needs to be requested again. Very unlikely to happen.
+ */
+ dev_dbg(kbdev->dev,
+ "GPU lost while already stopped with GPU requested");
+ kbase_arbif_gpu_request(kbdev);
+ start_request_timer(kbdev);
+ break;
case KBASE_VM_STATE_SUSPEND_WAIT_FOR_GRANT:
dev_dbg(kbdev->dev, "GPU lost while waiting to suspend");
kbase_arbiter_pm_vm_set_state(kbdev, KBASE_VM_STATE_SUSPENDED);
@@ -1020,8 +1043,8 @@ int kbase_arbiter_pm_ctx_active_handle_suspend(struct kbase_device *kbdev,
/**
* kbase_arbiter_pm_update_gpu_freq() - Updates GPU clock frequency received
* from arbiter.
- * @arb_freq - Pointer to struchture holding GPU clock frequenecy data
- * @freq - New frequency value in KHz
+ * @arb_freq: Pointer to struchture holding GPU clock frequenecy data
+ * @freq: New frequency value in KHz
*/
void kbase_arbiter_pm_update_gpu_freq(struct kbase_arbiter_freq *arb_freq,
uint32_t freq)
@@ -1045,8 +1068,8 @@ void kbase_arbiter_pm_update_gpu_freq(struct kbase_arbiter_freq *arb_freq,
/**
* enumerate_arb_gpu_clk() - Enumerate a GPU clock on the given index
- * @kbdev - kbase_device pointer
- * @index - GPU clock index
+ * @kbdev: kbase_device pointer
+ * @index: GPU clock index
*
* Returns pointer to structure holding GPU clock frequency data reported from
* arbiter, only index 0 is valid.
@@ -1061,8 +1084,8 @@ static void *enumerate_arb_gpu_clk(struct kbase_device *kbdev,
/**
* get_arb_gpu_clk_rate() - Get the current rate of GPU clock frequency value
- * @kbdev - kbase_device pointer
- * @index - GPU clock index
+ * @kbdev: kbase_device pointer
+ * @index: GPU clock index
*
* Returns the GPU clock frequency value saved when gpu is granted from arbiter
*/
@@ -1082,9 +1105,9 @@ static unsigned long get_arb_gpu_clk_rate(struct kbase_device *kbdev,
/**
* arb_gpu_clk_notifier_register() - Register a clock rate change notifier.
- * @kbdev - kbase_device pointer
- * @gpu_clk_handle - Handle unique to the enumerated GPU clock
- * @nb - notifier block containing the callback function pointer
+ * @kbdev: kbase_device pointer
+ * @gpu_clk_handle: Handle unique to the enumerated GPU clock
+ * @nb: notifier block containing the callback function pointer
*
* Returns 0 on success, negative error code otherwise.
*
@@ -1108,9 +1131,9 @@ static int arb_gpu_clk_notifier_register(struct kbase_device *kbdev,
/**
* gpu_clk_notifier_unregister() - Unregister clock rate change notifier
- * @kbdev - kbase_device pointer
- * @gpu_clk_handle - Handle unique to the enumerated GPU clock
- * @nb - notifier block containing the callback function pointer
+ * @kbdev: kbase_device pointer
+ * @gpu_clk_handle: Handle unique to the enumerated GPU clock
+ * @nb: notifier block containing the callback function pointer
*
* This function pointer is used to unregister a callback function that
* was previously registered to get notified of a frequency change of the
diff --git a/mali_kbase/arbiter/mali_kbase_arbiter_pm.h b/mali_kbase/arbiter/mali_kbase_arbiter_pm.h
index 1f570bb..091b431 100644
--- a/mali_kbase/arbiter/mali_kbase_arbiter_pm.h
+++ b/mali_kbase/arbiter/mali_kbase_arbiter_pm.h
@@ -20,7 +20,6 @@
*/
/**
- * @file
* Mali arbiter power manager state machine and APIs
*/
@@ -108,6 +107,7 @@ int kbase_arbiter_pm_install_interrupts(struct kbase_device *kbdev);
/**
* kbase_arbiter_pm_vm_event() - Dispatch VM event to the state machine
* @kbdev: The kbase device structure for the device (must be a valid pointer)
+ * @event: The event to dispatch
*
* The state machine function. Receives events and transitions states
* according the event received and the current state