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"
6 This reverts commit 2da56630b1cc422f58408033102b8f91ae97bc91.
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
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
21 #include "vchiq_arm.h"
22 #include "vchiq_connected.h"
23 +#include "vchiq_killable.h"
24 #include "vchiq_pagelist.h"
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
30 #include "vchiq_ioctl.h"
31 #include "vchiq_arm.h"
32 #include "vchiq_debugfs.h"
33 +#include "vchiq_killable.h"
35 #define DEVICE_NAME "vchiq"
37 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
38 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c
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>
47 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
48 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
50 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
52 #include "vchiq_core.h"
53 +#include "vchiq_killable.h"
55 #define VCHIQ_SLOT_HANDLER_STACK 8192
58 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_killable.h
61 + * Copyright (c) 2010-2012 Broadcom. All rights reserved.
63 + * Redistribution and use in source and binary forms, with or without
64 + * modification, are permitted provided that the following conditions
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.
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.
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.
93 +#ifndef VCHIQ_KILLABLE_H
94 +#define VCHIQ_KILLABLE_H
96 +#include <linux/mutex.h>
97 +#include <linux/semaphore.h>
99 +#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTRAP) | sigmask(SIGSTOP) | sigmask(SIGCONT))
101 +static inline int __must_check down_interruptible_killable(struct semaphore *sem)
103 + /* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */
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);
112 +#define down_interruptible down_interruptible_killable
115 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c
116 +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c
118 /* Copyright (c) 2010-2012 Broadcom. All rights reserved. */
120 #include "vchiq_util.h"
121 +#include "vchiq_killable.h"
123 static inline int is_pow2(int i)