pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS

Difference between
modified post 801dffa3e5 by Anonymous on Tue 22nd Oct 2019 13:45
original post ccbf2c by Anonymous on Tue 22nd Oct 2019 13:29
Download diff
Show old version | new version | both versions

    
1-
diff --git a/ptxdist/local_src/ecu01-comp-cap/main.c b/ptxdist/local_src/ecu01-comp-cap/main.c
1+
diff --git a/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp b/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
2-
index 1fe9651..785aa36 100644
2+
index 8dea629..c4b798c 100644
3-
--- a/ptxdist/local_src/ecu01-comp-cap/main.c
3+
--- a/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
4-
+++ b/ptxdist/local_src/ecu01-comp-cap/main.c
4+
+++ b/ptxdist/local_src/ecu01-codesys/io_driver/ecu01softcompcap.cpp
5-
@@ -47,7 +47,11 @@
5+
@@ -255,11 +255,11 @@ Ecu01SoftCompCap::Ecu01SoftCompCap():
6-
 #include <linux/seq_file.h>
6+
    _callback120(120),
7-
 #include <linux/cdev.h>
7+
    _statusFlag(1)
8-
 #include <linux/spinlock.h>
8+
 {
9-
-
9+
-   int prio = sched_get_priority_max(SCHED_FIFO);
10-
+#include <linux/irq.h>
10+
+   int softcc_prio = sched_get_priority_max(SCHED_FIFO)-2;
11-
+#include <linux/irqdesc.h>
11+
    struct sched_param param;
1712
18-
@@ -177,6 +181,79 @@ int comp_cap_release(struct inode *inode, struct file *filp)
13+
    (void)memset(&param, 0, sizeof(param));
19-
    return 0;
14+
-   param.sched_priority = prio;
20-
 }
15+
+   param.sched_priority = softcc_prio;
2116
22-
+static
17+
    if( _gpio120.isOpen() ){
23-
+struct task_struct *irq_desc_to_irq_thread_task_struct(struct irq_desc *irq_desc)
18+
       if( _gpio120.guardGpioChange( &_callback120, 1000 ) ){
24-
+{
19+
diff --git a/ptxdist/local_src/ecu01-comp-cap/main.c b/ptxdist/local_src/ecu01-comp-cap/main.c
25-
+	if (irq_desc && irq_desc->action)
20+
index 1fe9651..46b6593 100644
26-
+	{
21+
--- a/ptxdist/local_src/ecu01-comp-cap/main.c
27-
+		/*
22+
+++ b/ptxdist/local_src/ecu01-comp-cap/main.c
28-
+		 * Note: |irq_desc->action| can be chained if the irq
23+
@@ -47,7 +47,11 @@
29-
+		 * is a shared one. Maybe we should place a fatal assert
24+
 #include <linux/seq_file.h>
30-
+		 * for that case since we do not handle this here.
25+
 #include <linux/cdev.h>
31-
+		 */
26+
 #include <linux/spinlock.h>
32-
+		return irq_desc->action->thread;
27+
-
33-
+	}
28+
+#include <linux/irq.h>
34-
+
29+
+#include <linux/irqdesc.h>
35-
+	return NULL;
30+
+#include <linux/interrupt.h>
36-
+}
31+
+#include <linux/sched.h>
37-
+
32+
+#include <linux/sched/rt.h>
38-
+#define ECU01_CC_IRQ_THREAD_RTPRIO (MAX_USER_RT_PRIO-1)
33+
 //#include <asm/system.h>         /* cli(), *_flags */
39-
+
34+
 #include <asm/uaccess.h>        /* copy_*_user */
40-
+/*
35+
41-
+ * set scheduler paramters of the compare capture interrupt threads
36+
@@ -177,6 +181,79 @@ int comp_cap_release(struct inode *inode, struct file *filp)
42-
+ *
37+
    return 0;
43-
+ * Note: Realtime priorities of the compare capture interrupt
38+
 }
44-
+ * threads can be monitored with
39+
5040
+static
51-
+void set_cc_irq_thread_scheduler_parameters(struct comp_cap_dev_priv *priv_dev)
41+
+struct task_struct *irq_desc_to_irq_thread_task_struct(struct irq_desc *irq_desc)
5242
+{
53-
+	struct irq_desc *irq_desc;
43+
+	if (irq_desc && irq_desc->action)
6244
+	{
63-
+		/* This can fail with certain kernel CONFIG_* settings */
45+
+		/*
64-
+		(void)printk(KERN_EMERG "%s:%d: %s\n",
46+
+		 * Note: |irq_desc->action| can be chained if the irq
65-
+			__func__, __LINE__, "irq_to_desc() failed.");
47+
+		 * is a shared one. Maybe we should place a fatal assert
66-
+		return;
48+
+		 * for that case since we do not handle this here.
49+
+		 */
6751
+	}
6852
+
69-
+	ts = irq_desc_to_irq_thread_task_struct(irq_desc);
53+
+	return NULL;
70-
+	if (ts)
54+
+}
7555
+
76-
+	/*
56+
+#define ECU01_CC_IRQ_THREAD_RTPRIO (MAX_USER_RT_PRIO-1)
77-
+	 * Be very verbose&loud about setting the scheduler class
57+
+
78-
+	 * and priority, since the application will not work correctly
58+
+/*
79-
+	 * if we fail to do this.
59+
+ * set scheduler paramters of the compare capture interrupt threads
80-
+	 *
60+
+ *
81-
+	 * ToDo: Propagate an error to the caller, so that a device
61+
+ * Note: Realtime priorities of the compare capture interrupt
82-
+	 * |open()| FAILS.
62+
+ * threads can be monitored with
83-
+	 */
63+
+ * $ ps -eT -o s,tid,pid,cls,pri,rtprio,comm,time | egrep 'irq/.+CC' #
84-
+	(void)printk(KERN_EMERG "ecu01-compcap: "
64+
+ *
85-
+		"irq=%ld/%ld, %s interrupt thread pid=%ld to '%s'/rtprio=%ld\n",
65+
+ * ToDo: Failure to set the parameters should be fatal for the
86-
+		(long)irq_desc->irq_data.irq,
66+
+ * |open()| syscall which calls this function!
87-
+		(long)priv_dev->IRQ,
67+
+ */
88-
+		(set_sched_success?"changed":"failed to change"),
68+
+static
89-
+		(long)(ts?ts->pid:-1),
69+
+void set_cc_irq_thread_scheduler_parameters(struct comp_cap_dev_priv *priv_dev)
90-
+		"SCHED_FIFO",
70+
+{
91-
+		(long)param.sched_priority);
71+
+	struct irq_desc *irq_desc;
92-
+}
72+
+	bool set_sched_success = false;
73+
+	struct task_struct *ts;
9377
+
78+
+	irq_desc = irq_to_desc(priv_dev->IRQ);
9486
+
95-
 int start_comp_cap( struct comp_cap_dev *dev, int enable )
