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 14 /** 15 * adf_dbgfs_init() - add persistent debugfs entries 16 * @accel_dev: Pointer to acceleration device. 17 * 18 * This function creates debugfs entries that are persistent through a device 19 * state change (from up to down or vice versa). 20 */ 21 void adf_dbgfs_init(struct adf_accel_dev *accel_dev) 22 { 23 char name[ADF_DEVICE_NAME_LENGTH]; 24 void *ret; 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 ret = debugfs_create_dir(name, NULL); 32 if (IS_ERR_OR_NULL(ret)) 33 return; 34 35 accel_dev->debugfs_dir = ret; 36 37 adf_cfg_dev_dbgfs_add(accel_dev); 38 } 39 EXPORT_SYMBOL_GPL(adf_dbgfs_init); 40 41 /** 42 * adf_dbgfs_exit() - remove persistent debugfs entries 43 * @accel_dev: Pointer to acceleration device. 44 */ 45 void adf_dbgfs_exit(struct adf_accel_dev *accel_dev) 46 { 47 adf_cfg_dev_dbgfs_rm(accel_dev); 48 debugfs_remove(accel_dev->debugfs_dir); 49 } 50 EXPORT_SYMBOL_GPL(adf_dbgfs_exit); 51 52 /** 53 * adf_dbgfs_add() - add non-persistent debugfs entries 54 * @accel_dev: Pointer to acceleration device. 55 * 56 * This function creates debugfs entries that are not persistent through 57 * a device state change (from up to down or vice versa). 58 */ 59 void adf_dbgfs_add(struct adf_accel_dev *accel_dev) 60 { 61 if (!accel_dev->debugfs_dir) 62 return; 63 64 if (!accel_dev->is_vf) { 65 adf_fw_counters_dbgfs_add(accel_dev); 66 adf_heartbeat_dbgfs_add(accel_dev); 67 adf_pm_dbgfs_add(accel_dev); 68 adf_cnv_dbgfs_add(accel_dev); 69 } 70 } 71 72 /** 73 * adf_dbgfs_rm() - remove non-persistent debugfs entries 74 * @accel_dev: Pointer to acceleration device. 75 */ 76 void adf_dbgfs_rm(struct adf_accel_dev *accel_dev) 77 { 78 if (!accel_dev->debugfs_dir) 79 return; 80 81 if (!accel_dev->is_vf) { 82 adf_cnv_dbgfs_rm(accel_dev); 83 adf_pm_dbgfs_rm(accel_dev); 84 adf_heartbeat_dbgfs_rm(accel_dev); 85 adf_fw_counters_dbgfs_rm(accel_dev); 86 } 87 } 88