Skip to contentSkip to conversation

RISC-V ACPI: Assorted fixes

PATCH Superseded Sunil V L 2 participants 6 messages Jun 5, 2023 – Jun 7, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sunil V L

author
#0 lore raw

cover RISC-V ACPI: Assorted fixes

This series fixes couple of issues required to complete the previously merged basic ACPI support series.

1) Kernel test bot has found a new warning using the sparse tool. Though I believe this warning exists for other architectures also, I don't see an issue fixing this for RISC-V.

2) When sscofpmf extension is enabled, the perf driver tries to find out the root INTC domain to register the over flow interrupt handler. However, this function is DT based and needs to be enhanced to work on ACPI based systems.

Sunil V L (2):
RISC-V: ACPI : Fix for usage of pointers in different address space RISC-V/perf: Use standard interface to get INTC domain

 arch/riscv/kernel/acpi.c     |  4 ++--
 drivers/perf/riscv_pmu_sbi.c | 17 ++---------------
 2 files changed, 4 insertions(+), 17 deletions(-)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 RISC-V: ACPI : Fix for usage of pointers in different address space

The arch specific __acpi_map_table can be wrapper around either early_memremap or early_ioremap. But early_memremap routine works with normal pointers whereas __acpi_map_table expects pointers in iomem address space. This causes kernel test bot to fail while using the sparse tool. Fix the issue by using early_ioremap and similar fix done for __acpi_unmap_table.

---
 arch/riscv/kernel/acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/acpi.c +2 -2
index df5a45a2eb93..5ee03ebab80e 100644
@@ -204,7 +204,7 @@ void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
 	if (!size)
 		return NULL;
 
-	return early_memremap(phys, size);
+	return early_ioremap(phys, size);
 }
 
 void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
@@ -212,7 +212,7 @@ void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
 	if (!map || !size)
 		return;
 
-	early_memunmap(map, size);
+	early_iounmap(map, size);
 }
 
 void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 -next 1/2] RISC-V: ACPI : Fix for usage of pointers in different address space

Hey Sunil,

Quoted 10 lines · Sunil V L

The arch specific __acpi_map_table can be wrapper around either early_memremap or early_ioremap. But early_memremap routine works with normal pointers whereas __acpi_map_table expects pointers in iomem address space. This causes kernel test bot to fail while using the sparse tool. Fix the issue by using early_ioremap and similar fix done for __acpi_unmap_table.

Is this

Fixes a91a9ffbd3a5 ("RISC-V: Add support to build the ACPI core")

?
Otherwise,

Thanks,
Conor.

Quoted 29 lines
---
 arch/riscv/kernel/acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/kernel/acpi.c +2 -2
index df5a45a2eb93..5ee03ebab80e 100644
@@ -204,7 +204,7 @@ void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size)
 	if (!size)
 		return NULL;
 
-	return early_memremap(phys, size);
+	return early_ioremap(phys, size);
 }
 
 void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
@@ -212,7 +212,7 @@ void __init __acpi_unmap_table(void __iomem *map, unsigned long size)
 	if (!map || !size)
 		return;
 
-	early_memunmap(map, size);
+	early_iounmap(map, size);
 }
 
 void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
Signature · 1 line
2.34.1
author
#3 lore raw

Re: [PATCH v1 -next 1/2] RISC-V: ACPI : Fix for usage of pointers in different address space

Hi Conor,

Quoted 10 lines · Conor Dooley

Hey Sunil,

Quoted 7 lines · Sunil V L

The arch specific __acpi_map_table can be wrapper around either early_memremap or early_ioremap. But early_memremap routine works with normal pointers whereas __acpi_map_table expects pointers in iomem address space. This causes kernel test bot to fail while using the sparse tool. Fix the issue by using early_ioremap and similar fix done for __acpi_unmap_table.

Quoted 7 lines
Quoted 3 lines

Is this

Fixes a91a9ffbd3a5 ("RISC-V: Add support to build the ACPI core")

