kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code
@ 2023-03-03  3:11 Shaoqin Huang
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 1/3] arm: gic: Write one bit per time in gic_irq_set_clr_enable() Shaoqin Huang
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Shaoqin Huang @ 2023-03-03  3:11 UTC (permalink / raw)
  To: kvmarm; +Cc: Shaoqin Huang, Andrew Jones, Eric Auger, open list:ARM

Some tests still use their own code to enable/disable irq, use
gic_enable/disable_irq() to clean up them.

The first patch fixes a problem which will disable all irq when use
gic_disable_irq().

The patch 2-3 clean up the code by using the macro.

Changelog:
----------
v3:
  - s/diretly/directly.
  - Refer Gic Spec to make comments more clear.
v2:
  - tweak the comments in patch 1. (Eric)
  - Reviewed by Eric.

Shaoqin Huang (3):
  arm: gic: Write one bit per time in gic_irq_set_clr_enable()
  arm64: timer: Use gic_enable/disable_irq() macro in timer test
  arm64: microbench: Use gic_enable_irq() macro in microbench test

 arm/micro-bench.c | 15 +--------------
 arm/timer.c       | 20 +++-----------------
 lib/arm/gic.c     |  4 +---
 3 files changed, 5 insertions(+), 34 deletions(-)

-- 
2.39.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [kvm-unit-tests PATCH v3 1/3] arm: gic: Write one bit per time in gic_irq_set_clr_enable()
  2023-03-03  3:11 [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Shaoqin Huang
@ 2023-03-03  3:11 ` Shaoqin Huang
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 2/3] arm64: timer: Use gic_enable/disable_irq() macro in timer test Shaoqin Huang
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Shaoqin Huang @ 2023-03-03  3:11 UTC (permalink / raw)
  To: kvmarm; +Cc: Shaoqin Huang, Eric Auger, Andrew Jones, open list:ARM

When use gic_irq_set_clr_enable() to disable an interrupt, it will
disable all interrupt since it first read from Interrupt Clear-Enable
Registers where '1' indicates that forwarding of the corresponding
interrupt is enabled and then write this value with a mask into
Interrupt Clear-Enable Registers where '1' indicates disable the
forwarding of the corresponding interrupt.

So directly write one bit per time to enable or disable interrupt.

Fixes: cb573c2 ("arm: gic: Introduce gic_irq_set_clr_enable() helper")
Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
---
 lib/arm/gic.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/arm/gic.c b/lib/arm/gic.c
index 1bfcfcf..89a15fe 100644
--- a/lib/arm/gic.c
+++ b/lib/arm/gic.c
@@ -176,7 +176,6 @@ void gic_ipi_send_mask(int irq, const cpumask_t *dest)
 void gic_irq_set_clr_enable(int irq, bool enable)
 {
 	u32 offset, split = 32, shift = (irq % 32);
-	u32 reg, mask = BIT(shift);
 	void *base;
 
 	assert(irq < 1020);
@@ -199,8 +198,7 @@ void gic_irq_set_clr_enable(int irq, bool enable)
 		assert(0);
 	}
 	base += offset + (irq / split) * 4;
-	reg = readl(base);
-	writel(reg | mask, base);
+	writel(BIT(shift), base);
 }
 
 enum gic_irq_state gic_irq_state(int irq)
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [kvm-unit-tests PATCH v3 2/3] arm64: timer: Use gic_enable/disable_irq() macro in timer test
  2023-03-03  3:11 [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Shaoqin Huang
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 1/3] arm: gic: Write one bit per time in gic_irq_set_clr_enable() Shaoqin Huang
@ 2023-03-03  3:11 ` Shaoqin Huang
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 3/3] arm64: microbench: Use gic_enable_irq() macro in microbench test Shaoqin Huang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Shaoqin Huang @ 2023-03-03  3:11 UTC (permalink / raw)
  To: kvmarm; +Cc: Shaoqin Huang, Eric Auger, Andrew Jones, open list:ARM

Use gic_enable/disable_irq() to clean up the code.

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
---
 arm/timer.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/arm/timer.c b/arm/timer.c
index c4e7b10..c0a8388 100644
--- a/arm/timer.c
+++ b/arm/timer.c
@@ -14,9 +14,6 @@
 #include <asm/gic.h>
 #include <asm/io.h>
 
-static void *gic_isenabler;
-static void *gic_icenabler;
-
 static bool ptimer_unsupported;
 
 static void ptimer_unsupported_handler(struct pt_regs *regs, unsigned int esr)