87+
+	ts = irq_desc_to_irq_thread_task_struct(irq_desc);
96-
 {
88+
+	if (ts)
97-
    int res = -1;
89+
+	{
98-
@@ -188,6 +265,8 @@ int start_comp_cap( struct comp_cap_dev *dev, int enable )
90+
+		if (sched_setscheduler(ts, SCHED_FIFO, &param) == 0)
99-
91+
+			set_sched_success = true;
100-
    res = request_irq(priv_dev->IRQ, cc_isr, IRQF_DISABLED, dev->NAME , priv_dev );
92+
+	}
10393
+
104-
    cc_restart(priv_dev);
94+
+	/*
105-
95+
+	 * Be very verbose&loud about setting the scheduler class
106-
    priv_dev->clk = clk_get_sys( priv_dev->CLK_PROVIDER, priv_dev->CLK_PARENT);
96+
+	 * and priority, since the application will not work correctly
107-
97+
+	 * if we fail to do this.
108-
98+
+	 *
109-
99+
+	 * ToDo: Propagate an error to the caller, so that a device
110-
100+
+	 * |open()| FAILS.
111-
101+
+	 */
112-
102+
+	(void)printk(KERN_EMERG "ecu01-compcap: "
113-
103+
+		"irq=%ld/%ld, %s interrupt thread pid=%ld to '%s'/rtprio=%ld\n",
114-
104+
+		(long)irq_desc->irq_data.irq,
115-
105+
+		(long)priv_dev->IRQ,
116-
106+
+		(set_sched_success?"changed":"failed to change"),
117-
107+
+		(long)(ts?ts->pid:-1),
118-
108+
+		"SCHED_FIFO",
119-
109+
+		(long)param.sched_priority);
120-
110+
+}
121-
111+
+
122-
112+
+
123-
113+
 int start_comp_cap( struct comp_cap_dev *dev, int enable )
124-
114+
 {
125-
115+
    int res = -1;
126-
116+
@@ -188,6 +265,8 @@ int start_comp_cap( struct comp_cap_dev *dev, int enable )
127117
128-
118+
    res = request_irq(priv_dev->IRQ, cc_isr, IRQF_DISABLED, dev->NAME , priv_dev );
129119
130-
120+
+   set_cc_irq_thread_scheduler_parameters(priv_dev);
131-
121+
+
132-
122+
    cc_restart(priv_dev);
133123
134-
124+
    priv_dev->clk = clk_get_sys( priv_dev->CLK_PROVIDER, priv_dev->CLK_PARENT);
135125

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at