diff mbox series

[v14.b,7/7] ACPI: x86: s2idle: Add a function to get constraints for a device

Message ID 20230818194007.27410-8-mario.limonciello@amd.com
State New
Headers show
Series Export LPS0 constraints | expand

Commit Message

Mario Limonciello Aug. 18, 2023, 7:40 p.m. UTC
Other parts of the kernel may use constraints information to make
decisions on what power state to put a device into.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v13->v14:
 * Use acpi_device instead
 * Drop debugging statements (will be used by caller instead)
 * Return ACPI_STATE_UNKNOWN on no enabled constraints
v12->v13:
 * Drop checking for enabled, just return constraints
v11->v12:
 * Use for_each_lpi_constraint instead
 * use CONFIG_SUSPEND instead of CONFIG_ACPI_SLEEP
v9->v10:
 * split from other patches
 * kerneldoc fixes
 * move debug statement to this function
---
 drivers/acpi/x86/s2idle.c | 21 +++++++++++++++++++++
 include/linux/acpi.h      |  6 ++++++
 2 files changed, 27 insertions(+)

Comments

kernel test robot Aug. 25, 2023, 5:25 a.m. UTC | #1
Hi Mario,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.5-rc7]
[cannot apply to next-20230824]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Mario-Limonciello/ACPI-Adjust-ifdef-for-_lps0_dev-use/20230821-113922
base:   linus/master
patch link:    https://lore.kernel.org/r/20230818194007.27410-8-mario.limonciello%40amd.com
patch subject: [PATCH v14.b 7/7] ACPI: x86: s2idle: Add a function to get constraints for a device
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20230825/202308251347.C2sdb28f-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230825/202308251347.C2sdb28f-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308251347.C2sdb28f-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/acpi/x86/s2idle.c:311: warning: Function parameter or member 'adev' not described in 'acpi_get_lps0_constraint'
>> drivers/acpi/x86/s2idle.c:311: warning: Excess function parameter 'dev' description in 'acpi_get_lps0_constraint'


vim +311 drivers/acpi/x86/s2idle.c

   301	
   302	/**
   303	 * acpi_get_lps0_constraint - get the LPS0 constraint for a device
   304	 * @dev: device to get constraints for
   305	 *
   306	 * Returns:
   307	 *  - ACPI state value for constraint.
   308	 *  - Otherwise, ACPI_STATE_UNKNOWN.
   309	 */
   310	int acpi_get_lps0_constraint(struct acpi_device *adev)
 > 311	{
   312		struct lpi_constraints *entry;
   313	
   314		for_each_lpi_constraint(entry) {
   315			if (adev->handle != entry->handle)
   316				continue;
   317			return entry->min_dstate;
   318		}
   319	
   320		return ACPI_STATE_UNKNOWN;
   321	}
   322
diff mbox series

Patch

diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c
index 1aa3cd5677bd8..3019ca760ac1b 100644
--- a/drivers/acpi/x86/s2idle.c
+++ b/drivers/acpi/x86/s2idle.c
@@ -299,6 +299,27 @@  static void lpi_device_get_constraints(void)
 	ACPI_FREE(out_obj);
 }
 
+/**
+ * acpi_get_lps0_constraint - get the LPS0 constraint for a device
+ * @dev: device to get constraints for
+ *
+ * Returns:
+ *  - ACPI state value for constraint.
+ *  - Otherwise, ACPI_STATE_UNKNOWN.
+ */
+int acpi_get_lps0_constraint(struct acpi_device *adev)
+{
+	struct lpi_constraints *entry;
+
+	for_each_lpi_constraint(entry) {
+		if (adev->handle != entry->handle)
+			continue;
+		return entry->min_dstate;
+	}
+
+	return ACPI_STATE_UNKNOWN;
+}
+
 static void lpi_check_constraints(void)
 {
 	struct lpi_constraints *entry;
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index f1552c04a2856..2212668ce60b7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -1109,6 +1109,12 @@  struct acpi_s2idle_dev_ops {
 };
 int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg);
 void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg);
+int acpi_get_lps0_constraint(struct acpi_device *adev);
+#else /* CONFIG_SUSPEND && CONFIG_X86 */
+static inline int acpi_get_lps0_constraint(struct device *dev)
+{
+	return ACPI_STATE_UNKNOWN;
+}
 #endif /* CONFIG_SUSPEND && CONFIG_X86 */
 #ifndef CONFIG_IA64
 void arch_reserve_mem_area(acpi_physical_address addr, size_t size);