From 70bf8275efab7e155e9b3f9853a4cf7f38228c43 Mon Sep 17 00:00:00 2001 From: Kirill Artamonov Date: Mon, 12 Feb 2018 15:02:52 +0200 Subject: gpu: nvgpu: gv11b: implement gfxp wfi controls /sys/devices/gpu.0/gfxp_wfi_timeout_unit usec - microseconds sysclk - gpu clock count Treat gr_fe_gfxp_wfi_timeout_r as context-switched register on gv11b. Set default gfxp_wfi_timeout to 100 usec to match gp10b at 1GHz. bug 1888344 Signed-off-by: Kirill Artamonov Change-Id: I7fa64ce6912ae861244856807543b17bd7a26bed Reviewed-on: https://git-master.nvidia.com/r/1651517 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/sysfs.c | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/linux/sysfs.c b/drivers/gpu/nvgpu/common/linux/sysfs.c index afa08fc4..6709285d 100644 --- a/drivers/gpu/nvgpu/common/linux/sysfs.c +++ b/drivers/gpu/nvgpu/common/linux/sysfs.c @@ -28,6 +28,7 @@ #include "platform_gk20a.h" #include "gk20a/pmu_gk20a.h" #include "gk20a/gr_gk20a.h" +#include "gv11b/gr_gv11b.h" #define PTIMER_FP_FACTOR 1000000 @@ -977,6 +978,36 @@ static ssize_t gfxp_wfi_timeout_count_store(struct device *dev, gr->gfxp_wfi_timeout_count = val; + if (g->ops.gr.init_preemption_state && g->power_on) { + err = gk20a_busy(g); + if (err) + return err; + + err = gr_gk20a_elpg_protected_call(g, + g->ops.gr.init_preemption_state(g)); + + gk20a_idle(g); + + if (err) + return err; + } + return count; +} + +static ssize_t gfxp_wfi_timeout_unit_store(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct gk20a *g = get_gk20a(dev); + struct gr_gk20a *gr = &g->gr; + int err = -1; + + if (count > 0 && buf[0] == 's') + /* sysclk */ + gr->gfxp_wfi_timeout_unit = GFXP_WFI_TIMEOUT_UNIT_SYSCLK; + else + /* usec */ + gr->gfxp_wfi_timeout_unit = GFXP_WFI_TIMEOUT_UNIT_USEC; + if (g->ops.gr.init_preemption_state && g->power_on) { err = gk20a_busy(g); if (err) @@ -1004,9 +1035,23 @@ static ssize_t gfxp_wfi_timeout_count_read(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", val); } +static ssize_t gfxp_wfi_timeout_unit_read(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct gk20a *g = get_gk20a(dev); + struct gr_gk20a *gr = &g->gr; + + if (gr->gfxp_wfi_timeout_unit == GFXP_WFI_TIMEOUT_UNIT_USEC) + return snprintf(buf, PAGE_SIZE, "usec\n"); + else + return snprintf(buf, PAGE_SIZE, "sysclk\n"); +} + static DEVICE_ATTR(gfxp_wfi_timeout_count, (S_IRWXU|S_IRGRP|S_IROTH), gfxp_wfi_timeout_count_read, gfxp_wfi_timeout_count_store); +static DEVICE_ATTR(gfxp_wfi_timeout_unit, (S_IRWXU|S_IRGRP|S_IROTH), + gfxp_wfi_timeout_unit_read, gfxp_wfi_timeout_unit_store); void nvgpu_remove_sysfs(struct device *dev) { @@ -1045,6 +1090,7 @@ void nvgpu_remove_sysfs(struct device *dev) device_remove_file(dev, &dev_attr_czf_bypass); device_remove_file(dev, &dev_attr_pd_max_batches); device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_count); + device_remove_file(dev, &dev_attr_gfxp_wfi_timeout_unit); if (strcmp(dev_name(dev), "gpu.0")) { struct kobject *kobj = &dev->kobj; @@ -1094,6 +1140,7 @@ int nvgpu_create_sysfs(struct device *dev) error |= device_create_file(dev, &dev_attr_czf_bypass); error |= device_create_file(dev, &dev_attr_pd_max_batches); error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_count); + error |= device_create_file(dev, &dev_attr_gfxp_wfi_timeout_unit); if (strcmp(dev_name(dev), "gpu.0")) { struct kobject *kobj = &dev->kobj; -- cgit v1.2.2