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