1 // SPDX-License-Identifier: GPL-2.0-only 2 /* Copyright(c) 2023 Intel Corporation */ 3 4 #include <linux/debugfs.h> 5 #include "adf_accel_devices.h" 6 #include "adf_cfg.h" 7 #include "adf_common_drv.h" 8 #include "adf_cnv_dbgfs.h" 9 #include "adf_dbgfs.h" 10 #include "adf_fw_counters.h" 11 #include "adf_heartbeat_dbgfs.h" 12 #include "adf_pm_dbgfs.h" 13 #include "adf_tl_debugfs.h" 14 15 /** 16 * adf_dbgfs_init() - add persistent debugfs entries 17 * @accel_dev: Pointer to acceleration device. 18 * 19 * This function creates debugfs entries that are persistent through a device 20 * state change (from up to down or vice versa). 21 */ 22 void adf_dbgfs_init(struct adf_accel_dev *accel_dev) 23 { 24 char name[ADF_DEVICE_NAME_LENGTH]; 25 26 /* Create dev top level debugfs entry */ 27 snprintf(name, sizeof(name), "%s%s_%s", ADF_DEVICE_NAME_PREFIX, 28 accel_dev->hw_device->dev_class->name, 29 pci_name(accel_dev->accel_pci_dev.pci_dev)); 30 31 accel_dev->debugfs_dir = debugfs_create_dir(name, NULL); 32 33 adf_cfg_dev_dbgfs_add(accel_dev); 34 } 35 EXPORT_SYMBOL_GPL(adf_dbgfs_init); 36 37 /** 38 * adf_dbgfs_exit() - remove persistent debugfs entries 39 * @accel_dev: Pointer to acceleration device. 40 */ 41 void adf_dbgfs_exit(struct adf_accel_dev *accel_dev) 42 { 43 adf_cfg_dev_dbgfs_rm(accel_dev); 44 debugfs_remove(accel_dev->debugfs_dir); 45 } 46 EXPORT_SYMBOL_GPL(adf_dbgfs_exit); 47 48 /** 49 * adf_dbgfs_add() - add non-persistent debugfs entries 50 * @accel_dev: Pointer to acceleration device. 51 * 52 * This function creates debugfs entries that are not persistent through 53 * a device state change (from up to down or vice versa). 54 */ 55 void adf_dbgfs_add(struct adf_accel_dev *accel_dev) 56 { 57 if (!accel_dev->is_vf) { 58 adf_fw_counters_dbgfs_add(accel_dev); 59 adf_heartbeat_dbgfs_add(accel_dev); 60 adf_pm_dbgfs_add(accel_dev); 61 adf_cnv_dbgfs_add(accel_dev); 62 adf_tl_dbgfs_add(accel_dev); 63 } 64 } 65 66 /** 67 * adf_dbgfs_rm() - remove non-persistent debugfs entries 68 * @accel_dev: Pointer to acceleration device. 69 */ 70 void adf_dbgfs_rm(struct adf_accel_dev *accel_dev) 71 { 72 if (!accel_dev->is_vf) { 73 adf_tl_dbgfs_rm(accel_dev); 74 adf_cnv_dbgfs_rm(accel_dev); 75 adf_pm_dbgfs_rm(accel_dev); 76 adf_heartbeat_dbgfs_rm(accel_dev); 77 adf_fw_counters_dbgfs_rm(accel_dev); 78 } 79 } 80