@@ -139,12 +136,12 @@ static struct timer_info ptimer_info = {
 
 static void set_timer_irq_enabled(struct timer_info *info, bool enabled)
 {
-	u32 val = 1 << PPI(info->irq);
+	u32 irq = PPI(info->irq);
 
 	if (enabled)
-		writel(val, gic_isenabler);
+		gic_enable_irq(irq);
 	else
-		writel(val, gic_icenabler);
+		gic_disable_irq(irq);
 }
 
 static void irq_handler(struct pt_regs *regs)
@@ -366,17 +363,6 @@ static void test_init(void)
 
 	gic_enable_defaults();
 
-	switch (gic_version()) {
-	case 2:
-		gic_isenabler = gicv2_dist_base() + GICD_ISENABLER;
-		gic_icenabler = gicv2_dist_base() + GICD_ICENABLER;
-		break;
-	case 3:
-		gic_isenabler = gicv3_sgi_base() + GICR_ISENABLER0;
-		gic_icenabler = gicv3_sgi_base() + GICR_ICENABLER0;
-		break;
-	}
-
 	install_irq_handler(EL1H_IRQ, irq_handler);
 	set_timer_irq_enabled(&ptimer_info, true);
 	set_timer_irq_enabled(&vtimer_info, true);
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [kvm-unit-tests PATCH v3 3/3] arm64: microbench: Use gic_enable_irq() macro in microbench test
  2023-03-03  3:11 [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Shaoqin Huang
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 1/3] arm: gic: Write one bit per time in gic_irq_set_clr_enable() Shaoqin Huang
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 2/3] arm64: timer: Use gic_enable/disable_irq() macro in timer test Shaoqin Huang
@ 2023-03-03  3:11 ` Shaoqin Huang
  2023-03-07 13:44 ` [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Zenghui Yu
  2023-03-21 15:41 ` Andrew Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Shaoqin Huang @ 2023-03-03  3:11 UTC (permalink / raw)
  To: kvmarm; +Cc: Shaoqin Huang, Eric Auger, Andrew Jones, open list:ARM

Use gic_enable_irq() to clean up code.

Signed-off-by: Shaoqin Huang <shahuang@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
---
 arm/micro-bench.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/arm/micro-bench.c b/arm/micro-bench.c
index 8436612..090fda6 100644
--- a/arm/micro-bench.c
+++ b/arm/micro-bench.c
@@ -212,24 +212,11 @@ static void lpi_exec(void)
 
 static bool timer_prep(void)
 {
-	void *gic_isenabler;
-
 	gic_enable_defaults();
 	install_irq_handler(EL1H_IRQ, gic_irq_handler);
 	local_irq_enable();
 
-	switch (gic_version()) {
-	case 2:
-		gic_isenabler = gicv2_dist_base() + GICD_ISENABLER;
-		break;
-	case 3:
-		gic_isenabler = gicv3_sgi_base() + GICR_ISENABLER0;
-		break;
-	default:
-		assert_msg(0, "Unreachable");
-	}
-
-	writel(1 << PPI(TIMER_VTIMER_IRQ), gic_isenabler);
+	gic_enable_irq(PPI(TIMER_VTIMER_IRQ));
 	write_sysreg(ARCH_TIMER_CTL_IMASK | ARCH_TIMER_CTL_ENABLE, cntv_ctl_el0);
 	isb();
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code
  2023-03-03  3:11 [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Shaoqin Huang
                   ` (2 preceding siblings ...)
  2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 3/3] arm64: microbench: Use gic_enable_irq() macro in microbench test Shaoqin Huang
@ 2023-03-07 13:44 ` Zenghui Yu
  2023-03-21 15:41 ` Andrew Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Zenghui Yu @ 2023-03-07 13:44 UTC (permalink / raw)
  To: Shaoqin Huang; +Cc: kvmarm, Andrew Jones, Eric Auger, open list:ARM

On 2023/3/3 11:11, Shaoqin Huang wrote:
> Some tests still use their own code to enable/disable irq, use
> gic_enable/disable_irq() to clean up them.
> 
> The first patch fixes a problem which will disable all irq when use
> gic_disable_irq().
> 
> The patch 2-3 clean up the code by using the macro.

Series,

Reviewed-by: Zenghui Yu <yuzenghui@huawei.com>

and seems that gic_irq_unmask() in arm/pl031.c can also be replaced
by gic_enable_irq(pl031_irq).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code
  2023-03-03  3:11 [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Shaoqin Huang
                   ` (3 preceding siblings ...)
  2023-03-07 13:44 ` [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Zenghui Yu
@ 2023-03-21 15:41 ` Andrew Jones
  4 siblings, 0 replies; 6+ messages in thread
From: Andrew Jones @ 2023-03-21 15:41 UTC (permalink / raw)
  To: Shaoqin Huang, kvmarm; +Cc: open list:ARM, Eric Auger

On Thu, 2 Mar 2023 22:11:44 -0500, Shaoqin Huang wrote:
> Some tests still use their own code to enable/disable irq, use
> gic_enable/disable_irq() to clean up them.
> 
> The first patch fixes a problem which will disable all irq when use
> gic_disable_irq().
> 
> The patch 2-3 clean up the code by using the macro.
> 
> [...]

Applied to arm/queue, thanks!

https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue

drew

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-21 15:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03  3:11 [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Shaoqin Huang
2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 1/3] arm: gic: Write one bit per time in gic_irq_set_clr_enable() Shaoqin Huang
2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 2/3] arm64: timer: Use gic_enable/disable_irq() macro in timer test Shaoqin Huang
2023-03-03  3:11 ` [kvm-unit-tests PATCH v3 3/3] arm64: microbench: Use gic_enable_irq() macro in microbench test Shaoqin Huang
2023-03-07 13:44 ` [kvm-unit-tests PATCH v3 0/3] arm: Use gic_enable/disable_irq() macro to clean up code Zenghui Yu
2023-03-21 15:41 ` Andrew Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).