Skip to contentSkip to conversation

platform/x86/amd: pmc: Fix build without debugfs

PATCH In review Nathan Chancellor 3 participants 3 messages Sep 22, 2022 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/x86/amd: pmc: Fix build without debugfs

Without CONFIG_DEBUG_FS, the following build error occurs:

drivers/platform/x86/amd/pmc.c:984:17: error: use of undeclared identifier 'pmc_groups'; did you mean 'set_groups'?
.dev_groups = pmc_groups,
^~~~~~~~~~
set_groups
./include/linux/cred.h:65:13: note: 'set_groups' declared here

  extern void set_groups(struct cred *, struct group_info *);
              ^

drivers/platform/x86/amd/pmc.c:984:17: error: incompatible pointer types initializing 'const struct attribute_group **' with an expression of type 'void (struct cred *, struct group_info *)' [-Werror,-Wincompatible-pointer-types]
.dev_groups = pmc_groups,
^~~~~~~~~~
2 errors generated.

pmc_groups was only defined inside a CONFIG_DEBUG_FS block but commit 7f1ea75d499a ("platform/x86/amd: pmc: Add sysfs files for SMU") intended for these sysfs files to be available outside of debugfs. Shuffle the necessary functions out of the CONFIG_DEBUG_FS block so that the file always builds.

Fixes 7f1ea75d499a ("platform/x86/amd: pmc: Add sysfs files for SMU")
---
 drivers/platform/x86/amd/pmc.c | 116 ++++++++++++++++-----------------
 1 file changed, 58 insertions(+), 58 deletions(-)
drivers/platform/x86/amd/pmc.c +58 -58
index 0616ef8ce64c..e47e54b095af 100644
@@ -371,6 +371,64 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
 }
 #endif
 
+static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
+{
+	int rc;
+	u32 val;
+
+	rc = amd_pmc_send_cmd(dev, 0, &val, SMU_MSG_GETSMUVERSION, 1);
+	if (rc)
+		return rc;
+
+	dev->smu_program = (val >> 24) & GENMASK(7, 0);
+	dev->major = (val >> 16) & GENMASK(7, 0);
+	dev->minor = (val >> 8) & GENMASK(7, 0);
+	dev->rev = (val >> 0) & GENMASK(7, 0);
+
+	dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n",
+		dev->smu_program, dev->major, dev->minor, dev->rev);
+
+	return 0;
+}
+
+static ssize_t smu_fw_version_show(struct device *d, struct device_attribute *attr,
+				   char *buf)
+{
+	struct amd_pmc_dev *dev = dev_get_drvdata(d);
+
+	if (!dev->major) {
+		int rc = amd_pmc_get_smu_version(dev);
+
+		if (rc)
+			return rc;
+	}
+	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor, dev->rev);
+}
+
+static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
+				   char *buf)
+{
+	struct amd_pmc_dev *dev = dev_get_drvdata(d);
+
+	if (!dev->major) {
+		int rc = amd_pmc_get_smu_version(dev);
+
+		if (rc)
+			return rc;
+	}
+	return sysfs_emit(buf, "%u\n", dev->smu_program);
+}
+
+static DEVICE_ATTR_RO(smu_fw_version);
+static DEVICE_ATTR_RO(smu_program);
+
+static struct attribute *pmc_attrs[] = {
+	&dev_attr_smu_fw_version.attr,
+	&dev_attr_smu_program.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(pmc);
+
 #ifdef CONFIG_DEBUG_FS
 static int smu_fw_info_show(struct seq_file *s, void *unused)
 {
@@ -437,64 +495,6 @@ static int s0ix_stats_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(s0ix_stats);
 
-static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
-{
-	int rc;
-	u32 val;
-
-	rc = amd_pmc_send_cmd(dev, 0, &val, SMU_MSG_GETSMUVERSION, 1);
-	if (rc)
-		return rc;
-
-	dev->smu_program = (val >> 24) & GENMASK(7, 0);
-	dev->major = (val >> 16) & GENMASK(7, 0);
-	dev->minor = (val >> 8) & GENMASK(7, 0);
-	dev->rev = (val >> 0) & GENMASK(7, 0);
-
-	dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n",
-		dev->smu_program, dev->major, dev->minor, dev->rev);
-
-	return 0;
-}
-
-static ssize_t smu_fw_version_show(struct device *d, struct device_attribute *attr,
-				   char *buf)
-{
-	struct amd_pmc_dev *dev = dev_get_drvdata(d);
-
-	if (!dev->major) {
-		int rc = amd_pmc_get_smu_version(dev);
-
-		if (rc)
-			return rc;
-	}
-	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor, dev->rev);
-}
-
-static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
-				   char *buf)
-{
-	struct amd_pmc_dev *dev = dev_get_drvdata(d);
-
-	if (!dev->major) {
-		int rc = amd_pmc_get_smu_version(dev);
-
-		if (rc)
-			return rc;
-	}
-	return sysfs_emit(buf, "%u\n", dev->smu_program);
-}
-
-static DEVICE_ATTR_RO(smu_fw_version);
-static DEVICE_ATTR_RO(smu_program);
-
-static struct attribute *pmc_attrs[] = {
-	&dev_attr_smu_fw_version.attr,
-	&dev_attr_smu_program.attr,
-	NULL,
-};
-ATTRIBUTE_GROUPS(pmc);
-
 static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
 {
 	struct amd_pmc_dev *dev = s->private;

base-commit: 401199ffa9b69baf3fd1f9ad082aa65c10910585

Signature · 1 line
2.37.3
Reviewed-by on v1 1/1
#1 lore raw

[Public]

Quoted 27 lines

-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: Thursday, September 22, 2022 10:31
To: S-k, Shyam-sundar <[email protected]>; Limonciello, Mario <[email protected]>; Hans de Goede <[email protected]>; Mark Gross <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Nathan Chancellor <[email protected]>
Subject: [PATCH] platform/x86/amd: pmc: Fix build without debugfs

Without CONFIG_DEBUG_FS, the following build error occurs:

drivers/platform/x86/amd/pmc.c:984:17: error: use of undeclared identifier
'pmc_groups'; did you mean 'set_groups'?
.dev_groups = pmc_groups,
^~~~~~~~~~
set_groups
./include/linux/cred.h:65:13: note: 'set_groups' declared here

  extern void set_groups(struct cred *, struct group_info *);
              ^

drivers/platform/x86/amd/pmc.c:984:17: error: incompatible pointer types
initializing 'const struct attribute_group **' with an expression of type 'void (struct cred *, struct group_info *)' [-Werror,-Wincompatible-pointer-types]
.dev_groups = pmc_groups,
^~~~~~~~~~
2 errors generated.

Quoted 8 lines

pmc_groups was only defined inside a CONFIG_DEBUG_FS block but commit 7f1ea75d499a ("platform/x86/amd: pmc: Add sysfs files for SMU") intended for these sysfs files to be available outside of debugfs. Shuffle the necessary functions out of the CONFIG_DEBUG_FS block so that the file always builds.

Fixes 7f1ea75d499a ("platform/x86/amd: pmc: Add sysfs files for SMU")

Thanks a lot for the fix!

Quoted 153 lines
---
 drivers/platform/x86/amd/pmc.c | 116 ++++++++++++++++-----------------
 1 file changed, 58 insertions(+), 58 deletions(-)
drivers/platform/x86/amd/pmc.c +32 -0
index 0616ef8ce64c..e47e54b095af 100644
@@ -371,6 +371,64 @@ static void amd_pmc_validate_deepest(struct
 amd_pmc_dev *pdev)
 }
 #endif
 
+static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
+{
+	int rc;
+	u32 val;
+
+	rc = amd_pmc_send_cmd(dev, 0, &val,
 SMU_MSG_GETSMUVERSION, 1);
+	if (rc)
+		return rc;
+
+	dev->smu_program = (val >> 24) & GENMASK(7, 0);
+	dev->major = (val >> 16) & GENMASK(7, 0);
+	dev->minor = (val >> 8) & GENMASK(7, 0);
+	dev->rev = (val >> 0) & GENMASK(7, 0);
+
+	dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n",
+		dev->smu_program, dev->major, dev->minor, dev->rev);
+
+	return 0;
+}
+
+static ssize_t smu_fw_version_show(struct device *d, struct
 device_attribute *attr,
+				   char *buf)
+{
+	struct amd_pmc_dev *dev = dev_get_drvdata(d);
+
+	if (!dev->major) {
+		int rc = amd_pmc_get_smu_version(dev);
+
+		if (rc)
+			return rc;
+	}
+	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor,

dev->rev);

