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
6 vchiq: Include SIGSTOP and SIGCONT in list of signals not-masked by vchiq to allow gdb to work
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
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
21 #include "vchiq_arm.h"
22 #include "vchiq_2835.h"
23 #include "vchiq_connected.h"
24 +#include "vchiq_killable.h"
26 #define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2)
28 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
29 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_arm.c
31 #include "vchiq_ioctl.h"
32 #include "vchiq_arm.h"
33 #include "vchiq_debugfs.h"
34 +#include "vchiq_killable.h"
36 #define DEVICE_NAME "vchiq"
38 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_connected.c
39 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_connected.c
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>
48 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_core.c
49 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_core.c
53 #include "vchiq_core.h"
54 +#include "vchiq_killable.h"
56 #define VCHIQ_SLOT_HANDLER_STACK 8192
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
62 #include "vchiq_core.h"
63 #include "vchiq_arm.h"
64 +#include "vchiq_killable.h"
66 /* ---- Public Variables ------------------------------------------------- */
69 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_killable.h
72 + * Copyright (c) 2010-2012 Broadcom. All rights reserved.
74 + * Redistribution and use in source and binary forms, with or without
75 + * modification, are permitted provided that the following conditions
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.
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.
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.
104 +#ifndef VCHIQ_KILLABLE_H
105 +#define VCHIQ_KILLABLE_H
107 +#include <linux/mutex.h>
108 +#include <linux/semaphore.h>
110 +#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTRAP) | sigmask(SIGSTOP) | sigmask(SIGCONT))
112 +static inline int __must_check down_interruptible_killable(struct semaphore *sem)
114 + /* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */
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);
123 +#define down_interruptible down_interruptible_killable
126 +static inline int __must_check mutex_lock_interruptible_killable(struct mutex *lock)
128 + /* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */
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);
137 +#define mutex_lock_interruptible mutex_lock_interruptible_killable
140 --- a/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_util.c
141 +++ b/drivers/misc/vc04_services/interface/vchiq_arm/vchiq_util.c
145 #include "vchiq_util.h"
146 +#include "vchiq_killable.h"
148 static inline int is_pow2(int i)