Skip to contentSkip to conversation

hwmon: xgene: Support hwmon v2

PATCH Applied Hoan Tran 2 participants 6 messages Sep 21, 2017 – Oct 1, 2017 Hardware monitoring

v1 of 4 Applied Latest is v4 →

lore
Share & tools
lore

Hoan Tran

author
#0 lore raw

cover hwmon: xgene: Support hwmon v2

This patch supports xgene-hwmon v2 which uses the non-cachable memory as the PCC shared memory.

Hoan Tran (2):
hwmon: xgene: Support hwmon v2
hwmon: xgene: Support PCC shared memory in IO region

 drivers/hwmon/xgene-hwmon.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/2 hwmon: xgene: Support hwmon v2

This patch supports xgene-hwmon v2 which uses the non-cachable memory as the PCC shared memory.

---
 drivers/hwmon/xgene-hwmon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/xgene-hwmon.c +1 -0
index 9c0dbb8..5cd327e 100644
@@ -761,6 +761,7 @@ static int xgene_hwmon_remove(struct platform_device *pdev)
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id xgene_hwmon_acpi_match[] = {
 	{"APMC0D29", 0},
+	{"APMC0D8A", 0},
 	{},
 };
 MODULE_DEVICE_TABLE(acpi, xgene_hwmon_acpi_match);
Signature · 1 line
1.9.1
maintainer Applied
#2 lore raw
Quoted 4 lines · hotran

This patch supports xgene-hwmon v2 which uses the non-cachable memory as the PCC shared memory.

Applied to hwmon-next.

Thanks,
Guenter

Quoted 16 lines
---
 drivers/hwmon/xgene-hwmon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/xgene-hwmon.c +1 -0
index 9c0dbb8..5cd327e 100644
@@ -761,6 +761,7 @@ static int xgene_hwmon_remove(struct platform_device *pdev)
 #ifdef CONFIG_ACPI
 static const struct acpi_device_id xgene_hwmon_acpi_match[] = {
 	{"APMC0D29", 0},
+	{"APMC0D8A", 0},
 	{},
 };
 MODULE_DEVICE_TABLE(acpi, xgene_hwmon_acpi_match);
author
#3 lore raw

PATCH 2/2 hwmon: xgene: Support PCC shared memory in IO region

In reply to Hoan Tran

As the PCC shared memory could be in IO region which doesn't support caching, this patch simply uses ioremap() for IO region.

---
 drivers/hwmon/xgene-hwmon.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/hwmon/xgene-hwmon.c +11 -3
index 5cd327e..2dac1ed 100644
@@ -32,6 +32,7 @@
 #include <linux/kfifo.h>
 #include <linux/mailbox_controller.h>
 #include <linux/mailbox_client.h>
+#include <linux/memblock.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -135,6 +136,14 @@ static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask)
 	return ret;
 }
 
+static void __iomem *pcc_ioremap(phys_addr_t phys, size_t size)
+{
+	if (!memblock_is_memory(phys))
+		return ioremap(phys, size);
+
+	return memremap(phys, size, MEMREMAP_WB);
+}
+
 static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg)
 {
 	struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr;
@@ -690,9 +699,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		 */
 		ctx->comm_base_addr = cppc_ss->base_address;
 		if (ctx->comm_base_addr) {
-			ctx->pcc_comm_addr = memremap(ctx->comm_base_addr,
-							cppc_ss->length,
-							MEMREMAP_WB);
+			ctx->pcc_comm_addr = pcc_ioremap(ctx->comm_base_addr,
+							 cppc_ss->length);
 		} else {
 			dev_err(&pdev->dev, "Failed to get PCC comm region\n");
 			rc = -ENODEV;
Signature · 1 line
1.9.1
maintainer Applied
#4 lore raw

Re: [2/2] hwmon: xgene: Support PCC shared memory in IO region

Quoted 4 lines · hotran

As the PCC shared memory could be in IO region which doesn't support caching, this patch simply uses ioremap() for IO region.

Applied to hwmon-next.

Thanks,
Guenter

Quoted 43 lines
---
 drivers/hwmon/xgene-hwmon.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/hwmon/xgene-hwmon.c +11 -3
index 5cd327e..2dac1ed 100644
@@ -32,6 +32,7 @@
 #include <linux/kfifo.h>
 #include <linux/mailbox_controller.h>
 #include <linux/mailbox_client.h>
+#include <linux/memblock.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -135,6 +136,14 @@ static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask)
 	return ret;
 }
 
+static void __iomem *pcc_ioremap(phys_addr_t phys, size_t size)
+{
+	if (!memblock_is_memory(phys))
+		return ioremap(phys, size);
+
+	return memremap(phys, size, MEMREMAP_WB);
+}
+
 static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg)
 {
 	struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr;
@@ -690,9 +699,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		 */
 		ctx->comm_base_addr = cppc_ss->base_address;
 		if (ctx->comm_base_addr) {
-			ctx->pcc_comm_addr = memremap(ctx->comm_base_addr,
-							cppc_ss->length,
-							MEMREMAP_WB);
+			ctx->pcc_comm_addr = pcc_ioremap(ctx->comm_base_addr,
+							 cppc_ss->length);
 		} else {
 			dev_err(&pdev->dev, "Failed to get PCC comm region\n");
 			rc = -ENODEV;
maintainer
#5 lore raw

Re: [2/2] hwmon: xgene: Support PCC shared memory in IO region

Quoted 8 lines · Guenter Roeck
Quoted 4 lines · hotran

As the PCC shared memory could be in IO region which doesn't support caching, this patch simply uses ioremap() for IO region.

Applied to hwmon-next.

Turns out this doesn't work. memblock_is_memory() is not exported and marked __init_memblock, and thus not qavailable for modules. Dropped.

Guenter

Quoted 46 lines

Thanks,
Guenter

Quoted 43 lines
---
 drivers/hwmon/xgene-hwmon.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/hwmon/xgene-hwmon.c +11 -3
index 5cd327e..2dac1ed 100644
@@ -32,6 +32,7 @@
 #include <linux/kfifo.h>
 #include <linux/mailbox_controller.h>
 #include <linux/mailbox_client.h>
+#include <linux/memblock.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
@@ -135,6 +136,14 @@ static u16 xgene_word_tst_and_clr(u16 *addr, u16 mask)
 	return ret;
 }
 
+static void __iomem *pcc_ioremap(phys_addr_t phys, size_t size)
+{
+	if (!memblock_is_memory(phys))
+		return ioremap(phys, size);
+
+	return memremap(phys, size, MEMREMAP_WB);
+}
+
 static int xgene_hwmon_pcc_rd(struct xgene_hwmon_dev *ctx, u32 *msg)
 {
 	struct acpi_pcct_shared_memory *generic_comm_base = ctx->pcc_comm_addr;
@@ -690,9 +699,8 @@ static int xgene_hwmon_probe(struct platform_device *pdev)
 		 */
 		ctx->comm_base_addr = cppc_ss->base_address;
 		if (ctx->comm_base_addr) {
-			ctx->pcc_comm_addr = memremap(ctx->comm_base_addr,
-							cppc_ss->length,
-							MEMREMAP_WB);
+			ctx->pcc_comm_addr = pcc_ioremap(ctx->comm_base_addr,
+							 cppc_ss->length);
 		} else {
 			dev_err(&pdev->dev, "Failed to get PCC comm region\n");
 			rc = -ENODEV;