drivers/platform/x86/amd/pmc.c +3 -0
+}
+
+static ssize_t smu_program_show(struct device *d, struct device_attribute

*attr,

drivers/platform/x86/amd/pmc.c +23 -32
+				   char *buf)
+{
+	struct amd_pmc_dev *dev = dev_get_drvdata(d);
+
+	if (!dev->major) {
+		int rc = amd_pmc_get_smu_version(dev);
+
+		if (rc)
+			return rc;
+	}
+	return sysfs_emit(buf, "%u\n", dev->smu_program);
+}
+
+static DEVICE_ATTR_RO(smu_fw_version);
+static DEVICE_ATTR_RO(smu_program);
+
+static struct attribute *pmc_attrs[] = {
+	&dev_attr_smu_fw_version.attr,
+	&dev_attr_smu_program.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(pmc);
+
 #ifdef CONFIG_DEBUG_FS
 static int smu_fw_info_show(struct seq_file *s, void *unused)
 {
@@ -437,64 +495,6 @@ static int s0ix_stats_show(struct seq_file *s, void
 *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(s0ix_stats);
 
-static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
-{
-	int rc;
-	u32 val;
-
-	rc = amd_pmc_send_cmd(dev, 0, &val,
 SMU_MSG_GETSMUVERSION, 1);
-	if (rc)
-		return rc;
-
-	dev->smu_program = (val >> 24) & GENMASK(7, 0);
-	dev->major = (val >> 16) & GENMASK(7, 0);
-	dev->minor = (val >> 8) & GENMASK(7, 0);
-	dev->rev = (val >> 0) & GENMASK(7, 0);
-
-	dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n",
-		dev->smu_program, dev->major, dev->minor, dev->rev);
-
-	return 0;
-}
-
-static ssize_t smu_fw_version_show(struct device *d, struct
 device_attribute *attr,
-				   char *buf)
-{
-	struct amd_pmc_dev *dev = dev_get_drvdata(d);
-
-	if (!dev->major) {
-		int rc = amd_pmc_get_smu_version(dev);
-
-		if (rc)
-			return rc;
-	}
-	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor,

dev->rev);

drivers/platform/x86/amd/pmc.c +0 -3
-}
-
-static ssize_t smu_program_show(struct device *d, struct device_attribute

*attr,

drivers/platform/x86/amd/pmc.c +0 -23
-				   char *buf)
-{
-	struct amd_pmc_dev *dev = dev_get_drvdata(d);
-
-	if (!dev->major) {
-		int rc = amd_pmc_get_smu_version(dev);
-
-		if (rc)
-			return rc;
-	}
-	return sysfs_emit(buf, "%u\n", dev->smu_program);
-}
-
-static DEVICE_ATTR_RO(smu_fw_version);
-static DEVICE_ATTR_RO(smu_program);
-
-static struct attribute *pmc_attrs[] = {
-	&dev_attr_smu_fw_version.attr,
-	&dev_attr_smu_program.attr,
-	NULL,
-};
-ATTRIBUTE_GROUPS(pmc);
-
 static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
 {
 	struct amd_pmc_dev *dev = s->private;

base-commit: 401199ffa9b69baf3fd1f9ad082aa65c10910585 --
2.37.3

#2 lore raw
In reply to Nathan Chancellor

Hi,

Quoted 14 lines · Nathan Chancellor

Without CONFIG_DEBUG_FS, the following build error occurs:

drivers/platform/x86/amd/pmc.c:984:17: error: use of undeclared identifier 'pmc_groups'; did you mean 'set_groups'?
.dev_groups = pmc_groups,
^~~~~~~~~~
set_groups
./include/linux/cred.h:65:13: note: 'set_groups' declared here

  extern void set_groups(struct cred *, struct group_info *);
              ^

drivers/platform/x86/amd/pmc.c:984:17: error: incompatible pointer types initializing 'const struct attribute_group **' with an expression of type 'void (struct cred *, struct group_info *)' [-Werror,-Wincompatible-pointer-types]
.dev_groups = pmc_groups,
^~~~~~~~~~
2 errors generated.

Quoted 8 lines

pmc_groups was only defined inside a CONFIG_DEBUG_FS block but commit 7f1ea75d499a ("platform/x86/amd: pmc: Add sysfs files for SMU") intended for these sysfs files to be available outside of debugfs. Shuffle the necessary functions out of the CONFIG_DEBUG_FS block so that the file always builds.

Fixes 7f1ea75d499a ("platform/x86/amd: pmc: Add sysfs files for SMU")

Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans

Quoted 140 lines
---
 drivers/platform/x86/amd/pmc.c | 116 ++++++++++++++++-----------------
 1 file changed, 58 insertions(+), 58 deletions(-)
drivers/platform/x86/amd/pmc.c +58 -58
index 0616ef8ce64c..e47e54b095af 100644
@@ -371,6 +371,64 @@ static void amd_pmc_validate_deepest(struct amd_pmc_dev *pdev)
 }
 #endif
 
+static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
+{
+	int rc;
+	u32 val;
+
+	rc = amd_pmc_send_cmd(dev, 0, &val, SMU_MSG_GETSMUVERSION, 1);
+	if (rc)
+		return rc;
+
+	dev->smu_program = (val >> 24) & GENMASK(7, 0);
+	dev->major = (val >> 16) & GENMASK(7, 0);
+	dev->minor = (val >> 8) & GENMASK(7, 0);
+	dev->rev = (val >> 0) & GENMASK(7, 0);
+
+	dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n",
+		dev->smu_program, dev->major, dev->minor, dev->rev);
+
+	return 0;
+}
+
+static ssize_t smu_fw_version_show(struct device *d, struct device_attribute *attr,
+				   char *buf)
+{
+	struct amd_pmc_dev *dev = dev_get_drvdata(d);
+
+	if (!dev->major) {
+		int rc = amd_pmc_get_smu_version(dev);
+
+		if (rc)
+			return rc;
+	}
+	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor, dev->rev);
+}
+
+static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
+				   char *buf)
+{
+	struct amd_pmc_dev *dev = dev_get_drvdata(d);
+
+	if (!dev->major) {
+		int rc = amd_pmc_get_smu_version(dev);
+
+		if (rc)
+			return rc;
+	}
+	return sysfs_emit(buf, "%u\n", dev->smu_program);
+}
+
+static DEVICE_ATTR_RO(smu_fw_version);
+static DEVICE_ATTR_RO(smu_program);
+
+static struct attribute *pmc_attrs[] = {
+	&dev_attr_smu_fw_version.attr,
+	&dev_attr_smu_program.attr,
+	NULL,
+};
+ATTRIBUTE_GROUPS(pmc);
+
 #ifdef CONFIG_DEBUG_FS
 static int smu_fw_info_show(struct seq_file *s, void *unused)
 {
@@ -437,64 +495,6 @@ static int s0ix_stats_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(s0ix_stats);
 
-static int amd_pmc_get_smu_version(struct amd_pmc_dev *dev)
-{
-	int rc;
-	u32 val;
-
-	rc = amd_pmc_send_cmd(dev, 0, &val, SMU_MSG_GETSMUVERSION, 1);
-	if (rc)
-		return rc;
-
-	dev->smu_program = (val >> 24) & GENMASK(7, 0);
-	dev->major = (val >> 16) & GENMASK(7, 0);
-	dev->minor = (val >> 8) & GENMASK(7, 0);
-	dev->rev = (val >> 0) & GENMASK(7, 0);
-
-	dev_dbg(dev->dev, "SMU program %u version is %u.%u.%u\n",
-		dev->smu_program, dev->major, dev->minor, dev->rev);
-
-	return 0;
-}
-
-static ssize_t smu_fw_version_show(struct device *d, struct device_attribute *attr,
-				   char *buf)
-{
-	struct amd_pmc_dev *dev = dev_get_drvdata(d);
-
-	if (!dev->major) {
-		int rc = amd_pmc_get_smu_version(dev);
-
-		if (rc)
-			return rc;
-	}
-	return sysfs_emit(buf, "%u.%u.%u\n", dev->major, dev->minor, dev->rev);
-}
-
-static ssize_t smu_program_show(struct device *d, struct device_attribute *attr,
-				   char *buf)
-{
-	struct amd_pmc_dev *dev = dev_get_drvdata(d);
-
-	if (!dev->major) {
-		int rc = amd_pmc_get_smu_version(dev);
-
-		if (rc)
-			return rc;
-	}
-	return sysfs_emit(buf, "%u\n", dev->smu_program);
-}
-
-static DEVICE_ATTR_RO(smu_fw_version);
-static DEVICE_ATTR_RO(smu_program);
-
-static struct attribute *pmc_attrs[] = {
-	&dev_attr_smu_fw_version.attr,
-	&dev_attr_smu_program.attr,
-	NULL,
-};
-ATTRIBUTE_GROUPS(pmc);
-
 static int amd_pmc_idlemask_show(struct seq_file *s, void *unused)
 {
 	struct amd_pmc_dev *dev = s->private;

base-commit: 401199ffa9b69baf3fd1f9ad082aa65c10910585