?

Yes, I missed it. Will add.

Thanks!
Sunil

author
#4 lore raw

PATCH 2/2 RISC-V/perf: Use standard interface to get INTC domain

In reply to Sunil V L

Currently the PMU driver is using DT based lookup to find the INTC node for sscofpmf extension. This will not work for ACPI based systems causing the driver to fail to register the PMU overflow interrupt handler.

Hence, change the code to use the standard interface to find the INTC node which works irrespective of DT or ACPI.

---
 drivers/perf/riscv_pmu_sbi.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/perf/riscv_pmu_sbi.c +2 -15
index 4f3ac296b3e2..0bc491252a44 100644
@@ -739,7 +739,6 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
 {
 	int ret;
 	struct cpu_hw_events __percpu *hw_events = pmu->hw_events;
-	struct device_node *cpu, *child;
 	struct irq_domain *domain = NULL;
 
 	if (riscv_isa_extension_available(NULL, SSCOFPMF)) {
@@ -756,20 +755,8 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
 	if (!riscv_pmu_use_irq)
 		return -EOPNOTSUPP;
 
-	for_each_of_cpu_node(cpu) {
-		child = of_get_compatible_child(cpu, "riscv,cpu-intc");
-		if (!child) {
-			pr_err("Failed to find INTC node\n");
-			of_node_put(cpu);
-			return -ENODEV;
-		}
-		domain = irq_find_host(child);
-		of_node_put(child);
-		if (domain) {
-			of_node_put(cpu);
-			break;
-		}
-	}
+	domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(),
+					  DOMAIN_BUS_ANY);
 	if (!domain) {
 		pr_err("Failed to find INTC IRQ root domain\n");
 		return -ENODEV;
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH v1 -next 2/2] RISC-V/perf: Use standard interface to get INTC domain

Quoted 35 lines · Sunil V L

Currently the PMU driver is using DT based lookup to find the INTC node for sscofpmf extension. This will not work for ACPI based systems causing the driver to fail to register the PMU overflow interrupt handler.

Hence, change the code to use the standard interface to find the INTC node which works irrespective of DT or ACPI.

---
 drivers/perf/riscv_pmu_sbi.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/perf/riscv_pmu_sbi.c +0 -7
index 4f3ac296b3e2..0bc491252a44 100644
@@ -739,7 +739,6 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
 {
 	int ret;
 	struct cpu_hw_events __percpu *hw_events = pmu->hw_events;
-	struct device_node *cpu, *child;
 	struct irq_domain *domain = NULL;
 
 	if (riscv_isa_extension_available(NULL, SSCOFPMF)) {
@@ -756,20 +755,8 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde
 	if (!riscv_pmu_use_irq)
 		return -EOPNOTSUPP;
 
-	for_each_of_cpu_node(cpu) {
-		child = of_get_compatible_child(cpu, "riscv,cpu-intc");
-		if (!child) {
-			pr_err("Failed to find INTC node\n");
-			of_node_put(cpu);
-			return -ENODEV;

drivers/perf/riscv_pmu_sbi.c static int pmu_sbi_setup_irqs(struct riscv_pmu *pmu, struct platform_device *pde · line 759

Quoted 10 lines
drivers/perf/riscv_pmu_sbi.c +2 -8
-		}
-		domain = irq_find_host(child);
-		of_node_put(child);
-		if (domain) {
-			of_node_put(cpu);
-			break;
-		}
-	}
+	domain = irq_find_matching_fwnode(riscv_get_intc_hwnode(),
+					  DOMAIN_BUS_ANY);

This riscv_get_intc_hwnode stuff is horrific, but that's besides the point.

Cheers,
Conor.

Quoted 6 lines
drivers/perf/riscv_pmu_sbi.c +0 -0
 	if (!domain) {
 		pr_err("Failed to find INTC IRQ root domain\n");
 		return -ENODEV;
Signature · 1 line
2.34.1

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv