Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - expose pm_idle_enabled through sysfs

Expose 'pm_idle_enabled' sysfs attribute. This attribute controls how
idle conditions are handled. If it is set to 1 (idle support enabled)
when the device detects an idle condition, the driver will transition
the device to the 'MIN' power configuration.

In order to set the value of this attribute for a device, the device
must be in the 'down' state.

This only applies to qat_4xxx generation.

Signed-off-by: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Lucas Segarra Fernandez and committed by
Herbert Xu
2382b5ae 50053275

+101 -1
+35
Documentation/ABI/testing/sysfs-driver-qat
··· 58 58 dc 59 59 60 60 This attribute is only available for qat_4xxx devices. 61 + 62 + What: /sys/bus/pci/devices/<BDF>/qat/pm_idle_enabled 63 + Date: June 2023 64 + KernelVersion: 6.5 65 + Contact: qat-linux@intel.com 66 + Description: (RW) This configuration option provides a way to force the device into remaining in 67 + the MAX power state. 68 + If idle support is enabled the device will transition to the `MIN` power state when 69 + idle, otherwise will stay in the MAX power state. 70 + Write to the file to enable or disable idle support. 71 + 72 + The values are: 73 + 74 + * 0: idle support is disabled 75 + * 1: idle support is enabled 76 + 77 + Default value is 1. 78 + 79 + It is possible to set the pm_idle_enabled value only if the device 80 + is in the `down` state (see /sys/bus/pci/devices/<BDF>/qat/state) 81 + 82 + The following example shows how to change the pm_idle_enabled of 83 + a device:: 84 + 85 + # cat /sys/bus/pci/devices/<BDF>/qat/state 86 + up 87 + # cat /sys/bus/pci/devices/<BDF>/qat/pm_idle_enabled 88 + 1 89 + # echo down > /sys/bus/pci/devices/<BDF>/qat/state 90 + # echo 0 > /sys/bus/pci/devices/<BDF>/qat/pm_idle_enabled 91 + # echo up > /sys/bus/pci/devices/<BDF>/qat/state 92 + # cat /sys/bus/pci/devices/<BDF>/qat/pm_idle_enabled 93 + 0 94 + 95 + This attribute is only available for qat_4xxx devices.
+1
drivers/crypto/intel/qat/qat_common/adf_cfg_strings.h
··· 33 33 #define ADF_CFG_SYM_DC "sym;dc" 34 34 #define ADF_CFG_DC_SYM "dc;sym" 35 35 #define ADF_SERVICES_ENABLED "ServicesEnabled" 36 + #define ADF_PM_IDLE_SUPPORT "PmIdleSupport" 36 37 #define ADF_ETRMGR_COALESCING_ENABLED "InterruptCoalescingEnabled" 37 38 #define ADF_ETRMGR_COALESCING_ENABLED_FORMAT \ 38 39 ADF_ETRMGR_BANK "%d" ADF_ETRMGR_COALESCING_ENABLED
+11 -1
drivers/crypto/intel/qat/qat_common/adf_gen4_pm.c
··· 23 23 24 24 static int send_host_msg(struct adf_accel_dev *accel_dev) 25 25 { 26 + char pm_idle_support_cfg[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = {}; 26 27 void __iomem *pmisc = adf_get_pmisc_base(accel_dev); 28 + bool pm_idle_support; 27 29 u32 msg; 30 + int ret; 28 31 29 32 msg = ADF_CSR_RD(pmisc, ADF_GEN4_PM_HOST_MSG); 30 33 if (msg & ADF_GEN4_PM_MSG_PENDING) 31 34 return -EBUSY; 32 35 36 + adf_cfg_get_param_value(accel_dev, ADF_GENERAL_SEC, 37 + ADF_PM_IDLE_SUPPORT, pm_idle_support_cfg); 38 + ret = kstrtobool(pm_idle_support_cfg, &pm_idle_support); 39 + if (ret) 40 + pm_idle_support = true; 41 + 33 42 /* Send HOST_MSG */ 34 - msg = FIELD_PREP(ADF_GEN4_PM_MSG_PAYLOAD_BIT_MASK, PM_SET_MIN); 43 + msg = FIELD_PREP(ADF_GEN4_PM_MSG_PAYLOAD_BIT_MASK, 44 + pm_idle_support ? PM_SET_MIN : PM_NO_CHANGE); 35 45 msg |= ADF_GEN4_PM_MSG_PENDING; 36 46 ADF_CSR_WR(pmisc, ADF_GEN4_PM_HOST_MSG, msg); 37 47
+1
drivers/crypto/intel/qat/qat_common/adf_gen4_pm.h
··· 37 37 38 38 #define ADF_GEN4_PM_DEFAULT_IDLE_FILTER (0x0) 39 39 #define ADF_GEN4_PM_MAX_IDLE_FILTER (0x7) 40 + #define ADF_GEN4_PM_DEFAULT_IDLE_SUPPORT (0x1) 40 41 41 42 int adf_gen4_enable_pm(struct adf_accel_dev *accel_dev); 42 43 bool adf_gen4_handle_pm_interrupt(struct adf_accel_dev *accel_dev);
+53
drivers/crypto/intel/qat/qat_common/adf_sysfs.c
··· 152 152 return count; 153 153 } 154 154 155 + static ssize_t pm_idle_enabled_show(struct device *dev, struct device_attribute *attr, 156 + char *buf) 157 + { 158 + char pm_idle_enabled[ADF_CFG_MAX_VAL_LEN_IN_BYTES] = {}; 159 + struct adf_accel_dev *accel_dev; 160 + int ret; 161 + 162 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 163 + if (!accel_dev) 164 + return -EINVAL; 165 + 166 + ret = adf_cfg_get_param_value(accel_dev, ADF_GENERAL_SEC, 167 + ADF_PM_IDLE_SUPPORT, pm_idle_enabled); 168 + if (ret) 169 + return sysfs_emit(buf, "1\n"); 170 + 171 + return sysfs_emit(buf, "%s\n", pm_idle_enabled); 172 + } 173 + 174 + static ssize_t pm_idle_enabled_store(struct device *dev, struct device_attribute *attr, 175 + const char *buf, size_t count) 176 + { 177 + unsigned long pm_idle_enabled_cfg_val; 178 + struct adf_accel_dev *accel_dev; 179 + bool pm_idle_enabled; 180 + int ret; 181 + 182 + ret = kstrtobool(buf, &pm_idle_enabled); 183 + if (ret) 184 + return ret; 185 + 186 + pm_idle_enabled_cfg_val = pm_idle_enabled; 187 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 188 + if (!accel_dev) 189 + return -EINVAL; 190 + 191 + if (adf_dev_started(accel_dev)) { 192 + dev_info(dev, "Device qat_dev%d must be down to set pm_idle_enabled.\n", 193 + accel_dev->accel_id); 194 + return -EINVAL; 195 + } 196 + 197 + ret = adf_cfg_add_key_value_param(accel_dev, ADF_GENERAL_SEC, 198 + ADF_PM_IDLE_SUPPORT, &pm_idle_enabled_cfg_val, 199 + ADF_DEC); 200 + if (ret) 201 + return ret; 202 + 203 + return count; 204 + } 205 + static DEVICE_ATTR_RW(pm_idle_enabled); 206 + 155 207 static DEVICE_ATTR_RW(state); 156 208 static DEVICE_ATTR_RW(cfg_services); 157 209 158 210 static struct attribute *qat_attrs[] = { 159 211 &dev_attr_state.attr, 160 212 &dev_attr_cfg_services.attr, 213 + &dev_attr_pm_idle_enabled.attr, 161 214 NULL, 162 215 }; 163 216