amdgpu: make pmu support optional
authorArnd Bergmann <arnd@arndb.de>
Mon, 8 Jul 2019 14:41:43 +0000 (16:41 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 8 Jul 2019 18:56:22 +0000 (13:56 -0500)
When CONFIG_PERF_EVENTS is disabled, we cannot compile the pmu
portion of the amdgpu driver:

drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c:48:38: error: no member named 'hw' in 'struct perf_event'
        struct hw_perf_event *hwc = &event->hw;
                                     ~~~~~  ^
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c:51:13: error: no member named 'attr' in 'struct perf_event'
        if (event->attr.type != event->pmu->type)
            ~~~~~  ^
...

Use conditional compilation for this file.

Fixes: 9c7c85f7ea1f ("drm/amdgpu: add pmu counters")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/Makefile
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 7bbcf1b20cfdfcb6707cb33140a391603a5af639..56e084367b93896a83b94a5c7f083cd22a8f66b2 100644 (file)
@@ -54,7 +54,9 @@ amdgpu-y += amdgpu_device.o amdgpu_kms.o \
        amdgpu_gtt_mgr.o amdgpu_vram_mgr.o amdgpu_virt.o amdgpu_atomfirmware.o \
        amdgpu_vf_error.o amdgpu_sched.o amdgpu_debugfs.o amdgpu_ids.o \
        amdgpu_gmc.o amdgpu_xgmi.o amdgpu_csa.o amdgpu_ras.o amdgpu_vm_cpu.o \
-       amdgpu_vm_sdma.o amdgpu_pmu.o amdgpu_discovery.o
+       amdgpu_vm_sdma.o amdgpu_discovery.o
+
+amdgpu-$(CONFIG_PERF_EVENTS) += amdgpu_pmu.o
 
 # add asic specific block
 amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
index b4616853f46102b339ea1ef32a513383732edd83..d721b4d3024c4b4123cec0aca1cf9dfe76ea5757 100644 (file)
@@ -2809,7 +2809,8 @@ fence_driver_init:
                return r;
        }
 
-       r = amdgpu_pmu_init(adev);
+       if (IS_ENABLED(CONFIG_PERF_EVENTS))
+               r = amdgpu_pmu_init(adev);
        if (r)
                dev_err(adev->dev, "amdgpu_pmu_init failed\n");
 
@@ -2881,7 +2882,8 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
        amdgpu_debugfs_regs_cleanup(adev);
        device_remove_file(adev->dev, &dev_attr_pcie_replay_count);
        amdgpu_ucode_sysfs_fini(adev);
-       amdgpu_pmu_fini(adev);
+       if (IS_ENABLED(CONFIG_PERF_EVENTS))
+               amdgpu_pmu_fini(adev);
        amdgpu_debugfs_preempt_cleanup(adev);
        if (amdgpu_discovery)
                amdgpu_discovery_fini(adev);