Skip to contentSkip to conversation

platform/x86/intel/pmc: Add resume_fixup callback

PATCH Superseded David E. Box 2 participants 4 messages Jun 2, 2023 – Jun 5, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 platform/x86/intel/pmc: Add resume_fixup callback

Add a resume_fixup callback to perform platform specific fixups during resume from suspend.

---
 drivers/platform/x86/intel/pmc/core.c | 3 +++
 drivers/platform/x86/intel/pmc/core.h | 2 ++
 2 files changed, 5 insertions(+)
drivers/platform/x86/intel/pmc/core.c +3 -0
index da6e7206d38b..0fcd1cb7264b 100644
@@ -1229,6 +1229,9 @@ static __maybe_unused int pmc_core_resume(struct device *dev)
 	const struct pmc_bit_map **maps = pmcdev->map->lpm_sts;
 	int offset = pmcdev->map->lpm_status_offset;
 
+	if (pmcdev->resume_fixup)
+		pmcdev->resume_fixup();
+
 	/* Check if the syspend used S0ix */
 	if (pm_suspend_via_firmware())
 		return 0;
drivers/platform/x86/intel/pmc/core.h +2 -0
index 9ca9b9746719..b58458d00bd3 100644
@@ -327,6 +327,7 @@ struct pmc_reg_map {
  * @lpm_en_modes:	Array of enabled modes from lowest to highest priority
  * @lpm_req_regs:	List of substate requirements
  * @core_configure:	Function pointer to configure the platform
+ * @resume_fixup:	Function to perform fixups during resume
  *
  * pmc_dev contains info about power management controller device.
  */
@@ -345,6 +346,7 @@ struct pmc_dev {
 	int lpm_en_modes[LPM_MAX_NUM_MODES];
 	u32 *lpm_req_regs;
 	void (*core_configure)(struct pmc_dev *pmcdev);
+	void (*resume_fixup)(void);
 };
 
 extern const struct pmc_bit_map msr_map[];
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 platform/x86/intel/pmc/mtl: Put devices in D3 during resume

An earlier commit placed some driverless devices in D3 during boot so that they don't block package cstate entry. Also place these devices in D3 after resume from suspend.

Fixes 336ba968d3e3 ("platform/x86/intel/pmc/mtl: Put GNA/IPU/VPU devices in D3")
---
 drivers/platform/x86/intel/pmc/mtl.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/pmc/mtl.c +11 -4
index e8cc156412ce..d87c4597c6d4 100644
@@ -68,11 +68,8 @@ static void mtl_set_device_d3(unsigned int device)
 	}
 }
 
