* [PATCH][wip/dovetail] cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler
@ 2020-10-15 5:02 hongzha1
2020-10-15 14:23 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: hongzha1 @ 2020-10-15 5:02 UTC (permalink / raw)
To: xenomai, jan.kiszka
create and register RESCHEDULE_OOB_IPI interrupt handler
Signed-off-by: hongzha1 <hongzhan.chen@intel.com>
diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
index f39becb90..1d40925b6 100644
--- a/kernel/cobalt/sched.c
+++ b/kernel/cobalt/sched.c
@@ -30,6 +30,13 @@
#define CREATE_TRACE_POINTS
#include <trace/events/cobalt-core.h>
+struct xn_machine_cpudata {
+};
+
+DEFINE_PER_CPU(struct xn_machine_cpudata, xn_machine_cpudata);
+
+static void xnsched_destroy(struct xnsched *sched);
+
/**
* @ingroup cobalt_core
* @defgroup cobalt_core_sched Thread scheduling control
@@ -224,10 +231,18 @@ static void xnsched_init(struct xnsched *sched, int cpu)
#endif /* CONFIG_XENO_OPT_WATCHDOG */
}
+static irqreturn_t reschedule_interrupt(int irq, void *dev_id)
+{
+ __xnsched_run_handler();
+
+ return IRQ_HANDLED;
+}
+
void xnsched_init_all(void)
{
struct xnsched *sched;
int cpu;
+ int ret;
for_each_online_cpu(cpu) {
sched = &per_cpu(nksched, cpu);
@@ -235,12 +250,28 @@ void xnsched_init_all(void)
}
#ifdef CONFIG_SMP
-#warning TODO
/* ipipe_request_irq(&xnsched_realtime_domain,
IPIPE_RESCHEDULE_IPI,
(ipipe_irq_handler_t)__xnsched_run_handler,
NULL, NULL);*/
+ ret = __request_percpu_irq(RESCHEDULE_OOB_IPI,
+ reschedule_interrupt,
+ IRQF_OOB,
+ "Xenomai reschedule",
+ &xn_machine_cpudata);
+ if (ret)
+ goto cleanup_sched;
#endif
+ return;
+
+cleanup_sched:
+ for_each_online_cpu(cpu) {
+ sched = xnsched_struct(cpu);
+ xnsched_destroy(sched);
+ }
+
+ return;
+
}
static void xnsched_destroy(struct xnsched *sched)
@@ -264,6 +295,7 @@ void xnsched_destroy_all(void)
#ifdef CONFIG_SMP
#warning TODO
// ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI);
+ free_percpu_irq(RESCHEDULE_OOB_IPI, &xn_machine_cpudata);
#endif
xnlock_get_irqsave(&nklock, s);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH][wip/dovetail] cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler
2020-10-15 5:02 [PATCH][wip/dovetail] cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler hongzha1
@ 2020-10-15 14:23 ` Jan Kiszka
2020-10-16 1:32 ` Chen, Hongzhan
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2020-10-15 14:23 UTC (permalink / raw)
To: hongzha1, xenomai
On 15.10.20 07:02, hongzha1 wrote:
> create and register RESCHEDULE_OOB_IPI interrupt handler
>
> Signed-off-by: hongzha1 <hongzhan.chen@intel.com>
>
> diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
> index f39becb90..1d40925b6 100644
> --- a/kernel/cobalt/sched.c
> +++ b/kernel/cobalt/sched.c
> @@ -30,6 +30,13 @@
> #define CREATE_TRACE_POINTS
> #include <trace/events/cobalt-core.h>
>
> +struct xn_machine_cpudata {
> +};
> +
> +DEFINE_PER_CPU(struct xn_machine_cpudata, xn_machine_cpudata);
> +
> +static void xnsched_destroy(struct xnsched *sched);
> +
> /**
> * @ingroup cobalt_core
> * @defgroup cobalt_core_sched Thread scheduling control
> @@ -224,10 +231,18 @@ static void xnsched_init(struct xnsched *sched, int cpu)
> #endif /* CONFIG_XENO_OPT_WATCHDOG */
> }
>
> +static irqreturn_t reschedule_interrupt(int irq, void *dev_id)
> +{
> + __xnsched_run_handler();
> +
> + return IRQ_HANDLED;
> +}
> +
> void xnsched_init_all(void)
> {
> struct xnsched *sched;
> int cpu;
> + int ret;
>
> for_each_online_cpu(cpu) {
> sched = &per_cpu(nksched, cpu);
> @@ -235,12 +250,28 @@ void xnsched_init_all(void)
> }
>
> #ifdef CONFIG_SMP
> -#warning TODO
> /* ipipe_request_irq(&xnsched_realtime_domain,
> IPIPE_RESCHEDULE_IPI,
> (ipipe_irq_handler_t)__xnsched_run_handler,
> NULL, NULL);*/
> + ret = __request_percpu_irq(RESCHEDULE_OOB_IPI,
> + reschedule_interrupt,
> + IRQF_OOB,
> + "Xenomai reschedule",
> + &xn_machine_cpudata);
> + if (ret)
> + goto cleanup_sched;
> #endif
> + return;
> +
> +cleanup_sched:
> + for_each_online_cpu(cpu) {
> + sched = xnsched_struct(cpu);
> + xnsched_destroy(sched);
That will run for all cpus, also for those possibly not yet initialized
at this stage. Did you check if that is ok?
> + }
> +
> + return;
Unneeded "return" statement.
> +
> }
>
> static void xnsched_destroy(struct xnsched *sched)
> @@ -264,6 +295,7 @@ void xnsched_destroy_all(void)
> #ifdef CONFIG_SMP
> #warning TODO
> // ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI);
> + free_percpu_irq(RESCHEDULE_OOB_IPI, &xn_machine_cpudata);
> #endif
>
> xnlock_get_irqsave(&nklock, s);
>
Looks good otherwise. Another step forward.
Thanks,
Jan
--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH][wip/dovetail] cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler
2020-10-15 14:23 ` Jan Kiszka
@ 2020-10-16 1:32 ` Chen, Hongzhan
0 siblings, 0 replies; 3+ messages in thread
From: Chen, Hongzhan @ 2020-10-16 1:32 UTC (permalink / raw)
To: Jan Kiszka, xenomai
>> create and register RESCHEDULE_OOB_IPI interrupt handler
>>
>> Signed-off-by: hongzha1 <hongzhan.chen@intel.com>
>>
>> diff --git a/kernel/cobalt/sched.c b/kernel/cobalt/sched.c
>> index f39becb90..1d40925b6 100644
>> --- a/kernel/cobalt/sched.c
>> +++ b/kernel/cobalt/sched.c
>> @@ -30,6 +30,13 @@
>> #define CREATE_TRACE_POINTS
>> #include <trace/events/cobalt-core.h>
>>
>> +struct xn_machine_cpudata {
>> +};
>> +
>> +DEFINE_PER_CPU(struct xn_machine_cpudata, xn_machine_cpudata);
>> +
>> +static void xnsched_destroy(struct xnsched *sched);
>> +
>> /**
>> * @ingroup cobalt_core
>> * @defgroup cobalt_core_sched Thread scheduling control
>> @@ -224,10 +231,18 @@ static void xnsched_init(struct xnsched *sched, int cpu)
>> #endif /* CONFIG_XENO_OPT_WATCHDOG */
>> }
>>
>> +static irqreturn_t reschedule_interrupt(int irq, void *dev_id)
>> +{
>> + __xnsched_run_handler();
>> +
>> + return IRQ_HANDLED;
>> +}
>> +
>> void xnsched_init_all(void)
>> {
>> struct xnsched *sched;
>> int cpu;
>> + int ret;
>>
>> for_each_online_cpu(cpu) {
>> sched = &per_cpu(nksched, cpu);
Step 1: these code is to do initialization.
>> @@ -235,12 +250,28 @@ void xnsched_init_all(void)
>> }
>>
>> #ifdef CONFIG_SMP
>> -#warning TODO
>> /* ipipe_request_irq(&xnsched_realtime_domain,
>> IPIPE_RESCHEDULE_IPI,
>> (ipipe_irq_handler_t)__xnsched_run_handler,
>> NULL, NULL);*/
>> + ret = __request_percpu_irq(RESCHEDULE_OOB_IPI,
>> + reschedule_interrupt,
>> + IRQF_OOB,
>> + "Xenomai reschedule",
>> + &xn_machine_cpudata);
>> + if (ret)
>> + goto cleanup_sched;
>> #endif
>> + return;
>> +
>> +cleanup_sched:
>> + for_each_online_cpu(cpu) {
>> + sched = xnsched_struct(cpu);
>> + xnsched_destroy(sched);
>
>TThat will run for all cpus, also for those possibly not yet initialized
>aat this stage. Did you check if that is ok?
>
Hi Yan,
Thanks for your comments. Yes , it was already initialized from the start of current function, please check code where I comment at step 1 in original code.
cleanup_sched is to recall the initialization if fail to request irq before return current function.
>>> + }
>>> +
>>> + return;
>
>UUnneeded "return" statement.
>
>>> +
>>> }
>>>
>>> static void xnsched_destroy(struct xnsched *sched)
>>> @@ -264,6 +295,7 @@ void xnsched_destroy_all(void)
>>> #ifdef CONFIG_SMP
>>> #warning TODO
>>> // ipipe_free_irq(&xnsched_realtime_domain, IPIPE_RESCHEDULE_IPI);
>>> + free_percpu_irq(RESCHEDULE_OOB_IPI, &xn_machine_cpudata);
>>> #endif
>>>
>>> xnlock_get_irqsave(&nklock, s);
>>>
>
>Looks good otherwise. Another step forward.
>
>Thanks,
>Jan
>
>--
>Siemens AG, T RDA IOT
>Corporate Competence Center Embedded Linux
Regards
Hongzhan Chen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-16 1:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 5:02 [PATCH][wip/dovetail] cobalt/sched: init RESCHEDULE_OOB_IPI and register interrupt handler hongzha1
2020-10-15 14:23 ` Jan Kiszka
2020-10-16 1:32 ` Chen, Hongzhan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.