]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/linux/openzaurus-pxa27x-2.4.20-rmk2-embedix20050602/P03-C3000-SIGSTOP_FIX_041207.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / linux / openzaurus-pxa27x-2.4.20-rmk2-embedix20050602 / P03-C3000-SIGSTOP_FIX_041207.patch
1 diff -Nur c3000_pre/linux/arch/arm/config.in c3000_work/linux/arch/arm/config.in
2 --- c3000_pre/linux/arch/arm/config.in  2004-12-05 22:17:18.000000000 +0900
3 +++ c3000_work/linux/arch/arm/config.in 2004-12-06 01:13:03.000000000 +0900
4 @@ -481,6 +481,7 @@
5     if [ "$CONFIG_SL_CCCR_CHANGE" = "y" ]; then
6        bool 'Core voltage change enable (EXPERIMENTAL)' CONFIG_CHANGE_CORE_VOLT
7     fi
8 +      bool 'Fix send SIGSTOP to all tasks at suspend (EXPERIMENTAL)' CONFIG_SL_SIGSTOP_FIX
9     if [ "$CONFIG_ARCH_SHARP_SL" = "y" ]; then
10        define_bool CONFIG_BATT y
11     fi
12 diff -Nur c3000_pre/linux/arch/arm/mach-pxa/sharpsl_apm.c c3000_work/linux/arch/arm/mach-pxa/sharpsl_apm.c
13 --- c3000_pre/linux/arch/arm/mach-pxa/sharpsl_apm.c     2004-12-05 22:17:18.000000000 +0900
14 +++ c3000_work/linux/arch/arm/mach-pxa/sharpsl_apm.c    2004-12-06 23:48:35.000000000 +0900
15 @@ -75,6 +75,11 @@
16  #include <asm/system.h>
17  #include <asm/hardware.h>
18  
19 +extern int errno;
20 +// unistd.h is included for the configuration ioctl stuff
21 +#define __KERNEL_SYSCALLS__ 1
22 +#include <asm/unistd.h>
23 +
24  #ifdef CONFIG_ARCH_SHARP_SL
25  #include <asm/irq.h>
26  #include <asm/arch/irqs.h>
27 @@ -363,6 +368,8 @@
28  };
29  #define ERROR_COUNT    (sizeof(error_table)/sizeof(lookup_t))
30  
31 +#define APP_NAME_LIST "/etc/suspend.lst"
32 +
33  /*
34   * Function 
35   */
36 @@ -650,14 +657,81 @@
37         struct task_struct* p = NULL;
38         struct task_struct* tsk = current;
39  
40 +#if defined(CONFIG_SL_SIGSTOP_FIX)
41 +       int fd,x;
42 +       mm_segment_t old_fs = get_fs ();
43 +       char line_buffer[256];
44 +
45         if (! spin_trylock(&lock))
46                 return;
47 +
48 +       // Try opening the send sig application name list
49 +
50 +       set_fs(KERNEL_DS);
51 +       fd = open(APP_NAME_LIST, O_RDONLY, 0);
52 +       set_fs(old_fs);
53   
54         /* send signal to all procs except for kernel-threads */
55         read_lock(&tasklist_lock);
56 +
57 +       if(fd  < 0){
58 +               for_each_task(p) {
59 +                       struct siginfo si;
60 +
61 +                       if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p))
62 +                               continue;
63 +                       if (!strcmp(p->comm,"cardmgr")) {               //Send sig to cardmgr
64 +                               si.si_signo = signo;
65 +                               si.si_errno = 0;
66 +                               si.si_code = SI_KERNEL;
67 +                               si.si_pid = tsk->pid;
68 +                               si.si_uid = tsk->uid;
69 +                               send_sig_info(signo, &si, p);
70 +                       }
71 +               }
72 +
73 +       }else {
74 +        for(;;){
75 +                       memset(line_buffer, '\0', 256);
76 +                       set_fs(KERNEL_DS);
77 +                       for (x = 0; x < 256; x++) {
78 +                               if (!read(fd, &line_buffer[x], 1))
79 +                                       goto sig_send_done;
80 +                               if (line_buffer[x] == '\n' || line_buffer[x] == '\r')
81 +                                       break;
82 +                       }
83 +                       set_fs(old_fs);
84 +
85 +                       for_each_task(p) {
86 +                               struct siginfo si;
87 +
88 +                               if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p))
89 +                                       continue;
90 +                               if (!strncmp(p->comm,line_buffer,strlen(p->comm))) {            //Send sig to cardmgr
91 +//                                     printk ("Send SIG to application\n");
92 +                                       si.si_signo = signo;
93 +                                       si.si_errno = 0;
94 +                                       si.si_code = SI_KERNEL;
95 +                                       si.si_pid = tsk->pid;
96 +                                       si.si_uid = tsk->uid;
97 +                                       send_sig_info(signo, &si, p);
98 +                               }
99 +                       }
100 +               }
101 +       sig_send_done:
102 +
103 +        close(fd);
104 +
105 +       }
106 +#else
107 +       if (! spin_trylock(&lock))
108 +               return;
109 +
110 +       /* send signal to all procs except for kernel-threads */
111 +       read_lock(&tasklist_lock);
112         for_each_task(p) {
113                 struct siginfo si;
114 -
115
116                 if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p))
117                         continue;
118  
119 @@ -667,7 +741,8 @@
120                 si.si_pid = tsk->pid;
121                 si.si_uid = tsk->uid;
122                 send_sig_info(signo, &si, p);
123 -       }
124 +       } 
125 +#endif
126         read_unlock(&tasklist_lock);
127  
128         if (signo == SIGSTOP) {
129 @@ -679,6 +754,58 @@
130                 schedule();
131                 set_current_state(state);
132  
133 +#if defined(CONFIG_SL_SIGSTOP_FIX)
134 +               set_fs(KERNEL_DS);
135 +               fd = open(APP_NAME_LIST, O_RDONLY, 0);
136 +               set_fs(old_fs);
137 +
138 +               read_lock(&tasklist_lock);
139 +               if(fd  < 0){
140 +                       for_each_task(p) {
141 +                               if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p))
142 +                                       continue;
143 +                               if (!strcmp(p->comm,"cardmgr")) {
144 +//                                 printk ("Check application stopped\n");
145 +       
146 +                                   if (p->state != TASK_STOPPED) {
147 +                                       read_unlock(&tasklist_lock);
148 +                                       goto retry;
149 +                                   }
150 +                               }
151 +                       }
152 +               }else {
153 +
154 +               for(;;){
155 +                               memset(line_buffer, '\0', 256);
156 +                               old_fs = get_fs();
157 +                               set_fs(KERNEL_DS);
158 +                               for (x = 0; x < 256; x++) {
159 +                                       if (!read(fd, &line_buffer[x], 1))
160 +                                               goto sig_stop_done;
161 +                                       if (line_buffer[x] == '\n' || line_buffer[x] == '\r')
162 +                                               break;
163 +                               }
164 +                               set_fs(old_fs);
165 +
166 +                               for_each_task(p) {
167 +                                       if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p))
168 +                                               continue;
169 +                                       if (!strncmp(p->comm,line_buffer,strlen(p->comm))) {
170 +               
171 +                                           if (p->state != TASK_STOPPED) {
172 +                                               read_unlock(&tasklist_lock);
173 +                                               goto retry;
174 +                                           }
175 +                                       }
176 +                               }
177 +                       }
178 +               sig_stop_done:
179 +                close(fd);
180 +               }
181 +
182 +               read_unlock(&tasklist_lock);
183 +       }
184 +#else
185                 read_lock(&tasklist_lock);
186                 for_each_task(p) {
187                         if (p->pid == 1 || p->pid == tsk->pid || is_kernel_thread(p))
188 @@ -691,6 +818,7 @@
189                 }
190                 read_unlock(&tasklist_lock);
191         }
192 +#endif
193  
194         spin_unlock(&lock);
195  }