Skip to contentSkip to conversation

dovetail/sirq: implement sirq request and free and post

PATCH In review hongzha1 4 participants 25 messages Jan 11, 2021 – Jan 12, 2021

lore
Share & tools
lore

hongzha1

author
#0 lore raw

PATCH 1/10 dovetail/sirq: implement sirq request and free and post

inband sirq request through synthetic_irq_domain and free and post srq.

---
 .../cobalt/kernel/dovetail/pipeline/sirq.h    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
include/cobalt/kernel/dovetail/pipeline/sirq.h +23 -5
index be9dc587f..1da9d13b2 100644
@@ -23,9 +23,24 @@ int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
 	 * Allocate an IRQ from the synthetic interrupt domain then
 	 * trap it to @handler, to be fired from the in-band stage.
 	 */
-	TODO();
+	int sirq, ret;
 
-	return 0;
+	sirq = irq_create_direct_mapping(synthetic_irq_domain);
+	if (sirq == 0)
+		return -EAGAIN;
+
+	ret = __request_percpu_irq(sirq,
+			handler,
+			IRQF_NO_THREAD,
+			"Inband sirq",
+			&cobalt_machine_cpudata);
+
+	if (ret) {
+		irq_dispose_mapping(sirq);
+		return ret;
+	}
+
+	return sirq;
 }
 
 static inline
@@ -35,13 +50,16 @@ void pipeline_delete_inband_sirq(int sirq)
 	 * Free the synthetic IRQ then deallocate it to its
 	 * originating domain.
 	 */
-	TODO();
+	free_percpu_irq(sirq,
+		&cobalt_machine_cpudata);
+
+	irq_dispose_mapping(sirq);
 }
 
 static inline void pipeline_post_sirq(int sirq)
 {
 	/* Trigger the synthetic IRQ */
-	TODO();
+	irq_post_inband(sirq);
 }
 
-#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
+#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/10 dovetail/clock: implement pipeline_read_cycle_counter

---
 include/cobalt/kernel/dovetail/pipeline/clock.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +1 -3
index 19e3d8986..5176b1506 100644
@@ -13,9 +13,7 @@ struct timespec64;
 static inline u64 pipeline_read_cycle_counter(void)
 {
 	/* Read the raw cycle counter of the core clock. */
-	TODO();
-
-	return 0;
+	return  ktime_get_raw_fast_ns();
 }
 
 static inline void pipeline_set_timer_shot(unsigned long cycles)
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 02/10] dovetail/clock: implement pipeline_read_cycle_counter

Quoted 10 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 include/cobalt/kernel/dovetail/pipeline/clock.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +0 -0
index 19e3d8986..5176b1506 100644

include/cobalt/kernel/dovetail/pipeline/clock.h struct timespec64; · line 19

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/clock.h +1 -3
@@ -13,9 +13,7 @@ struct timespec64;
 static inline u64 pipeline_read_cycle_counter(void)
 {
 	/* Read the raw cycle counter of the core clock. */
-	TODO();
-
-	return 0;
+	return  ktime_get_raw_fast_ns();
 }
 
 static inline void pipeline_set_timer_shot(unsigned long cycles)

Ack, picking up this patch. Thanks.

NOTE: this can only work because Dovetail requires us to align on the in-band kernel's idea of time, i.e. nanosecs. In that case, one Cobalt "TSC" tick equals one nanosecond.

Signature · 1 line
Philippe.
author
#3 lore raw

PATCH 3/10 dovetail/clock: implement pipeline_get_host_time

In reply to hongzha1
---
 include/cobalt/kernel/dovetail/pipeline/clock.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +2 -1
index 5176b1506..28d89b44b 100644
@@ -7,6 +7,7 @@
 
 #include <cobalt/uapi/kernel/types.h>
 #include <cobalt/kernel/assert.h>
+#include <linux/ktime.h>
 
 struct timespec64;
 
@@ -50,7 +51,7 @@ static inline const char *pipeline_clock_name(void)
 static inline int pipeline_get_host_time(struct timespec64 *tp)
 {
 	/* Convert ktime_get_real_fast_ns() to timespec. */
-	TODO();
+	*tp = ktime_to_timespec64(ktime_get_real_fast_ns());
 
 	return 0;
 }
Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH 03/10] dovetail/clock: implement pipeline_get_host_time

Quoted 18 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 include/cobalt/kernel/dovetail/pipeline/clock.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +1 -0
index 5176b1506..28d89b44b 100644
@@ -7,6 +7,7 @@
 
 #include <cobalt/uapi/kernel/types.h>
 #include <cobalt/kernel/assert.h>
+#include <linux/ktime.h>
 
 struct timespec64;
 

include/cobalt/kernel/dovetail/pipeline/clock.h static inline const char *pipeline_clock_name(void) · line 57

Quoted 8 lines
include/cobalt/kernel/dovetail/pipeline/clock.h +1 -1
@@ -50,7 +51,7 @@ static inline const char *pipeline_clock_name(void)
 static inline int pipeline_get_host_time(struct timespec64 *tp)
 {
 	/* Convert ktime_get_real_fast_ns() to timespec. */
-	TODO();
+	*tp = ktime_to_timespec64(ktime_get_real_fast_ns());
 
 	return 0;
 }

Yummie. Ack, picking up this patch. Thanks.

Signature · 1 line
Philippe.
author
#5 lore raw

PATCH 4/10 dovetail/sched: implement pipeline_init_shadow_tcb and pipeline_init_root_tcb

In reply to hongzha1
---
 kernel/cobalt/dovetail/sched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cobalt/dovetail/sched.c +2 -2
index 71f763d39..82e29136c 100644
@@ -36,7 +36,7 @@ void pipeline_init_shadow_tcb(struct xnthread *thread)
 	/*
 	 * Initialize the alternate scheduling control block.
 	 */
-	TODO();
+	dovetail_init_altsched(&xnthread_archtcb(thread)->altsched);
 
 	trace_cobalt_shadow_map(thread);
 }
@@ -46,7 +46,7 @@ void pipeline_init_root_tcb(struct xnthread *thread)
 	/*
 	 * Initialize the alternate scheduling control block.
 	 */
-	TODO();
+	dovetail_init_altsched(&xnthread_archtcb(thread)->altsched);
 }
 
 int pipeline_leave_inband(void)
Signature · 1 line
2.17.1
#6 lore raw

Re: [PATCH 04/10] dovetail/sched: implement pipeline_init_shadow_tcb and pipeline_init_root_tcb

Quoted 19 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 kernel/cobalt/dovetail/sched.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cobalt/dovetail/sched.c +1 -1
index 71f763d39..82e29136c 100644
@@ -36,7 +36,7 @@ void pipeline_init_shadow_tcb(struct xnthread *thread)
 	/*
 	 * Initialize the alternate scheduling control block.
 	 */
-	TODO();
+	dovetail_init_altsched(&xnthread_archtcb(thread)->altsched);
 
 	trace_cobalt_shadow_map(thread);
 }

