Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.4 commit in: /
Date: Sat, 29 Jan 2022 17:44:17
Message-Id: 1643478242.5646f140920c548b890e8513ed749a05c8ab56ca.mpagano@gentoo
1 commit: 5646f140920c548b890e8513ed749a05c8ab56ca
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jan 29 17:44:02 2022 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Sat Jan 29 17:44:02 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=5646f140
7
8 Linux patch 5.4.175
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1174_linux-5.4.175.patch | 891 +++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 895 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 865a37b6..2c90c35b 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -739,6 +739,10 @@ Patch: 1173_linux-5.4.174.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.4.174
23
24 +Patch: 1174_linux-5.4.175.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.4.175
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1174_linux-5.4.175.patch b/1174_linux-5.4.175.patch
33 new file mode 100644
34 index 00000000..acd7452d
35 --- /dev/null
36 +++ b/1174_linux-5.4.175.patch
37 @@ -0,0 +1,891 @@
38 +diff --git a/Makefile b/Makefile
39 +index 3075f06f77131..2f6c51097d003 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 5
45 + PATCHLEVEL = 4
46 +-SUBLEVEL = 174
47 ++SUBLEVEL = 175
48 + EXTRAVERSION =
49 + NAME = Kleptomaniac Octopus
50 +
51 +diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
52 +index 50c64146d4926..af81f386793ca 100644
53 +--- a/arch/arm/boot/dts/bcm283x.dtsi
54 ++++ b/arch/arm/boot/dts/bcm283x.dtsi
55 +@@ -183,6 +183,7 @@
56 +
57 + interrupt-controller;
58 + #interrupt-cells = <2>;
59 ++ gpio-ranges = <&gpio 0 0 54>;
60 +
61 + /* Defines pin muxing groups according to
62 + * BCM2835-ARM-Peripherals.pdf page 102.
63 +diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
64 +index 08b35587bc6dc..352c102f3459c 100644
65 +--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
66 ++++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
67 +@@ -118,6 +118,9 @@ struct drm_i915_gem_object {
68 +
69 + I915_SELFTEST_DECLARE(struct list_head st_link);
70 +
71 ++ unsigned long flags;
72 ++#define I915_BO_WAS_BOUND_BIT 0
73 ++
74 + /*
75 + * Is the object to be mapped as read-only to the GPU
76 + * Only honoured if hardware has relevant pte bit
77 +diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pages.c b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
78 +index 18f0ce0135c17..aa63fa0ab575e 100644
79 +--- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c
80 ++++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c
81 +@@ -8,6 +8,8 @@
82 + #include "i915_gem_object.h"
83 + #include "i915_scatterlist.h"
84 +
85 ++#include "gt/intel_gt.h"
86 ++
87 + void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
88 + struct sg_table *pages,
89 + unsigned int sg_page_sizes)
90 +@@ -176,6 +178,14 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
91 + __i915_gem_object_reset_page_iter(obj);
92 + obj->mm.page_sizes.phys = obj->mm.page_sizes.sg = 0;
93 +
94 ++ if (test_and_clear_bit(I915_BO_WAS_BOUND_BIT, &obj->flags)) {
95 ++ struct drm_i915_private *i915 = to_i915(obj->base.dev);
96 ++ intel_wakeref_t wakeref;
97 ++
98 ++ with_intel_runtime_pm_if_in_use(&i915->runtime_pm, wakeref)
99 ++ intel_gt_invalidate_tlbs(&i915->gt);
100 ++ }
101 ++
102 + return pages;
103 + }
104 +
105 +diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c
106 +index d48ec9a76ed16..c8c070375d298 100644
107 +--- a/drivers/gpu/drm/i915/gt/intel_gt.c
108 ++++ b/drivers/gpu/drm/i915/gt/intel_gt.c
109 +@@ -15,6 +15,8 @@ void intel_gt_init_early(struct intel_gt *gt, struct drm_i915_private *i915)
110 +
111 + spin_lock_init(&gt->irq_lock);
112 +
113 ++ mutex_init(&gt->tlb_invalidate_lock);
114 ++
115 + INIT_LIST_HEAD(&gt->closed_vma);
116 + spin_lock_init(&gt->closed_lock);
117 +
118 +@@ -266,3 +268,100 @@ void intel_gt_driver_late_release(struct intel_gt *gt)
119 + intel_uc_driver_late_release(&gt->uc);
120 + intel_gt_fini_reset(gt);
121 + }
122 ++
123 ++struct reg_and_bit {
124 ++ i915_reg_t reg;
125 ++ u32 bit;
126 ++};
127 ++
128 ++static struct reg_and_bit
129 ++get_reg_and_bit(const struct intel_engine_cs *engine, const bool gen8,
130 ++ const i915_reg_t *regs, const unsigned int num)
131 ++{
132 ++ const unsigned int class = engine->class;
133 ++ struct reg_and_bit rb = { };
134 ++
135 ++ if (WARN_ON_ONCE(class >= num || !regs[class].reg))
136 ++ return rb;
137 ++
138 ++ rb.reg = regs[class];
139 ++ if (gen8 && class == VIDEO_DECODE_CLASS)
140 ++ rb.reg.reg += 4 * engine->instance; /* GEN8_M2TCR */
141 ++ else
142 ++ rb.bit = engine->instance;
143 ++
144 ++ rb.bit = BIT(rb.bit);
145 ++
146 ++ return rb;
147 ++}
148 ++
149 ++void intel_gt_invalidate_tlbs(struct intel_gt *gt)
150 ++{
151 ++ static const i915_reg_t gen8_regs[] = {
152 ++ [RENDER_CLASS] = GEN8_RTCR,
153 ++ [VIDEO_DECODE_CLASS] = GEN8_M1TCR, /* , GEN8_M2TCR */
154 ++ [VIDEO_ENHANCEMENT_CLASS] = GEN8_VTCR,
155 ++ [COPY_ENGINE_CLASS] = GEN8_BTCR,
156 ++ };
157 ++ static const i915_reg_t gen12_regs[] = {
158 ++ [RENDER_CLASS] = GEN12_GFX_TLB_INV_CR,
159 ++ [VIDEO_DECODE_CLASS] = GEN12_VD_TLB_INV_CR,
160 ++ [VIDEO_ENHANCEMENT_CLASS] = GEN12_VE_TLB_INV_CR,
161 ++ [COPY_ENGINE_CLASS] = GEN12_BLT_TLB_INV_CR,
162 ++ };
163 ++ struct drm_i915_private *i915 = gt->i915;
164 ++ struct intel_uncore *uncore = gt->uncore;
165 ++ struct intel_engine_cs *engine;
166 ++ enum intel_engine_id id;
167 ++ const i915_reg_t *regs;
168 ++ unsigned int num = 0;
169 ++
170 ++ if (I915_SELFTEST_ONLY(gt->awake == -ENODEV))
171 ++ return;
172 ++
173 ++ if (INTEL_GEN(i915) == 12) {
174 ++ regs = gen12_regs;
175 ++ num = ARRAY_SIZE(gen12_regs);
176 ++ } else if (INTEL_GEN(i915) >= 8 && INTEL_GEN(i915) <= 11) {
177 ++ regs = gen8_regs;
178 ++ num = ARRAY_SIZE(gen8_regs);
179 ++ } else if (INTEL_GEN(i915) < 8) {
180 ++ return;
181 ++ }
182 ++
183 ++ if (WARN_ONCE(!num, "Platform does not implement TLB invalidation!"))
184 ++ return;
185 ++
186 ++ GEM_TRACE("\n");
187 ++
188 ++ assert_rpm_wakelock_held(&i915->runtime_pm);
189 ++
190 ++ mutex_lock(&gt->tlb_invalidate_lock);
191 ++ intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL);
192 ++
193 ++ for_each_engine(engine, gt, id) {
194 ++ /*
195 ++ * HW architecture suggest typical invalidation time at 40us,
196 ++ * with pessimistic cases up to 100us and a recommendation to
197 ++ * cap at 1ms. We go a bit higher just in case.
198 ++ */
199 ++ const unsigned int timeout_us = 100;
200 ++ const unsigned int timeout_ms = 4;
201 ++ struct reg_and_bit rb;
202 ++
203 ++ rb = get_reg_and_bit(engine, regs == gen8_regs, regs, num);
204 ++ if (!i915_mmio_reg_offset(rb.reg))
205 ++ continue;
206 ++
207 ++ intel_uncore_write_fw(uncore, rb.reg, rb.bit);
208 ++ if (__intel_wait_for_register_fw(uncore,
209 ++ rb.reg, rb.bit, 0,
210 ++ timeout_us, timeout_ms,
211 ++ NULL))
212 ++ DRM_ERROR_RATELIMITED("%s TLB invalidation did not complete in %ums!\n",
213 ++ engine->name, timeout_ms);
214 ++ }
215 ++
216 ++ intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL);
217 ++ mutex_unlock(&gt->tlb_invalidate_lock);
218 ++}
219 +diff --git a/drivers/gpu/drm/i915/gt/intel_gt.h b/drivers/gpu/drm/i915/gt/intel_gt.h
220 +index 4920cb351f109..4eab15bdcd97b 100644
221 +--- a/drivers/gpu/drm/i915/gt/intel_gt.h
222 ++++ b/drivers/gpu/drm/i915/gt/intel_gt.h
223 +@@ -57,4 +57,6 @@ static inline bool intel_gt_is_wedged(struct intel_gt *gt)
224 +
225 + void intel_gt_queue_hangcheck(struct intel_gt *gt);
226 +
227 ++void intel_gt_invalidate_tlbs(struct intel_gt *gt);
228 ++
229 + #endif /* __INTEL_GT_H__ */
230 +diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
231 +index dc295c196d11c..82a78719b32d5 100644
232 +--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
233 ++++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
234 +@@ -40,6 +40,8 @@ struct intel_gt {
235 +
236 + struct intel_uc uc;
237 +
238 ++ struct mutex tlb_invalidate_lock;
239 ++
240 + struct intel_gt_timelines {
241 + spinlock_t lock; /* protects active_list */
242 + struct list_head active_list;
243 +diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
244 +index 7b6e68f082f8c..1386d0f5eac63 100644
245 +--- a/drivers/gpu/drm/i915/i915_reg.h
246 ++++ b/drivers/gpu/drm/i915/i915_reg.h
247 +@@ -2519,6 +2519,12 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
248 + #define GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING (1 << 28)
249 + #define GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT (1 << 24)
250 +
251 ++#define GEN8_RTCR _MMIO(0x4260)
252 ++#define GEN8_M1TCR _MMIO(0x4264)
253 ++#define GEN8_M2TCR _MMIO(0x4268)
254 ++#define GEN8_BTCR _MMIO(0x426c)
255 ++#define GEN8_VTCR _MMIO(0x4270)
256 ++
257 + #if 0
258 + #define PRB0_TAIL _MMIO(0x2030)
259 + #define PRB0_HEAD _MMIO(0x2034)
260 +@@ -2602,6 +2608,11 @@ static inline bool i915_mmio_reg_valid(i915_reg_t reg)
261 + #define FAULT_VA_HIGH_BITS (0xf << 0)
262 + #define FAULT_GTT_SEL (1 << 4)
263 +
264 ++#define GEN12_GFX_TLB_INV_CR _MMIO(0xced8)
265 ++#define GEN12_VD_TLB_INV_CR _MMIO(0xcedc)
266 ++#define GEN12_VE_TLB_INV_CR _MMIO(0xcee0)
267 ++#define GEN12_BLT_TLB_INV_CR _MMIO(0xcee4)
268 ++
269 + #define FPGA_DBG _MMIO(0x42300)
270 + #define FPGA_DBG_RM_NOCLAIM (1 << 31)
271 +
272 +diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
273 +index e0e677b2a3a94..c24f49ee10d73 100644
274 +--- a/drivers/gpu/drm/i915/i915_vma.c
275 ++++ b/drivers/gpu/drm/i915/i915_vma.c
276 +@@ -341,6 +341,10 @@ int i915_vma_bind(struct i915_vma *vma, enum i915_cache_level cache_level,
277 + return ret;
278 +
279 + vma->flags |= bind_flags;
280 ++
281 ++ if (vma->obj)
282 ++ set_bit(I915_BO_WAS_BOUND_BIT, &vma->obj->flags);
283 ++
284 + return 0;
285 + }
286 +
287 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
288 +index 5eb73ded8e07a..765f7a62870db 100644
289 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
290 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
291 +@@ -1002,15 +1002,14 @@ extern int vmw_execbuf_fence_commands(struct drm_file *file_priv,
292 + struct vmw_private *dev_priv,
293 + struct vmw_fence_obj **p_fence,
294 + uint32_t *p_handle);
295 +-extern void vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
296 ++extern int vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
297 + struct vmw_fpriv *vmw_fp,
298 + int ret,
299 + struct drm_vmw_fence_rep __user
300 + *user_fence_rep,
301 + struct vmw_fence_obj *fence,
302 + uint32_t fence_handle,
303 +- int32_t out_fence_fd,
304 +- struct sync_file *sync_file);
305 ++ int32_t out_fence_fd);
306 + bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd);
307 +
308 + /**
309 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
310 +index ff86d49dc5e8a..e3d20048075bf 100644
311 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
312 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
313 +@@ -3413,17 +3413,17 @@ int vmw_execbuf_fence_commands(struct drm_file *file_priv,
314 + * Also if copying fails, user-space will be unable to signal the fence object
315 + * so we wait for it immediately, and then unreference the user-space reference.
316 + */
317 +-void
318 ++int
319 + vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
320 + struct vmw_fpriv *vmw_fp, int ret,
321 + struct drm_vmw_fence_rep __user *user_fence_rep,
322 + struct vmw_fence_obj *fence, uint32_t fence_handle,
323 +- int32_t out_fence_fd, struct sync_file *sync_file)
324 ++ int32_t out_fence_fd)
325 + {
326 + struct drm_vmw_fence_rep fence_rep;
327 +
328 + if (user_fence_rep == NULL)
329 +- return;
330 ++ return 0;
331 +
332 + memset(&fence_rep, 0, sizeof(fence_rep));
333 +
334 +@@ -3451,20 +3451,14 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
335 + * handle.
336 + */
337 + if (unlikely(ret != 0) && (fence_rep.error == 0)) {
338 +- if (sync_file)
339 +- fput(sync_file->file);
340 +-
341 +- if (fence_rep.fd != -1) {
342 +- put_unused_fd(fence_rep.fd);
343 +- fence_rep.fd = -1;
344 +- }
345 +-
346 + ttm_ref_object_base_unref(vmw_fp->tfile, fence_handle,
347 + TTM_REF_USAGE);
348 + VMW_DEBUG_USER("Fence copy error. Syncing.\n");
349 + (void) vmw_fence_obj_wait(fence, false, false,
350 + VMW_FENCE_WAIT_TIMEOUT);
351 + }
352 ++
353 ++ return ret ? -EFAULT : 0;
354 + }
355 +
356 + /**
357 +@@ -3806,16 +3800,23 @@ int vmw_execbuf_process(struct drm_file *file_priv,
358 +
359 + (void) vmw_fence_obj_wait(fence, false, false,
360 + VMW_FENCE_WAIT_TIMEOUT);
361 ++ }
362 ++ }
363 ++
364 ++ ret = vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret,
365 ++ user_fence_rep, fence, handle, out_fence_fd);
366 ++
367 ++ if (sync_file) {
368 ++ if (ret) {
369 ++ /* usercopy of fence failed, put the file object */
370 ++ fput(sync_file->file);
371 ++ put_unused_fd(out_fence_fd);
372 + } else {
373 + /* Link the fence with the FD created earlier */
374 + fd_install(out_fence_fd, sync_file->file);
375 + }
376 + }
377 +
378 +- vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret,
379 +- user_fence_rep, fence, handle, out_fence_fd,
380 +- sync_file);
381 +-
382 + /* Don't unreference when handing fence out */
383 + if (unlikely(out_fence != NULL)) {
384 + *out_fence = fence;
385 +@@ -3833,7 +3834,7 @@ int vmw_execbuf_process(struct drm_file *file_priv,
386 + */
387 + vmw_validation_unref_lists(&val_ctx);
388 +
389 +- return 0;
390 ++ return ret;
391 +
392 + out_unlock_binding:
393 + mutex_unlock(&dev_priv->binding_mutex);
394 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
395 +index 178a6cd1a06fe..874093a0b04f0 100644
396 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
397 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
398 +@@ -1171,7 +1171,7 @@ int vmw_fence_event_ioctl(struct drm_device *dev, void *data,
399 + }
400 +
401 + vmw_execbuf_copy_fence_user(dev_priv, vmw_fp, 0, user_fence_rep, fence,
402 +- handle, -1, NULL);
403 ++ handle, -1);
404 + vmw_fence_obj_unreference(&fence);
405 + return 0;
406 + out_no_create:
407 +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
408 +index 33b1519887474..0b800c3540492 100644
409 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
410 ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
411 +@@ -2570,7 +2570,7 @@ void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv,
412 + if (file_priv)
413 + vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv),
414 + ret, user_fence_rep, fence,
415 +- handle, -1, NULL);
416 ++ handle, -1);
417 + if (out_fence)
418 + *out_fence = fence;
419 + else
420 +diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
421 +index 2c01e2ebef7aa..d97c19ef75830 100644
422 +--- a/drivers/mmc/host/sdhci-esdhc-imx.c
423 ++++ b/drivers/mmc/host/sdhci-esdhc-imx.c
424 +@@ -218,8 +218,7 @@ static struct esdhc_soc_data usdhc_imx7ulp_data = {
425 + static struct esdhc_soc_data usdhc_imx8qxp_data = {
426 + .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
427 + | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
428 +- | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES
429 +- | ESDHC_FLAG_CQHCI,
430 ++ | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES,
431 + };
432 +
433 + struct pltfm_imx_data {
434 +diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
435 +index 0de1a3a96984c..fa742535f6791 100644
436 +--- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c
437 ++++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c
438 +@@ -19,6 +19,7 @@
439 + #include <linux/irq.h>
440 + #include <linux/irqdesc.h>
441 + #include <linux/init.h>
442 ++#include <linux/interrupt.h>
443 + #include <linux/of_address.h>
444 + #include <linux/of.h>
445 + #include <linux/of_irq.h>
446 +@@ -37,12 +38,10 @@
447 +
448 + #define MODULE_NAME "pinctrl-bcm2835"
449 + #define BCM2835_NUM_GPIOS 54
450 ++#define BCM2711_NUM_GPIOS 58
451 + #define BCM2835_NUM_BANKS 2
452 + #define BCM2835_NUM_IRQS 3
453 +
454 +-#define BCM2835_PIN_BITMAP_SZ \
455 +- DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8)
456 +-
457 + /* GPIO register offsets */
458 + #define GPFSEL0 0x0 /* Function Select */
459 + #define GPSET0 0x1c /* Pin Output Set */
460 +@@ -78,13 +77,15 @@
461 + struct bcm2835_pinctrl {
462 + struct device *dev;
463 + void __iomem *base;
464 ++ int *wake_irq;
465 +
466 + /* note: locking assumes each bank will have its own unsigned long */
467 + unsigned long enabled_irq_map[BCM2835_NUM_BANKS];
468 +- unsigned int irq_type[BCM2835_NUM_GPIOS];
469 ++ unsigned int irq_type[BCM2711_NUM_GPIOS];
470 +
471 + struct pinctrl_dev *pctl_dev;
472 + struct gpio_chip gpio_chip;
473 ++ struct pinctrl_desc pctl_desc;
474 + struct pinctrl_gpio_range gpio_range;
475 +
476 + raw_spinlock_t irq_lock[BCM2835_NUM_BANKS];
477 +@@ -147,6 +148,10 @@ static struct pinctrl_pin_desc bcm2835_gpio_pins[] = {
478 + BCM2835_GPIO_PIN(51),
479 + BCM2835_GPIO_PIN(52),
480 + BCM2835_GPIO_PIN(53),
481 ++ BCM2835_GPIO_PIN(54),
482 ++ BCM2835_GPIO_PIN(55),
483 ++ BCM2835_GPIO_PIN(56),
484 ++ BCM2835_GPIO_PIN(57),
485 + };
486 +
487 + /* one pin per group */
488 +@@ -205,6 +210,10 @@ static const char * const bcm2835_gpio_groups[] = {
489 + "gpio51",
490 + "gpio52",
491 + "gpio53",
492 ++ "gpio54",
493 ++ "gpio55",
494 ++ "gpio56",
495 ++ "gpio57",
496 + };
497 +
498 + enum bcm2835_fsel {
499 +@@ -355,6 +364,22 @@ static const struct gpio_chip bcm2835_gpio_chip = {
500 + .can_sleep = false,
501 + };
502 +
503 ++static const struct gpio_chip bcm2711_gpio_chip = {
504 ++ .label = "pinctrl-bcm2711",
505 ++ .owner = THIS_MODULE,
506 ++ .request = gpiochip_generic_request,
507 ++ .free = gpiochip_generic_free,
508 ++ .direction_input = bcm2835_gpio_direction_input,
509 ++ .direction_output = bcm2835_gpio_direction_output,
510 ++ .get_direction = bcm2835_gpio_get_direction,
511 ++ .get = bcm2835_gpio_get,
512 ++ .set = bcm2835_gpio_set,
513 ++ .set_config = gpiochip_generic_config,
514 ++ .base = -1,
515 ++ .ngpio = BCM2711_NUM_GPIOS,
516 ++ .can_sleep = false,
517 ++};
518 ++
519 + static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc,
520 + unsigned int bank, u32 mask)
521 + {
522 +@@ -401,7 +426,7 @@ static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
523 + bcm2835_gpio_irq_handle_bank(pc, 0, 0xf0000000);
524 + bcm2835_gpio_irq_handle_bank(pc, 1, 0x00003fff);
525 + break;
526 +- case 2: /* IRQ2 covers GPIOs 46-53 */
527 ++ case 2: /* IRQ2 covers GPIOs 46-57 */
528 + bcm2835_gpio_irq_handle_bank(pc, 1, 0x003fc000);
529 + break;
530 + }
531 +@@ -409,6 +434,11 @@ static void bcm2835_gpio_irq_handler(struct irq_desc *desc)
532 + chained_irq_exit(host_chip, desc);
533 + }
534 +
535 ++static irqreturn_t bcm2835_gpio_wake_irq_handler(int irq, void *dev_id)
536 ++{
537 ++ return IRQ_HANDLED;
538 ++}
539 ++
540 + static inline void __bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc,
541 + unsigned reg, unsigned offset, bool enable)
542 + {
543 +@@ -608,6 +638,34 @@ static void bcm2835_gpio_irq_ack(struct irq_data *data)
544 + bcm2835_gpio_set_bit(pc, GPEDS0, gpio);
545 + }
546 +
547 ++static int bcm2835_gpio_irq_set_wake(struct irq_data *data, unsigned int on)
548 ++{
549 ++ struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
550 ++ struct bcm2835_pinctrl *pc = gpiochip_get_data(chip);
551 ++ unsigned gpio = irqd_to_hwirq(data);
552 ++ unsigned int irqgroup;
553 ++ int ret = -EINVAL;
554 ++
555 ++ if (!pc->wake_irq)
556 ++ return ret;
557 ++
558 ++ if (gpio <= 27)
559 ++ irqgroup = 0;
560 ++ else if (gpio >= 28 && gpio <= 45)
561 ++ irqgroup = 1;
562 ++ else if (gpio >= 46 && gpio <= 57)
563 ++ irqgroup = 2;
564 ++ else
565 ++ return ret;
566 ++
567 ++ if (on)
568 ++ ret = enable_irq_wake(pc->wake_irq[irqgroup]);
569 ++ else
570 ++ ret = disable_irq_wake(pc->wake_irq[irqgroup]);
571 ++
572 ++ return ret;
573 ++}
574 ++
575 + static struct irq_chip bcm2835_gpio_irq_chip = {
576 + .name = MODULE_NAME,
577 + .irq_enable = bcm2835_gpio_irq_enable,
578 +@@ -616,11 +674,13 @@ static struct irq_chip bcm2835_gpio_irq_chip = {
579 + .irq_ack = bcm2835_gpio_irq_ack,
580 + .irq_mask = bcm2835_gpio_irq_disable,
581 + .irq_unmask = bcm2835_gpio_irq_enable,
582 ++ .irq_set_wake = bcm2835_gpio_irq_set_wake,
583 ++ .flags = IRQCHIP_MASK_ON_SUSPEND,
584 + };
585 +
586 + static int bcm2835_pctl_get_groups_count(struct pinctrl_dev *pctldev)
587 + {
588 +- return ARRAY_SIZE(bcm2835_gpio_groups);
589 ++ return BCM2835_NUM_GPIOS;
590 + }
591 +
592 + static const char *bcm2835_pctl_get_group_name(struct pinctrl_dev *pctldev,
593 +@@ -778,7 +838,7 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
594 + err = of_property_read_u32_index(np, "brcm,pins", i, &pin);
595 + if (err)
596 + goto out;
597 +- if (pin >= ARRAY_SIZE(bcm2835_gpio_pins)) {
598 ++ if (pin >= pc->pctl_desc.npins) {
599 + dev_err(pc->dev, "%pOF: invalid brcm,pins value %d\n",
600 + np, pin);
601 + err = -EINVAL;
602 +@@ -854,7 +914,7 @@ static int bcm2835_pmx_get_function_groups(struct pinctrl_dev *pctldev,
603 + {
604 + /* every pin can do every function */
605 + *groups = bcm2835_gpio_groups;
606 +- *num_groups = ARRAY_SIZE(bcm2835_gpio_groups);
607 ++ *num_groups = BCM2835_NUM_GPIOS;
608 +
609 + return 0;
610 + }
611 +@@ -1054,29 +1114,66 @@ static const struct pinconf_ops bcm2711_pinconf_ops = {
612 + .pin_config_set = bcm2711_pinconf_set,
613 + };
614 +
615 +-static struct pinctrl_desc bcm2835_pinctrl_desc = {
616 ++static const struct pinctrl_desc bcm2835_pinctrl_desc = {
617 + .name = MODULE_NAME,
618 + .pins = bcm2835_gpio_pins,
619 +- .npins = ARRAY_SIZE(bcm2835_gpio_pins),
620 ++ .npins = BCM2835_NUM_GPIOS,
621 + .pctlops = &bcm2835_pctl_ops,
622 + .pmxops = &bcm2835_pmx_ops,
623 + .confops = &bcm2835_pinconf_ops,
624 + .owner = THIS_MODULE,
625 + };
626 +
627 +-static struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = {
628 ++static const struct pinctrl_desc bcm2711_pinctrl_desc = {
629 ++ .name = "pinctrl-bcm2711",
630 ++ .pins = bcm2835_gpio_pins,
631 ++ .npins = BCM2711_NUM_GPIOS,
632 ++ .pctlops = &bcm2835_pctl_ops,
633 ++ .pmxops = &bcm2835_pmx_ops,
634 ++ .confops = &bcm2711_pinconf_ops,
635 ++ .owner = THIS_MODULE,
636 ++};
637 ++
638 ++static const struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range = {
639 + .name = MODULE_NAME,
640 + .npins = BCM2835_NUM_GPIOS,
641 + };
642 +
643 ++static const struct pinctrl_gpio_range bcm2711_pinctrl_gpio_range = {
644 ++ .name = "pinctrl-bcm2711",
645 ++ .npins = BCM2711_NUM_GPIOS,
646 ++};
647 ++
648 ++struct bcm_plat_data {
649 ++ const struct gpio_chip *gpio_chip;
650 ++ const struct pinctrl_desc *pctl_desc;
651 ++ const struct pinctrl_gpio_range *gpio_range;
652 ++};
653 ++
654 ++static const struct bcm_plat_data bcm2835_plat_data = {
655 ++ .gpio_chip = &bcm2835_gpio_chip,
656 ++ .pctl_desc = &bcm2835_pinctrl_desc,
657 ++ .gpio_range = &bcm2835_pinctrl_gpio_range,
658 ++};
659 ++
660 ++static const struct bcm_plat_data bcm2711_plat_data = {
661 ++ .gpio_chip = &bcm2711_gpio_chip,
662 ++ .pctl_desc = &bcm2711_pinctrl_desc,
663 ++ .gpio_range = &bcm2711_pinctrl_gpio_range,
664 ++};
665 ++
666 + static const struct of_device_id bcm2835_pinctrl_match[] = {
667 + {
668 + .compatible = "brcm,bcm2835-gpio",
669 +- .data = &bcm2835_pinconf_ops,
670 ++ .data = &bcm2835_plat_data,
671 + },
672 + {
673 + .compatible = "brcm,bcm2711-gpio",
674 +- .data = &bcm2711_pinconf_ops,
675 ++ .data = &bcm2711_plat_data,
676 ++ },
677 ++ {
678 ++ .compatible = "brcm,bcm7211-gpio",
679 ++ .data = &bcm2711_plat_data,
680 + },
681 + {}
682 + };
683 +@@ -1085,14 +1182,16 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
684 + {
685 + struct device *dev = &pdev->dev;
686 + struct device_node *np = dev->of_node;
687 ++ const struct bcm_plat_data *pdata;
688 + struct bcm2835_pinctrl *pc;
689 + struct gpio_irq_chip *girq;
690 + struct resource iomem;
691 + int err, i;
692 + const struct of_device_id *match;
693 ++ int is_7211 = 0;
694 +
695 +- BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_pins) != BCM2835_NUM_GPIOS);
696 +- BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_groups) != BCM2835_NUM_GPIOS);
697 ++ BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_pins) != BCM2711_NUM_GPIOS);
698 ++ BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_groups) != BCM2711_NUM_GPIOS);
699 +
700 + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
701 + if (!pc)
702 +@@ -1111,7 +1210,14 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
703 + if (IS_ERR(pc->base))
704 + return PTR_ERR(pc->base);
705 +
706 +- pc->gpio_chip = bcm2835_gpio_chip;
707 ++ match = of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node);
708 ++ if (!match)
709 ++ return -EINVAL;
710 ++
711 ++ pdata = match->data;
712 ++ is_7211 = of_device_is_compatible(np, "brcm,bcm7211-gpio");
713 ++
714 ++ pc->gpio_chip = *pdata->gpio_chip;
715 + pc->gpio_chip.parent = dev;
716 + pc->gpio_chip.of_node = np;
717 +
718 +@@ -1135,6 +1241,18 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
719 + raw_spin_lock_init(&pc->irq_lock[i]);
720 + }
721 +
722 ++ pc->pctl_desc = *pdata->pctl_desc;
723 ++ pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc);
724 ++ if (IS_ERR(pc->pctl_dev)) {
725 ++ gpiochip_remove(&pc->gpio_chip);
726 ++ return PTR_ERR(pc->pctl_dev);
727 ++ }
728 ++
729 ++ pc->gpio_range = *pdata->gpio_range;
730 ++ pc->gpio_range.base = pc->gpio_chip.base;
731 ++ pc->gpio_range.gc = &pc->gpio_chip;
732 ++ pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
733 ++
734 + girq = &pc->gpio_chip.irq;
735 + girq->chip = &bcm2835_gpio_irq_chip;
736 + girq->parent_handler = bcm2835_gpio_irq_handler;
737 +@@ -1142,8 +1260,19 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
738 + girq->parents = devm_kcalloc(dev, BCM2835_NUM_IRQS,
739 + sizeof(*girq->parents),
740 + GFP_KERNEL);
741 +- if (!girq->parents)
742 ++ if (!girq->parents) {
743 ++ pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
744 + return -ENOMEM;
745 ++ }
746 ++
747 ++ if (is_7211) {
748 ++ pc->wake_irq = devm_kcalloc(dev, BCM2835_NUM_IRQS,
749 ++ sizeof(*pc->wake_irq),
750 ++ GFP_KERNEL);
751 ++ if (!pc->wake_irq)
752 ++ return -ENOMEM;
753 ++ }
754 ++
755 + /*
756 + * Use the same handler for all groups: this is necessary
757 + * since we use one gpiochip to cover all lines - the
758 +@@ -1151,34 +1280,44 @@ static int bcm2835_pinctrl_probe(struct platform_device *pdev)
759 + * bank that was firing the IRQ and look up the per-group
760 + * and bank data.
761 + */
762 +- for (i = 0; i < BCM2835_NUM_IRQS; i++)
763 ++ for (i = 0; i < BCM2835_NUM_IRQS; i++) {
764 ++ int len;
765 ++ char *name;
766 ++
767 + girq->parents[i] = irq_of_parse_and_map(np, i);
768 ++ if (!is_7211)
769 ++ continue;
770 ++
771 ++ /* Skip over the all banks interrupts */
772 ++ pc->wake_irq[i] = irq_of_parse_and_map(np, i +
773 ++ BCM2835_NUM_IRQS + 1);
774 ++
775 ++ len = strlen(dev_name(pc->dev)) + 16;
776 ++ name = devm_kzalloc(pc->dev, len, GFP_KERNEL);
777 ++ if (!name)
778 ++ return -ENOMEM;
779 ++
780 ++ snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i);
781 ++
782 ++ /* These are optional interrupts */
783 ++ err = devm_request_irq(dev, pc->wake_irq[i],
784 ++ bcm2835_gpio_wake_irq_handler,
785 ++ IRQF_SHARED, name, pc);
786 ++ if (err)
787 ++ dev_warn(dev, "unable to request wake IRQ %d\n",
788 ++ pc->wake_irq[i]);
789 ++ }
790 ++
791 + girq->default_type = IRQ_TYPE_NONE;
792 + girq->handler = handle_level_irq;
793 +
794 + err = gpiochip_add_data(&pc->gpio_chip, pc);
795 + if (err) {
796 + dev_err(dev, "could not add GPIO chip\n");
797 ++ pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range);
798 + return err;
799 + }
800 +
801 +- match = of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node);
802 +- if (match) {
803 +- bcm2835_pinctrl_desc.confops =
804 +- (const struct pinconf_ops *)match->data;
805 +- }
806 +-
807 +- pc->pctl_dev = devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc);
808 +- if (IS_ERR(pc->pctl_dev)) {
809 +- gpiochip_remove(&pc->gpio_chip);
810 +- return PTR_ERR(pc->pctl_dev);
811 +- }
812 +-
813 +- pc->gpio_range = bcm2835_pinctrl_gpio_range;
814 +- pc->gpio_range.base = pc->gpio_chip.base;
815 +- pc->gpio_range.gc = &pc->gpio_chip;
816 +- pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range);
817 +-
818 + return 0;
819 + }
820 +
821 +diff --git a/fs/select.c b/fs/select.c
822 +index e51796063cb6e..7716d9d5be1e8 100644
823 +--- a/fs/select.c
824 ++++ b/fs/select.c
825 +@@ -458,9 +458,11 @@ get_max:
826 + return max;
827 + }
828 +
829 +-#define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | EPOLLHUP | EPOLLERR)
830 +-#define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT | EPOLLERR)
831 +-#define POLLEX_SET (EPOLLPRI)
832 ++#define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | EPOLLHUP | EPOLLERR |\
833 ++ EPOLLNVAL)
834 ++#define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT | EPOLLERR |\
835 ++ EPOLLNVAL)
836 ++#define POLLEX_SET (EPOLLPRI | EPOLLNVAL)
837 +
838 + static inline void wait_key_set(poll_table *wait, unsigned long in,
839 + unsigned long out, unsigned long bit,
840 +@@ -527,6 +529,7 @@ static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time)
841 + break;
842 + if (!(bit & all_bits))
843 + continue;
844 ++ mask = EPOLLNVAL;
845 + f = fdget(i);
846 + if (f.file) {
847 + wait_key_set(wait, in, out, bit,
848 +@@ -534,34 +537,34 @@ static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time)
849 + mask = vfs_poll(f.file, wait);
850 +
851 + fdput(f);
852 +- if ((mask & POLLIN_SET) && (in & bit)) {
853 +- res_in |= bit;
854 +- retval++;
855 +- wait->_qproc = NULL;
856 +- }
857 +- if ((mask & POLLOUT_SET) && (out & bit)) {
858 +- res_out |= bit;
859 +- retval++;
860 +- wait->_qproc = NULL;
861 +- }
862 +- if ((mask & POLLEX_SET) && (ex & bit)) {
863 +- res_ex |= bit;
864 +- retval++;
865 +- wait->_qproc = NULL;
866 +- }
867 +- /* got something, stop busy polling */
868 +- if (retval) {
869 +- can_busy_loop = false;
870 +- busy_flag = 0;
871 +-
872 +- /*
873 +- * only remember a returned
874 +- * POLL_BUSY_LOOP if we asked for it
875 +- */
876 +- } else if (busy_flag & mask)
877 +- can_busy_loop = true;
878 +-
879 + }
880 ++ if ((mask & POLLIN_SET) && (in & bit)) {
881 ++ res_in |= bit;
882 ++ retval++;
883 ++ wait->_qproc = NULL;
884 ++ }
885 ++ if ((mask & POLLOUT_SET) && (out & bit)) {
886 ++ res_out |= bit;
887 ++ retval++;
888 ++ wait->_qproc = NULL;
889 ++ }
890 ++ if ((mask & POLLEX_SET) && (ex & bit)) {
891 ++ res_ex |= bit;
892 ++ retval++;
893 ++ wait->_qproc = NULL;
894 ++ }
895 ++ /* got something, stop busy polling */
896 ++ if (retval) {
897 ++ can_busy_loop = false;
898 ++ busy_flag = 0;
899 ++
900 ++ /*
901 ++ * only remember a returned
902 ++ * POLL_BUSY_LOOP if we asked for it
903 ++ */
904 ++ } else if (busy_flag & mask)
905 ++ can_busy_loop = true;
906 ++
907 + }
908 + if (res_in)
909 + *rinp = res_in;
910 +diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c
911 +index 7777c35e0a171..5797cf2909b00 100644
912 +--- a/kernel/rcu/tree.c
913 ++++ b/kernel/rcu/tree.c
914 +@@ -1358,10 +1358,11 @@ static void __maybe_unused rcu_advance_cbs_nowake(struct rcu_node *rnp,
915 + struct rcu_data *rdp)
916 + {
917 + rcu_lockdep_assert_cblist_protected(rdp);
918 +- if (!rcu_seq_state(rcu_seq_current(&rnp->gp_seq)) ||
919 +- !raw_spin_trylock_rcu_node(rnp))
920 ++ if (!rcu_seq_state(rcu_seq_current(&rnp->gp_seq)) || !raw_spin_trylock_rcu_node(rnp))
921 + return;
922 +- WARN_ON_ONCE(rcu_advance_cbs(rnp, rdp));
923 ++ // The grace period cannot end while we hold the rcu_node lock.
924 ++ if (rcu_seq_state(rcu_seq_current(&rnp->gp_seq)))
925 ++ WARN_ON_ONCE(rcu_advance_cbs(rnp, rdp));
926 + raw_spin_unlock_rcu_node(rnp);
927 + }
928 +