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_dbgfs.h" 9 #include "adf_fw_counters.h" 10 #include "adf_heartbeat_dbgfs.h" 11 12 /** 13 * adf_dbgfs_init() - add persistent debugfs entries 14 * @accel_dev: Pointer to acceleration device. 15 * 16 * This function creates debugfs entries that are persistent through a device 17 * state change (from up to down or vice versa). 18 */ 19 void adf_dbgfs_init(struct adf_accel_dev *accel_dev) 20 { 21 char name[ADF_DEVICE_NAME_LENGTH]; 22 23 /* Create dev top level debugfs entry */ 24 snprintf(name, sizeof(name), "%s%s_%s", ADF_DEVICE_NAME_PREFIX, 25 accel_dev->hw_device->dev_class->name, 26 pci_name(accel_dev->accel_pci_dev.pci_dev)); 27 28 accel_dev->debugfs_dir = debugfs_create_dir(name, NULL); 29 30 adf_cfg_dev_dbgfs_add(accel_dev); 31 } 32 EXPORT_SYMBOL_GPL(adf_dbgfs_init); 33 34 /** 35 * adf_dbgfs_exit() - remove persistent debugfs entries 36 * @accel_dev: Pointer to acceleration device. 37 */ 38 void adf_dbgfs_exit(struct adf_accel_dev *accel_dev) 39 { 40 adf_cfg_dev_dbgfs_rm(accel_dev); 41 debugfs_remove(accel_dev->debugfs_dir); 42 } 43 EXPORT_SYMBOL_GPL(adf_dbgfs_exit); 44 45 /** 46 * adf_dbgfs_add() - add non-persistent debugfs entries 47 * @accel_dev: Pointer to acceleration device. 48 * 49 * This function creates debugfs entries that are not persistent through 50 * a device state change (from up to down or vice versa). 51 */ 52 void adf_dbgfs_add(struct adf_accel_dev *accel_dev) 53 { 54 if (!accel_dev->is_vf) { 55 adf_fw_counters_dbgfs_add(accel_dev); 56 adf_heartbeat_dbgfs_add(accel_dev); 57 } 58 } 59 60 /** 61 * adf_dbgfs_rm() - remove non-persistent debugfs entries 62 * @accel_dev: Pointer to acceleration device. 63 */ 64 void adf_dbgfs_rm(struct adf_accel_dev *accel_dev) 65 { 66 if (!accel_dev->is_vf) { 67 adf_heartbeat_dbgfs_rm(accel_dev); 68 adf_fw_counters_dbgfs_rm(accel_dev); 69 } 70 } 71