lantiq: Use the BAR0 base address in the ath PCI fixup code
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.18 / 0011-vchiq-Avoid-high-load-when-blocked-and-unkillable.patch
1 From e0412853d9f9e12fc7d8a3125cc3b4a62d19007d Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Mon, 12 May 2014 15:12:02 +0100
4 Subject: [PATCH 011/114] vchiq: Avoid high load when blocked and unkillable
5
6 vchiq: Include SIGSTOP and SIGCONT in list of signals not-masked by vchiq to allow gdb to work
7 ---
8 .../interface/vchiq_arm/vchiq_2835_arm.c | 1 +
9 .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 1 +
10 .../interface/vchiq_arm/vchiq_connected.c | 1 +
11 .../vc04_services/interface/vchiq_arm/vchiq_core.c | 1 +
12 .../interface/vchiq_arm/vchiq_kern_lib.c | 1 +
13 .../interface/vchiq_arm/vchiq_killable.h | 69 ++++++++++++++++++++++
14 .../vc04_services/interface/vchiq_arm/vchiq_util.c | 1 +
15 7 files changed, 75 insertions(+)
16 create mode 100644 drivers/misc/vc04_services/interface/vchiq_arm/vchiq_killable.h
17
18 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
19 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
20 @@ -56,6 +56,7 @@
21 #include "vchiq_arm.h"
22 #include "vchiq_2835.h"
23 #include "vchiq_connected.h"
24 +#include "vchiq_killable.h"
25
26 #define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2)
27
28 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
29 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
30 @@ -50,6 +50,7 @@
31 #include "vchiq_ioctl.h"
32 #include "vchiq_arm.h"
33 #include "vchiq_debugfs.h"
34 +#include "vchiq_killable.h"
35
36 #define DEVICE_NAME "vchiq"
37
38 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_connected.c
39 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_connected.c
40 @@ -33,6 +33,7 @@
41
42 #include "vchiq_connected.h"
43 #include "vchiq_core.h"
44 +#include "vchiq_killable.h"
45 #include <linux/module.h>
46 #include <linux/mutex.h>
47
48 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_core.c
49 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_core.c
50 @@ -32,6 +32,7 @@
51 */
52
53 #include "vchiq_core.h"
54 +#include "vchiq_killable.h"
55
56 #define VCHIQ_SLOT_HANDLER_STACK 8192
57
58 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
59 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_kern_lib.c
60 @@ -39,6 +39,7 @@
61
62 #include "vchiq_core.h"
63 #include "vchiq_arm.h"
64 +#include "vchiq_killable.h"
65
66 /* ---- Public Variables ------------------------------------------------- */
67
68 --- /dev/null
69 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_killable.h
70 @@ -0,0 +1,69 @@
71 +/**
72 + * Copyright (c) 2010-2012 Broadcom. All rights reserved.
73 + *
74 + * Redistribution and use in source and binary forms, with or without
75 + * modification, are permitted provided that the following conditions
76 + * are met:
77 + * 1. Redistributions of source code must retain the above copyright
78 + * notice, this list of conditions, and the following disclaimer,
79 + * without modification.
80 + * 2. Redistributions in binary form must reproduce the above copyright
81 + * notice, this list of conditions and the following disclaimer in the
82 + * documentation and/or other materials provided with the distribution.
83 + * 3. The names of the above-listed copyright holders may not be used
84 + * to endorse or promote products derived from this software without
85 + * specific prior written permission.
86 + *
87 + * ALTERNATIVELY, this software may be distributed under the terms of the
88 + * GNU General Public License ("GPL") version 2, as published by the Free
89 + * Software Foundation.
90 + *
91 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
92 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
93 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
94 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
95 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
96 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
97 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
98 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
99 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
100 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
101 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
102 + */
103 +
104 +#ifndef VCHIQ_KILLABLE_H
105 +#define VCHIQ_KILLABLE_H
106 +
107 +#include <linux/mutex.h>
108 +#include <linux/semaphore.h>
109 +
110 +#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTRAP) | sigmask(SIGSTOP) | sigmask(SIGCONT))
111 +
112 +static inline int __must_check down_interruptible_killable(struct semaphore *sem)
113 +{
114 + /* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */
115 + int ret;
116 + sigset_t blocked, oldset;
117 + siginitsetinv(&blocked, SHUTDOWN_SIGS);
118 + sigprocmask(SIG_SETMASK, &blocked, &oldset);
119 + ret = down_interruptible(sem);
120 + sigprocmask(SIG_SETMASK, &oldset, NULL);
121 + return ret;
122 +}
123 +#define down_interruptible down_interruptible_killable
124 +
125 +
126 +static inline int __must_check mutex_lock_interruptible_killable(struct mutex *lock)
127 +{
128 + /* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */
129 + int ret;
130 + sigset_t blocked, oldset;
131 + siginitsetinv(&blocked, SHUTDOWN_SIGS);
132 + sigprocmask(SIG_SETMASK, &blocked, &oldset);
133 + ret = mutex_lock_interruptible(lock);
134 + sigprocmask(SIG_SETMASK, &oldset, NULL);
135 + return ret;
136 +}
137 +#define mutex_lock_interruptible mutex_lock_interruptible_killable
138 +
139 +#endif
140 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_util.c
141 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_util.c
142 @@ -32,6 +32,7 @@
143 */
144
145 #include "vchiq_util.h"
146 +#include "vchiq_killable.h"
147
148 static inline int is_pow2(int i)
149 {