Loading drivers/gpu/msm/adreno_dispatch.c +3 −0 Original line number Diff line number Diff line Loading @@ -1678,6 +1678,9 @@ static void adreno_fault_header(struct kgsl_device *device, struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); drawctxt->base.total_fault_count++; drawctxt->base.last_faulted_cmd_ts = drawobj->timestamp; trace_adreno_gpu_fault(drawobj->context->id, drawobj->timestamp, status, rptr, wptr, ib1base, ib1sz, Loading drivers/gpu/msm/kgsl.c +76 −0 Original line number Diff line number Diff line Loading @@ -1396,6 +1396,81 @@ static inline bool kgsl_mem_entry_set_pend(struct kgsl_mem_entry *entry) return ret; } static int kgsl_get_ctxt_fault_stats(struct kgsl_context *context, struct kgsl_context_property *ctxt_property) { struct kgsl_context_property_fault fault_stats; size_t copy; /* Return the size of the subtype struct */ if (ctxt_property->size == 0) { ctxt_property->size = sizeof(fault_stats); return 0; } memset(&fault_stats, 0, sizeof(fault_stats)); copy = min_t(size_t, ctxt_property->size, sizeof(fault_stats)); fault_stats.faults = context->total_fault_count; fault_stats.timestamp = context->last_faulted_cmd_ts; /* * Copy the context fault stats to data which also serves as * the out parameter. */ if (copy_to_user(u64_to_user_ptr(ctxt_property->data), &fault_stats, copy)) return -EFAULT; return 0; } static long kgsl_get_ctxt_properties(struct kgsl_device_private *dev_priv, struct kgsl_device_getproperty *param) { /* Return fault stats of given context */ struct kgsl_context_property ctxt_property; struct kgsl_context *context; size_t copy; long ret; /* * If sizebytes is zero, tell the user how big the * ctxt_property struct should be. */ if (param->sizebytes == 0) { param->sizebytes = sizeof(ctxt_property); return 0; } memset(&ctxt_property, 0, sizeof(ctxt_property)); copy = min_t(size_t, param->sizebytes, sizeof(ctxt_property)); /* We expect the value passed in to contain the context id */ if (copy_from_user(&ctxt_property, param->value, copy)) return -EFAULT; /* ctxt type zero is not valid, as we consider it as uninitialized. */ if (ctxt_property.type == 0) return -EINVAL; context = kgsl_context_get_owner(dev_priv, ctxt_property.contextid); if (!context) return -EINVAL; if (ctxt_property.type == KGSL_CONTEXT_PROP_FAULTS) ret = kgsl_get_ctxt_fault_stats(context, &ctxt_property); else ret = -EOPNOTSUPP; kgsl_context_put(context); return ret; } static long kgsl_prop_version(struct kgsl_device_private *dev_priv, struct kgsl_device_getproperty *param) { Loading Loading @@ -1597,6 +1672,7 @@ static const struct { { KGSL_PROP_SECURE_BUFFER_ALIGNMENT, kgsl_prop_secure_buf_alignment }, { KGSL_PROP_SECURE_CTXT_SUPPORT, kgsl_prop_secure_ctxt_support }, { KGSL_PROP_QUERY_CAPABILITIES, kgsl_prop_query_capabilities }, { KGSL_PROP_CONTEXT_PROPERTY, kgsl_get_ctxt_properties }, }; /*call all ioctl sub functions with driver locked*/ Loading drivers/gpu/msm/kgsl_device.h +4 −0 Original line number Diff line number Diff line Loading @@ -377,6 +377,8 @@ struct kgsl_process_private; * @fault_time: time of the first gpu hang in last _context_throttle_time ms * @user_ctxt_record: memory descriptor used by CP to save/restore VPC data * across preemption * @total_fault_count: number of times gpu faulted in this context * @last_faulted_cmd_ts: last faulted command batch timestamp */ struct kgsl_context { struct kref refcount; Loading @@ -396,6 +398,8 @@ struct kgsl_context { unsigned int fault_count; unsigned long fault_time; struct kgsl_mem_entry *user_ctxt_record; unsigned int total_fault_count; unsigned int last_faulted_cmd_ts; }; #define _context_comm(_c) \ Loading include/uapi/linux/msm_kgsl.h +16 −0 Original line number Diff line number Diff line Loading @@ -338,6 +338,7 @@ enum kgsl_timestamp_type { #define KGSL_PROP_SPEED_BIN 0x25 /* KGSL_PROP_GAMING_BIN is 0x26 in 4.14 but not yet supported here */ #define KGSL_PROP_QUERY_CAPABILITIES 0x27 #define KGSL_PROP_CONTEXT_PROPERTY 0x28 /* * kgsl_capabilties_properties returns a list of supported properties. Loading Loading @@ -408,6 +409,21 @@ struct kgsl_gpmu_version { unsigned int features; }; struct kgsl_context_property { __u64 data; __u32 size; __u32 type; __u32 contextid; }; struct kgsl_context_property_fault { __s32 faults; __u32 timestamp; }; /* Context property sub types */ #define KGSL_CONTEXT_PROP_FAULTS 1 /* Performance counter groups */ #define KGSL_PERFCOUNTER_GROUP_CP 0x0 Loading Loading
drivers/gpu/msm/adreno_dispatch.c +3 −0 Original line number Diff line number Diff line Loading @@ -1678,6 +1678,9 @@ static void adreno_fault_header(struct kgsl_device *device, struct adreno_context *drawctxt = ADRENO_CONTEXT(drawobj->context); drawctxt->base.total_fault_count++; drawctxt->base.last_faulted_cmd_ts = drawobj->timestamp; trace_adreno_gpu_fault(drawobj->context->id, drawobj->timestamp, status, rptr, wptr, ib1base, ib1sz, Loading
drivers/gpu/msm/kgsl.c +76 −0 Original line number Diff line number Diff line Loading @@ -1396,6 +1396,81 @@ static inline bool kgsl_mem_entry_set_pend(struct kgsl_mem_entry *entry) return ret; } static int kgsl_get_ctxt_fault_stats(struct kgsl_context *context, struct kgsl_context_property *ctxt_property) { struct kgsl_context_property_fault fault_stats; size_t copy; /* Return the size of the subtype struct */ if (ctxt_property->size == 0) { ctxt_property->size = sizeof(fault_stats); return 0; } memset(&fault_stats, 0, sizeof(fault_stats)); copy = min_t(size_t, ctxt_property->size, sizeof(fault_stats)); fault_stats.faults = context->total_fault_count; fault_stats.timestamp = context->last_faulted_cmd_ts; /* * Copy the context fault stats to data which also serves as * the out parameter. */ if (copy_to_user(u64_to_user_ptr(ctxt_property->data), &fault_stats, copy)) return -EFAULT; return 0; } static long kgsl_get_ctxt_properties(struct kgsl_device_private *dev_priv, struct kgsl_device_getproperty *param) { /* Return fault stats of given context */ struct kgsl_context_property ctxt_property; struct kgsl_context *context; size_t copy; long ret; /* * If sizebytes is zero, tell the user how big the * ctxt_property struct should be. */ if (param->sizebytes == 0) { param->sizebytes = sizeof(ctxt_property); return 0; } memset(&ctxt_property, 0, sizeof(ctxt_property)); copy = min_t(size_t, param->sizebytes, sizeof(ctxt_property)); /* We expect the value passed in to contain the context id */ if (copy_from_user(&ctxt_property, param->value, copy)) return -EFAULT; /* ctxt type zero is not valid, as we consider it as uninitialized. */ if (ctxt_property.type == 0) return -EINVAL; context = kgsl_context_get_owner(dev_priv, ctxt_property.contextid); if (!context) return -EINVAL; if (ctxt_property.type == KGSL_CONTEXT_PROP_FAULTS) ret = kgsl_get_ctxt_fault_stats(context, &ctxt_property); else ret = -EOPNOTSUPP; kgsl_context_put(context); return ret; } static long kgsl_prop_version(struct kgsl_device_private *dev_priv, struct kgsl_device_getproperty *param) { Loading Loading @@ -1597,6 +1672,7 @@ static const struct { { KGSL_PROP_SECURE_BUFFER_ALIGNMENT, kgsl_prop_secure_buf_alignment }, { KGSL_PROP_SECURE_CTXT_SUPPORT, kgsl_prop_secure_ctxt_support }, { KGSL_PROP_QUERY_CAPABILITIES, kgsl_prop_query_capabilities }, { KGSL_PROP_CONTEXT_PROPERTY, kgsl_get_ctxt_properties }, }; /*call all ioctl sub functions with driver locked*/ Loading
drivers/gpu/msm/kgsl_device.h +4 −0 Original line number Diff line number Diff line Loading @@ -377,6 +377,8 @@ struct kgsl_process_private; * @fault_time: time of the first gpu hang in last _context_throttle_time ms * @user_ctxt_record: memory descriptor used by CP to save/restore VPC data * across preemption * @total_fault_count: number of times gpu faulted in this context * @last_faulted_cmd_ts: last faulted command batch timestamp */ struct kgsl_context { struct kref refcount; Loading @@ -396,6 +398,8 @@ struct kgsl_context { unsigned int fault_count; unsigned long fault_time; struct kgsl_mem_entry *user_ctxt_record; unsigned int total_fault_count; unsigned int last_faulted_cmd_ts; }; #define _context_comm(_c) \ Loading
include/uapi/linux/msm_kgsl.h +16 −0 Original line number Diff line number Diff line Loading @@ -338,6 +338,7 @@ enum kgsl_timestamp_type { #define KGSL_PROP_SPEED_BIN 0x25 /* KGSL_PROP_GAMING_BIN is 0x26 in 4.14 but not yet supported here */ #define KGSL_PROP_QUERY_CAPABILITIES 0x27 #define KGSL_PROP_CONTEXT_PROPERTY 0x28 /* * kgsl_capabilties_properties returns a list of supported properties. Loading Loading @@ -408,6 +409,21 @@ struct kgsl_gpmu_version { unsigned int features; }; struct kgsl_context_property { __u64 data; __u32 size; __u32 type; __u32 contextid; }; struct kgsl_context_property_fault { __s32 faults; __u32 timestamp; }; /* Context property sub types */ #define KGSL_CONTEXT_PROP_FAULTS 1 /* Performance counter groups */ #define KGSL_PERFCOUNTER_GROUP_CP 0x0 Loading