summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Diver <diverj@google.com>2024-03-05 04:30:24 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2024-03-05 04:30:24 +0000
commit25b3644869b8cd7caa160f220689712f432591fb (patch)
tree2b4916e815dec456be77c4769f95a3e9bf128f9a
parentf0e8151d40baded811a3fc4756b989087a46ec5b (diff)
parent01d962ed80c456fb8b39584fec920621b2832f8a (diff)
downloadgpu-25b3644869b8cd7caa160f220689712f432591fb.tar.gz
mgm: sysfs node to manually retain SLC partition am: 01d962ed80
Original change: https://partner-android-review.googlesource.com/c/kernel/private/google-modules/gpu/+/2753879 Change-Id: I306292b24e42669dde336c5f41e64183cff16c37 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu7
-rw-r--r--mali_pixel/memory_group_manager.c23
-rw-r--r--mali_pixel/pixel_slc.c20
-rw-r--r--mali_pixel/pixel_slc.h5
4 files changed, 54 insertions, 1 deletions
diff --git a/mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu b/mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu
new file mode 100644
index 0000000..1d3bc11
--- /dev/null
+++ b/mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu
@@ -0,0 +1,7 @@
+What: /sys/kernel/pixel_stat/gpu/mem/slc_pin_partition
+Date: Feb 2024
+Contact: "Jack Diver" <diverj@google.com>
+Description:
+ Write-only node to manually pin the SLC partition in the enabled
+ state. This useful when profiling SLC performance.
+
diff --git a/mali_pixel/memory_group_manager.c b/mali_pixel/memory_group_manager.c
index 81abfb4..9076a65 100644
--- a/mali_pixel/memory_group_manager.c
+++ b/mali_pixel/memory_group_manager.c
@@ -254,6 +254,8 @@ extern struct kobject *pixel_stat_gpu_kobj;
#define MGM_ATTR_RO(_name) \
static struct kobj_attribute _name##_attr = __ATTR_RO(_name)
+#define MGM_ATTR_WO(_name) \
+ static struct kobj_attribute _name##_attr = __ATTR_WO(_name)
static ssize_t total_page_count_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
@@ -296,10 +298,31 @@ static ssize_t large_page_count_show(struct kobject *kobj,
}
MGM_ATTR_RO(large_page_count);
+static ssize_t slc_pin_partition_store(struct kobject* kobj,
+ struct kobj_attribute* attr,
+ const char* buf,
+ size_t count)
+{
+ struct mgm_groups *data = container_of(kobj, struct mgm_groups, kobj);
+ bool pin;
+
+ if (!data)
+ return -ENODEV;
+
+ if (kstrtobool(buf, &pin))
+ return -EINVAL;
+
+ slc_pin(&data->slc_data, pin);
+
+ return count;
+}
+MGM_ATTR_WO(slc_pin_partition);
+
static struct attribute *mgm_attrs[] = {
&total_page_count_attr.attr,
&small_page_count_attr.attr,
&large_page_count_attr.attr,
+ &slc_pin_partition_attr.attr,
NULL,
};
ATTRIBUTE_GROUPS(mgm);
diff --git a/mali_pixel/pixel_slc.c b/mali_pixel/pixel_slc.c
index f06d495..45506ab 100644
--- a/mali_pixel/pixel_slc.c
+++ b/mali_pixel/pixel_slc.c
@@ -56,7 +56,8 @@ static bool partition_required(struct slc_partition *pt)
{
lockdep_assert_held(&pt->lock);
- return atomic_read(&pt->refcount) && (pt->signal >= PARTITION_ENABLE_THRESHOLD);
+ return (atomic_read(&pt->refcount) && (pt->signal >= PARTITION_ENABLE_THRESHOLD)) ||
+ pt->pinned;
}
/**
@@ -251,6 +252,22 @@ void slc_update_signal(struct slc_data *data, u64 signal)
spin_unlock_irqrestore(&pt->lock, flags);
}
+void slc_pin(struct slc_data *data, bool pin)
+{
+ struct slc_partition *pt = &data->partition;
+ unsigned long flags;
+
+ spin_lock_irqsave(&pt->lock, flags);
+
+ pt->pinned = pin;
+ if (pin)
+ enable_partition(data, pt);
+ else if (!partition_required(pt))
+ queue_disable_worker(data);
+
+ spin_unlock_irqrestore(&pt->lock, flags);
+}
+
/**
* init_partition - Register and initialize a partition with the SLC driver.
*
@@ -291,6 +308,7 @@ static int init_partition(struct slc_data *data, struct slc_partition *pt, u32 i
.enabled = false,
.refcount = ATOMIC_INIT(0),
.signal = 0,
+ .pinned = false,
};
spin_lock_init(&pt->lock);
diff --git a/mali_pixel/pixel_slc.h b/mali_pixel/pixel_slc.h
index 1ac3da4..cb8e90d 100644
--- a/mali_pixel/pixel_slc.h
+++ b/mali_pixel/pixel_slc.h
@@ -54,6 +54,9 @@ struct slc_partition {
/** @signal: Partition enable/disable signal from SLC governor */
u64 signal;
+
+ /** @pinned: Is the partition pinned to the enabled state */
+ bool pinned;
};
/**
@@ -88,6 +91,8 @@ void slc_inc_refcount(struct slc_data *data);
void slc_dec_refcount(struct slc_data *data);
+void slc_pin(struct slc_data *data, bool pin);
+
void slc_update_signal(struct slc_data *data, u64 signal);
#endif /* _PIXEL_SLC_H_ */