static ssize_t gk20a_load_show(struct device *dev, struct device_attribute *attr, char *buf) { struct platform_device *pdev = to_platform_device(dev); struct gk20a *g = get_gk20a(pdev); u32 busy_time; ssize_t res; int err; if (!g->power_on) { busy_time = 0; } else { err = gk20a_busy(g->dev); if (err) return err; gk20a_pmu_load_update(g); gk20a_pmu_load_norm(g, &busy_time); gk20a_idle(g->dev); } res = snprintf(buf, PAGE_SIZE, "%u\n", busy_time); return res; }
static void update_load_estimate_gpmu(struct platform_device *pdev) { struct gk20a *g = get_gk20a(pdev); struct gk20a_scale_profile *profile = g->scale_profile; unsigned long dt; u32 busy_time; ktime_t t; t = ktime_get(); dt = ktime_us_delta(t, profile->last_event_time); profile->dev_stat.total_time = dt; profile->last_event_time = t; gk20a_pmu_load_norm(g, &busy_time); profile->dev_stat.busy_time = (busy_time * dt) / 1000; }