kernel/cobalt/dovetail/sched.c void pipeline_init_root_tcb(struct xnthread *thread) · line 52

Quoted 8 lines
kernel/cobalt/dovetail/sched.c +1 -1
@@ -46,7 +46,7 @@ void pipeline_init_root_tcb(struct xnthread *thread)
 	/*
 	 * Initialize the alternate scheduling control block.
 	 */
-	TODO();
+	dovetail_init_altsched(&xnthread_archtcb(thread)->altsched);
 }
 
 int pipeline_leave_inband(void)

Looks good, picking up this one too.

Thanks.

Signature · 1 line
Philippe.
author
#7 lore raw

PATCH 5/10 dovetail/init: implement Xenomai stage enabling and disabling

In reply to hongzha1
---
 kernel/cobalt/dovetail/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cobalt/dovetail/init.c +2 -2
index 983186abe..bc891b4c1 100644
@@ -20,7 +20,7 @@ int __init pipeline_init(void)
 	}
 
 	/* Enable the Xenomai out-of-band stage */
-	TODO();
+	enable_oob_stage("Xenomai");
 
 	ret = xnclock_init();
 	if (ret)
@@ -46,7 +46,7 @@ int __init pipeline_late_init(void)
 __init void pipeline_cleanup(void)
 {
 	/* Disable the Xenomai stage */
-	TODO();
+	disable_oob_stage();
 
 	xnclock_cleanup();
 }
Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH 05/10] dovetail/init: implement Xenomai stage enabling and disabling

Quoted 19 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 kernel/cobalt/dovetail/init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cobalt/dovetail/init.c +1 -1
index 983186abe..bc891b4c1 100644
@@ -20,7 +20,7 @@ int __init pipeline_init(void)
 	}
 
 	/* Enable the Xenomai out-of-band stage */
-	TODO();
+	enable_oob_stage("Xenomai");
 
 	ret = xnclock_init();
 	if (ret)

kernel/cobalt/dovetail/init.c int __init pipeline_late_init(void) · line 52

Quoted 8 lines
kernel/cobalt/dovetail/init.c +1 -1
@@ -46,7 +46,7 @@ int __init pipeline_late_init(void)
 __init void pipeline_cleanup(void)
 {
 	/* Disable the Xenomai stage */
-	TODO();
+	disable_oob_stage();
 
 	xnclock_cleanup();
 }

Works for me, queuing for upstream merge via my tree.

Thanks,

Signature · 1 line
Philippe.
author
#9 lore raw

PATCH 6/10 dovetail/pipeline: implement oob irq request and free and post for both TIMER_OOB_IPI and RESCHEDULE_OOB_IPI

In reply to hongzha1
---
 .../kernel/dovetail/pipeline/pipeline.h       | 44 ++++++++++++++-----
 1 file changed, 34 insertions(+), 10 deletions(-)
include/cobalt/kernel/dovetail/pipeline/pipeline.h +34 -10
index 23c4a2c18..a345e1399 100644
@@ -8,9 +8,12 @@
 #include <linux/irq_pipeline.h>
 #include <cobalt/kernel/assert.h>
 #include <asm/xenomai/features.h>
+#include <pipeline/machine.h>
 
 typedef unsigned long spl_t;
 
