0011-vchiq-Avoid-high-load-when-blocked-and-unkillable.patch 5.6 KB

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