From: Sasha Levin Date: Mon, 11 Dec 2023 04:13:36 +0000 (-0500) Subject: Fixes for 5.15 X-Git-Tag: v6.6.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0304634e4af54fbc562373704238ffa846a14e3;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.15 Signed-off-by: Sasha Levin --- diff --git a/queue-5.15/drm-amd-amdgpu-fix-warnings-in-amdgpu-amdgpu_display.patch b/queue-5.15/drm-amd-amdgpu-fix-warnings-in-amdgpu-amdgpu_display.patch new file mode 100644 index 00000000000..5edf8d2ba74 --- /dev/null +++ b/queue-5.15/drm-amd-amdgpu-fix-warnings-in-amdgpu-amdgpu_display.patch @@ -0,0 +1,180 @@ +From 1cbb792bf183d92dcdffc97e05e9505dbc331698 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 18 Jul 2023 12:28:37 +0530 +Subject: drm/amd/amdgpu: Fix warnings in amdgpu/amdgpu_display.c +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Srinivasan Shanmugam + +[ Upstream commit 93125cb704919f572c01e02ef64923caff1c3164 ] + +Fixes the below checkpatch.pl warnings: + +WARNING: Block comments use * on subsequent lines +WARNING: Block comments use a trailing */ on a separate line +WARNING: suspect code indent for conditional statements (8, 12) +WARNING: braces {} are not necessary for single statement blocks + +Cc: Christian König +Cc: Alex Deucher +Signed-off-by: Srinivasan Shanmugam +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Stable-dep-of: c6df7f313794 ("drm/amdgpu: correct the amdgpu runtime dereference usage count") +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 42 ++++++++++++--------- + 1 file changed, 25 insertions(+), 17 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +index d2286a83e302f..2952f89734487 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +@@ -80,7 +80,7 @@ static void amdgpu_display_flip_work_func(struct work_struct *__work) + + struct drm_crtc *crtc = &amdgpu_crtc->base; + unsigned long flags; +- unsigned i; ++ unsigned int i; + int vpos, hpos; + + if (amdgpu_display_flip_handle_fence(work, &work->excl)) +@@ -159,7 +159,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc, + u64 tiling_flags; + int i, r; + +- work = kzalloc(sizeof *work, GFP_KERNEL); ++ work = kzalloc(sizeof(*work), GFP_KERNEL); + if (work == NULL) + return -ENOMEM; + +@@ -290,13 +290,15 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set, + + adev = drm_to_adev(dev); + /* if we have active crtcs and we don't have a power ref, +- take the current one */ ++ * take the current one ++ */ + if (active && !adev->have_disp_power_ref) { + adev->have_disp_power_ref = true; + return ret; + } + /* if we have no active crtcs, then drop the power ref +- we got before */ ++ * we got before ++ */ + if (!active && adev->have_disp_power_ref) { + pm_runtime_put_autosuspend(dev->dev); + adev->have_disp_power_ref = false; +@@ -465,11 +467,10 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector, + if (amdgpu_connector->router.ddc_valid) + amdgpu_i2c_router_select_ddc_port(amdgpu_connector); + +- if (use_aux) { ++ if (use_aux) + ret = i2c_transfer(&amdgpu_connector->ddc_bus->aux.ddc, msgs, 2); +- } else { ++ else + ret = i2c_transfer(&amdgpu_connector->ddc_bus->adapter, msgs, 2); +- } + + if (ret != 2) + /* Couldn't find an accessible DDC on this connector */ +@@ -478,10 +479,12 @@ bool amdgpu_display_ddc_probe(struct amdgpu_connector *amdgpu_connector, + * EDID header starts with: + * 0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00. + * Only the first 6 bytes must be valid as +- * drm_edid_block_valid() can fix the last 2 bytes */ ++ * drm_edid_block_valid() can fix the last 2 bytes ++ */ + if (drm_edid_header_is_valid(buf) < 6) { + /* Couldn't find an accessible EDID on this +- * connector */ ++ * connector ++ */ + return false; + } + return true; +@@ -1189,8 +1192,10 @@ amdgpu_display_user_framebuffer_create(struct drm_device *dev, + + obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); + if (obj == NULL) { +- drm_dbg_kms(dev, "No GEM object associated to handle 0x%08X, " +- "can't create framebuffer\n", mode_cmd->handles[0]); ++ drm_dbg_kms(dev, ++ "No GEM object associated to handle 0x%08X, can't create framebuffer\n", ++ mode_cmd->handles[0]); ++ + return ERR_PTR(-ENOENT); + } + +@@ -1384,6 +1389,7 @@ bool amdgpu_display_crtc_scaling_mode_fixup(struct drm_crtc *crtc, + } + if (amdgpu_crtc->rmx_type != RMX_OFF) { + fixed20_12 a, b; ++ + a.full = dfixed_const(src_v); + b.full = dfixed_const(dst_v); + amdgpu_crtc->vsc.full = dfixed_div(a, b); +@@ -1403,7 +1409,7 @@ bool amdgpu_display_crtc_scaling_mode_fixup(struct drm_crtc *crtc, + * + * \param dev Device to query. + * \param pipe Crtc to query. +- * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0). ++ * \param flags from caller (DRM_CALLED_FROM_VBLIRQ or 0). + * For driver internal use only also supports these flags: + * + * USE_REAL_VBLANKSTART to use the real start of vblank instead +@@ -1479,8 +1485,8 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev, + + /* Called from driver internal vblank counter query code? */ + if (flags & GET_DISTANCE_TO_VBLANKSTART) { +- /* Caller wants distance from real vbl_start in *hpos */ +- *hpos = *vpos - vbl_start; ++ /* Caller wants distance from real vbl_start in *hpos */ ++ *hpos = *vpos - vbl_start; + } + + /* Fudge vblank to start a few scanlines earlier to handle the +@@ -1502,7 +1508,7 @@ int amdgpu_display_get_crtc_scanoutpos(struct drm_device *dev, + + /* In vblank? */ + if (in_vbl) +- ret |= DRM_SCANOUTPOS_IN_VBLANK; ++ ret |= DRM_SCANOUTPOS_IN_VBLANK; + + /* Called from driver internal vblank counter query code? */ + if (flags & GET_DISTANCE_TO_VBLANKSTART) { +@@ -1593,6 +1599,7 @@ int amdgpu_display_suspend_helper(struct amdgpu_device *adev) + + if (amdgpu_crtc->cursor_bo && !adev->enable_virtual_display) { + struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); ++ + r = amdgpu_bo_reserve(aobj, true); + if (r == 0) { + amdgpu_bo_unpin(aobj); +@@ -1600,9 +1607,9 @@ int amdgpu_display_suspend_helper(struct amdgpu_device *adev) + } + } + +- if (fb == NULL || fb->obj[0] == NULL) { ++ if (!fb || !fb->obj[0]) + continue; +- } ++ + robj = gem_to_amdgpu_bo(fb->obj[0]); + /* don't unpin kernel fb objects */ + if (!amdgpu_fbdev_robj_is_fb(adev, robj)) { +@@ -1630,6 +1637,7 @@ int amdgpu_display_resume_helper(struct amdgpu_device *adev) + + if (amdgpu_crtc->cursor_bo && !adev->enable_virtual_display) { + struct amdgpu_bo *aobj = gem_to_amdgpu_bo(amdgpu_crtc->cursor_bo); ++ + r = amdgpu_bo_reserve(aobj, true); + if (r == 0) { + r = amdgpu_bo_pin(aobj, AMDGPU_GEM_DOMAIN_VRAM); +-- +2.42.0 + diff --git a/queue-5.15/drm-amdgpu-correct-the-amdgpu-runtime-dereference-us.patch b/queue-5.15/drm-amdgpu-correct-the-amdgpu-runtime-dereference-us.patch new file mode 100644 index 00000000000..ebd69abfd2b --- /dev/null +++ b/queue-5.15/drm-amdgpu-correct-the-amdgpu-runtime-dereference-us.patch @@ -0,0 +1,45 @@ +From 6cc584a89cfe01fa658ea5e407757fb3f94b7542 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 8 Nov 2023 14:38:29 +0800 +Subject: drm/amdgpu: correct the amdgpu runtime dereference usage count + +From: Prike Liang + +[ Upstream commit c6df7f313794c3ad41a49b9a7c95da369db607f3 ] + +Fix the amdgpu runpm dereference usage count. + +Signed-off-by: Prike Liang +Reviewed-by: Alex Deucher +Signed-off-by: Alex Deucher +Cc: stable@vger.kernel.org +Signed-off-by: Sasha Levin +--- + drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +index 2952f89734487..11413b3e80c5b 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +@@ -296,14 +296,11 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set, + adev->have_disp_power_ref = true; + return ret; + } +- /* if we have no active crtcs, then drop the power ref +- * we got before ++ /* if we have no active crtcs, then go to ++ * drop the power ref we got before + */ +- if (!active && adev->have_disp_power_ref) { +- pm_runtime_put_autosuspend(dev->dev); ++ if (!active && adev->have_disp_power_ref) + adev->have_disp_power_ref = false; +- } +- + out: + /* drop the power reference we got coming in here */ + pm_runtime_put_autosuspend(dev->dev); +-- +2.42.0 + diff --git a/queue-5.15/gpiolib-sysfs-fix-error-handling-on-failed-export.patch b/queue-5.15/gpiolib-sysfs-fix-error-handling-on-failed-export.patch new file mode 100644 index 00000000000..dde5c9634e5 --- /dev/null +++ b/queue-5.15/gpiolib-sysfs-fix-error-handling-on-failed-export.patch @@ -0,0 +1,61 @@ +From b4917333d274c85c779f5559d381f67eba27be39 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Nov 2023 16:23:07 +0100 +Subject: gpiolib: sysfs: Fix error handling on failed export + +From: Boerge Struempfel + +[ Upstream commit 95dd1e34ff5bbee93a28ff3947eceaf6de811b1a ] + +If gpio_set_transitory() fails, we should free the GPIO again. Most +notably, the flag FLAG_REQUESTED has previously been set in +gpiod_request_commit(), and should be reset on failure. + +To my knowledge, this does not affect any current users, since the +gpio_set_transitory() mainly returns 0 and -ENOTSUPP, which is converted +to 0. However the gpio_set_transitory() function calles the .set_config() +function of the corresponding GPIO chip and there are some GPIO drivers in +which some (unlikely) branches return other values like -EPROBE_DEFER, +and -EINVAL. In these cases, the above mentioned FLAG_REQUESTED would not +be reset, which results in the pin being blocked until the next reboot. + +Fixes: e10f72bf4b3e ("gpio: gpiolib: Generalise state persistence beyond sleep") +Signed-off-by: Boerge Struempfel +Reviewed-by: Andy Shevchenko +Signed-off-by: Bartosz Golaszewski +Signed-off-by: Sasha Levin +--- + drivers/gpio/gpiolib-sysfs.c | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c +index 44c1ad51b3fe9..95bd1a4a08d11 100644 +--- a/drivers/gpio/gpiolib-sysfs.c ++++ b/drivers/gpio/gpiolib-sysfs.c +@@ -480,14 +480,17 @@ static ssize_t export_store(struct class *class, + goto done; + + status = gpiod_set_transitory(desc, false); +- if (!status) { +- status = gpiod_export(desc, true); +- if (status < 0) +- gpiod_free(desc); +- else +- set_bit(FLAG_SYSFS, &desc->flags); ++ if (status) { ++ gpiod_free(desc); ++ goto done; + } + ++ status = gpiod_export(desc, true); ++ if (status < 0) ++ gpiod_free(desc); ++ else ++ set_bit(FLAG_SYSFS, &desc->flags); ++ + done: + if (status) + pr_debug("%s: status %d\n", __func__, status); +-- +2.42.0 + diff --git a/queue-5.15/kbuild-move-to-std-gnu11.patch b/queue-5.15/kbuild-move-to-std-gnu11.patch new file mode 100644 index 00000000000..78c0542e358 --- /dev/null +++ b/queue-5.15/kbuild-move-to-std-gnu11.patch @@ -0,0 +1,157 @@ +From ad2a1dd4c3c6bdf8c928604927415ba7e4016008 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 8 Mar 2022 22:56:14 +0100 +Subject: Kbuild: move to -std=gnu11 + +From: Arnd Bergmann + +[ Upstream commit e8c07082a810fbb9db303a2b66b66b8d7e588b53 ] + +During a patch discussion, Linus brought up the option of changing +the C standard version from gnu89 to gnu99, which allows using variable +declaration inside of a for() loop. While the C99, C11 and later standards +introduce many other features, most of these are already available in +gnu89 as GNU extensions as well. + +An earlier attempt to do this when gcc-5 started defaulting to +-std=gnu11 failed because at the time that caused warnings about +designated initializers with older compilers. Now that gcc-5.1 is +the minimum compiler version used for building kernels, that is no +longer a concern. Similarly, the behavior of 'inline' functions changes +between gnu89 using gnu_inline behavior and gnu11 using standard c99+ +behavior, but this was taken care of by defining 'inline' to include +__attribute__((gnu_inline)) in order to allow building with clang a +while ago. + +Nathan Chancellor reported a new -Wdeclaration-after-statement +warning that appears in a system header on arm, this still needs a +workaround. + +The differences between gnu99, gnu11, gnu1x and gnu17 are fairly +minimal and mainly impact warnings at the -Wpedantic level that the +kernel never enables. Between these, gnu11 is the newest version +that is supported by all supported compiler versions, though it is +only the default on gcc-5, while all other supported versions of +gcc or clang default to gnu1x/gnu17. + +Link: https://lore.kernel.org/lkml/CAHk-=wiyCH7xeHcmiFJ-YgXUy2Jaj7pnkdKpcovt8fYbVFW3TA@mail.gmail.com/ +Link: https://github.com/ClangBuiltLinux/linux/issues/1603 +Suggested-by: Linus Torvalds +Acked-by: Marco Elver +Acked-by: Jani Nikula +Acked-by: David Sterba +Tested-by: Sedat Dilek +Reviewed-by: Alex Shi +Reviewed-by: Nick Desaulniers +Reviewed-by: Miguel Ojeda +Signed-off-by: Arnd Bergmann +Reviewed-by: Nathan Chancellor +Signed-off-by: Masahiro Yamada +Signed-off-by: Sasha Levin +--- + Documentation/process/programming-language.rst | 6 +++--- + .../translations/it_IT/process/programming-language.rst | 4 ++-- + .../translations/zh_CN/process/programming-language.rst | 3 +-- + .../translations/zh_TW/process/programming-language.rst | 3 +-- + Makefile | 4 ++-- + arch/arm64/kernel/vdso32/Makefile | 2 +- + 6 files changed, 10 insertions(+), 12 deletions(-) + +diff --git a/Documentation/process/programming-language.rst b/Documentation/process/programming-language.rst +index ec474a70a02fa..5fc9160ca1fa5 100644 +--- a/Documentation/process/programming-language.rst ++++ b/Documentation/process/programming-language.rst +@@ -5,9 +5,9 @@ Programming Language + + The kernel is written in the C programming language [c-language]_. + More precisely, the kernel is typically compiled with ``gcc`` [gcc]_ +-under ``-std=gnu89`` [gcc-c-dialect-options]_: the GNU dialect of ISO C90 +-(including some C99 features). ``clang`` [clang]_ is also supported, see +-docs on :ref:`Building Linux with Clang/LLVM `. ++under ``-std=gnu11`` [gcc-c-dialect-options]_: the GNU dialect of ISO C11. ++``clang`` [clang]_ is also supported, see docs on ++:ref:`Building Linux with Clang/LLVM `. + + This dialect contains many extensions to the language [gnu-extensions]_, + and many of them are used within the kernel as a matter of course. +diff --git a/Documentation/translations/it_IT/process/programming-language.rst b/Documentation/translations/it_IT/process/programming-language.rst +index 41db2598ce119..c1a9b481a6f99 100644 +--- a/Documentation/translations/it_IT/process/programming-language.rst ++++ b/Documentation/translations/it_IT/process/programming-language.rst +@@ -10,8 +10,8 @@ Linguaggio di programmazione + + Il kernel è scritto nel linguaggio di programmazione C [it-c-language]_. + Più precisamente, il kernel viene compilato con ``gcc`` [it-gcc]_ usando +-l'opzione ``-std=gnu89`` [it-gcc-c-dialect-options]_: il dialetto GNU +-dello standard ISO C90 (con l'aggiunta di alcune funzionalità da C99). ++l'opzione ``-std=gnu11`` [it-gcc-c-dialect-options]_: il dialetto GNU ++dello standard ISO C11. + Linux supporta anche ``clang`` [it-clang]_, leggete la documentazione + :ref:`Building Linux with Clang/LLVM `. + +diff --git a/Documentation/translations/zh_CN/process/programming-language.rst b/Documentation/translations/zh_CN/process/programming-language.rst +index 2a47a1d2ec20f..fabdc338dbfbc 100644 +--- a/Documentation/translations/zh_CN/process/programming-language.rst ++++ b/Documentation/translations/zh_CN/process/programming-language.rst +@@ -9,8 +9,7 @@ + ============ + + 内核是用C语言 :ref:`c-language ` 编写的。更准确地说,内核通常是用 :ref:`gcc ` +-在 ``-std=gnu89`` :ref:`gcc-c-dialect-options ` 下编译的:ISO C90的 GNU 方言( +-包括一些C99特性) ++在 ``-std=gnu11`` :ref:`gcc-c-dialect-options ` 下编译的:ISO C11的 GNU 方言 + + 这种方言包含对语言 :ref:`gnu-extensions ` 的许多扩展,当然,它们许多都在内核中使用。 + +diff --git a/Documentation/translations/zh_TW/process/programming-language.rst b/Documentation/translations/zh_TW/process/programming-language.rst +index 54e3699eadf85..144bdaf81a416 100644 +--- a/Documentation/translations/zh_TW/process/programming-language.rst ++++ b/Documentation/translations/zh_TW/process/programming-language.rst +@@ -12,8 +12,7 @@ + ============ + + 內核是用C語言 :ref:`c-language ` 編寫的。更準確地說,內核通常是用 :ref:`gcc ` +-在 ``-std=gnu89`` :ref:`gcc-c-dialect-options ` 下編譯的:ISO C90的 GNU 方言( +-包括一些C99特性) ++在 ``-std=gnu11`` :ref:`gcc-c-dialect-options ` 下編譯的:ISO C11的 GNU 方言 + + 這種方言包含對語言 :ref:`gnu-extensions ` 的許多擴展,當然,它們許多都在內核中使用。 + +diff --git a/Makefile b/Makefile +index 5976e71522607..fb1517f05c3ff 100644 +--- a/Makefile ++++ b/Makefile +@@ -524,7 +524,7 @@ KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ + -Werror=implicit-function-declaration -Werror=implicit-int \ + -Werror=return-type -Wno-format-security \ +- -std=gnu89 ++ -std=gnu11 + KBUILD_CPPFLAGS := -D__KERNEL__ + KBUILD_AFLAGS_KERNEL := + KBUILD_CFLAGS_KERNEL := +@@ -809,7 +809,7 @@ KBUILD_CFLAGS += $(KBUILD_CFLAGS-y) + + ifdef CONFIG_CC_IS_CLANG + KBUILD_CPPFLAGS += -Qunused-arguments +-# The kernel builds with '-std=gnu89' so use of GNU extensions is acceptable. ++# The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable. + KBUILD_CFLAGS += -Wno-gnu + # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the + # source of a reference will be _MergedGlobals and not on of the whitelisted names. +diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile +index 50cb1ec092ae5..d7f5b140a5d2a 100644 +--- a/arch/arm64/kernel/vdso32/Makefile ++++ b/arch/arm64/kernel/vdso32/Makefile +@@ -77,7 +77,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -Werror-implicit-function-declaration \ + -Wno-format-security \ + -Wdeclaration-after-statement \ +- -std=gnu89 ++ -std=gnu11 + VDSO_CFLAGS += -O2 + # Some useful compiler-dependent flags from top-level Makefile + VDSO_CFLAGS += $(call cc32-option,-Wdeclaration-after-statement,) +-- +2.42.0 + diff --git a/queue-5.15/kbuild-use-wdeclaration-after-statement.patch b/queue-5.15/kbuild-use-wdeclaration-after-statement.patch new file mode 100644 index 00000000000..2086106a2e8 --- /dev/null +++ b/queue-5.15/kbuild-use-wdeclaration-after-statement.patch @@ -0,0 +1,91 @@ +From 49ab1d1dd523ae5f59cdb5ae94d437a25c7f8933 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Tue, 8 Mar 2022 22:56:13 +0100 +Subject: Kbuild: use -Wdeclaration-after-statement +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Mark Rutland + +[ Upstream commit 4d94f910e79a349b00a4f8aab6f3ae87129d8c5a ] + +The kernel is moving from using `-std=gnu89` to `-std=gnu11`, permitting +the use of additional C11 features such as for-loop initial declarations. + +One contentious aspect of C99 is that it permits mixed declarations and +code, and for now at least, it seems preferable to enforce that +declarations must come first. + +These warnings were already enabled in the kernel itself, but not +for KBUILD_USERCFLAGS or the compat VDSO on arch/arm64, which uses +a separate set of CFLAGS. + +This patch fixes an existing violation in modpost.c, which is not +reported because of the missing flag in KBUILD_USERCFLAGS: + +| scripts/mod/modpost.c: In function ‘match’: +| scripts/mod/modpost.c:837:3: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] +| 837 | const char *endp = p + strlen(p) - 1; +| | ^~~~~ + +Signed-off-by: Mark Rutland +[arnd: don't add a duplicate flag to the default set, update changelog] +Signed-off-by: Arnd Bergmann +Reviewed-by: Nathan Chancellor +Reviewed-by: Nick Desaulniers +Tested-by: Sedat Dilek # LLVM/Clang v13.0.0 (x86-64) +Signed-off-by: Masahiro Yamada +Stable-dep-of: e8c07082a810 ("Kbuild: move to -std=gnu11") +Signed-off-by: Sasha Levin +--- + Makefile | 3 ++- + arch/arm64/kernel/vdso32/Makefile | 1 + + scripts/mod/modpost.c | 4 +++- + 3 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/Makefile b/Makefile +index 678e712591f89..5976e71522607 100644 +--- a/Makefile ++++ b/Makefile +@@ -440,7 +440,8 @@ endif + HOSTPKG_CONFIG = pkg-config + + export KBUILD_USERCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \ +- -O2 -fomit-frame-pointer -std=gnu89 ++ -O2 -fomit-frame-pointer -std=gnu89 \ ++ -Wdeclaration-after-statement + export KBUILD_USERLDFLAGS := + + KBUILD_HOSTCFLAGS := $(KBUILD_USERCFLAGS) $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) +diff --git a/arch/arm64/kernel/vdso32/Makefile b/arch/arm64/kernel/vdso32/Makefile +index 83e9399e38368..50cb1ec092ae5 100644 +--- a/arch/arm64/kernel/vdso32/Makefile ++++ b/arch/arm64/kernel/vdso32/Makefile +@@ -76,6 +76,7 @@ VDSO_CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ + -fno-strict-aliasing -fno-common \ + -Werror-implicit-function-declaration \ + -Wno-format-security \ ++ -Wdeclaration-after-statement \ + -std=gnu89 + VDSO_CFLAGS += -O2 + # Some useful compiler-dependent flags from top-level Makefile +diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c +index c6e655e0ed988..945f9ecb34079 100644 +--- a/scripts/mod/modpost.c ++++ b/scripts/mod/modpost.c +@@ -833,8 +833,10 @@ static int match(const char *sym, const char * const pat[]) + { + const char *p; + while (*pat) { ++ const char *endp; ++ + p = *pat++; +- const char *endp = p + strlen(p) - 1; ++ endp = p + strlen(p) - 1; + + /* "*foo*" */ + if (*p == '*' && *endp == '*') { +-- +2.42.0 + diff --git a/queue-5.15/perf-core-add-a-new-read-format-to-get-a-number-of-l.patch b/queue-5.15/perf-core-add-a-new-read-format-to-get-a-number-of-l.patch new file mode 100644 index 00000000000..c39b74fc586 --- /dev/null +++ b/queue-5.15/perf-core-add-a-new-read-format-to-get-a-number-of-l.patch @@ -0,0 +1,194 @@ +From 2c32a52c6d2af30d94e1accf5a73d8f3282f5e59 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 16 Jun 2022 11:06:23 -0700 +Subject: perf/core: Add a new read format to get a number of lost samples + +From: Namhyung Kim + +[ Upstream commit 119a784c81270eb88e573174ed2209225d646656 ] + +Sometimes we want to know an accurate number of samples even if it's +lost. Currenlty PERF_RECORD_LOST is generated for a ring-buffer which +might be shared with other events. So it's hard to know per-event +lost count. + +Add event->lost_samples field and PERF_FORMAT_LOST to retrieve it from +userspace. + +Original-patch-by: Jiri Olsa +Signed-off-by: Namhyung Kim +Signed-off-by: Peter Zijlstra (Intel) +Link: https://lkml.kernel.org/r/20220616180623.1358843-1-namhyung@kernel.org +Stable-dep-of: 382c27f4ed28 ("perf: Fix perf_event_validate_size()") +Signed-off-by: Sasha Levin +--- + include/linux/perf_event.h | 2 ++ + include/uapi/linux/perf_event.h | 5 ++++- + kernel/events/core.c | 21 ++++++++++++++++++--- + kernel/events/ring_buffer.c | 5 ++++- + 4 files changed, 28 insertions(+), 5 deletions(-) + +diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h +index dbf6ba59fbd09..200995c5210ea 100644 +--- a/include/linux/perf_event.h ++++ b/include/linux/perf_event.h +@@ -750,6 +750,8 @@ struct perf_event { + struct pid_namespace *ns; + u64 id; + ++ atomic64_t lost_samples; ++ + u64 (*clock)(void); + perf_overflow_handler_t overflow_handler; + void *overflow_handler_context; +diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h +index a7fb8d2b77096..25bc59231961c 100644 +--- a/include/uapi/linux/perf_event.h ++++ b/include/uapi/linux/perf_event.h +@@ -301,6 +301,7 @@ enum { + * { u64 time_enabled; } && PERF_FORMAT_TOTAL_TIME_ENABLED + * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING + * { u64 id; } && PERF_FORMAT_ID ++ * { u64 lost; } && PERF_FORMAT_LOST + * } && !PERF_FORMAT_GROUP + * + * { u64 nr; +@@ -308,6 +309,7 @@ enum { + * { u64 time_running; } && PERF_FORMAT_TOTAL_TIME_RUNNING + * { u64 value; + * { u64 id; } && PERF_FORMAT_ID ++ * { u64 lost; } && PERF_FORMAT_LOST + * } cntr[nr]; + * } && PERF_FORMAT_GROUP + * }; +@@ -317,8 +319,9 @@ enum perf_event_read_format { + PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1, + PERF_FORMAT_ID = 1U << 2, + PERF_FORMAT_GROUP = 1U << 3, ++ PERF_FORMAT_LOST = 1U << 4, + +- PERF_FORMAT_MAX = 1U << 4, /* non-ABI */ ++ PERF_FORMAT_MAX = 1U << 5, /* non-ABI */ + }; + + #define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */ +diff --git a/kernel/events/core.c b/kernel/events/core.c +index 8e1290340aaf6..c25dc417d79fc 100644 +--- a/kernel/events/core.c ++++ b/kernel/events/core.c +@@ -1914,6 +1914,9 @@ static void __perf_event_read_size(struct perf_event *event, int nr_siblings) + if (event->attr.read_format & PERF_FORMAT_ID) + entry += sizeof(u64); + ++ if (event->attr.read_format & PERF_FORMAT_LOST) ++ entry += sizeof(u64); ++ + if (event->attr.read_format & PERF_FORMAT_GROUP) { + nr += nr_siblings; + size += sizeof(u64); +@@ -5431,11 +5434,15 @@ static int __perf_read_group_add(struct perf_event *leader, + values[n++] += perf_event_count(leader); + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(leader); ++ if (read_format & PERF_FORMAT_LOST) ++ values[n++] = atomic64_read(&leader->lost_samples); + + for_each_sibling_event(sub, leader) { + values[n++] += perf_event_count(sub); + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(sub); ++ if (read_format & PERF_FORMAT_LOST) ++ values[n++] = atomic64_read(&sub->lost_samples); + } + + unlock: +@@ -5489,7 +5496,7 @@ static int perf_read_one(struct perf_event *event, + u64 read_format, char __user *buf) + { + u64 enabled, running; +- u64 values[4]; ++ u64 values[5]; + int n = 0; + + values[n++] = __perf_event_read_value(event, &enabled, &running); +@@ -5499,6 +5506,8 @@ static int perf_read_one(struct perf_event *event, + values[n++] = running; + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(event); ++ if (read_format & PERF_FORMAT_LOST) ++ values[n++] = atomic64_read(&event->lost_samples); + + if (copy_to_user(buf, values, n * sizeof(u64))) + return -EFAULT; +@@ -7059,7 +7068,7 @@ static void perf_output_read_one(struct perf_output_handle *handle, + u64 enabled, u64 running) + { + u64 read_format = event->attr.read_format; +- u64 values[4]; ++ u64 values[5]; + int n = 0; + + values[n++] = perf_event_count(event); +@@ -7073,6 +7082,8 @@ static void perf_output_read_one(struct perf_output_handle *handle, + } + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(event); ++ if (read_format & PERF_FORMAT_LOST) ++ values[n++] = atomic64_read(&event->lost_samples); + + __output_copy(handle, values, n * sizeof(u64)); + } +@@ -7083,7 +7094,7 @@ static void perf_output_read_group(struct perf_output_handle *handle, + { + struct perf_event *leader = event->group_leader, *sub; + u64 read_format = event->attr.read_format; +- u64 values[5]; ++ u64 values[6]; + int n = 0; + + values[n++] = 1 + leader->nr_siblings; +@@ -7101,6 +7112,8 @@ static void perf_output_read_group(struct perf_output_handle *handle, + values[n++] = perf_event_count(leader); + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(leader); ++ if (read_format & PERF_FORMAT_LOST) ++ values[n++] = atomic64_read(&leader->lost_samples); + + __output_copy(handle, values, n * sizeof(u64)); + +@@ -7114,6 +7127,8 @@ static void perf_output_read_group(struct perf_output_handle *handle, + values[n++] = perf_event_count(sub); + if (read_format & PERF_FORMAT_ID) + values[n++] = primary_event_id(sub); ++ if (read_format & PERF_FORMAT_LOST) ++ values[n++] = atomic64_read(&sub->lost_samples); + + __output_copy(handle, values, n * sizeof(u64)); + } +diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c +index 6808873555f0d..45965f13757e4 100644 +--- a/kernel/events/ring_buffer.c ++++ b/kernel/events/ring_buffer.c +@@ -172,8 +172,10 @@ __perf_output_begin(struct perf_output_handle *handle, + goto out; + + if (unlikely(rb->paused)) { +- if (rb->nr_pages) ++ if (rb->nr_pages) { + local_inc(&rb->lost); ++ atomic64_inc(&event->lost_samples); ++ } + goto out; + } + +@@ -254,6 +256,7 @@ __perf_output_begin(struct perf_output_handle *handle, + + fail: + local_inc(&rb->lost); ++ atomic64_inc(&event->lost_samples); + perf_output_put_handle(handle); + out: + rcu_read_unlock(); +-- +2.42.0 + diff --git a/queue-5.15/perf-fix-perf_event_validate_size.patch b/queue-5.15/perf-fix-perf_event_validate_size.patch new file mode 100644 index 00000000000..58d1c7091e9 --- /dev/null +++ b/queue-5.15/perf-fix-perf_event_validate_size.patch @@ -0,0 +1,135 @@ +From 5a73dc1086bf6675d8f24f811a93c1807b98a867 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 29 Nov 2023 15:24:52 +0100 +Subject: perf: Fix perf_event_validate_size() + +From: Peter Zijlstra + +[ Upstream commit 382c27f4ed28f803b1f1473ac2d8db0afc795a1b ] + +Budimir noted that perf_event_validate_size() only checks the size of +the newly added event, even though the sizes of all existing events +can also change due to not all events having the same read_format. + +When we attach the new event, perf_group_attach(), we do re-compute +the size for all events. + +Fixes: a723968c0ed3 ("perf: Fix u16 overflows") +Reported-by: Budimir Markovic +Signed-off-by: Peter Zijlstra (Intel) +Signed-off-by: Sasha Levin +--- + kernel/events/core.c | 61 +++++++++++++++++++++++++++----------------- + 1 file changed, 38 insertions(+), 23 deletions(-) + +diff --git a/kernel/events/core.c b/kernel/events/core.c +index c25dc417d79fc..521d64b355ef2 100644 +--- a/kernel/events/core.c ++++ b/kernel/events/core.c +@@ -1899,31 +1899,34 @@ static inline void perf_event__state_init(struct perf_event *event) + PERF_EVENT_STATE_INACTIVE; + } + +-static void __perf_event_read_size(struct perf_event *event, int nr_siblings) ++static int __perf_event_read_size(u64 read_format, int nr_siblings) + { + int entry = sizeof(u64); /* value */ + int size = 0; + int nr = 1; + +- if (event->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) ++ if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) + size += sizeof(u64); + +- if (event->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) ++ if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) + size += sizeof(u64); + +- if (event->attr.read_format & PERF_FORMAT_ID) ++ if (read_format & PERF_FORMAT_ID) + entry += sizeof(u64); + +- if (event->attr.read_format & PERF_FORMAT_LOST) ++ if (read_format & PERF_FORMAT_LOST) + entry += sizeof(u64); + +- if (event->attr.read_format & PERF_FORMAT_GROUP) { ++ if (read_format & PERF_FORMAT_GROUP) { + nr += nr_siblings; + size += sizeof(u64); + } + +- size += entry * nr; +- event->read_size = size; ++ /* ++ * Since perf_event_validate_size() limits this to 16k and inhibits ++ * adding more siblings, this will never overflow. ++ */ ++ return size + nr * entry; + } + + static void __perf_event_header_size(struct perf_event *event, u64 sample_type) +@@ -1973,8 +1976,9 @@ static void __perf_event_header_size(struct perf_event *event, u64 sample_type) + */ + static void perf_event__header_size(struct perf_event *event) + { +- __perf_event_read_size(event, +- event->group_leader->nr_siblings); ++ event->read_size = ++ __perf_event_read_size(event->attr.read_format, ++ event->group_leader->nr_siblings); + __perf_event_header_size(event, event->attr.sample_type); + } + +@@ -2005,24 +2009,35 @@ static void perf_event__id_header_size(struct perf_event *event) + event->id_header_size = size; + } + ++/* ++ * Check that adding an event to the group does not result in anybody ++ * overflowing the 64k event limit imposed by the output buffer. ++ * ++ * Specifically, check that the read_size for the event does not exceed 16k, ++ * read_size being the one term that grows with groups size. Since read_size ++ * depends on per-event read_format, also (re)check the existing events. ++ * ++ * This leaves 48k for the constant size fields and things like callchains, ++ * branch stacks and register sets. ++ */ + static bool perf_event_validate_size(struct perf_event *event) + { +- /* +- * The values computed here will be over-written when we actually +- * attach the event. +- */ +- __perf_event_read_size(event, event->group_leader->nr_siblings + 1); +- __perf_event_header_size(event, event->attr.sample_type & ~PERF_SAMPLE_READ); +- perf_event__id_header_size(event); ++ struct perf_event *sibling, *group_leader = event->group_leader; + +- /* +- * Sum the lot; should not exceed the 64k limit we have on records. +- * Conservative limit to allow for callchains and other variable fields. +- */ +- if (event->read_size + event->header_size + +- event->id_header_size + sizeof(struct perf_event_header) >= 16*1024) ++ if (__perf_event_read_size(event->attr.read_format, ++ group_leader->nr_siblings + 1) > 16*1024) + return false; + ++ if (__perf_event_read_size(group_leader->attr.read_format, ++ group_leader->nr_siblings + 1) > 16*1024) ++ return false; ++ ++ for_each_sibling_event(sibling, group_leader) { ++ if (__perf_event_read_size(sibling->attr.read_format, ++ group_leader->nr_siblings + 1) > 16*1024) ++ return false; ++ } ++ + return true; + } + +-- +2.42.0 + diff --git a/queue-5.15/series b/queue-5.15/series index 4e517a8235d..e3a4c9fa19e 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -109,3 +109,10 @@ arm64-dts-mediatek-align-thermal-zone-node-names-wit.patch arm64-dts-mediatek-mt8183-move-thermal-zones-to-the-.patch arm64-dts-mediatek-add-missing-space-before.patch arm64-dts-mt8183-kukui-fix-underscores-in-node-names.patch +perf-core-add-a-new-read-format-to-get-a-number-of-l.patch +perf-fix-perf_event_validate_size.patch +gpiolib-sysfs-fix-error-handling-on-failed-export.patch +drm-amd-amdgpu-fix-warnings-in-amdgpu-amdgpu_display.patch +drm-amdgpu-correct-the-amdgpu-runtime-dereference-us.patch +kbuild-use-wdeclaration-after-statement.patch +kbuild-move-to-std-gnu11.patch