diff options
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1856-drm-amdgpu-add-new-sysfs-interface-for-memory-realti.patch')
-rw-r--r-- | meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1856-drm-amdgpu-add-new-sysfs-interface-for-memory-realti.patch | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1856-drm-amdgpu-add-new-sysfs-interface-for-memory-realti.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1856-drm-amdgpu-add-new-sysfs-interface-for-memory-realti.patch new file mode 100644 index 00000000..c423b307 --- /dev/null +++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.19.8/1856-drm-amdgpu-add-new-sysfs-interface-for-memory-realti.patch @@ -0,0 +1,91 @@ +From 7c503c5360dd11fe5b0bb9a92002c4d655e8f336 Mon Sep 17 00:00:00 2001 +From: Evan Quan <evan.quan@amd.com> +Date: Fri, 26 Apr 2019 12:02:48 +0800 +Subject: [PATCH 1856/2940] drm/amdgpu: add new sysfs interface for memory + realtime utilization + +A new sysfs interface mem_busy_percent is added for telling +how busy the VRAM is(in percentage). + +Change-Id: Id91a82f7a9661252985dac7faae9dc1f02cc22c7 +Signed-off-by: Evan Quan <evan.quan@amd.com> +Reviewed-by: Alex Deucher <alexander.deucher@amd.com> +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 40 ++++++++++++++++++++++++++ + 1 file changed, 40 insertions(+) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +index a3e9b5d27c72..5e2d039e09ad 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +@@ -1301,6 +1301,32 @@ static ssize_t amdgpu_get_busy_percent(struct device *dev, + return snprintf(buf, PAGE_SIZE, "%d\n", value); + } + ++/** ++ * DOC: mem_busy_percent ++ * ++ * The amdgpu driver provides a sysfs API for reading how busy the VRAM ++ * is as a percentage. The file mem_busy_percent is used for this. ++ * The SMU firmware computes a percentage of load based on the ++ * aggregate activity level in the IP cores. ++ */ ++static ssize_t amdgpu_get_memory_busy_percent(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct drm_device *ddev = dev_get_drvdata(dev); ++ struct amdgpu_device *adev = ddev->dev_private; ++ int r, value, size = sizeof(value); ++ ++ /* read the IP busy sensor */ ++ r = amdgpu_dpm_read_sensor(adev, AMDGPU_PP_SENSOR_MEM_LOAD, ++ (void *)&value, &size); ++ ++ if (r) ++ return r; ++ ++ return snprintf(buf, PAGE_SIZE, "%d\n", value); ++} ++ + /** + * DOC: pcie_bw + * +@@ -1370,6 +1396,8 @@ static DEVICE_ATTR(pp_od_clk_voltage, S_IRUGO | S_IWUSR, + amdgpu_set_pp_od_clk_voltage); + static DEVICE_ATTR(gpu_busy_percent, S_IRUGO, + amdgpu_get_busy_percent, NULL); ++static DEVICE_ATTR(mem_busy_percent, S_IRUGO, ++ amdgpu_get_memory_busy_percent, NULL); + static DEVICE_ATTR(pcie_bw, S_IRUGO, amdgpu_get_pcie_bw, NULL); + static DEVICE_ATTR(ppfeatures, S_IRUGO | S_IWUSR, + amdgpu_get_ppfeature_status, +@@ -2752,6 +2780,16 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) + "gpu_busy_level\n"); + return ret; + } ++ /* APU does not have its own dedicated memory */ ++ if (!(adev->flags & AMD_IS_APU)) { ++ ret = device_create_file(adev->dev, ++ &dev_attr_mem_busy_percent); ++ if (ret) { ++ DRM_ERROR("failed to create device file " ++ "mem_busy_percent\n"); ++ return ret; ++ } ++ } + /* PCIe Perf counters won't work on APU nodes */ + if (!(adev->flags & AMD_IS_APU)) { + ret = device_create_file(adev->dev, &dev_attr_pcie_bw); +@@ -2817,6 +2855,8 @@ void amdgpu_pm_sysfs_fini(struct amdgpu_device *adev) + device_remove_file(adev->dev, + &dev_attr_pp_od_clk_voltage); + device_remove_file(adev->dev, &dev_attr_gpu_busy_percent); ++ if (!(adev->flags & AMD_IS_APU)) ++ device_remove_file(adev->dev, &dev_attr_mem_busy_percent); + if (!(adev->flags & AMD_IS_APU)) + device_remove_file(adev->dev, &dev_attr_pcie_bw); + if ((adev->asic_type >= CHIP_VEGA10) && +-- +2.17.1 + |