diff options
author | Sidath Senanayake <sidaths@google.com> | 2018-07-31 15:28:14 +0200 |
---|---|---|
committer | Sidath Senanayake <sidaths@google.com> | 2018-07-31 15:28:14 +0200 |
commit | f32af5a9ba3c2b556d92827a96dbeec3df200968 (patch) | |
tree | f408feaf7cd8b87a980575c132f11d3ba45a3f8d /mali_kbase/backend/gpu/mali_kbase_pm_policy.h | |
parent | 5574d60cda52fa08ca2cc714ae051ee2b6f850d7 (diff) | |
download | gpu-f32af5a9ba3c2b556d92827a96dbeec3df200968.tar.gz |
Mali Bifrost DDK r14p0 KMD
Provenance:
37fe8262c (collaborate/EAC/b_r14p0)
BX304L01B-BU-00000-r14p0-01rel0
BX304L06A-BU-00000-r14p0-01rel0
BX304X07X-BU-00000-r14p0-01rel0
Signed-off-by: Sidath Senanayake <sidaths@google.com>
Change-Id: I0eb3b666045d72d33e2953954de5b416f909da0f
Diffstat (limited to 'mali_kbase/backend/gpu/mali_kbase_pm_policy.h')
-rw-r--r-- | mali_kbase/backend/gpu/mali_kbase_pm_policy.h | 149 |
1 files changed, 72 insertions, 77 deletions
diff --git a/mali_kbase/backend/gpu/mali_kbase_pm_policy.h b/mali_kbase/backend/gpu/mali_kbase_pm_policy.h index 2f15888..2e86929 100644 --- a/mali_kbase/backend/gpu/mali_kbase_pm_policy.h +++ b/mali_kbase/backend/gpu/mali_kbase_pm_policy.h @@ -73,11 +73,25 @@ enum kbase_pm_cores_ready { /** - * kbase_pm_request_cores_sync - Synchronous variant of kbase_pm_request_cores() + * kbase_pm_request_cores - Request the desired cores to be powered up. + * @kbdev: Kbase device + * @tiler_required: true if tiler is required + * @shader_required: true if shaders are required * - * @kbdev: The kbase device structure for the device - * @tiler_required: true if the tiler is required, false otherwise - * @shader_cores: A bitmask of shader cores which are necessary for the job + * Called by the scheduler to request power to the desired cores. + * + * There is no guarantee that the HW will be powered up on return. Use + * kbase_pm_cores_requested()/kbase_pm_cores_ready() to verify that cores are + * now powered, or instead call kbase_pm_request_cores_sync(). + */ +void kbase_pm_request_cores(struct kbase_device *kbdev, bool tiler_required, + bool shader_required); + +/** + * kbase_pm_request_cores_sync - Synchronous variant of kbase_pm_request_cores() + * @kbdev: Kbase device + * @tiler_required: true if tiler is required + * @shader_required: true if shaders are required * * When this function returns, the @shader_cores will be in the READY state. * @@ -87,98 +101,79 @@ enum kbase_pm_cores_ready { * is made. */ void kbase_pm_request_cores_sync(struct kbase_device *kbdev, - bool tiler_required, u64 shader_cores); + bool tiler_required, bool shader_required); /** - * kbase_pm_request_cores - Mark one or more cores as being required - * for jobs to be submitted - * - * @kbdev: The kbase device structure for the device - * @tiler_required: true if the tiler is required, false otherwise - * @shader_cores: A bitmask of shader cores which are necessary for the job - * - * This function is called by the job scheduler to mark one or more cores as - * being required to submit jobs that are ready to run. - * - * The cores requested are reference counted and a subsequent call to - * kbase_pm_register_inuse_cores() or kbase_pm_unrequest_cores() should be - * made to dereference the cores as being 'needed'. + * kbase_pm_release_cores - Request the desired cores to be powered down. + * @kbdev: Kbase device + * @tiler_required: true if tiler is required + * @shader_required: true if shaders are required * - * The active power policy will meet or exceed the requirements of the - * requested cores in the system. Any core transitions needed will be begun - * immediately, but they might not complete/the cores might not be available - * until a Power Management IRQ. - * - * Return: 0 if the cores were successfully requested, or -errno otherwise. + * Called by the scheduler to release its power reference on the desired cores. */ -void kbase_pm_request_cores(struct kbase_device *kbdev, - bool tiler_required, u64 shader_cores); +void kbase_pm_release_cores(struct kbase_device *kbdev, bool tiler_required, + bool shader_required); /** - * kbase_pm_unrequest_cores - Unmark one or more cores as being required for - * jobs to be submitted. + * kbase_pm_cores_requested - Check that a power request has been locked into + * the HW. + * @kbdev: Kbase device + * @tiler_required: true if tiler is required + * @shader_required: true if shaders are required + * + * Called by the scheduler to check if a power on request has been locked into + * the HW. * - * @kbdev: The kbase device structure for the device - * @tiler_required: true if the tiler is required, false otherwise - * @shader_cores: A bitmask of shader cores (as given to - * kbase_pm_request_cores() ) + * Note that there is no guarantee that the cores are actually ready, however + * when the request has been locked into the HW, then it is safe to submit work + * since the HW will wait for the transition to ready. * - * This function undoes the effect of kbase_pm_request_cores(). It should be - * used when a job is not going to be submitted to the hardware (e.g. the job is - * cancelled before it is enqueued). + * A reference must first be taken prior to making this call. * - * The active power policy will meet or exceed the requirements of the - * requested cores in the system. Any core transitions needed will be begun - * immediately, but they might not complete until a Power Management IRQ. + * Caller must hold the hwaccess_lock. * - * The policy may use this as an indication that it can power down cores. + * Return: true if the request to the HW was successfully made else false if the + * request is still pending. */ -void kbase_pm_unrequest_cores(struct kbase_device *kbdev, - bool tiler_required, u64 shader_cores); +static inline bool kbase_pm_cores_requested(struct kbase_device *kbdev, + bool tiler_required, bool shader_required) +{ + lockdep_assert_held(&kbdev->hwaccess_lock); + + if ((shader_required && !kbdev->shader_available_bitmap) || + (tiler_required && !kbdev->tiler_available_bitmap)) + return false; + + return true; +} /** - * kbase_pm_register_inuse_cores - Register a set of cores as in use by a job - * - * @kbdev: The kbase device structure for the device - * @tiler_required: true if the tiler is required, false otherwise - * @shader_cores: A bitmask of shader cores (as given to - * kbase_pm_request_cores() ) + * kbase_pm_cores_ready - Check that the required cores have been powered on by + * the HW. + * @kbdev: Kbase device + * @tiler_required: true if tiler is required + * @shader_required: true if shaders are required * - * This function should be called after kbase_pm_request_cores() when the job - * is about to be submitted to the hardware. It will check that the necessary - * cores are available and if so update the 'needed' and 'inuse' bitmasks to - * reflect that the job is now committed to being run. + * Called by the scheduler to check if cores are ready. * - * If the necessary cores are not currently available then the function will - * return %KBASE_CORES_NOT_READY and have no effect. + * Note that the caller should ensure that they have first requested cores + * before calling this function. * - * Return: %KBASE_CORES_NOT_READY if the cores are not immediately ready, + * Caller must hold the hwaccess_lock. * - * %KBASE_NEW_AFFINITY if the affinity requested is not allowed, - * - * %KBASE_CORES_READY if the cores requested are already available + * Return: true if the cores are ready. */ -enum kbase_pm_cores_ready kbase_pm_register_inuse_cores( - struct kbase_device *kbdev, - bool tiler_required, - u64 shader_cores); +static inline bool kbase_pm_cores_ready(struct kbase_device *kbdev, + bool tiler_required, bool shader_required) +{ + lockdep_assert_held(&kbdev->hwaccess_lock); -/** - * kbase_pm_release_cores - Release cores after a job has run - * - * @kbdev: The kbase device structure for the device - * @tiler_required: true if the tiler is required, false otherwise - * @shader_cores: A bitmask of shader cores (as given to - * kbase_pm_register_inuse_cores() ) - * - * This function should be called when a job has finished running on the - * hardware. A call to kbase_pm_register_inuse_cores() must have previously - * occurred. The reference counts of the specified cores will be decremented - * which may cause the bitmask of 'inuse' cores to be reduced. The power policy - * may then turn off any cores which are no longer 'inuse'. - */ -void kbase_pm_release_cores(struct kbase_device *kbdev, - bool tiler_required, u64 shader_cores); + if ((shader_required && !kbdev->shader_ready_bitmap) || + (tiler_required && !kbdev->tiler_available_bitmap)) + return false; + + return true; +} /** * kbase_pm_request_l2_caches - Request l2 caches |