+extern void xnintr_core_clock_handler(void);
+
 /*
  * We only keep the LSB when testing in SMP mode in order to strip off
  * the recursion marker (0x2) the nklock may store there.
@@ -30,18 +33,29 @@ typedef unsigned long spl_t;
 
 #ifdef CONFIG_SMP
 
+static irqreturn_t reschedule_interrupt_handler(int irq, void *dev_id)
+{
+
+	/* Will reschedule from irq_exit_pipeline. */
+
+	return IRQ_HANDLED;
+}
+
+
 static inline int pipeline_request_resched_ipi(void (*handler)(void))
 {
 	/* Trap the out-of-band rescheduling interrupt. */
-	TODO();
-
-	return 0;
+	return __request_percpu_irq(RESCHEDULE_OOB_IPI,
+			reschedule_interrupt_handler,
+			IRQF_OOB,
+			"Xenomai reschedule",
+			&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_free_resched_ipi(void)
 {
 	/* Release the out-of-band rescheduling interrupt. */
-	TODO();
+	free_percpu_irq(RESCHEDULE_OOB_IPI, &cobalt_machine_cpudata);
 }
 
 static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
@@ -50,21 +64,31 @@ static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
 	 * Trigger the out-of-band rescheduling interrupt on remote
 	 * CPU(s).
 	 */
-	TODO();
+	irq_pipeline_send_remote(RESCHEDULE_OOB_IPI, dest);
 }
 
+static irqreturn_t timer_ipi_interrupt_handler(int irq, void *dev_id)
+{
+	xnintr_core_clock_handler();
+
+	return IRQ_HANDLED;
+}
+
+
 static inline int pipeline_request_timer_ipi(void (*handler)(void))
 {
 	/* Trap the out-of-band timer interrupt. */
-	TODO();
-
-	return 0;
+	return __request_percpu_irq(TIMER_OOB_IPI,
+			timer_ipi_interrupt_handler,
+			IRQF_OOB, "Xenomai timer IPI",
+			&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_free_timer_ipi(void)
 {
 	/* Release the out-of-band timer interrupt. */
-	TODO();
+	free_percpu_irq(TIMER_OOB_IPI,
+		&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
@@ -72,7 +96,7 @@ static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
 	/*
 	 * Trigger the out-of-band timer interrupt on remote CPU(s).
 	 */
-	TODO();
+	irq_pipeline_send_remote(TIMER_OOB_IPI, dest);
 }
 
 #endif
Signature · 1 line
2.17.1
#10 lore raw

Re: [PATCH 06/10] dovetail/pipeline: implement oob irq request and free and post for both TIMER_OOB_IPI and RESCHEDULE_OOB_IPI

Quoted 10 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 .../kernel/dovetail/pipeline/pipeline.h       | 44 ++++++++++++++-----
 1 file changed, 34 insertions(+), 10 deletions(-)
include/cobalt/kernel/dovetail/pipeline/pipeline.h +0 -0
index 23c4a2c18..a345e1399 100644

include/cobalt/kernel/dovetail/pipeline/pipeline.h line 16

Quoted 9 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +3 -0
@@ -8,9 +8,12 @@
 #include <linux/irq_pipeline.h>
 #include <cobalt/kernel/assert.h>
 #include <asm/xenomai/features.h>
+#include <pipeline/machine.h>
 
 typedef unsigned long spl_t;
 
+extern void xnintr_core_clock_handler(void);
+

No need for mentioning the storage class in the declaration. We know this is extern by default, otherwise we would have mentioned "static". Will fix while merging.

Quoted 38 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +15 -4
 /*
  * We only keep the LSB when testing in SMP mode in order to strip off
  * the recursion marker (0x2) the nklock may store there.
@@ -30,18 +33,29 @@ typedef unsigned long spl_t;
 
 #ifdef CONFIG_SMP
 
+static irqreturn_t reschedule_interrupt_handler(int irq, void *dev_id)
+{
+
+	/* Will reschedule from irq_exit_pipeline. */
+
+	return IRQ_HANDLED;
+}
+
+
 static inline int pipeline_request_resched_ipi(void (*handler)(void))
 {
 	/* Trap the out-of-band rescheduling interrupt. */
-	TODO();
-
-	return 0;
+	return __request_percpu_irq(RESCHEDULE_OOB_IPI,
+			reschedule_interrupt_handler,
+			IRQF_OOB,
+			"Xenomai reschedule",
+			&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_free_resched_ipi(void)
 {
 	/* Release the out-of-band rescheduling interrupt. */
-	TODO();
+	free_percpu_irq(RESCHEDULE_OOB_IPI, &cobalt_machine_cpudata);
 }
 
 static inline void pipeline_send_resched_ipi(const struct cpumask *dest)

include/cobalt/kernel/dovetail/pipeline/pipeline.h static inline void pipeline_send_resched_ipi(const struct cpumask *dest) · line 67

Quoted 5 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +1 -1
@@ -50,21 +64,31 @@ static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
 	 * Trigger the out-of-band rescheduling interrupt on remote
 	 * CPU(s).
 	 */
-	TODO();
+	irq_pipeline_send_remote(RESCHEDULE_OOB_IPI, dest);

This call was recently renamed irq_send_oob_ipi() in an effort to clarify the interface. I'll fix this up while merging.

Quoted 18 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +10 -3
 }
 
+static irqreturn_t timer_ipi_interrupt_handler(int irq, void *dev_id)
+{
+	xnintr_core_clock_handler();
+
+	return IRQ_HANDLED;
+}
+
+
 static inline int pipeline_request_timer_ipi(void (*handler)(void))
 {
 	/* Trap the out-of-band timer interrupt. */
-	TODO();
-
-	return 0;
+	return __request_percpu_irq(TIMER_OOB_IPI,
+			timer_ipi_interrupt_handler,

include/cobalt/kernel/dovetail/pipeline/pipeline.h static inline void pipeline_send_resched_ipi(const struct cpumask *dest) · line 91

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +4 -1
+			IRQF_OOB, "Xenomai timer IPI",
+			&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_free_timer_ipi(void)
 {
 	/* Release the out-of-band timer interrupt. */
-	TODO();
+	free_percpu_irq(TIMER_OOB_IPI,
+		&cobalt_machine_cpudata);

Single line. Will fix.

include/cobalt/kernel/dovetail/pipeline/pipeline.h static inline void pipeline_send_timer_ipi(const struct cpumask *dest) · line 100

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +1 -1
 }
 
 static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
@@ -72,7 +96,7 @@ static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
 	/*
 	 * Trigger the out-of-band timer interrupt on remote CPU(s).
 	 */
-	TODO();
+	irq_pipeline_send_remote(TIMER_OOB_IPI, dest);
 }

Ditto.

Ack.

Signature · 1 line
Philippe.
#11 lore raw

Re: [PATCH 06/10] dovetail/pipeline: implement oob irq request and free and post for both TIMER_OOB_IPI and RESCHEDULE_OOB_IPI

Also, the short log should be more concise. The changes are all about out-of-band IRQ management and handling, details about which IRQs this applies to can appear in the main part of the commit log.

There are too many changes for me to fix up that patch on the fly while merging eventually. You may want to resubmit it.

Thanks,

Quoted 118 lines · Philippe Gerum via Xenomai
Quoted 10 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 .../kernel/dovetail/pipeline/pipeline.h       | 44 ++++++++++++++-----
 1 file changed, 34 insertions(+), 10 deletions(-)
include/cobalt/kernel/dovetail/pipeline/pipeline.h +0 -0
index 23c4a2c18..a345e1399 100644

include/cobalt/kernel/dovetail/pipeline/pipeline.h line 16

Quoted 9 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +3 -0
@@ -8,9 +8,12 @@
 #include <linux/irq_pipeline.h>
 #include <cobalt/kernel/assert.h>
 #include <asm/xenomai/features.h>
+#include <pipeline/machine.h>
 
 typedef unsigned long spl_t;
 
+extern void xnintr_core_clock_handler(void);
+

No need for mentioning the storage class in the declaration. We know this is extern by default, otherwise we would have mentioned "static". Will fix while merging.

Quoted 38 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +15 -4
 /*
  * We only keep the LSB when testing in SMP mode in order to strip off
  * the recursion marker (0x2) the nklock may store there.
@@ -30,18 +33,29 @@ typedef unsigned long spl_t;
 
 #ifdef CONFIG_SMP
 
+static irqreturn_t reschedule_interrupt_handler(int irq, void *dev_id)
+{
+
+	/* Will reschedule from irq_exit_pipeline. */
+
+	return IRQ_HANDLED;
+}
+
+
 static inline int pipeline_request_resched_ipi(void (*handler)(void))
 {
 	/* Trap the out-of-band rescheduling interrupt. */
-	TODO();
-
-	return 0;
+	return __request_percpu_irq(RESCHEDULE_OOB_IPI,
+			reschedule_interrupt_handler,
+			IRQF_OOB,
+			"Xenomai reschedule",
+			&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_free_resched_ipi(void)
 {
 	/* Release the out-of-band rescheduling interrupt. */
-	TODO();
+	free_percpu_irq(RESCHEDULE_OOB_IPI, &cobalt_machine_cpudata);
 }
 
 static inline void pipeline_send_resched_ipi(const struct cpumask *dest)

include/cobalt/kernel/dovetail/pipeline/pipeline.h static inline void pipeline_send_resched_ipi(const struct cpumask *dest) · line 67

Quoted 5 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +1 -1
@@ -50,21 +64,31 @@ static inline void pipeline_send_resched_ipi(const struct cpumask *dest)
 	 * Trigger the out-of-band rescheduling interrupt on remote
 	 * CPU(s).
 	 */
-	TODO();
+	irq_pipeline_send_remote(RESCHEDULE_OOB_IPI, dest);

This call was recently renamed irq_send_oob_ipi() in an effort to clarify the interface. I'll fix this up while merging.

Quoted 18 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +10 -3
 }
 
+static irqreturn_t timer_ipi_interrupt_handler(int irq, void *dev_id)
+{
+	xnintr_core_clock_handler();
+
+	return IRQ_HANDLED;
+}
+
+
 static inline int pipeline_request_timer_ipi(void (*handler)(void))
 {
 	/* Trap the out-of-band timer interrupt. */
-	TODO();
-
-	return 0;
+	return __request_percpu_irq(TIMER_OOB_IPI,
+			timer_ipi_interrupt_handler,

include/cobalt/kernel/dovetail/pipeline/pipeline.h static inline void pipeline_send_resched_ipi(const struct cpumask *dest) · line 91

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +4 -1
+			IRQF_OOB, "Xenomai timer IPI",
+			&cobalt_machine_cpudata);
 }
 
 static inline void pipeline_free_timer_ipi(void)
 {
 	/* Release the out-of-band timer interrupt. */
-	TODO();
+	free_percpu_irq(TIMER_OOB_IPI,
+		&cobalt_machine_cpudata);

Single line. Will fix.

include/cobalt/kernel/dovetail/pipeline/pipeline.h static inline void pipeline_send_timer_ipi(const struct cpumask *dest) · line 100

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/pipeline.h +1 -1
 }
 
 static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
@@ -72,7 +96,7 @@ static inline void pipeline_send_timer_ipi(const struct cpumask *dest)
 	/*
 	 * Trigger the out-of-band timer interrupt on remote CPU(s).
 	 */
-	TODO();
+	irq_pipeline_send_remote(TIMER_OOB_IPI, dest);
 }

Ditto.

Ack.

Signature · 1 line
Philippe.
author
#12 lore raw

PATCH 7/10 dovetail/tick: implement proxy tick device installing and uninstalling

In reply to hongzha1
---
 kernel/cobalt/dovetail/tick.c | 85 ++++++++++++++++++++++++++++++++++-
 1 file changed, 83 insertions(+), 2 deletions(-)
kernel/cobalt/dovetail/tick.c +83 -2
index 02cd86690..6a196496c 100644
@@ -6,11 +6,92 @@
  */
 
 #include <linux/tick.h>
+#include <linux/clockchips.h>
 #include <cobalt/kernel/intr.h>
 #include <pipeline/tick.h>
+#include <cobalt/kernel/sched.h>
+#include <cobalt/kernel/timer.h>
 
 extern struct xnintr nktimer;
 
+static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
+
+static int proxy_set_next_ktime(ktime_t expires,
+				struct clock_event_device *proxy_dev)
+{
+	struct xnsched *sched;
+	ktime_t delta;
+	unsigned long flags;
+	int ret;
+
+	/*
+	 * When Negative delta have been observed, we set delta zero.
+	 * Or else exntimer_start() will return -ETIMEDOUT and do not
+	 * trigger shot
+	 */
+	delta = ktime_sub(expires, ktime_get_mono_fast_ns());
+	if (delta < 0)
+		delta = 0;
+
+	flags = hard_local_irq_save(); /* Prevent CPU migration. */
+	sched = xnsched_current();
+	ret = xntimer_start(&sched->htimer, delta, XN_INFINITE, XN_RELATIVE);
+	hard_local_irq_restore(flags);
+
+	return ret ? -ETIME : 0;
+}
+
+
+void xn_core_tick(struct clock_event_device *dummy) /* hard irqs off */
+{
+	xnintr_core_clock_handler();
+}
+
+static int proxy_set_oneshot_stopped(struct clock_event_device *proxy_dev)
+{
+	struct clock_event_device *real_dev;
+	struct clock_proxy_device *dev;
+	struct xnsched *sched;
+	spl_t s;
+
+	dev = container_of(proxy_dev, struct clock_proxy_device, proxy_device);
+
+	/*
+	 * In-band wants to disable the clock hardware on entering a
+	 * tickless state, so we have to stop our in-band tick
+	 * emulation. Propagate the request for shutting down the
+	 * hardware to the real device only if we have no outstanding
+	 * OOB timers. CAUTION: the in-band timer is counted when
+	 * assessing the RQ_IDLE condition, so we need to stop it
+	 * prior to testing the latter.
+	 */
+	xnlock_get_irqsave(&nklock, s);
+	sched = xnsched_current();
+	xntimer_stop(&sched->htimer);
+	//sched->lflags |= XNTSTOP;
+
+	if (sched->lflags & XNIDLE) {
+		real_dev = dev->real_device;
+		real_dev->set_state_oneshot_stopped(real_dev);
+	}
+
+	xnlock_put_irqrestore(&nklock, s);
+
+	return 0;
+}
+
+static void setup_proxy(struct clock_proxy_device *dev)
+{
+	struct clock_event_device *proxy_dev = &dev->proxy_device;
+
+	dev->handle_oob_event = xn_core_tick;
+	proxy_dev->features |= CLOCK_EVT_FEAT_KTIME;
+	proxy_dev->set_next_ktime = proxy_set_next_ktime;
+	if (proxy_dev->set_state_oneshot_stopped)
+		proxy_dev->set_state_oneshot_stopped = proxy_set_oneshot_stopped;
+	__this_cpu_write(proxy_device, dev);
+}
+
 int pipeline_install_tick_proxy(void)
 {
 	int ret;
@@ -20,7 +101,7 @@ int pipeline_install_tick_proxy(void)
 		return ret;
 
 	/* Install the proxy tick device */
-	TODO();	ret = 0;
+	ret = tick_install_proxy(setup_proxy, &xnsched_realtime_cpus);
 	if (ret)
 		goto fail_proxy;
 
@@ -35,7 +116,7 @@ fail_proxy:
 void pipeline_uninstall_tick_proxy(void)
 {
 	/* Uninstall the proxy tick device. */
-	TODO();
+	tick_uninstall_proxy(&xnsched_realtime_cpus);
 
 	pipeline_free_timer_ipi();
 
Signature · 1 line
2.17.1
author
#13 lore raw

PATCH 8/10 dovetail/clock: implement pipeline_set_timer_shot to trigger tick shot

In reply to hongzha1
---
 .../cobalt/kernel/dovetail/pipeline/clock.h   |  4 +++-
 kernel/cobalt/dovetail/tick.c                 | 24 +++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +3 -1
index 28d89b44b..ce9a5c867 100644
@@ -11,6 +11,8 @@
 
 struct timespec64;
 
+extern inline void xnproxy_timer_set(unsigned long delta);
+
 static inline u64 pipeline_read_cycle_counter(void)
 {
 	/* Read the raw cycle counter of the core clock. */
@@ -26,7 +28,7 @@ static inline void pipeline_set_timer_shot(unsigned long cycles)
 	 * pipeline_set_timer_shot() should not be part of the
 	 * pipeline interface.
 	 */
-	TODO();
+	xnproxy_timer_set(cycles);
 }
 
 static inline const char *pipeline_timer_name(void)
kernel/cobalt/dovetail/tick.c +24 -0
index 6a196496c..58662e94e 100644
@@ -16,6 +16,30 @@ extern struct xnintr nktimer;
 
 static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
 
+inline void xnproxy_timer_set(unsigned long delta)
+{
+	struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
+	struct clock_event_device *real_dev = dev->real_device;
+	int ret;
+	u64 cycles;
+
+	if (delta <= 0)
+		delta = real_dev->min_delta_ns;
+	else {
+		delta = min_t(int64_t, delta,
+				(int64_t)real_dev->max_delta_ns);
+		delta = max_t(int64_t, delta,
+					(int64_t)real_dev->min_delta_ns);
+	}
+	cycles = ((u64)delta * real_dev->mult) >> real_dev->shift;
+
+	ret = real_dev->set_next_event(cycles, real_dev);
+	if (ret) {
+		ret = real_dev->set_next_event(real_dev->min_delta_ticks,
+					real_dev);
+	}
+}
+
 static int proxy_set_next_ktime(ktime_t expires,
 				struct clock_event_device *proxy_dev)
 {
Signature · 1 line
2.17.1
author
#14 lore raw

PATCH 9/10 dovetail/clock: implement pipeline_timer_name to get name of real device

In reply to hongzha1
---
 include/cobalt/kernel/dovetail/pipeline/clock.h | 5 ++---
 kernel/cobalt/dovetail/tick.c                   | 8 ++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +2 -3
index ce9a5c867..771104ab4 100644
@@ -12,6 +12,7 @@
 struct timespec64;
 
 extern inline void xnproxy_timer_set(unsigned long delta);
+inline const char *xn_get_timer_name(void);
 
 static inline u64 pipeline_read_cycle_counter(void)
 {
@@ -37,9 +38,7 @@ static inline const char *pipeline_timer_name(void)
 	 * Return the name of the current clock event chip, which is
 	 * the real device controlled by the proxy tick device.
 	 */
-	TODO();
-
-	return "?";
+	return xn_get_timer_name();
 }
 
 static inline const char *pipeline_clock_name(void)
kernel/cobalt/dovetail/tick.c +8 -0
index 58662e94e..e40ec06cb 100644
@@ -16,6 +16,14 @@ extern struct xnintr nktimer;
 
 static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
 
+inline const char *xn_get_timer_name(void)
+{
+	struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
+	struct clock_event_device *real_dev = dev->real_device;
+
+	return real_dev->name;
+}
+
 inline void xnproxy_timer_set(unsigned long delta)
 {
 	struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
Signature · 1 line
2.17.1
#15 lore raw

Re: [PATCH 09/10] dovetail/clock: implement pipeline_timer_name to get name of real device

Quoted 19 lines · On 2021年01月11日 14:43, hongzha1 via Xenomai wrote:
---
  include/cobalt/kernel/dovetail/pipeline/clock.h | 5 ++---
  kernel/cobalt/dovetail/tick.c                   | 8 ++++++++
  2 files changed, 10 insertions(+), 3 deletions(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +1 -0
index ce9a5c867..771104ab4 100644
@@ -12,6 +12,7 @@
  struct timespec64;
 
  extern inline void xnproxy_timer_set(unsigned long delta);
+inline const char *xn_get_timer_name(void);
 
  static inline u64 pipeline_read_cycle_counter(void)
  {

include/cobalt/kernel/dovetail/pipeline/clock.h static inline const char *pipeline_timer_name(void) · line 43

Quoted 9 lines
include/cobalt/kernel/dovetail/pipeline/clock.h +1 -3
@@ -37,9 +38,7 @@ static inline const char *pipeline_timer_name(void)
  	 * Return the name of the current clock event chip, which is
  	 * the real device controlled by the proxy tick device.
  	 */
-	TODO();
-
-	return "?";
+	return xn_get_timer_name();
  }
 

PATCH 02/10, PATCH 08/10 and this one, all of them have the changes for pipeline_read_cycle_counter in include/cobalt/kernel/dovetail/pipeline/clock.h, and they look different, how so? or they are incremental implementation,but PATCH 02/10 returns ktime_get_raw_fast_ns() and PATCH 09/10 returns xn_get_timer_name();.

Quoted 21 lines
include/cobalt/kernel/dovetail/pipeline/clock.h +0 -0
  static inline const char *pipeline_clock_name(void)
kernel/cobalt/dovetail/tick.c +8 -0
index 58662e94e..e40ec06cb 100644
@@ -16,6 +16,14 @@ extern struct xnintr nktimer;
 
  static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
 
+inline const char *xn_get_timer_name(void)
+{
+	struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
+	struct clock_event_device *real_dev = dev->real_device;
+
+	return real_dev->name;
+}
+
  inline void xnproxy_timer_set(unsigned long delta)
  {
  	struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
#16 lore raw

RE: [PATCH 09/10] dovetail/clock: implement pipeline_timer_name to get name of real device

Quoted 38 lines

-----Original Message-----
From: chensong <[email protected]>
Sent: Tuesday, January 12, 2021 9:21 AM
To: Chen, Hongzhan <[email protected]>; [email protected]
Subject: Re: [PATCH 09/10] dovetail/clock: implement pipeline_timer_name to get name of real device

Quoted 27 lines · On 2021?01?11? 14:43, hongzha1 via Xenomai wrote:
---
  include/cobalt/kernel/dovetail/pipeline/clock.h | 5 ++---
  kernel/cobalt/dovetail/tick.c                   | 8 ++++++++
  2 files changed, 10 insertions(+), 3 deletions(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +2 -3
index ce9a5c867..771104ab4 100644
@@ -12,6 +12,7 @@
  struct timespec64;
 
  extern inline void xnproxy_timer_set(unsigned long delta);
+inline const char *xn_get_timer_name(void);
 
  static inline u64 pipeline_read_cycle_counter(void)
  {
@@ -37,9 +38,7 @@ static inline const char *pipeline_timer_name(void)
          * Return the name of the current clock event chip, which is
          * the real device controlled by the proxy tick device.
          */
-        TODO();
-
-        return "?";
+       return xn_get_timer_name();
  }
Quoted 9 lines
Quoted 1 line

PATCH 02/10, PATCH 08/10 and this one, all of them have the changes for pipeline_read_cycle_counter in include/cobalt/kernel/dovetail/pipeline/clock.h, and they look different, how so? or they are incremental implementation,but PATCH 02/10 returns ktime_get_raw_fast_ns() and PATCH 09/10 returns xn_get_timer_name();.

Patch 02/10 really modify pipeline_read_cycle_counte but 08/10 actually modify pipeline_set_timer_shot and this one modify pipeline_timer_name. The patch format created by git send-email is really not friendly to read, I also made such mistake before.

Regards

Hongzhan Chen

Quoted 21 lines
Quoted 21 lines

static inline const char *pipeline_clock_name(void)

kernel/cobalt/dovetail/tick.c +8 -0
index 58662e94e..e40ec06cb 100644
@@ -16,6 +16,14 @@ extern struct xnintr nktimer;
 
  static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
 
+inline const char *xn_get_timer_name(void)
+{
+       struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
+       struct clock_event_device *real_dev = dev->real_device;
+
+       return real_dev->name;
+}
+
  inline void xnproxy_timer_set(unsigned long delta)
  {
         struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
#17 lore raw

Re: [PATCH 09/10] dovetail/clock: implement pipeline_timer_name to get name of real device

Quoted 99 lines · Hongzhan
Quoted 6 lines

-----Original Message-----

Quoted 7 lines

From: chensong <[email protected]>

Sent: Tuesday, January 12, 2021 9:21 AM

To: Chen, Hongzhan <[email protected]>; [email protected]

Subject: Re: [PATCH 09/10] dovetail/clock: implement

pipeline_timer_name to get name of real device

Quoted 14 lines · On 2021?01?11? 14:43, hongzha1 via Xenomai wrote:
Quoted 6 lines

---

  include/cobalt/kernel/dovetail/pipeline/clock.h | 5 ++---
Quoted 7 lines

Review

Quoted 7 lines
  kernel/cobalt/dovetail/tick.c                   | 8 ++++++++
  2 files changed, 10 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/include/cobalt/kernel/dovetail/pipeline/clock.h

Quoted 48 lines
Quoted 31 lines

index ce9a5c867..771104ab4 100644

--- a/include/cobalt/kernel/dovetail/pipeline/clock.h

+++ b/include/cobalt/kernel/dovetail/pipeline/clock.h

(quoted diff) +1 -0
@@ -12,6 +12,7 @@
 
  struct timespec64;
 
 
 
  extern inline void xnproxy_timer_set(unsigned long delta);
 
+inline const char *xn_get_timer_name(void);
 
 
 
  static inline u64 pipeline_read_cycle_counter(void)
 
  {
@@ -37,9 +38,7 @@ static inline const char *pipeline_timer_name(void)
 
          * Return the name of the current clock event chip, which is
 
          * the real device controlled by the proxy tick device.
 
          */

Review static inline const char *pipeline_timer_name(void)

Quoted 10 lines
(quoted diff) +1 -3
 
-        TODO();
 
-
 
-        return "?";
 
+       return xn_get_timer_name();
 
  }

PATCH 02/10, PATCH 08/10 and this one, all of them have the changes for

pipeline_read_cycle_counter in

Quoted 9 lines

include/cobalt/kernel/dovetail/pipeline/clock.h, and they look

different, how so? or they are incremental implementation,but PATCH

02/10 returns ktime_get_raw_fast_ns() and PATCH 09/10 returns

xn_get_timer_name();.

Patch 02/10 really modify pipeline_read_cycle_counte but 08/10 actually modify

Quoted 6 lines

pipeline_set_timer_shot and this one modify pipeline_timer_name. The patch format

created by git send-email is really not friendly to read, I also

made such mistake before.

it's really confusing,anyway,clear to me,many thanks.

song

Quoted 48 lines

Regards

Hongzhan Chen

Quoted 3 lines

Review

Quoted 3 lines

static inline const char *pipeline_clock_name(void)

(quoted diff) +0 -0

b/kernel/cobalt/dovetail/tick.c

Quoted 37 lines
Quoted 37 lines

index 58662e94e..e40ec06cb 100644

--- a/kernel/cobalt/dovetail/tick.c

+++ b/kernel/cobalt/dovetail/tick.c

kernel/cobalt/dovetail/tick.c +8 -0
@@ -16,6 +16,14 @@ extern struct xnintr nktimer;
 
 
 
  static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
 
 
 
+inline const char *xn_get_timer_name(void)
 
+{
 
+       struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
 
+       struct clock_event_device *real_dev = dev->real_device;
 
+
 
+       return real_dev->name;
 
+}
 
+
 
  inline void xnproxy_timer_set(unsigned long delta)
 
  {
 
         struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
#18 lore raw

Re: [PATCH 09/10] dovetail/clock: implement pipeline_timer_name to get name of real device

In reply to hongzha1
Quoted 35 lines · hongzha1 via Xenomai <[email protected]> writes:
---
 include/cobalt/kernel/dovetail/pipeline/clock.h | 5 ++---
 kernel/cobalt/dovetail/tick.c                   | 8 ++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
include/cobalt/kernel/dovetail/pipeline/clock.h +2 -3
index ce9a5c867..771104ab4 100644
@@ -12,6 +12,7 @@
 struct timespec64;
 
 extern inline void xnproxy_timer_set(unsigned long delta);
+inline const char *xn_get_timer_name(void);
 
 static inline u64 pipeline_read_cycle_counter(void)
 {
@@ -37,9 +38,7 @@ static inline const char *pipeline_timer_name(void)
 	 * Return the name of the current clock event chip, which is
 	 * the real device controlled by the proxy tick device.
 	 */
-	TODO();
-
-	return "?";
+	return xn_get_timer_name();
 }
 
 static inline const char *pipeline_clock_name(void)
kernel/cobalt/dovetail/tick.c +0 -0
index 58662e94e..e40ec06cb 100644
@@ -16,6 +16,14 @@ extern struct xnintr nktimer;
 

kernel/cobalt/dovetail/tick.c extern struct xnintr nktimer; · line 26

Quoted 10 lines
kernel/cobalt/dovetail/tick.c +8 -0
 static DEFINE_PER_CPU(struct clock_proxy_device *, proxy_device);
 
+inline const char *xn_get_timer_name(void)
+{
+	struct clock_proxy_device *dev = __this_cpu_read(proxy_device);
+	struct clock_event_device *real_dev = dev->real_device;
+
+	return real_dev->name;
+}
+

Please rename xn_get_timer_name() directly to pipeline_timer_name(), which should be out of line, so that we don't have to expose the proxy_device variable. This stuff is rarely called, and definitely not on the hot path.

Signature · 1 line
Philippe.
author
#19 lore raw

PATCH 10/10 dovetail/kevents: dovetail: implement handle_ptrace_cont

In reply to hongzha1
---
 kernel/cobalt/dovetail/kevents.c | 78 ++++++++++++++++++++++++++++++--
 1 file changed, 75 insertions(+), 3 deletions(-)
kernel/cobalt/dovetail/kevents.c +75 -3
index b5dc50ea7..13c31297c 100644
@@ -473,7 +473,7 @@ int handle_ptrace_resume(struct task_struct *tracee)
 	return KEVENT_PROPAGATE;
 }
 
-static void handle_ptrace_cont(void)
+static void handle_ptrace_cont(struct task_struct *next_task)
 {
 	/*
 	 * This is the place where the ptrace-related work which used
@@ -482,7 +482,79 @@ static void handle_ptrace_cont(void)
 	 * stopped state, which is what look for in
 	 * handle_schedule_event().
 	 */
-	TODO();
+	struct task_struct *prev_task;
+	struct xnthread *next;
+	sigset_t pending;
+	spl_t s;
+
+	cobalt_signal_yield();
+
+	prev_task = current;
+	next = xnthread_from_task(next_task);
+	if (next == NULL)
+		goto out;
+
+	xnlock_get_irqsave(&nklock, s);
+
+	/*
+	 * Track tasks leaving the ptraced state.  Check both SIGSTOP
+	 * (NPTL) and SIGINT (LinuxThreads) to detect ptrace
+	 * continuation.
+	 */
+	if (xnthread_test_state(next, XNSSTEP)) {
+		if (signal_pending(next_task)) {
+			/*
+			 * Do not grab the sighand lock here: it's
+			 * useless, and we already own the runqueue
+			 * lock, so this would expose us to deadlock
+			 * situations on SMP.
+			 */
+			sigorsets(&pending,
+				  &next_task->pending.signal,
+				  &next_task->signal->shared_pending.signal);
+			if (sigismember(&pending, SIGSTOP) ||
+			    sigismember(&pending, SIGINT))
+				goto no_ptrace;
+		}
+
+		/*
+		 * Do not unregister before the thread migrated.
+		 * unregister_debugged_thread will then be called by our
+		 * resume_oob_task.
+		 */
+		if (!xnthread_test_info(next, XNCONTHI))
+			unregister_debugged_thread(next);
+
+		xnthread_set_localinfo(next, XNHICCUP);
+	}
+
+no_ptrace:
+	xnlock_put_irqrestore(&nklock, s);
+
+	/*
+	 * Do basic sanity checks on the incoming thread state.
+	 * NOTE: we allow ptraced threads to run shortly in order to
+	 * properly recover from a stopped state.
+	 */
+	if (!XENO_WARN(COBALT, !xnthread_test_state(next, XNRELAX),
+		       "hardened thread %s[%d] running in Linux domain?! "
+		       "(status=0x%x, sig=%d, prev=%s[%d])",
+		       next->name, task_pid_nr(next_task),
+		       xnthread_get_state(next),
+		       signal_pending(next_task),
+		       prev_task->comm, task_pid_nr(prev_task)))
+		XENO_WARN(COBALT,
+			  !(next_task->ptrace & PT_PTRACED) &&
+			   !xnthread_test_state(next, XNDORMANT)
+			  && xnthread_test_state(next, XNPEND),
+			  "blocked thread %s[%d] rescheduled?! "
+			  "(status=0x%x, sig=%d, prev=%s[%d])",
+			  next->name, task_pid_nr(next_task),
+			  xnthread_get_state(next),
+			  signal_pending(next_task), prev_task->comm,
+			  task_pid_nr(prev_task));
+out:
+	return KEVENT_PROPAGATE;
 }
 
 void handle_inband_event(enum inband_event_type event, void *data)
@@ -505,7 +577,7 @@ void handle_inband_event(enum inband_event_type event, void *data)
 		handle_ptrace_resume(data);
 		break;
 	case INBAND_TASK_PTCONT:
-		handle_ptrace_cont();
+		handle_ptrace_cont(data);
 		break;
 	case INBAND_TASK_PTSTOP:
 		break;
Signature · 1 line
2.17.1
#20 lore raw
In reply to hongzha1
Quoted 50 lines · On 11.01.21 07:43, hongzha1 via Xenomai wrote:

inband sirq request through synthetic_irq_domain and free and post srq.

---
 .../cobalt/kernel/dovetail/pipeline/sirq.h    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
include/cobalt/kernel/dovetail/pipeline/sirq.h +21 -3
index be9dc587f..1da9d13b2 100644
@@ -23,9 +23,24 @@ int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
 	 * Allocate an IRQ from the synthetic interrupt domain then
 	 * trap it to @handler, to be fired from the in-band stage.
 	 */
-	TODO();
+	int sirq, ret;
 
-	return 0;
+	sirq = irq_create_direct_mapping(synthetic_irq_domain);
+	if (sirq == 0)
+		return -EAGAIN;
+
+	ret = __request_percpu_irq(sirq,
+			handler,
+			IRQF_NO_THREAD,
+			"Inband sirq",
+			&cobalt_machine_cpudata);
+
+	if (ret) {
+		irq_dispose_mapping(sirq);
+		return ret;
+	}
+
+	return sirq;
 }
 
 static inline
@@ -35,13 +50,16 @@ void pipeline_delete_inband_sirq(int sirq)
 	 * Free the synthetic IRQ then deallocate it to its
 	 * originating domain.
 	 */
-	TODO();
+	free_percpu_irq(sirq,
+		&cobalt_machine_cpudata);
+
+	irq_dispose_mapping(sirq);
 }

include/cobalt/kernel/dovetail/pipeline/sirq.h void pipeline_delete_inband_sirq(int sirq) · line 65

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/sirq.h +2 -2
 
 static inline void pipeline_post_sirq(int sirq)
 {
 	/* Trigger the synthetic IRQ */
-	TODO();
+	irq_post_inband(sirq);
 }
 
-#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
+#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */

Does this series merely target review / discussion?

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#21 lore raw
Quoted 58 lines · Jan Kiszka via Xenomai
Quoted 57 lines · On 11.01.21 07:43, hongzha1 via Xenomai wrote:

inband sirq request through synthetic_irq_domain and free and post srq.

---
 .../cobalt/kernel/dovetail/pipeline/sirq.h    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
include/cobalt/kernel/dovetail/pipeline/sirq.h +22 -4
index be9dc587f..1da9d13b2 100644
@@ -23,9 +23,24 @@ int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
 	 * Allocate an IRQ from the synthetic interrupt domain then
 	 * trap it to @handler, to be fired from the in-band stage.
 	 */
-	TODO();
+	int sirq, ret;
 
-	return 0;
+	sirq = irq_create_direct_mapping(synthetic_irq_domain);
+	if (sirq == 0)
+		return -EAGAIN;
+
+	ret = __request_percpu_irq(sirq,
+			handler,
+			IRQF_NO_THREAD,
+			"Inband sirq",
+			&cobalt_machine_cpudata);
+
+	if (ret) {
+		irq_dispose_mapping(sirq);
+		return ret;
+	}
+
+	return sirq;
 }
 
 static inline
@@ -35,13 +50,16 @@ void pipeline_delete_inband_sirq(int sirq)
 	 * Free the synthetic IRQ then deallocate it to its
 	 * originating domain.
 	 */
-	TODO();
+	free_percpu_irq(sirq,
+		&cobalt_machine_cpudata);
+
+	irq_dispose_mapping(sirq);
 }
 
 static inline void pipeline_post_sirq(int sirq)
 {
 	/* Trigger the synthetic IRQ */
-	TODO();
+	irq_post_inband(sirq);
 }
 
Quoted 6 lines

include/cobalt/kernel/dovetail/pipeline/sirq.h void pipeline_delete_inband_sirq(int sirq) · line 65

Quoted 3 lines
include/cobalt/kernel/dovetail/pipeline/sirq.h +1 -1
-#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
+#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */

Does this series merely target review / discussion?

It is always open for discussion particularly if something needs to be clarified wrt the way Dovetail works. If not, then this should be considered as a merge merge request.

Signature · 1 line
Philippe.
#22 lore raw
Quoted 68 lines · Philippe Gerum
Quoted 58 lines · Jan Kiszka via Xenomai
Quoted 57 lines · On 11.01.21 07:43, hongzha1 via Xenomai wrote:

inband sirq request through synthetic_irq_domain and free and post srq.

---
 .../cobalt/kernel/dovetail/pipeline/sirq.h    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
include/cobalt/kernel/dovetail/pipeline/sirq.h +22 -4
index be9dc587f..1da9d13b2 100644
@@ -23,9 +23,24 @@ int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
 	 * Allocate an IRQ from the synthetic interrupt domain then
 	 * trap it to @handler, to be fired from the in-band stage.
 	 */
-	TODO();
+	int sirq, ret;
 
-	return 0;
+	sirq = irq_create_direct_mapping(synthetic_irq_domain);
+	if (sirq == 0)
+		return -EAGAIN;
+
+	ret = __request_percpu_irq(sirq,
+			handler,
+			IRQF_NO_THREAD,
+			"Inband sirq",
+			&cobalt_machine_cpudata);
+
+	if (ret) {
+		irq_dispose_mapping(sirq);
+		return ret;
+	}
+
+	return sirq;
 }
 
 static inline
@@ -35,13 +50,16 @@ void pipeline_delete_inband_sirq(int sirq)
 	 * Free the synthetic IRQ then deallocate it to its
 	 * originating domain.
 	 */
-	TODO();
+	free_percpu_irq(sirq,
+		&cobalt_machine_cpudata);
+
+	irq_dispose_mapping(sirq);
 }
 
 static inline void pipeline_post_sirq(int sirq)
 {
 	/* Trigger the synthetic IRQ */
-	TODO();
+	irq_post_inband(sirq);
 }
 
Quoted 6 lines

include/cobalt/kernel/dovetail/pipeline/sirq.h void pipeline_delete_inband_sirq(int sirq) · line 65

Quoted 3 lines
include/cobalt/kernel/dovetail/pipeline/sirq.h +1 -1
-#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
+#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */

Does this series merely target review / discussion?

Quoted 4 lines

It is always open for discussion particularly if something needs to be clarified wrt the way Dovetail works. If not, then this should be considered as a merge merge request.

I read "TODO", and I thought of the markers we had in wip/dovetail. So this series is targeting next already?

Jan

Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
#23 lore raw
Quoted 69 lines · Jan Kiszka
Quoted 68 lines · Philippe Gerum
Quoted 64 lines · Jan Kiszka via Xenomai
Quoted 50 lines · On 11.01.21 07:43, hongzha1 via Xenomai wrote:

inband sirq request through synthetic_irq_domain and free and post srq.

---
 .../cobalt/kernel/dovetail/pipeline/sirq.h    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
include/cobalt/kernel/dovetail/pipeline/sirq.h +21 -3
index be9dc587f..1da9d13b2 100644
@@ -23,9 +23,24 @@ int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
 	 * Allocate an IRQ from the synthetic interrupt domain then
 	 * trap it to @handler, to be fired from the in-band stage.
 	 */
-	TODO();
+	int sirq, ret;
 
-	return 0;
+	sirq = irq_create_direct_mapping(synthetic_irq_domain);
+	if (sirq == 0)
+		return -EAGAIN;
+
+	ret = __request_percpu_irq(sirq,
+			handler,
+			IRQF_NO_THREAD,
+			"Inband sirq",
+			&cobalt_machine_cpudata);
+
+	if (ret) {
+		irq_dispose_mapping(sirq);
+		return ret;
+	}
+
+	return sirq;
 }
 
 static inline
@@ -35,13 +50,16 @@ void pipeline_delete_inband_sirq(int sirq)
 	 * Free the synthetic IRQ then deallocate it to its
 	 * originating domain.
 	 */
-	TODO();
+	free_percpu_irq(sirq,
+		&cobalt_machine_cpudata);
+
+	irq_dispose_mapping(sirq);
 }

include/cobalt/kernel/dovetail/pipeline/sirq.h void pipeline_delete_inband_sirq(int sirq) · line 65

Quoted 10 lines
include/cobalt/kernel/dovetail/pipeline/sirq.h +2 -2
 
 static inline void pipeline_post_sirq(int sirq)
 {
 	/* Trigger the synthetic IRQ */
-	TODO();
+	irq_post_inband(sirq);
 }
 
-#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
+#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */

Does this series merely target review / discussion?

Quoted 8 lines
Quoted 4 lines

It is always open for discussion particularly if something needs to be clarified wrt the way Dovetail works. If not, then this should be considered as a merge merge request.

I read "TODO", and I thought of the markers we had in wip/dovetail. So this series is targeting next already?

Yes. TODOs are being gradually fixed up by Hongzhan, whose patch series will be following mine once I have reviewed it. Those TODOs do not affect the behavior of I-pipe side, only the Dovetail-related section which is WIP. This way, it is possible for me to prep the code base for introducing Dovetail support, leaving the actual implementation to Hongzhan, so that we can increase the bus factor by at least one regarding this stuff.

Signature · 1 line
Philippe.
#24 lore raw
In reply to hongzha1
Quoted 40 lines · hongzha1 via Xenomai <[email protected]> writes:

inband sirq request through synthetic_irq_domain and free and post srq.

---
 .../cobalt/kernel/dovetail/pipeline/sirq.h    | 28 +++++++++++++++----
 1 file changed, 23 insertions(+), 5 deletions(-)
include/cobalt/kernel/dovetail/pipeline/sirq.h +17 -2
index be9dc587f..1da9d13b2 100644
@@ -23,9 +23,24 @@ int pipeline_create_inband_sirq(irqreturn_t (*handler)(int irq, void *dev_id))
 	 * Allocate an IRQ from the synthetic interrupt domain then
 	 * trap it to @handler, to be fired from the in-band stage.
 	 */
-	TODO();
+	int sirq, ret;
 
-	return 0;
+	sirq = irq_create_direct_mapping(synthetic_irq_domain);
+	if (sirq == 0)
+		return -EAGAIN;
+
+	ret = __request_percpu_irq(sirq,
+			handler,
+			IRQF_NO_THREAD,
+			"Inband sirq",
+			&cobalt_machine_cpudata);
+
+	if (ret) {
+		irq_dispose_mapping(sirq);
+		return ret;
+	}
+
+	return sirq;
 }
 
 static inline

include/cobalt/kernel/dovetail/pipeline/sirq.h void pipeline_delete_inband_sirq(int sirq) · line 55

Quoted 7 lines
include/cobalt/kernel/dovetail/pipeline/sirq.h +3 -1
@@ -35,13 +50,16 @@ void pipeline_delete_inband_sirq(int sirq)
 	 * Free the synthetic IRQ then deallocate it to its
 	 * originating domain.
 	 */
-	TODO();
+	free_percpu_irq(sirq,
+		&cobalt_machine_cpudata);
+

Nitpicking: lines should be joined. I'll fix this while merging.

include/cobalt/kernel/dovetail/pipeline/sirq.h void pipeline_delete_inband_sirq(int sirq) · line 65

Quoted 12 lines
include/cobalt/kernel/dovetail/pipeline/sirq.h +3 -2
+	irq_dispose_mapping(sirq);
 }
 
 static inline void pipeline_post_sirq(int sirq)
 {
 	/* Trigger the synthetic IRQ */
-	TODO();
+	irq_post_inband(sirq);
 }
 
-#endif /* !_COBALT_KERNEL_IPIPE_SIRQ_H */
+#endif /* !_COBALT_KERNEL_DOVETAIL_SIRQ_H */

Looks good, I'm picking up this patch.

Thanks,

Signature · 1 line
Philippe.