-void mtl_core_init(struct pmc_dev *pmcdev)
+static void mtl_fixup(void)
 {
-	pmcdev->map = &mtl_reg_map;
-	pmcdev->core_configure = mtl_core_configure;
-
 	/*
 	 * Set power state of select devices that do not have drivers to D3
 	 * so that they do not block Package C entry.
@@ -81,3 +78,13 @@ void mtl_core_init(struct pmc_dev *pmcdev)
 	mtl_set_device_d3(MTL_IPU_PCI_DEV);
 	mtl_set_device_d3(MTL_VPU_PCI_DEV);
 }
+
+void mtl_core_init(struct pmc_dev *pmcdev)
+{
+	pmcdev->map = &mtl_reg_map;
+	pmcdev->core_configure = mtl_core_configure;
+
+	mtl_fixup();
+
+	pmcdev->resume_fixup = mtl_fixup;
+}
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [PATCH 2/2] platform/x86/intel/pmc/mtl: Put devices in D3 during resume

Quoted 28 lines · David E. Box

An earlier commit placed some driverless devices in D3 during boot so that they don't block package cstate entry. Also place these devices in D3 after resume from suspend.

Fixes 336ba968d3e3 ("platform/x86/intel/pmc/mtl: Put GNA/IPU/VPU devices in D3")
---
 drivers/platform/x86/intel/pmc/mtl.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/pmc/mtl.c +1 -4
index e8cc156412ce..d87c4597c6d4 100644
@@ -68,11 +68,8 @@ static void mtl_set_device_d3(unsigned int device)
 	}
 }
 
-void mtl_core_init(struct pmc_dev *pmcdev)
+static void mtl_fixup(void)
 {
-	pmcdev->map = &mtl_reg_map;
-	pmcdev->core_configure = mtl_core_configure;
-
 	/*
 	 * Set power state of select devices that do not have drivers to D3
 	 * so that they do not block Package C entry.

drivers/platform/x86/intel/pmc/mtl.c void mtl_core_init(struct pmc_dev *pmcdev) · line 79

Quoted 2 lines
drivers/platform/x86/intel/pmc/mtl.c +0 -0
@@ -81,3 +78,13 @@ void mtl_core_init(struct pmc_dev *pmcdev)
 	mtl_set_device_d3(MTL_IPU_PCI_DEV);
 	mtl_set_device_d3(MTL_VPU_PCI_DEV);

I'd prefer the function be called something related to d3 / power state / or some along those lines rather than something obscure such as mtl_fixup(). And you can move the comment to be a function comment now.

drivers/platform/x86/intel/pmc/mtl.c void mtl_core_init(struct pmc_dev *pmcdev) · line 89

Quoted 10 lines
drivers/platform/x86/intel/pmc/mtl.c +9 -0
 }
+
+void mtl_core_init(struct pmc_dev *pmcdev)
+{
+	pmcdev->map = &mtl_reg_map;
+	pmcdev->core_configure = mtl_core_configure;
+
+	mtl_fixup();
+
+	pmcdev->resume_fixup = mtl_fixup;

I'm a bit on the edge here whether this is a good approach in long-term or if it would be better to just provide a way for the platform file to replace entire .resume() (for this task it's obviously enough but it feels a bit hacky to hook into one fixed place on resume path).

static __maybe_unused int pmc_core_resume(struct device *dev)

{
	if (pmcdev->resume)
		return pmcdev->resume();
	else
		return pmc_core_resume_common();
}

where pmc_core_resume_common() contains the current pmc_core_resume() contents.

mtl_resume() would just call the d3 func and the common resume functions.

Signature · 1 line
 i.
#3 lore raw

Re: [PATCH 2/2] platform/x86/intel/pmc/mtl: Put devices in D3 during resume

Quoted 30 lines · Ilpo Järvinen
Quoted 28 lines · David E. Box

An earlier commit placed some driverless devices in D3 during boot so that they don't block package cstate entry. Also place these devices in D3 after resume from suspend.

Fixes 336ba968d3e3 ("platform/x86/intel/pmc/mtl: Put GNA/IPU/VPU devices in

D3")

---
 drivers/platform/x86/intel/pmc/mtl.c | 15 +++++++++++----

 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/pmc/mtl.c +0 -0
index e8cc156412ce..d87c4597c6d4 100644
@@ -68,11 +68,8 @@ static void mtl_set_device_d3(unsigned int device)
         }
  }

drivers/platform/x86/intel/pmc/mtl.c +1 -1
-void mtl_core_init(struct pmc_dev *pmcdev)
+static void mtl_fixup(void)

 {
-       pmcdev->map = &mtl_reg_map;
-       pmcdev->core_configure = mtl_core_configure;
-
        /*
         * Set power state of select devices that do not have drivers to D3

Quoted 8 lines

drivers/platform/x86/intel/pmc/mtl.c void mtl_core_init(struct pmc_dev *pmcdev) · line 79

Quoted 4 lines

         * so that they do not block Package C entry.

drivers/platform/x86/intel/pmc/mtl.c +0 -0
@@ -81,3 +78,13 @@ void mtl_core_init(struct pmc_dev *pmcdev)
         mtl_set_device_d3(MTL_IPU_PCI_DEV);
         mtl_set_device_d3(MTL_VPU_PCI_DEV);

I'd prefer the function be called something related to d3 / power state / or some along those lines rather than something obscure such as mtl_fixup(). And you can move the comment to be a function comment now.

Okay.

Quoted 25 lines

drivers/platform/x86/intel/pmc/mtl.c void mtl_core_init(struct pmc_dev *pmcdev) · line 89

Quoted 11 lines
drivers/platform/x86/intel/pmc/mtl.c +9 -0
  }
+
+void mtl_core_init(struct pmc_dev *pmcdev)
+{
+       pmcdev->map = &mtl_reg_map;
+       pmcdev->core_configure = mtl_core_configure;
+
+       mtl_fixup();
+
+       pmcdev->resume_fixup = mtl_fixup;

I'm a bit on the edge here whether this is a good approach in long-term or if it would be better to just provide a way for the platform file to replace entire .resume() (for this task it's obviously enough but it feels a bit hacky to hook into one fixed place on resume path).

static __maybe_unused int pmc_core_resume(struct device *dev) {
        if (pmcdev->resume)
                return pmcdev->resume();
        else
                return pmc_core_resume_common();
}

Quoted 4 lines

where pmc_core_resume_common() contains the current pmc_core_resume() contents.

mtl_resume() would just call the d3 func and the common resume functions.

Yeah, makes sense. There are several conditional tasks in the current resume code, so trying to have a fixed place in there to call a platform specific workaround may not be possible if we need to use this again for a different reason.

David

Quoted 2 lines