summaryrefslogtreecommitdiff
path: root/mali_kbase/mali_kbase_core_linux.c
diff options
context:
space:
mode:
authorSiddharth Kapoor <ksiddharth@google.com>2022-03-02 14:51:29 +0800
committerSiddharth Kapoor <ksiddharth@google.com>2022-03-02 14:51:29 +0800
commit88d7d984fed1c2a4358ce2bbc334e82d71e3a391 (patch)
tree18f20402a0ed15ae9fe62b29a9957922ebcc2ada /mali_kbase/mali_kbase_core_linux.c
parent0207d6c3b7a2002f15c60d08617e956faf5ba90c (diff)
downloadgpu-88d7d984fed1c2a4358ce2bbc334e82d71e3a391.tar.gz
Mali Valhall Android DDK r36p0 KMD
Provenance: 9f72c118d9 (ipdelivery/EAC/v_r36p0) VX504X08X-BU-00000-r36p0-01eac0 - Valhall Android DDK VX504X08X-BU-60000-r36p0-01eac0 - Valhall Android Document Bundle VX504X08X-DC-11001-r36p0-01eac0 - Valhall Android DDK Software Errata VX504X08X-SW-99006-r36p0-01eac0 - Valhall Android Renderscript AOSP parts Signed-off-by: Siddharth Kapoor <ksiddharth@google.com> Change-Id: I4a63b707fedc68d7b7d046596c7098da47a139cb
Diffstat (limited to 'mali_kbase/mali_kbase_core_linux.c')
-rw-r--r--mali_kbase/mali_kbase_core_linux.c687
1 files changed, 397 insertions, 290 deletions
diff --git a/mali_kbase/mali_kbase_core_linux.c b/mali_kbase/mali_kbase_core_linux.c
index 0cbbf44..5197e4a 100644
--- a/mali_kbase/mali_kbase_core_linux.c
+++ b/mali_kbase/mali_kbase_core_linux.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
/*
*
- * (C) COPYRIGHT 2010-2021 ARM Limited. All rights reserved.
+ * (C) COPYRIGHT 2010-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
@@ -86,6 +86,7 @@
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/of_platform.h>
#include <linux/miscdevice.h>
@@ -140,12 +141,15 @@
#define KBASE_API_MAJ(api_version) ((api_version >> 20) & 0xFFF)
/**
- * typedef mali_kbase_capability_def - kbase capabilities table
+ * struct mali_kbase_capability_def - kbase capabilities table
+ *
+ * @required_major: required major
+ * @required_minor: required minor
*/
-typedef struct mali_kbase_capability_def {
+struct mali_kbase_capability_def {
u16 required_major;
u16 required_minor;
-} mali_kbase_capability_def;
+};
/*
* This must be kept in-sync with mali_kbase_cap
@@ -153,32 +157,34 @@ typedef struct mali_kbase_capability_def {
* TODO: The alternative approach would be to embed the cap enum values
* in the table. Less efficient but potentially safer.
*/
-static mali_kbase_capability_def kbase_caps_table[MALI_KBASE_NUM_CAPS] = {
+static const struct mali_kbase_capability_def kbase_caps_table[MALI_KBASE_NUM_CAPS] = {
#if MALI_USE_CSF
- { 1, 0 }, /* SYSTEM_MONITOR */
- { 1, 0 }, /* JIT_PRESSURE_LIMIT */
- { 1, 0 }, /* MEM_GROW_ON_GPF */
- { 1, 0 } /* MEM_PROTECTED */
+ { 1, 0 }, /* SYSTEM_MONITOR */
+ { 1, 0 }, /* JIT_PRESSURE_LIMIT */
+ { 1, 0 }, /* MEM_GROW_ON_GPF */
+ { 1, 0 } /* MEM_PROTECTED */
#else
- { 11, 15 }, /* SYSTEM_MONITOR */
- { 11, 25 }, /* JIT_PRESSURE_LIMIT */
- { 11, 2 }, /* MEM_GROW_ON_GPF */
- { 11, 2 } /* MEM_PROTECTED */
+ { 11, 15 }, /* SYSTEM_MONITOR */
+ { 11, 25 }, /* JIT_PRESSURE_LIMIT */
+ { 11, 2 }, /* MEM_GROW_ON_GPF */
+ { 11, 2 } /* MEM_PROTECTED */
#endif
};
/**
* mali_kbase_supports_cap - Query whether a kbase capability is supported
*
- * @api_version: API version to convert
- * @cap: Capability to query for - see mali_kbase_caps.h
+ * @api_version: API version to convert
+ * @cap: Capability to query for - see mali_kbase_caps.h
+ *
+ * Return: true if the capability is supported
*/
-bool mali_kbase_supports_cap(unsigned long api_version, mali_kbase_cap cap)
+bool mali_kbase_supports_cap(unsigned long api_version, enum mali_kbase_cap cap)
{
bool supported = false;
unsigned long required_ver;
- mali_kbase_capability_def const *cap_def;
+ struct mali_kbase_capability_def const *cap_def;
if (WARN_ON(cap < 0))
return false;
@@ -205,7 +211,7 @@ bool mali_kbase_supports_cap(unsigned long api_version, mali_kbase_cap cap)
* address space) and no API version number. Both must be assigned before
* kbase_file_get_kctx_if_setup_complete() can be used successfully.
*
- * @return Address of an object representing a simulated device file, or NULL
+ * Return: Address of an object representing a simulated device file, or NULL
* on failure.
*/
static struct kbase_file *kbase_file_new(struct kbase_device *const kbdev,
@@ -784,14 +790,14 @@ static int kbase_api_job_submit(struct kbase_context *kctx,
}
#endif /* !MALI_USE_CSF */
-static int kbase_api_get_gpuprops(struct kbase_context *kctx,
+static int kbase_api_get_gpuprops(struct kbase_file *kfile,
struct kbase_ioctl_get_gpuprops *get_props)
{
- struct kbase_gpu_props *kprops = &kctx->kbdev->gpu_props;
+ struct kbase_gpu_props *kprops = &kfile->kbdev->gpu_props;
int err;
if (get_props->flags != 0) {
- dev_err(kctx->kbdev->dev, "Unsupported flags to get_gpuprops");
+ dev_err(kfile->kbdev->dev, "Unsupported flags to get_gpuprops");
return -EINVAL;
}
@@ -816,11 +822,12 @@ static int kbase_api_post_term(struct kbase_context *kctx)
}
#endif /* !MALI_USE_CSF */
-static int kbase_api_mem_alloc(struct kbase_context *kctx,
- union kbase_ioctl_mem_alloc *alloc)
+#if MALI_USE_CSF
+static int kbase_api_mem_alloc_ex(struct kbase_context *kctx,
+ union kbase_ioctl_mem_alloc_ex *alloc_ex)
{
struct kbase_va_region *reg;
- u64 flags = alloc->in.flags;
+ u64 flags = alloc_ex->in.flags;
u64 gpu_va;
/* Calls to this function are inherently asynchronous, with respect to
@@ -828,24 +835,60 @@ static int kbase_api_mem_alloc(struct kbase_context *kctx,
*/
const enum kbase_caller_mmu_sync_info mmu_sync_info = CALLER_MMU_ASYNC;
+ bool gpu_executable = (flags & BASE_MEM_PROT_GPU_EX) && kbase_has_exec_va_zone(kctx);
+ bool fixed_or_fixable = (flags & (BASE_MEM_FIXED | BASE_MEM_FIXABLE));
+
if (!kbase_mem_allow_alloc(kctx))
return -EINVAL;
+ /* The driver counts the number of FIXABLE and FIXED allocations because
+ * they're not supposed to happen at the same time. However, that is not
+ * a security concern: nothing bad happens if the two types of allocations
+ * are made at the same time. The only reason why the driver is guarding
+ * against them is because there's no client use case that is supposed
+ * to need both of them at the same time, and the driver wants to help
+ * the user space catch some obvious mistake.
+ *
+ * The driver is able to switch from FIXABLE allocations to FIXED and
+ * vice versa, if all the allocations of one kind are freed before trying
+ * to create allocations of a different kind.
+ */
+ if ((flags & BASE_MEM_FIXED) && (atomic64_read(&kctx->num_fixable_allocs) > 0))
+ return -EINVAL;
+
+ if ((flags & BASE_MEM_FIXABLE) && (atomic64_read(&kctx->num_fixed_allocs) > 0))
+ return -EINVAL;
+
if (flags & BASEP_MEM_FLAGS_KERNEL_ONLY)
return -ENOMEM;
- /* Force SAME_VA if a 64-bit client.
- * The only exception is GPU-executable memory if an EXEC_VA zone
- * has been initialized. In that case, GPU-executable memory may
- * or may not be SAME_VA.
+ /* The fixed_address parameter must be either a non-zero, page-aligned
+ * value for FIXED allocations or zero for any other kind of allocation.
+ */
+ if (flags & BASE_MEM_FIXED) {
+ u64 aligned_fixed_address = alloc_ex->in.fixed_address & PAGE_MASK;
+
+ if ((aligned_fixed_address == 0) ||
+ (aligned_fixed_address != alloc_ex->in.fixed_address))
+ return -EINVAL;
+
+ gpu_va = aligned_fixed_address;
+ } else if (alloc_ex->in.fixed_address != 0) {
+ return -EINVAL;
+ }
+
+ /* For 64-bit clients, force SAME_VA up to 2^(47)-1.
+ * For 32-bit clients, force SAME_VA up to 2^(32)-1.
+ *
+ * In both cases, the executable and fixed/fixable zones, and
+ * the executable+fixed/fixable zone, are all above this range.
*/
if ((!kbase_ctx_flag(kctx, KCTX_COMPAT)) &&
kbase_ctx_flag(kctx, KCTX_FORCE_SAME_VA)) {
- if (!(flags & BASE_MEM_PROT_GPU_EX) || !kbase_has_exec_va_zone(kctx))
+ if (!gpu_executable && !fixed_or_fixable)
flags |= BASE_MEM_SAME_VA;
}
-#if MALI_USE_CSF
/* If CSF event memory allocation, need to force certain flags.
* SAME_VA - GPU address needs to be used as a CPU address, explicit
* mmap has to be avoided.
@@ -854,15 +897,75 @@ static int kbase_api_mem_alloc(struct kbase_context *kctx,
* to event memory so need to leverage the coherency support.
*/
if (flags & BASE_MEM_CSF_EVENT) {
+ /* We cannot honor this request */
+ if (gpu_executable || fixed_or_fixable)
+ return -ENOMEM;
+
flags |= (BASE_MEM_SAME_VA |
BASE_MEM_CACHED_CPU |
BASE_MEM_COHERENT_SYSTEM);
}
-#endif
- reg = kbase_mem_alloc(kctx, alloc->in.va_pages, alloc->in.commit_pages,
- alloc->in.extension, &flags, &gpu_va,
- mmu_sync_info);
+ reg = kbase_mem_alloc(kctx, alloc_ex->in.va_pages, alloc_ex->in.commit_pages,
+ alloc_ex->in.extension, &flags, &gpu_va, mmu_sync_info);
+
+ if (!reg)
+ return -ENOMEM;
+
+ alloc_ex->out.flags = flags;
+ alloc_ex->out.gpu_va = gpu_va;
+
+ return 0;
+}
+
+static int kbase_api_mem_alloc(struct kbase_context *kctx, union kbase_ioctl_mem_alloc *alloc)
+{
+ int ret;
+ union kbase_ioctl_mem_alloc_ex mem_alloc_ex = { { 0 } };
+
+ mem_alloc_ex.in.va_pages = alloc->in.va_pages;
+ mem_alloc_ex.in.commit_pages = alloc->in.commit_pages;
+ mem_alloc_ex.in.extension = alloc->in.extension;
+ mem_alloc_ex.in.flags = alloc->in.flags;
+ mem_alloc_ex.in.fixed_address = 0;
+
+ ret = kbase_api_mem_alloc_ex(kctx, &mem_alloc_ex);
+
+ alloc->out.flags = mem_alloc_ex.out.flags;
+ alloc->out.gpu_va = mem_alloc_ex.out.gpu_va;
+
+ return ret;
+}
+#else
+static int kbase_api_mem_alloc(struct kbase_context *kctx, union kbase_ioctl_mem_alloc *alloc)
+{
+ struct kbase_va_region *reg;
+ u64 flags = alloc->in.flags;
+ u64 gpu_va;
+
+ /* Calls to this function are inherently asynchronous, with respect to
+ * MMU operations.
+ */
+ const enum kbase_caller_mmu_sync_info mmu_sync_info = CALLER_MMU_ASYNC;
+
+ if (!kbase_mem_allow_alloc(kctx))
+ return -EINVAL;
+
+ if (flags & BASEP_MEM_FLAGS_KERNEL_ONLY)
+ return -ENOMEM;
+
+ /* Force SAME_VA if a 64-bit client.
+ * The only exception is GPU-executable memory if an EXEC_VA zone
+ * has been initialized. In that case, GPU-executable memory may
+ * or may not be SAME_VA.
+ */
+ if ((!kbase_ctx_flag(kctx, KCTX_COMPAT)) && kbase_ctx_flag(kctx, KCTX_FORCE_SAME_VA)) {
+ if (!(flags & BASE_MEM_PROT_GPU_EX) || !kbase_has_exec_va_zone(kctx))
+ flags |= BASE_MEM_SAME_VA;
+ }
+
+ reg = kbase_mem_alloc(kctx, alloc->in.va_pages, alloc->in.commit_pages, alloc->in.extension,
+ &flags, &gpu_va, mmu_sync_info);
if (!reg)
return -ENOMEM;
@@ -872,6 +975,7 @@ static int kbase_api_mem_alloc(struct kbase_context *kctx,
return 0;
}
+#endif /* MALI_USE_CSF */
static int kbase_api_mem_query(struct kbase_context *kctx,
union kbase_ioctl_mem_query *query)
@@ -1649,6 +1753,10 @@ static long kbase_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
union kbase_ioctl_kinstr_prfcnt_setup,
kfile);
break;
+ case KBASE_IOCTL_GET_GPUPROPS:
+ KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_GET_GPUPROPS, kbase_api_get_gpuprops,
+ struct kbase_ioctl_get_gpuprops, kfile);
+ break;
}
kctx = kbase_file_get_kctx_if_setup_complete(kfile);
@@ -1665,12 +1773,6 @@ static long kbase_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
kctx);
break;
#endif /* !MALI_USE_CSF */
- case KBASE_IOCTL_GET_GPUPROPS:
- KBASE_HANDLE_IOCTL_IN(KBASE_IOCTL_GET_GPUPROPS,
- kbase_api_get_gpuprops,
- struct kbase_ioctl_get_gpuprops,
- kctx);
- break;
#if !MALI_USE_CSF
case KBASE_IOCTL_POST_TERM:
KBASE_HANDLE_IOCTL(KBASE_IOCTL_POST_TERM,
@@ -1684,6 +1786,12 @@ static long kbase_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
union kbase_ioctl_mem_alloc,
kctx);
break;
+#if MALI_USE_CSF
+ case KBASE_IOCTL_MEM_ALLOC_EX:
+ KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_MEM_ALLOC_EX, kbase_api_mem_alloc_ex,
+ union kbase_ioctl_mem_alloc_ex, kctx);
+ break;
+#endif
case KBASE_IOCTL_MEM_QUERY:
KBASE_HANDLE_IOCTL_INOUT(KBASE_IOCTL_MEM_QUERY,
kbase_api_mem_query,
@@ -2062,6 +2170,8 @@ static ssize_t kbase_read(struct file *filp, char __user *buf, size_t count, lof
if (count < sizeof(uevent))
return -ENOBUFS;
+ memset(&uevent, 0, sizeof(uevent));
+
do {
while (kbase_event_dequeue(kctx, &uevent)) {
if (out_count > 0)
@@ -2191,19 +2301,19 @@ static const struct file_operations kbase_fops = {
};
/**
- * show_policy - Show callback for the power_policy sysfs file.
- *
- * This function is called to get the contents of the power_policy sysfs
- * file. This is a list of the available policies with the currently active one
- * surrounded by square brackets.
+ * power_policy_show - Show callback for the power_policy sysfs file.
*
* @dev: The device this sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The output buffer for the sysfs file contents
*
+ * This function is called to get the contents of the power_policy sysfs
+ * file. This is a list of the available policies with the currently active one
+ * surrounded by square brackets.
+ *
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_policy(struct device *dev, struct device_attribute *attr, char *const buf)
+static ssize_t power_policy_show(struct device *dev, struct device_attribute *attr, char *const buf)
{
struct kbase_device *kbdev;
const struct kbase_pm_policy *current_policy;
@@ -2240,21 +2350,21 @@ static ssize_t show_policy(struct device *dev, struct device_attribute *attr, ch
}
/**
- * set_policy - Store callback for the power_policy sysfs file.
- *
- * This function is called when the power_policy sysfs file is written to.
- * It matches the requested policy against the available policies and if a
- * matching policy is found calls kbase_pm_set_policy() to change the
- * policy.
+ * power_policy_store - Store callback for the power_policy sysfs file.
*
* @dev: The device with sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
* @count: The number of bytes to write to the sysfs file
*
+ * This function is called when the power_policy sysfs file is written to.
+ * It matches the requested policy against the available policies and if a
+ * matching policy is found calls kbase_pm_set_policy() to change the
+ * policy.
+ *
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_policy(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t power_policy_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
const struct kbase_pm_policy *new_policy = NULL;
@@ -2293,20 +2403,20 @@ static ssize_t set_policy(struct device *dev, struct device_attribute *attr, con
* determining which policy is currently active, and changing the active
* policy.
*/
-static DEVICE_ATTR(power_policy, S_IRUGO | S_IWUSR, show_policy, set_policy);
+static DEVICE_ATTR_RW(power_policy);
/*
- * show_core_mask - Show callback for the core_mask sysfs file.
- *
- * This function is called to get the contents of the core_mask sysfs file.
+ * core_mask_show - Show callback for the core_mask sysfs file.
*
* @dev: The device this sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The output buffer for the sysfs file contents
*
+ * This function is called to get the contents of the core_mask sysfs file.
+ *
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_core_mask(struct device *dev, struct device_attribute *attr, char * const buf)
+static ssize_t core_mask_show(struct device *dev, struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
unsigned long flags;
@@ -2351,18 +2461,18 @@ static ssize_t show_core_mask(struct device *dev, struct device_attribute *attr,
}
/**
- * set_core_mask - Store callback for the core_mask sysfs file.
- *
- * This function is called when the core_mask sysfs file is written to.
+ * core_mask_store - Store callback for the core_mask sysfs file.
*
* @dev: The device with sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
* @count: The number of bytes to write to the sysfs file
*
+ * This function is called when the core_mask sysfs file is written to.
+ *
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_core_mask(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t core_mask_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
#if MALI_USE_CSF
@@ -2492,11 +2602,11 @@ end:
* Reading it will show the current core mask and the mask of cores available.
* Writing to it will set the current core mask.
*/
-static DEVICE_ATTR(core_mask, S_IRUGO | S_IWUSR, show_core_mask, set_core_mask);
+static DEVICE_ATTR_RW(core_mask);
#if !MALI_USE_CSF
/**
- * set_soft_job_timeout - Store callback for the soft_job_timeout sysfs
+ * soft_job_timeout_store - Store callback for the soft_job_timeout sysfs
* file.
*
* @dev: The device this sysfs file is for.
@@ -2512,7 +2622,7 @@ static DEVICE_ATTR(core_mask, S_IRUGO | S_IWUSR, show_core_mask, set_core_mask);
*
* Return: count if the function succeeded. An error code on failure.
*/
-static ssize_t set_soft_job_timeout(struct device *dev,
+static ssize_t soft_job_timeout_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -2534,18 +2644,18 @@ static ssize_t set_soft_job_timeout(struct device *dev,
}
/**
- * show_soft_job_timeout - Show callback for the soft_job_timeout sysfs
+ * soft_job_timeout_show - Show callback for the soft_job_timeout sysfs
* file.
*
- * This will return the timeout for the software jobs.
- *
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer for the sysfs file contents.
*
+ * This will return the timeout for the software jobs.
+ *
* Return: The number of bytes output to buf.
*/
-static ssize_t show_soft_job_timeout(struct device *dev,
+static ssize_t soft_job_timeout_show(struct device *dev,
struct device_attribute *attr,
char * const buf)
{
@@ -2559,14 +2669,14 @@ static ssize_t show_soft_job_timeout(struct device *dev,
atomic_read(&kbdev->js_data.soft_job_timeout_ms));
}
-static DEVICE_ATTR(soft_job_timeout, S_IRUGO | S_IWUSR,
- show_soft_job_timeout, set_soft_job_timeout);
+static DEVICE_ATTR_RW(soft_job_timeout);
static u32 timeout_ms_to_ticks(struct kbase_device *kbdev, long timeout_ms,
int default_ticks, u32 old_ticks)
{
if (timeout_ms > 0) {
u64 ticks = timeout_ms * 1000000ULL;
+
do_div(ticks, kbdev->js_data.scheduling_period_ns);
if (!ticks)
return 1;
@@ -2579,7 +2689,12 @@ static u32 timeout_ms_to_ticks(struct kbase_device *kbdev, long timeout_ms,
}
/**
- * set_js_timeouts - Store callback for the js_timeouts sysfs file.
+ * js_timeouts_store - Store callback for the js_timeouts sysfs file.
+ *
+ * @dev: The device with sysfs file is for
+ * @attr: The attributes of the sysfs file
+ * @buf: The value written to the sysfs file
+ * @count: The number of bytes to write to the sysfs file
*
* This function is called to get the contents of the js_timeouts sysfs
* file. This file contains five values separated by whitespace. The values
@@ -2592,14 +2707,9 @@ static u32 timeout_ms_to_ticks(struct kbase_device *kbdev, long timeout_ms,
* use by the job scheduler to get override. Note that a value needs to
* be other than 0 for it to override the current job scheduler value.
*
- * @dev: The device with sysfs file is for
- * @attr: The attributes of the sysfs file
- * @buf: The value written to the sysfs file
- * @count: The number of bytes to write to the sysfs file
- *
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_js_timeouts(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t js_timeouts_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
int items;
@@ -2679,19 +2789,20 @@ static unsigned long get_js_timeout_in_ms(
}
/**
- * show_js_timeouts - Show callback for the js_timeouts sysfs file.
+ * js_timeouts_show - Show callback for the js_timeouts sysfs file.
+ *
+ * @dev: The device this sysfs file is for
+ * @attr: The attributes of the sysfs file
+ * @buf: The output buffer for the sysfs file contents
*
* This function is called to get the contents of the js_timeouts sysfs
* file. It returns the last set values written to the js_timeouts sysfs file.
* If the file didn't get written yet, the values will be current setting in
* use.
- * @dev: The device this sysfs file is for
- * @attr: The attributes of the sysfs file
- * @buf: The output buffer for the sysfs file contents
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_js_timeouts(struct device *dev, struct device_attribute *attr, char * const buf)
+static ssize_t js_timeouts_show(struct device *dev, struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
ssize_t ret;
@@ -2754,7 +2865,7 @@ static ssize_t show_js_timeouts(struct device *dev, struct device_attribute *att
* JS_RESET_TICKS_CL
* JS_RESET_TICKS_DUMPING.
*/
-static DEVICE_ATTR(js_timeouts, S_IRUGO | S_IWUSR, show_js_timeouts, set_js_timeouts);
+static DEVICE_ATTR_RW(js_timeouts);
static u32 get_new_js_timeout(
u32 old_period,
@@ -2762,12 +2873,13 @@ static u32 get_new_js_timeout(
u32 new_scheduling_period_ns)
{
u64 ticks = (u64)old_period * (u64)old_ticks;
+
do_div(ticks, new_scheduling_period_ns);
return ticks?ticks:1;
}
/**
- * set_js_scheduling_period - Store callback for the js_scheduling_period sysfs
+ * js_scheduling_period_store - Store callback for the js_scheduling_period sysfs
* file
* @dev: The device the sysfs file is for
* @attr: The attributes of the sysfs file
@@ -2780,7 +2892,7 @@ static u32 get_new_js_timeout(
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_js_scheduling_period(struct device *dev,
+static ssize_t js_scheduling_period_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
@@ -2849,7 +2961,7 @@ static ssize_t set_js_scheduling_period(struct device *dev,
}
/**
- * show_js_scheduling_period - Show callback for the js_scheduling_period sysfs
+ * js_scheduling_period_show - Show callback for the js_scheduling_period sysfs
* entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
@@ -2860,7 +2972,7 @@ static ssize_t set_js_scheduling_period(struct device *dev,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_js_scheduling_period(struct device *dev,
+static ssize_t js_scheduling_period_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
@@ -2879,12 +2991,11 @@ static ssize_t show_js_scheduling_period(struct device *dev,
return ret;
}
-static DEVICE_ATTR(js_scheduling_period, S_IRUGO | S_IWUSR,
- show_js_scheduling_period, set_js_scheduling_period);
+static DEVICE_ATTR_RW(js_scheduling_period);
#ifdef CONFIG_MALI_DEBUG
-static ssize_t set_js_softstop_always(struct device *dev,
+static ssize_t js_softstop_always_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
@@ -2909,7 +3020,7 @@ static ssize_t set_js_softstop_always(struct device *dev,
return count;
}
-static ssize_t show_js_softstop_always(struct device *dev,
+static ssize_t js_softstop_always_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
@@ -2936,7 +3047,7 @@ static ssize_t show_js_softstop_always(struct device *dev,
* used for debug and unit-testing purposes.
* (see CL t6xx_stress_1 unit-test as an example whereby this feature is used.)
*/
-static DEVICE_ATTR(js_softstop_always, S_IRUGO | S_IWUSR, show_js_softstop_always, set_js_softstop_always);
+static DEVICE_ATTR_RW(js_softstop_always);
#endif /* CONFIG_MALI_DEBUG */
#endif /* !MALI_USE_CSF */
@@ -2963,24 +3074,24 @@ static void kbasep_ktrace_dump_wrapper(struct kbase_device *kbdev)
/* Debug commands supported by the driver */
static const struct kbasep_debug_command debug_commands[] = {
{
- .str = "dumptrace",
- .func = &kbasep_ktrace_dump_wrapper,
- }
+ .str = "dumptrace",
+ .func = &kbasep_ktrace_dump_wrapper,
+ }
};
/**
- * show_debug - Show callback for the debug_command sysfs file.
- *
- * This function is called to get the contents of the debug_command sysfs
- * file. This is a list of the available debug commands, separated by newlines.
+ * debug_command_show - Show callback for the debug_command sysfs file.
*
* @dev: The device this sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The output buffer for the sysfs file contents
*
+ * This function is called to get the contents of the debug_command sysfs
+ * file. This is a list of the available debug commands, separated by newlines.
+ *
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_debug(struct device *dev, struct device_attribute *attr, char * const buf)
+static ssize_t debug_command_show(struct device *dev, struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
int i;
@@ -3004,21 +3115,21 @@ static ssize_t show_debug(struct device *dev, struct device_attribute *attr, cha
}
/**
- * issue_debug - Store callback for the debug_command sysfs file.
- *
- * This function is called when the debug_command sysfs file is written to.
- * It matches the requested command against the available commands, and if
- * a matching command is found calls the associated function from
- * @debug_commands to issue the command.
+ * debug_command_store - Store callback for the debug_command sysfs file.
*
* @dev: The device with sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
* @count: The number of bytes written to the sysfs file
*
+ * This function is called when the debug_command sysfs file is written to.
+ * It matches the requested command against the available commands, and if
+ * a matching command is found calls the associated function from
+ * @debug_commands to issue the command.
+ *
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t issue_debug(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
+static ssize_t debug_command_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
int i;
@@ -3046,11 +3157,11 @@ static ssize_t issue_debug(struct device *dev, struct device_attribute *attr, co
* Reading it will produce a list of debug commands, separated by newlines.
* Writing to it with one of those commands will issue said command.
*/
-static DEVICE_ATTR(debug_command, S_IRUGO | S_IWUSR, show_debug, issue_debug);
+static DEVICE_ATTR_RW(debug_command);
#endif /* CONFIG_MALI_DEBUG */
/**
- * kbase_show_gpuinfo - Show callback for the gpuinfo sysfs entry.
+ * gpuinfo_show - Show callback for the gpuinfo sysfs entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer to receive the GPU information.
@@ -3064,61 +3175,61 @@ static DEVICE_ATTR(debug_command, S_IRUGO | S_IWUSR, show_debug, issue_debug);
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t kbase_show_gpuinfo(struct device *dev,
+static ssize_t gpuinfo_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
static const struct gpu_product_id_name {
- unsigned id;
+ unsigned int id;
char *name;
} gpu_product_id_names[] = {
- { .id = GPU_ID2_PRODUCT_TMIX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TMIX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G71" },
- { .id = GPU_ID2_PRODUCT_THEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_THEX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G72" },
- { .id = GPU_ID2_PRODUCT_TSIX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TSIX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G51" },
- { .id = GPU_ID2_PRODUCT_TNOX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TNOX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G76" },
- { .id = GPU_ID2_PRODUCT_TDVX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TDVX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G31" },
- { .id = GPU_ID2_PRODUCT_TGOX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TGOX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G52" },
- { .id = GPU_ID2_PRODUCT_TTRX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TTRX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G77" },
- { .id = GPU_ID2_PRODUCT_TBEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TBEX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G78" },
- { .id = GPU_ID2_PRODUCT_TBAX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TBAX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G78AE" },
- { .id = GPU_ID2_PRODUCT_LBEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_LBEX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G68" },
- { .id = GPU_ID2_PRODUCT_TNAX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TNAX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G57" },
- { .id = GPU_ID2_PRODUCT_TODX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TODX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G710" },
- { .id = GPU_ID2_PRODUCT_LODX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_LODX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G610" },
- { .id = GPU_ID2_PRODUCT_TGRX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TGRX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G510" },
- { .id = GPU_ID2_PRODUCT_TVAX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TVAX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-G310" },
- { .id = GPU_ID2_PRODUCT_TTUX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_TTUX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-TTUX" },
- { .id = GPU_ID2_PRODUCT_LTUX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT,
+ { .id = GPU_ID2_PRODUCT_LTUX >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT,
.name = "Mali-LTUX" },
};
const char *product_name = "(Unknown Mali GPU)";
struct kbase_device *kbdev;
u32 gpu_id;
- unsigned product_id, product_id_mask;
- unsigned i;
+ unsigned int product_id, product_id_mask;
+ unsigned int i;
kbdev = to_kbase_device(dev);
if (!kbdev)
return -ENODEV;
gpu_id = kbdev->gpu_props.props.raw_props.gpu_id;
- product_id = gpu_id >> GPU_ID_VERSION_PRODUCT_ID_SHIFT;
- product_id_mask = GPU_ID2_PRODUCT_MODEL >> GPU_ID_VERSION_PRODUCT_ID_SHIFT;
+ product_id = gpu_id >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
+ product_id_mask = GPU_ID2_PRODUCT_MODEL >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
for (i = 0; i < ARRAY_SIZE(gpu_product_id_names); ++i) {
const struct gpu_product_id_name *p = &gpu_product_id_names[i];
@@ -3130,16 +3241,16 @@ static ssize_t kbase_show_gpuinfo(struct device *dev,
}
}
- return scnprintf(buf, PAGE_SIZE, "%s %d cores r%dp%d 0x%04X\n",
- product_name, kbdev->gpu_props.num_cores,
- (gpu_id & GPU_ID_VERSION_MAJOR) >> GPU_ID_VERSION_MAJOR_SHIFT,
- (gpu_id & GPU_ID_VERSION_MINOR) >> GPU_ID_VERSION_MINOR_SHIFT,
- product_id);
+ return scnprintf(buf, PAGE_SIZE, "%s %d cores r%dp%d 0x%04X\n", product_name,
+ kbdev->gpu_props.num_cores,
+ (gpu_id & GPU_ID_VERSION_MAJOR) >> KBASE_GPU_ID_VERSION_MAJOR_SHIFT,
+ (gpu_id & GPU_ID_VERSION_MINOR) >> KBASE_GPU_ID_VERSION_MINOR_SHIFT,
+ product_id);
}
-static DEVICE_ATTR(gpuinfo, S_IRUGO, kbase_show_gpuinfo, NULL);
+static DEVICE_ATTR_RO(gpuinfo);
/**
- * set_dvfs_period - Store callback for the dvfs_period sysfs file.
+ * dvfs_period_store - Store callback for the dvfs_period sysfs file.
* @dev: The device with sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
@@ -3150,7 +3261,7 @@ static DEVICE_ATTR(gpuinfo, S_IRUGO, kbase_show_gpuinfo, NULL);
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_dvfs_period(struct device *dev,
+static ssize_t dvfs_period_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
@@ -3175,7 +3286,7 @@ static ssize_t set_dvfs_period(struct device *dev,
}
/**
- * show_dvfs_period - Show callback for the dvfs_period sysfs entry.
+ * dvfs_period_show - Show callback for the dvfs_period sysfs entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer to receive the GPU information.
@@ -3185,7 +3296,7 @@ static ssize_t set_dvfs_period(struct device *dev,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_dvfs_period(struct device *dev,
+static ssize_t dvfs_period_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
@@ -3200,11 +3311,10 @@ static ssize_t show_dvfs_period(struct device *dev,
return ret;
}
-static DEVICE_ATTR(dvfs_period, S_IRUGO | S_IWUSR, show_dvfs_period,
- set_dvfs_period);
+static DEVICE_ATTR_RW(dvfs_period);
/**
- * set_pm_poweroff - Store callback for the pm_poweroff sysfs file.
+ * pm_poweroff_store - Store callback for the pm_poweroff sysfs file.
* @dev: The device with sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
@@ -3220,7 +3330,7 @@ static DEVICE_ATTR(dvfs_period, S_IRUGO | S_IWUSR, show_dvfs_period,
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_pm_poweroff(struct device *dev,
+static ssize_t pm_poweroff_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
@@ -3259,7 +3369,7 @@ static ssize_t set_pm_poweroff(struct device *dev,
}
/**
- * show_pm_poweroff - Show callback for the pm_poweroff sysfs entry.
+ * pm_poweroff_show - Show callback for the pm_poweroff sysfs entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer to receive the GPU information.
@@ -3269,7 +3379,7 @@ static ssize_t set_pm_poweroff(struct device *dev,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_pm_poweroff(struct device *dev,
+static ssize_t pm_poweroff_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
@@ -3293,80 +3403,10 @@ static ssize_t show_pm_poweroff(struct device *dev,
return ret;
}
-static DEVICE_ATTR(pm_poweroff, S_IRUGO | S_IWUSR, show_pm_poweroff,
- set_pm_poweroff);
+static DEVICE_ATTR_RW(pm_poweroff);
-#if MALI_USE_CSF
/**
- * set_idle_hysteresis_time - Store callback for CSF idle_hysteresis_time
- * sysfs file.
- * @dev: The device with sysfs file is for
- * @attr: The attributes of the sysfs file
- * @buf: The value written to the sysfs file
- * @count: The number of bytes written to the sysfs file
- *
- * This function is called when the idle_hysteresis_time sysfs file is
- * written to.
- *
- * This file contains values of the idle idle hysteresis duration.
- *
- * Return: @count if the function succeeded. An error code on failure.
- */
-static ssize_t set_idle_hysteresis_time(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct kbase_device *kbdev;
- u32 dur;
-
- kbdev = to_kbase_device(dev);
- if (!kbdev)
- return -ENODEV;
-
- if (kstrtou32(buf, 0, &dur)) {
- dev_err(kbdev->dev, "Couldn't process idle_hysteresis_time write operation.\n"
- "Use format <idle_hysteresis_time>\n");
- return -EINVAL;
- }
-
- kbase_csf_firmware_set_gpu_idle_hysteresis_time(kbdev, dur);
-
- return count;
-}
-
-/**
- * show_idle_hysteresis_time - Show callback for CSF idle_hysteresis_time
- * sysfs entry.
- * @dev: The device this sysfs file is for.
- * @attr: The attributes of the sysfs file.
- * @buf: The output buffer to receive the GPU information.
- *
- * This function is called to get the current idle hysteresis duration in ms.
- *
- * Return: The number of bytes output to @buf.
- */
-static ssize_t show_idle_hysteresis_time(struct device *dev,
- struct device_attribute *attr, char * const buf)
-{
- struct kbase_device *kbdev;
- ssize_t ret;
- u32 dur;
-
- kbdev = to_kbase_device(dev);
- if (!kbdev)
- return -ENODEV;
-
- dur = kbase_csf_firmware_get_gpu_idle_hysteresis_time(kbdev);
- ret = scnprintf(buf, PAGE_SIZE, "%u\n", dur);
-
- return ret;
-}
-
-static DEVICE_ATTR(idle_hysteresis_time, S_IRUGO | S_IWUSR,
- show_idle_hysteresis_time, set_idle_hysteresis_time);
-#endif
-
-/**
- * set_reset_timeout - Store callback for the reset_timeout sysfs file.
+ * reset_timeout_store - Store callback for the reset_timeout sysfs file.
* @dev: The device with sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
@@ -3377,7 +3417,7 @@ static DEVICE_ATTR(idle_hysteresis_time, S_IRUGO | S_IWUSR,
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_reset_timeout(struct device *dev,
+static ssize_t reset_timeout_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *kbdev;
@@ -3402,7 +3442,7 @@ static ssize_t set_reset_timeout(struct device *dev,
}
/**
- * show_reset_timeout - Show callback for the reset_timeout sysfs entry.
+ * reset_timeout_show - Show callback for the reset_timeout sysfs entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer to receive the GPU information.
@@ -3411,7 +3451,7 @@ static ssize_t set_reset_timeout(struct device *dev,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_reset_timeout(struct device *dev,
+static ssize_t reset_timeout_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
@@ -3426,11 +3466,9 @@ static ssize_t show_reset_timeout(struct device *dev,
return ret;
}
-static DEVICE_ATTR(reset_timeout, S_IRUGO | S_IWUSR, show_reset_timeout,
- set_reset_timeout);
+static DEVICE_ATTR_RW(reset_timeout);
-
-static ssize_t show_mem_pool_size(struct device *dev,
+static ssize_t mem_pool_size_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3443,7 +3481,7 @@ static ssize_t show_mem_pool_size(struct device *dev,
kbase_mem_pool_debugfs_size);
}
-static ssize_t set_mem_pool_size(struct device *dev,
+static ssize_t mem_pool_size_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3459,10 +3497,9 @@ static ssize_t set_mem_pool_size(struct device *dev,
return err ? err : count;
}
-static DEVICE_ATTR(mem_pool_size, S_IRUGO | S_IWUSR, show_mem_pool_size,
- set_mem_pool_size);
+static DEVICE_ATTR_RW(mem_pool_size);
-static ssize_t show_mem_pool_max_size(struct device *dev,
+static ssize_t mem_pool_max_size_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3475,7 +3512,7 @@ static ssize_t show_mem_pool_max_size(struct device *dev,
kbase_mem_pool_debugfs_max_size);
}
-static ssize_t set_mem_pool_max_size(struct device *dev,
+static ssize_t mem_pool_max_size_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3491,11 +3528,10 @@ static ssize_t set_mem_pool_max_size(struct device *dev,
return err ? err : count;
}
-static DEVICE_ATTR(mem_pool_max_size, S_IRUGO | S_IWUSR, show_mem_pool_max_size,
- set_mem_pool_max_size);
+static DEVICE_ATTR_RW(mem_pool_max_size);
/**
- * show_lp_mem_pool_size - Show size of the large memory pages pool.
+ * lp_mem_pool_size_show - Show size of the large memory pages pool.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer to receive the pool size.
@@ -3504,7 +3540,7 @@ static DEVICE_ATTR(mem_pool_max_size, S_IRUGO | S_IWUSR, show_mem_pool_max_size,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_lp_mem_pool_size(struct device *dev,
+static ssize_t lp_mem_pool_size_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3518,7 +3554,7 @@ static ssize_t show_lp_mem_pool_size(struct device *dev,
}
/**
- * set_lp_mem_pool_size - Set size of the large memory pages pool.
+ * lp_mem_pool_size_store - Set size of the large memory pages pool.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The value written to the sysfs file.
@@ -3529,7 +3565,7 @@ static ssize_t show_lp_mem_pool_size(struct device *dev,
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_lp_mem_pool_size(struct device *dev,
+static ssize_t lp_mem_pool_size_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3545,11 +3581,10 @@ static ssize_t set_lp_mem_pool_size(struct device *dev,
return err ? err : count;
}
-static DEVICE_ATTR(lp_mem_pool_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_size,
- set_lp_mem_pool_size);
+static DEVICE_ATTR_RW(lp_mem_pool_size);
/**
- * show_lp_mem_pool_max_size - Show maximum size of the large memory pages pool.
+ * lp_mem_pool_max_size_show - Show maximum size of the large memory pages pool.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The output buffer to receive the pool size.
@@ -3558,7 +3593,7 @@ static DEVICE_ATTR(lp_mem_pool_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_size,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_lp_mem_pool_max_size(struct device *dev,
+static ssize_t lp_mem_pool_max_size_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3572,7 +3607,7 @@ static ssize_t show_lp_mem_pool_max_size(struct device *dev,
}
/**
- * set_lp_mem_pool_max_size - Set maximum size of the large memory pages pool.
+ * lp_mem_pool_max_size_store - Set maximum size of the large memory pages pool.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
* @buf: The value written to the sysfs file.
@@ -3582,7 +3617,7 @@ static ssize_t show_lp_mem_pool_max_size(struct device *dev,
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_lp_mem_pool_max_size(struct device *dev,
+static ssize_t lp_mem_pool_max_size_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_device *const kbdev = to_kbase_device(dev);
@@ -3598,8 +3633,7 @@ static ssize_t set_lp_mem_pool_max_size(struct device *dev,
return err ? err : count;
}
-static DEVICE_ATTR(lp_mem_pool_max_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_max_size,
- set_lp_mem_pool_max_size);
+static DEVICE_ATTR_RW(lp_mem_pool_max_size);
/**
* show_simplified_mem_pool_max_size - Show the maximum size for the memory
@@ -3800,7 +3834,7 @@ static DEVICE_ATTR(ctx_default_max_size, 0600,
#if !MALI_USE_CSF
/**
- * show_js_ctx_scheduling_mode - Show callback for js_ctx_scheduling_mode sysfs
+ * js_ctx_scheduling_mode_show - Show callback for js_ctx_scheduling_mode sysfs
* entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
@@ -3810,7 +3844,7 @@ static DEVICE_ATTR(ctx_default_max_size, 0600,
*
* Return: The number of bytes output to @buf.
*/
-static ssize_t show_js_ctx_scheduling_mode(struct device *dev,
+static ssize_t js_ctx_scheduling_mode_show(struct device *dev,
struct device_attribute *attr, char * const buf)
{
struct kbase_device *kbdev;
@@ -3823,7 +3857,7 @@ static ssize_t show_js_ctx_scheduling_mode(struct device *dev,
}
/**
- * set_js_ctx_scheduling_mode - Set callback for js_ctx_scheduling_mode sysfs
+ * js_ctx_scheduling_mode_store - Set callback for js_ctx_scheduling_mode sysfs
* entry.
* @dev: The device this sysfs file is for.
* @attr: The attributes of the sysfs file.
@@ -3836,7 +3870,7 @@ static ssize_t show_js_ctx_scheduling_mode(struct device *dev,
*
* Return: @count if the function succeeded. An error code on failure.
*/
-static ssize_t set_js_ctx_scheduling_mode(struct device *dev,
+static ssize_t js_ctx_scheduling_mode_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
struct kbase_context *kctx;
@@ -3878,9 +3912,7 @@ static ssize_t set_js_ctx_scheduling_mode(struct device *dev,
return count;
}
-static DEVICE_ATTR(js_ctx_scheduling_mode, S_IRUGO | S_IWUSR,
- show_js_ctx_scheduling_mode,
- set_js_ctx_scheduling_mode);
+static DEVICE_ATTR_RW(js_ctx_scheduling_mode);
/* Number of entries in serialize_jobs_settings[] */
#define NR_SERIALIZE_JOBS_SETTINGS 5
@@ -3904,15 +3936,15 @@ static struct
* update_serialize_jobs_setting - Update the serialization setting for the
* submission of GPU jobs.
*
- * This function is called when the serialize_jobs sysfs/debugfs file is
- * written to. It matches the requested setting against the available settings
- * and if a matching setting is found updates kbdev->serialize_jobs.
- *
* @kbdev: An instance of the GPU platform device, allocated from the probe
* method of the driver.
* @buf: Buffer containing the value written to the sysfs/debugfs file.
* @count: The number of bytes to write to the sysfs/debugfs file.
*
+ * This function is called when the serialize_jobs sysfs/debugfs file is
+ * written to. It matches the requested setting against the available settings
+ * and if a matching setting is found updates kbdev->serialize_jobs.
+ *
* Return: @count if the function succeeded. An error code on failure.
*/
static ssize_t update_serialize_jobs_setting(struct kbase_device *kbdev,
@@ -4034,14 +4066,14 @@ static const struct file_operations kbasep_serialize_jobs_debugfs_fops = {
/**
* show_serialize_jobs_sysfs - Show callback for serialize_jobs sysfs file.
*
- * This function is called to get the contents of the serialize_jobs sysfs
- * file. This is a list of the available settings with the currently active
- * one surrounded by square brackets.
- *
* @dev: The device this sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The output buffer for the sysfs file contents
*
+ * This function is called to get the contents of the serialize_jobs sysfs
+ * file. This is a list of the available settings with the currently active
+ * one surrounded by square brackets.
+ *
* Return: The number of bytes output to @buf.
*/
static ssize_t show_serialize_jobs_sysfs(struct device *dev,
@@ -4076,15 +4108,15 @@ static ssize_t show_serialize_jobs_sysfs(struct device *dev,
/**
* store_serialize_jobs_sysfs - Store callback for serialize_jobs sysfs file.
*
- * This function is called when the serialize_jobs sysfs file is written to.
- * It matches the requested setting against the available settings and if a
- * matching setting is found updates kbdev->serialize_jobs.
- *
* @dev: The device this sysfs file is for
* @attr: The attributes of the sysfs file
* @buf: The value written to the sysfs file
* @count: The number of bytes to write to the sysfs file
*
+ * This function is called when the serialize_jobs sysfs file is written to.
+ * It matches the requested setting against the available settings and if a
+ * matching setting is found updates kbdev->serialize_jobs.
+ *
* Return: @count if the function succeeded. An error code on failure.
*/
static ssize_t store_serialize_jobs_sysfs(struct device *dev,
@@ -4364,8 +4396,8 @@ int kbase_device_pm_init(struct kbase_device *kbdev)
kbase_pm_register_access_enable(kbdev);
gpu_id = kbase_reg_read(kbdev, GPU_CONTROL_REG(GPU_ID));
kbase_pm_register_access_disable(kbdev);
- product_id = KBASE_UBFX32(gpu_id,
- GPU_ID_VERSION_PRODUCT_ID_SHIFT, 16);
+ product_id =
+ KBASE_UBFX32(gpu_id, KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT, 16);
gpu_model_id = GPU_ID2_MODEL_MATCH_VALUE(product_id);
if (gpu_model_id != GPU_ID2_PRODUCT_TGOX
@@ -4417,7 +4449,7 @@ int power_control_init(struct kbase_device *kbdev)
int err = 0;
unsigned int i;
#if defined(CONFIG_REGULATOR)
- static const char *regulator_names[] = {
+ static const char * const regulator_names[] = {
"mali", "shadercores"
};
BUILD_BUG_ON(ARRAY_SIZE(regulator_names) < BASE_MAX_NR_CLOCKS_REGULATORS);
@@ -4787,7 +4819,7 @@ int kbase_device_debugfs_init(struct kbase_device *kbdev)
&kbase_device_debugfs_mem_pool_max_size_fops);
if (kbase_hw_has_feature(kbdev, BASE_HW_FEATURE_PROTECTED_DEBUG_MODE)) {
- debugfs_create_file("protected_debug_mode", S_IRUGO,
+ debugfs_create_file("protected_debug_mode", 0444,
kbdev->mali_debugfs_directory, kbdev,
&fops_protected_debug_mode);
}
@@ -4806,7 +4838,7 @@ int kbase_device_debugfs_init(struct kbase_device *kbdev)
#endif /* CONFIG_MALI_DEVFREQ */
#if !MALI_USE_CSF
- debugfs_create_file("serialize_jobs", S_IRUGO | S_IWUSR,
+ debugfs_create_file("serialize_jobs", 0644,
kbdev->mali_debugfs_directory, kbdev,
&kbasep_serialize_jobs_debugfs_fops);
@@ -4832,12 +4864,13 @@ int kbase_device_coherency_init(struct kbase_device *kbdev)
u32 supported_coherency_bitmap =
kbdev->gpu_props.props.raw_props.coherency_mode;
const void *coherency_override_dts;
+ bool dma_coherent;
u32 override_coherency, gpu_id;
unsigned int prod_id;
gpu_id = kbdev->gpu_props.props.raw_props.gpu_id;
gpu_id &= GPU_ID_VERSION_PRODUCT_ID;
- prod_id = gpu_id >> GPU_ID_VERSION_PRODUCT_ID_SHIFT;
+ prod_id = gpu_id >> KBASE_GPU_ID_VERSION_PRODUCT_ID_SHIFT;
/* Only for tMIx :
* (COHERENCY_ACE_LITE | COHERENCY_ACE) was incorrectly
@@ -4856,12 +4889,23 @@ int kbase_device_coherency_init(struct kbase_device *kbdev)
/* device tree may override the coherency */
#if IS_ENABLED(CONFIG_OF)
+ /* treat "dma-coherency" as a synonym for ACE-lite */
+ dma_coherent = of_dma_is_coherent(kbdev->dev->of_node);
coherency_override_dts = of_get_property(kbdev->dev->of_node,
"system-coherency",
NULL);
- if (coherency_override_dts) {
-
- override_coherency = be32_to_cpup(coherency_override_dts);
+ if (coherency_override_dts || dma_coherent) {
+ if (coherency_override_dts) {
+ override_coherency = be32_to_cpup(coherency_override_dts);
+ if (dma_coherent && override_coherency != COHERENCY_ACE_LITE) {
+ dev_err(kbdev->dev,
+ "system-coherency needs to be 0 when dma-coherent is set\n");
+ return -EINVAL;
+ }
+ } else {
+ /* dma-coherent set and system-coherency not specified */
+ override_coherency = COHERENCY_ACE_LITE;
+ }
#if MALI_USE_CSF && !IS_ENABLED(CONFIG_MALI_NO_MALI)
/* ACE coherency mode is not supported by Driver on CSF GPUs.
@@ -4969,8 +5013,7 @@ static ssize_t csg_scheduling_period_show(struct device *dev,
return ret;
}
-static DEVICE_ATTR(csg_scheduling_period, 0644, csg_scheduling_period_show,
- csg_scheduling_period_store);
+static DEVICE_ATTR_RW(csg_scheduling_period);
/**
* fw_timeout_store - Store callback for the fw_timeout sysfs file.
@@ -5038,7 +5081,73 @@ static ssize_t fw_timeout_show(struct device *dev,
return ret;
}
-static DEVICE_ATTR(fw_timeout, 0644, fw_timeout_show, fw_timeout_store);
+static DEVICE_ATTR_RW(fw_timeout);
+
+/**
+ * idle_hysteresis_time_store - Store callback for CSF idle_hysteresis_time
+ * sysfs file.
+ * @dev: The device with sysfs file is for
+ * @attr: The attributes of the sysfs file
+ * @buf: The value written to the sysfs file
+ * @count: The number of bytes written to the sysfs file
+ *
+ * This function is called when the idle_hysteresis_time sysfs file is
+ * written to.
+ *
+ * This file contains values of the idle hysteresis duration.
+ *
+ * Return: @count if the function succeeded. An error code on failure.
+ */
+static ssize_t idle_hysteresis_time_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct kbase_device *kbdev;
+ u32 dur = 0;
+
+ kbdev = to_kbase_device(dev);
+ if (!kbdev)
+ return -ENODEV;
+
+ if (kstrtou32(buf, 0, &dur)) {
+ dev_err(kbdev->dev, "Couldn't process idle_hysteresis_time write operation.\n"
+ "Use format <idle_hysteresis_time>\n");
+ return -EINVAL;
+ }
+
+ kbase_csf_firmware_set_gpu_idle_hysteresis_time(kbdev, dur);
+
+ return count;
+}
+
+/**
+ * idle_hysteresis_time_show - Show callback for CSF idle_hysteresis_time
+ * sysfs entry.
+ * @dev: The device this sysfs file is for.
+ * @attr: The attributes of the sysfs file.
+ * @buf: The output buffer to receive the GPU information.
+ *
+ * This function is called to get the current idle hysteresis duration in ms.
+ *
+ * Return: The number of bytes output to @buf.
+ */
+static ssize_t idle_hysteresis_time_show(struct device *dev,
+ struct device_attribute *attr, char * const buf)
+{
+ struct kbase_device *kbdev;
+ ssize_t ret;
+ u32 dur;
+
+ kbdev = to_kbase_device(dev);
+ if (!kbdev)
+ return -ENODEV;
+
+ dur = kbase_csf_firmware_get_gpu_idle_hysteresis_time(kbdev);
+ ret = scnprintf(buf, PAGE_SIZE, "%u\n", dur);
+
+ return ret;
+}
+
+static DEVICE_ATTR_RW(idle_hysteresis_time);
#endif /* MALI_USE_CSF */
static struct attribute *kbase_scheduling_attrs[] = {
@@ -5062,15 +5171,13 @@ static struct attribute *kbase_attrs[] = {
&dev_attr_gpuinfo.attr,
&dev_attr_dvfs_period.attr,
&dev_attr_pm_poweroff.attr,
-#if MALI_USE_CSF
- &dev_attr_idle_hysteresis_time.attr,
-#endif
&dev_attr_reset_timeout.attr,
#if !MALI_USE_CSF
&dev_attr_js_scheduling_period.attr,
#else
&dev_attr_csg_scheduling_period.attr,
&dev_attr_fw_timeout.attr,
+ &dev_attr_idle_hysteresis_time.attr,
#endif /* !MALI_USE_CSF */
&dev_attr_power_policy.attr,
&dev_attr_core_mask.attr,
@@ -5233,10 +5340,10 @@ static int kbase_platform_device_probe(struct platform_device *pdev)
/**
* kbase_device_suspend - Suspend callback from the OS.
*
- * This is called by Linux when the device should suspend.
- *
* @dev: The device to suspend
*
+ * This is called by Linux when the device should suspend.
+ *
* Return: A standard Linux error code on failure, 0 otherwise.
*/
static int kbase_device_suspend(struct device *dev)
@@ -5268,10 +5375,10 @@ static int kbase_device_suspend(struct device *dev)
/**
* kbase_device_resume - Resume callback from the OS.
*
- * This is called by Linux when the device should resume from suspension.
- *
* @dev: The device to resume
*
+ * This is called by Linux when the device should resume from suspension.
+ *
* Return: A standard Linux error code
*/
static int kbase_device_resume(struct device *dev)
@@ -5303,12 +5410,12 @@ static int kbase_device_resume(struct device *dev)
/**
* kbase_device_runtime_suspend - Runtime suspend callback from the OS.
*
+ * @dev: The device to suspend
+ *
* This is called by Linux when the device should prepare for a condition in
* which it will not be able to communicate with the CPU(s) and RAM due to
* power management.
*
- * @dev: The device to suspend
- *
* Return: A standard Linux error code
*/
#ifdef KBASE_PM_RUNTIME
@@ -5349,10 +5456,10 @@ static int kbase_device_runtime_suspend(struct device *dev)
/**
* kbase_device_runtime_resume - Runtime resume callback from the OS.
*
- * This is called by Linux when the device should go into a fully active state.
- *
* @dev: The device to suspend
*
+ * This is called by Linux when the device should go into a fully active state.
+ *
* Return: A standard Linux error code
*/
@@ -5520,7 +5627,7 @@ void kbase_trace_mali_page_fault_insert_pages(u32 dev_id, int event, u32 value)
trace_mali_page_fault_insert_pages(dev_id, event, value);
}
-void kbase_trace_mali_total_alloc_pages_change(u32 dev_id, long long int event)
+void kbase_trace_mali_total_alloc_pages_change(u32 dev_id, long long event)
{
trace_mali_total_alloc_pages_change(dev_id, event);
}