6.1.120-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 552/772 serial: amba-pl011: Fix RX stall when DMA is used
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kartik Rajput <[email protected]>
[ Upstream commit 2bcacc1c87acf9a8ebc17de18cb2b3cfeca547cf ]
Function pl011_throttle_rx() calls pl011_stop_rx() to disable RX, which also disables the RX DMA by clearing the RXDMAE bit of the DMACR register. However, to properly unthrottle RX when DMA is used, the function pl011_unthrottle_rx() is expected to set the RXDMAE bit of the DMACR register, which it currently lacks. This causes RX to stall after the throttle API is called.
Set RXDMAE bit in the DMACR register while unthrottling RX if RX DMA is used.
--- drivers/tty/serial/amba-pl011.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/amba-pl011.c +5 -0
@@ -1837,6 +1837,11 @@ static void pl011_unthrottle_rx(struct uart_port *port)pl011_write (uap->im, uap,REG_IMSC ); +if (uap->using_rx_dma) { + uap->dmacr |=UART011_RXDMAE ; +pl011_write (uap->dmacr, uap,REG_DMACR ); + } +uart_port_unlock_irqrestore (&uap->port, flags); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 553/772 usb: dwc3: gadget: Rewrite endpoint allocation flow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
[ Upstream commit b311048c174da893f47fc09439bc1f6fa2a29589 ]
The driver dwc3 deviates from the programming guide in regard to endpoint configuration. It does this command sequence:
DEPSTARTCFG -> DEPXFERCFG -> DEPCFG
Instead of the suggested flow:
DEPSTARTCFG -> DEPCFG -> DEPXFERCFG
The reasons for this deviation were as follow, quoted:
1) The databook says to do %DWC3_DEPCMD_DEPSTARTCFG for every %USB_REQ_SET_CONFIGURATION and %USB_REQ_SET_INTERFACE (8.1.5). This is incorrect in the scenario of multiple interfaces.
2) The databook does not mention doing more %DWC3_DEPCMD_DEPXFERCFG for new endpoint on alt setting (8.1.6).
Regarding 1), DEPSTARTCFG resets the endpoints' resource and can be a problem if used with SET_INTERFACE request of a multiple interface configuration. But we can still satisfy the programming guide requirement by assigning the endpoint resource as part of usb_ep_enable(). We will only reset endpoint resources on controller initialization and SET_CONFIGURATION request.
Regarding 2), the later versions of the programming guide were updated to clarify this flow (see "Alternate Initialization on SetInterface Request" of the programming guide). As long as the platform has enough physical endpoints, we can assign resource to a new endpoint.
The order of the command sequence will not be a problem to most platforms for the current implementation of the dwc3 driver. However, this order is required in different scenarios (such as initialization during controller's hibernation restore). Let's keep the flow consistent and follow the programming guide.
Stable-dep-of: 5d2fb074dea2 ("usb: dwc3: ep0: Don't clear ep0 DWC3_EP_TRANSFER_STARTED")
--- drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/ep0.c | 1 + drivers/usb/dwc3/gadget.c | 89 +++++++++++++++++---------------------- drivers/usb/dwc3/gadget.h | 1 + 4 files changed, 41 insertions(+), 51 deletions(-)
drivers/usb/dwc3/core.h +1 -0
@@ -744,6 +744,7 @@ struct dwc3_ep {#define DWC3_EP_PENDING_CLEAR_STALL BIT(11)#define DWC3_EP_TXFIFO_RESIZED BIT(12)#define DWC3_EP_DELAY_STOP BIT(13) +#define DWC3_EP_RESOURCE_ALLOCATED BIT(14)/* This last one is specific to EP0 */ #define DWC3_EP0_DIR_IN BIT(31)
drivers/usb/dwc3/ep0.c +1 -0
@@ -643,6 +643,7 @@ static int dwc3_ep0_set_config(struct dwc3 *dwc, struct usb_ctrlrequest *ctrl)return -EINVAL ;case USB_STATE_ADDRESS : +dwc3_gadget_start_config (dwc,2 );dwc3_gadget_clear_tx_fifos (dwc); ret =dwc3_ep0_delegate_req (dwc, ctrl);
drivers/usb/dwc3/gadget.c +38 -51
144 lines not on this page · raw message
drivers/usb/dwc3/gadget.h +1 -0
@@ -119,6 +119,7 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,int __dwc3_gadget_ep_set_halt (struct dwc3_ep *dep,int value,int protocol);void dwc3_ep0_send_delayed_status (struct dwc3 *dwc);void dwc3_stop_active_transfer (struct dwc3_ep *dep,bool force,bool interrupt); +int dwc3_gadget_start_config (struct dwc3 *dwc,unsigned int resource_index);/** * dwc3_gadget_ep_get_transfer_index - Gets transfer index from HW
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 554/772 usb: dwc3: ep0: Dont reset resource alloc flag (including ep0)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Grzeschik <[email protected]>
[ Upstream commit 72fca8371f205d654f95b09cd023a71fd5307041 ]
The DWC3_EP_RESOURCE_ALLOCATED flag ensures that the resource of an endpoint is only assigned once. Unless the endpoint is reset, don't clear this flag. Otherwise we may set endpoint resource again, which prevents the driver from initiate transfer after handling a STALL or endpoint halt to the control endpoint.
Commit f2e0eee47038 ("usb: dwc3: ep0: Don't reset resource alloc flag") was fixing the initial issue, but did this only for physical ep1. Since the function dwc3_ep0_stall_and_restart is resetting the flags for both physical endpoints, this also has to be done for ep0.
Stable-dep-of: 5d2fb074dea2 ("usb: dwc3: ep0: Don't clear ep0 DWC3_EP_TRANSFER_STARTED")
--- drivers/usb/dwc3/ep0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/dwc3/ep0.c +2 -1
@@ -229,7 +229,8 @@ void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)/* stall is always issued on EP0 */ dep = dwc->eps[0 ];__dwc3_gadget_ep_set_halt (dep,1 , false); - dep->flags =DWC3_EP_ENABLED ; + dep->flags &=DWC3_EP_RESOURCE_ALLOCATED ; + dep->flags |=DWC3_EP_ENABLED ; dwc->delayed_status = false;if (!list_empty (&dep->pending_list)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 555/772 usb: dwc3: ep0: Dont clear ep0 DWC3_EP_TRANSFER_STARTED
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thinh Nguyen <[email protected]>
[ Upstream commit 5d2fb074dea289c41f5aaf2c3f68286bee370634 ]
The driver cannot issue the End Transfer command to the SETUP transfer. Don't clear DWC3_EP_TRANSFER_STARTED flag to make sure that the driver won't send Start Transfer command again, which can cause no-resource error. For example this can occur if the host issues a reset to the device.
--- drivers/usb/dwc3/ep0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/dwc3/ep0.c +1 -1
@@ -229,7 +229,7 @@ void dwc3_ep0_stall_and_restart(struct dwc3 *dwc)/* stall is always issued on EP0 */ dep = dwc->eps[0 ];__dwc3_gadget_ep_set_halt (dep,1 , false); - dep->flags &=DWC3_EP_RESOURCE_ALLOCATED ; + dep->flags &=DWC3_EP_RESOURCE_ALLOCATED |DWC3_EP_TRANSFER_STARTED ; dep->flags |=DWC3_EP_ENABLED ; dwc->delayed_status = false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 556/772 powerpc/vdso: Skip objtool from running on VDSO files
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sathvika Vasireddy <[email protected]>
[ Upstream commit d0160bd5d389da247fb5affb6a35ea393d22fedb ]
Do not run objtool on VDSO files, by using OBJECT_FILES_NON_STANDARD.
Stable-dep-of: d677ce521334 ("powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang")
--- arch/powerpc/kernel/vdso/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/kernel/vdso/Makefile +2 -0
@@ -102,3 +102,5 @@ quiet_cmd_vdso64ld_and_check = VDSO64L $@ cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check) quiet_cmd_vdso64as = VDSO64A $@ cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $< + +OBJECT_FILES_NON_STANDARD := y
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 557/772 powerpc/vdso: Remove unused -s flag from ASFLAGS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit 024734d132846dcb27f07deb1ec5be64d4cbfae9 ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it warns:
clang-16: error: argument unused during compilation: '-s' [-Werror,-Wunused-command-line-argument]
The compiler's '-s' flag is a linking option (it is passed along to the linker directly), which means it does nothing when the linker is not invoked by the compiler. The kernel builds all .o files with '-c', which stops the compilation pipeline before linking, so '-s' can be safely dropped from ASFLAGS.
Stable-dep-of: d677ce521334 ("powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang")
--- arch/powerpc/kernel/vdso/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/kernel/vdso/Makefile +2 -2
@@ -51,10 +51,10 @@ ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32 -AS32FLAGS := -D__VDSO32__ -s +AS32FLAGS := -D__VDSO32__ CC64FLAGS := -Wl,-soname=linux-vdso64.so.1 -AS64FLAGS := -D__VDSO64__ -s +AS64FLAGS := -D__VDSO64__ targets += vdso32.lds CPPFLAGS_vdso32.lds += -P -C -Upowerpc
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 558/772 powerpc/vdso: Improve linker flags
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit f0a42fbab447ed9f55bbd99751183e71f3a1f6ec ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, there are several warnings in the PowerPC vDSO:
clang-16: error: -Wl,-soname=linux-vdso32.so.1: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-16: error: -Wl,--hash-style=both: 'linker' input unused [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-shared' [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-nostdinc' [-Werror,-Wunused-command-line-argument]
clang-16: error: argument unused during compilation: '-Wa,-maltivec' [-Werror,-Wunused-command-line-argument]
The first group of warnings point out that linker flags were being added to all invocations of $(CC), even though they will only be used during the final vDSO link. Move those flags to ldflags-y.
The second group of warnings are compiler or assembler flags that will be unused during linking. Filter them out from KBUILD_CFLAGS so that they are not used during linking.
Additionally, '-z noexecstack' was added directly to the ld_and_check rule in commit 1d53c0192b15 ("powerpc/vdso: link with -z noexecstack") but now that there is a common ldflags variable, it can be moved there.
Stable-dep-of: d677ce521334 ("powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang")
--- arch/powerpc/kernel/vdso/Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
arch/powerpc/kernel/vdso/Makefile +12 -8
@@ -47,13 +47,17 @@ KCOV_INSTRUMENT := n UBSAN_SANITIZE := n KASAN_SANITIZE := n -ccflags-y := -shared -fno-common -fno-builtin -nostdlib -Wl,--hash-style=both -ccflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) - -CC32FLAGS := -Wl,-soname=linux-vdso32.so.1 -m32 +ccflags-y := -fno-common -fno-builtin +ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack +ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) +# Filter flags that clang will warn are unused for linking +ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS)) + +CC32FLAGS := -m32 +LD32FLAGS := -Wl,-soname=linux-vdso32.so.1 AS32FLAGS := -D__VDSO32__ -CC64FLAGS := -Wl,-soname=linux-vdso64.so.1 +LD64FLAGS := -Wl,-soname=linux-vdso64.so.1 AS64FLAGS := -D__VDSO64__ targets += vdso32.lds
@@ -92,15 +96,15 @@ include/generated/vdso64-offsets.h: $(obj)/vdso64.so.dbg FORCE # actual build commands quiet_cmd_vdso32ld_and_check = VDSO32L $@ - cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check) + cmd_vdso32ld_and_check = $(VDSOCC) $(ldflags-y) $(CC32FLAGS) $(LD32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) quiet_cmd_vdso32as = VDSO32A $@ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< quiet_cmd_vdso32cc = VDSO32C $@ cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< quiet_cmd_vdso64ld_and_check = VDSO64L $@ - cmd_vdso64ld_and_check = $(VDSOCC) $(c_flags) $(CC64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check) + cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check) quiet_cmd_vdso64as = VDSO64A $@ - cmd_vdso64as = $(VDSOCC) $(a_flags) $(CC64FLAGS) $(AS64FLAGS) -c -o $@ $< + cmd_vdso64as = $(VDSOCC) $(a_flags) $(AS64FLAGS) -c -o $@ $< OBJECT_FILES_NON_STANDARD := y
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 559/772 powerpc/vdso: Remove an unsupported flag from vgettimeofday-32.o with clang
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit 05e05bfc92d196669a3d087fc34d3998b6ddb758 ]
When clang's -Qunused-arguments is dropped from KBUILD_CPPFLAGS, it warns:
clang-16: error: argument unused during compilation: '-fno-stack-clash-protection' [-Werror,-Wunused-command-line-argument]
This warning happens because vgettimeofday-32.c gets its base CFLAGS from the main kernel, which may contain flags that are only supported on a 64-bit target but not a 32-bit one, which is the case here. -fstack-clash-protection and its negation are only suppported by the 64-bit powerpc target but that flag is included in an invocation for a 32-bit powerpc target, so clang points out that while the flag is one that it recognizes, it is not actually used by this compiler job.
To eliminate the warning, remove -fno-stack-clash-protection from vgettimeofday-32.c's CFLAGS when using clang, as has been done for other flags previously.
Stable-dep-of: d677ce521334 ("powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang")
--- arch/powerpc/kernel/vdso/Makefile | 5 +++++ 1 file changed, 5 insertions(+)
arch/powerpc/kernel/vdso/Makefile +5 -0
@@ -16,6 +16,11 @@ ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc + # This flag is supported by clang for 64-bit but not 32-bit so it will cause + # an unused command line flag warning for this file. + ifdef CONFIG_CC_IS_CLANG + CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection + endif CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y) CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 560/772 powerpc/vdso: Include CLANG_FLAGS explicitly in ldflags-y
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit a7e5eb53bf9b800d086e2ebcfebd9a3bb16bd1b0 ]
A future change will move CLANG_FLAGS from KBUILD_{A,C}FLAGS to KBUILD_CPPFLAGS so that '--target' is available while preprocessing. When that occurs, the following error appears when building the compat PowerPC vDSO:
clang: error: unsupported option '-mbig-endian' for target 'x86_64-pc-linux-gnu' make[3]: *** [.../arch/powerpc/kernel/vdso/Makefile:76: arch/powerpc/kernel/vdso/vdso32.so.dbg] Error 1
Explicitly add CLANG_FLAGS to ldflags-y, so that '--target' will always be present.
Stable-dep-of: d677ce521334 ("powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang")
--- arch/powerpc/kernel/vdso/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/vdso/Makefile +1 -1
@@ -53,7 +53,7 @@ UBSAN_SANITIZE := n KASAN_SANITIZE := n ccflags-y := -fno-common -fno-builtin -ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack +ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) # Filter flags that clang will warn are unused for linking ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 561/772 powerpc/vdso: Refactor CFLAGS for CVDSO build
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
[ Upstream commit a6b67eb09963af29991625862cbb4f56b85954ed ]
In order to avoid two much duplication when we add new VDSO functionnalities in C like getrandom, refactor common CFLAGS.
Stable-dep-of: d677ce521334 ("powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang")
--- arch/powerpc/kernel/vdso/Makefile | 32 +++++++++++++------------------ 1 file changed, 13 insertions(+), 19 deletions(-)
arch/powerpc/kernel/vdso/Makefile +13 -19
@@ -10,28 +10,11 @@ obj-vdso64 = sigtramp64-64.o gettimeofday-64.o datapage-64.o cacheflush-64.o not ifneq ($(c-gettimeofday-y),) CFLAGS_vgettimeofday-32.o += -include $(c-gettimeofday-y) - CFLAGS_vgettimeofday-32.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) - CFLAGS_vgettimeofday-32.o += $(call cc-option, -fno-stack-protector) - CFLAGS_vgettimeofday-32.o += -DDISABLE_BRANCH_PROFILING - CFLAGS_vgettimeofday-32.o += -ffreestanding -fasynchronous-unwind-tables - CFLAGS_REMOVE_vgettimeofday-32.o = $(CC_FLAGS_FTRACE) - CFLAGS_REMOVE_vgettimeofday-32.o += -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc - # This flag is supported by clang for 64-bit but not 32-bit so it will cause - # an unused command line flag warning for this file. - ifdef CONFIG_CC_IS_CLANG - CFLAGS_REMOVE_vgettimeofday-32.o += -fno-stack-clash-protection - endif - CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y) - CFLAGS_vgettimeofday-64.o += $(DISABLE_LATENT_ENTROPY_PLUGIN) - CFLAGS_vgettimeofday-64.o += $(call cc-option, -fno-stack-protector) - CFLAGS_vgettimeofday-64.o += -DDISABLE_BRANCH_PROFILING - CFLAGS_vgettimeofday-64.o += -ffreestanding -fasynchronous-unwind-tables - CFLAGS_REMOVE_vgettimeofday-64.o = $(CC_FLAGS_FTRACE) # Go prior to 1.16.x assumes r30 is not clobbered by any VDSO code. That used to be true # by accident when the VDSO was hand-written asm code, but may not be now that the VDSO is # compiler generated. To avoid breaking Go tell GCC not to use r30. Impact on code # generation is minimal, it will just use r29 instead. - CFLAGS_vgettimeofday-64.o += $(call cc-option, -ffixed-r30) + CFLAGS_vgettimeofday-64.o += -include $(c-gettimeofday-y) $(call cc-option, -ffixed-r30) endif # Build rules
@@ -53,12 +36,23 @@ UBSAN_SANITIZE := n KASAN_SANITIZE := n ccflags-y := -fno-common -fno-builtin +ccflags-y += $(DISABLE_LATENT_ENTROPY_PLUGIN) +ccflags-y += $(call cc-option, -fno-stack-protector) +ccflags-y += -DDISABLE_BRANCH_PROFILING +ccflags-y += -ffreestanding -fasynchronous-unwind-tables +ccflags-remove-y := $(CC_FLAGS_FTRACE) ldflags-y := -Wl,--hash-style=both -nostdlib -shared -z noexecstack $(CLANG_FLAGS) ldflags-$(CONFIG_LD_IS_LLD) += $(call cc-option,--ld-path=$(LD),-fuse-ld=lld) # Filter flags that clang will warn are unused for linking ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS)) CC32FLAGS := -m32 +CC32FLAGSREMOVE := -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc + # This flag is supported by clang for 64-bit but not 32-bit so it will cause + # an unused command line flag warning for this file. +ifdef CONFIG_CC_IS_CLANG +CC32FLAGSREMOVE += -fno-stack-clash-protection +endif LD32FLAGS := -Wl,-soname=linux-vdso32.so.1 AS32FLAGS := -D__VDSO32__
@@ -105,7 +99,7 @@ quiet_cmd_vdso32ld_and_check = VDSO32L $@ quiet_cmd_vdso32as = VDSO32A $@ cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) $(AS32FLAGS) -c -o $@ $< quiet_cmd_vdso32cc = VDSO32C $@ - cmd_vdso32cc = $(VDSOCC) $(c_flags) $(CC32FLAGS) -c -o $@ $< + cmd_vdso32cc = $(VDSOCC) $(filter-out $(CC32FLAGSREMOVE), $(c_flags)) $(CC32FLAGS) -c -o $@ $< quiet_cmd_vdso64ld_and_check = VDSO64L $@ cmd_vdso64ld_and_check = $(VDSOCC) $(ldflags-y) $(LD64FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 562/772 powerpc/vdso: Drop -mstack-protector-guard flags in 32-bit files with clang
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit d677ce521334d8f1f327cafc8b1b7854b0833158 ]
Under certain conditions, the 64-bit '-mstack-protector-guard' flags may end up in the 32-bit vDSO flags, resulting in build failures due to the structure of clang's argument parsing of the stack protector options, which validates the arguments of the stack protector guard flags unconditionally in the frontend, choking on the 64-bit values when targeting 32-bit:
clang: error: invalid value 'r13' in 'mstack-protector-guard-reg=', expected one of: r2
clang: error: invalid value 'r13' in 'mstack-protector-guard-reg=', expected one of: r2 make[3]: *** [arch/powerpc/kernel/vdso/Makefile:85: arch/powerpc/kernel/vdso/vgettimeofday-32.o] Error 1 make[3]: *** [arch/powerpc/kernel/vdso/Makefile:87: arch/powerpc/kernel/vdso/vgetrandom-32.o] Error 1
Remove these flags by adding them to the CC32FLAGSREMOVE variable, which already handles situations similar to this. Additionally, reformat and align a comment better for the expanding CONFIG_CC_IS_CLANG block.
--- arch/powerpc/kernel/vdso/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/kernel/vdso/Makefile +6 -2
@@ -48,10 +48,14 @@ ldflags-y += $(filter-out $(CC_FLAGS_FTRACE) -Wa$(comma)%, $(KBUILD_CFLAGS)) CC32FLAGS := -m32 CC32FLAGSREMOVE := -mcmodel=medium -mabi=elfv1 -mabi=elfv2 -mcall-aixdesc - # This flag is supported by clang for 64-bit but not 32-bit so it will cause - # an unused command line flag warning for this file. ifdef CONFIG_CC_IS_CLANG +# This flag is supported by clang for 64-bit but not 32-bit so it will cause +# an unused command line flag warning for this file. CC32FLAGSREMOVE += -fno-stack-clash-protection +# -mstack-protector-guard values from the 64-bit build are not valid for the +# 32-bit one. clang validates the values passed to these arguments during +# parsing, even when -fno-stack-protector is passed afterwards. +CC32FLAGSREMOVE += -mstack-protector-guard% endif LD32FLAGS := -Wl,-soname=linux-vdso32.so.1 AS32FLAGS := -D__VDSO32__
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 563/772 ntp: Remove invalid cast in time offset math
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcelo Dalmas <[email protected]>
commit f5807b0606da7ac7c1b74a386b22134ec7702d05 upstream.
Due to an unsigned cast, adjtimex() returns the wrong offest when using ADJ_MICRO and the offset is negative. In this case a small negative offset returns approximately 4.29 seconds (~ 2^32/1000 milliseconds) due to the unsigned cast of the negative offset.
This cast was added when the kernel internal struct timex was changed to use type long long for the time offset value to address the problem of a 64bit/32bit division on 32bit systems.
The correct cast would have been (s32), which is correct as time_offset can only be in the range of [INT_MIN..INT_MAX] because the shift constant used for calculating it is 32. But that's non-obvious.
Remove the cast and use div_s64() to cure the issue.
[ tglx: Fix white space damage, use div_s64() and amend the change log ]
--- kernel/time/ntp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/time/ntp.c +1 -1
@@ -796,7 +796,7 @@ int __do_adjtimex(struct __kernel_timex txc->offset =shift_right (time_offset *NTP_INTERVAL_FREQ ,NTP_SCALE_SHIFT );if (!(time_status &STA_NANO )) - txc->offset = (u32 )txc->offset /NSEC_PER_USEC ; + txc->offset =div_s64 (txc->offset,NSEC_PER_USEC ); } result = time_state;/* mostly `TIME_OK' */
Greg Kroah-Hartman
maintainerPATCH 564/772 driver core: fw_devlink: Improve logs for cycle detection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravana Kannan <[email protected]>
[ Upstream commit 6e7ad1aebb4fc9fed0217dd50ef6e58a53f17d81 ]
The links in a cycle are not all logged in a consistent manner or not logged at all. Make them consistent by adding a "cycle:" string and log all the link in the cycles (even the child ==> parent dependency) so that it's easier to debug cycle detection code. Also, mark the start and end of a cycle so it's easy to tell when multiple cycles are logged back to back.
Stable-dep-of: bac3b10b78e5 ("driver core: fw_devlink: Stop trying to optimize cycle detection logic")
--- drivers/base/core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/base/core.c +9 -2
@@ -137,7 +137,7 @@ static void __fwnode_link_del(struct fwnode_link *link)*/ static void __fwnode_link_cycle (struct fwnode_link *link) { -pr_debug ("%pfwf: Relaxing link with %pfwf\n" , +pr_debug ("%pfwf: cycle: depends on %pfwf\n" , link->consumer, link->supplier); link->flags |=FWLINK_FLAG_CYCLE ; }
@@ -1956,6 +1956,7 @@ static bool __fw_devlink_relax_cycles(struct device *con,/* Termination condition. */ if (sup_dev == con) { +pr_debug ("----- cycle: start -----\n" ); ret = true; goto out; }
@@ -1987,8 +1988,11 @@ static bool __fw_devlink_relax_cycles(struct device *con,else par_dev =fwnode_get_next_parent_dev (sup_handle); -if (par_dev &&__fw_devlink_relax_cycles (con, par_dev->fwnode)) +if (par_dev &&__fw_devlink_relax_cycles (con, par_dev->fwnode)) { +pr_debug ("%pfwf: cycle: child of %pfwf\n" , sup_handle, + par_dev->fwnode); ret = true; + }if (!sup_dev) goto out;
@@ -2004,6 +2008,8 @@ static bool __fw_devlink_relax_cycles(struct device *con,if (__fw_devlink_relax_cycles (con, dev_link->supplier->fwnode)) { +pr_debug ("%pfwf: cycle: depends on %pfwf\n" , sup_handle, + dev_link->supplier->fwnode);fw_devlink_relax_link (dev_link); dev_link->flags |=DL_FLAG_CYCLE ; ret = true;
@@ -2083,6 +2089,7 @@ static int fw_devlink_create_devlink(struct device *con,if (__fw_devlink_relax_cycles (con, sup_handle)) {__fwnode_link_cycle (link); flags =fw_devlink_get_flags (link->flags); +pr_debug ("----- cycle: end -----\n" );dev_info (con,"Fixed dependency cycle(s) with %pfwf\n" , sup_handle); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 565/772 driver core: Add FWLINK_FLAG_IGNORE to completely ignore a fwnode link
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravana Kannan <[email protected]>
[ Upstream commit b7e1241d8f77ed64404a5e4450f43a319310fc91 ]
A fwnode link between specific supplier-consumer fwnodes can be added multiple times for multiple reasons. If that dependency doesn't exist, deleting the fwnode link once doesn't guarantee that it won't get created again.
So, add FWLINK_FLAG_IGNORE flag to mark a fwnode link as one that needs to be completely ignored. Since a fwnode link's flags is an OR of all the flags passed to all the fwnode_link_add() calls to create that specific fwnode link, the FWLINK_FLAG_IGNORE flag is preserved and can be used to mark a fwnode link as on that need to be completely ignored until it is deleted.
Stable-dep-of: bac3b10b78e5 ("driver core: fw_devlink: Stop trying to optimize cycle detection logic")
--- drivers/base/core.c | 9 ++++++++- include/linux/fwnode.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/base/core.c +8 -1
@@ -1082,7 +1082,8 @@ static struct fwnode_handle *fwnode_links_check_suppliers(return NULL ;list_for_each_entry (link, &fwnode->suppliers, c_hook) -if (!(link->flags &FWLINK_FLAG_CYCLE )) +if (!(link->flags & + (FWLINK_FLAG_CYCLE |FWLINK_FLAG_IGNORE )))return link->supplier;return NULL ;
@@ -1973,6 +1974,9 @@ static bool __fw_devlink_relax_cycles(struct device *con, }list_for_each_entry (link, &sup_handle->suppliers, c_hook) { +if (link->flags &FWLINK_FLAG_IGNORE ) +continue ; +if (__fw_devlink_relax_cycles (con, link->supplier)) {__fwnode_link_cycle (link); ret = true;
@@ -2051,6 +2055,9 @@ static int fw_devlink_create_devlink(struct device *con,int ret =0 ;u32 flags; +if (link->flags &FWLINK_FLAG_IGNORE ) +return 0 ; +if (con->fwnode == link->consumer) flags =fw_devlink_get_flags (link->flags);else
include/linux/fwnode.h +2 -0
@@ -51,8 +51,10 @@ struct fwnode_handle {* fwnode link flags * * CYCLE: The fwnode link is part of a cycle. Don't defer probe. +* IGNORE: Completely ignore this link, even during cycle detection. */ #define FWLINK_FLAG_CYCLE BIT(0) +#define FWLINK_FLAG_IGNORE BIT(1)struct fwnode_link {struct fwnode_handle *supplier;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 566/772 driver core: fw_devlink: Stop trying to optimize cycle detection logic
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saravana Kannan <[email protected]>
[ Upstream commit bac3b10b78e54b7da3cede397258f75a2180609b ]
In attempting to optimize fw_devlink runtime, I introduced numerous cycle detection bugs by foregoing cycle detection logic under specific conditions. Each fix has further narrowed the conditions for optimization.
It's time to give up on these optimization attempts and just run the cycle detection logic every time fw_devlink tries to create a device link.
The specific bug report that triggered this fix involved a supplier fwnode that never gets a device created for it. Instead, the supplier fwnode is represented by the device that corresponds to an ancestor fwnode.
In this case, fw_devlink didn't do any cycle detection because the cycle detection logic is only run when a device link is created between the devices that correspond to the actual consumer and supplier fwnodes.
With this change, fw_devlink will run cycle detection logic even when creating SYNC_STATE_ONLY proxy device links from a device that is an ancestor of a consumer fwnode.
--- drivers/base/core.c | 55 ++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 31 deletions(-)
drivers/base/core.c +24 -31
@@ -1933,10 +1933,10 @@ static bool fwnode_ancestor_init_without_drv(struct fwnode_handle *fwnode)* * Return true if one or more cycles were found. Otherwise, return false. */ -static bool __fw_devlink_relax_cycles (struct device *con, +static bool __fw_devlink_relax_cycles (struct fwnode_handle *con_handle,struct fwnode_handle *sup_handle) { -struct device *sup_dev =NULL , *par_dev =NULL ; +struct device *sup_dev =NULL , *par_dev =NULL , *con_dev =NULL ;struct fwnode_link *link;struct device_link *dev_link;bool ret = false;
@@ -1953,22 +1953,22 @@ static bool __fw_devlink_relax_cycles(struct device *con, sup_handle->flags |=FWNODE_FLAG_VISITED ; - sup_dev =get_dev_from_fwnode (sup_handle); -/* Termination condition. */ -if (sup_dev == con) { +if (sup_handle == con_handle) {pr_debug ("----- cycle: start -----\n" ); ret = true; goto out; } + sup_dev =get_dev_from_fwnode (sup_handle); + con_dev =get_dev_from_fwnode (con_handle);/* * If sup_dev is bound to a driver and @con hasn't started binding to a * driver, sup_dev can't be a consumer of @con. So, no need to check * further. */ if (sup_dev && sup_dev->links.status ==DL_DEV_DRIVER_BOUND && - con->links.status ==DL_DEV_NO_DRIVER ) { + con_dev && con_dev->links.status ==DL_DEV_NO_DRIVER ) { ret = false; goto out; }
@@ -1977,7 +1977,7 @@ static bool __fw_devlink_relax_cycles(struct device *con,if (link->flags &FWLINK_FLAG_IGNORE )continue ; -if (__fw_devlink_relax_cycles (con, link->supplier)) { +if (__fw_devlink_relax_cycles (con_handle, link->supplier)) {__fwnode_link_cycle (link); ret = true; }
@@ -1992,7 +1992,7 @@ static bool __fw_devlink_relax_cycles(struct device *con,else par_dev =fwnode_get_next_parent_dev (sup_handle); -if (par_dev &&__fw_devlink_relax_cycles (con, par_dev->fwnode)) { +if (par_dev &&__fw_devlink_relax_cycles (con_handle, par_dev->fwnode)) {pr_debug ("%pfwf: cycle: child of %pfwf\n" , sup_handle, par_dev->fwnode); ret = true;
@@ -2010,7 +2010,7 @@ static bool __fw_devlink_relax_cycles(struct device *con, !(dev_link->flags & DL_FLAG_CYCLE))continue ; -if (__fw_devlink_relax_cycles (con, +if (__fw_devlink_relax_cycles (con_handle, dev_link->supplier->fwnode)) {pr_debug ("%pfwf: cycle: depends on %pfwf\n" , sup_handle, dev_link->supplier->fwnode);
@@ -2058,11 +2058,6 @@ static int fw_devlink_create_devlink(struct device *con,if (link->flags &FWLINK_FLAG_IGNORE )return 0 ; -if (con->fwnode == link->consumer) - flags =fw_devlink_get_flags (link->flags); -else - flags =FW_DEVLINK_FLAGS_PERMISSIVE ; -/* * In some cases, a device P might also be a supplier to its child node * C. However, this would defer the probe of C until the probe of P
@@ -2083,25 +2078,23 @@ static int fw_devlink_create_devlink(struct device *con,return -EINVAL ;/* -* SYNC_STATE_ONLY device links don't block probing and supports cycles. -* So, one might expect that cycle detection isn't necessary for them. -* However, if the device link was marked as SYNC_STATE_ONLY because -* it's part of a cycle, then we still need to do cycle detection. This -* is because the consumer and supplier might be part of multiple cycles -* and we need to detect all those cycles. +* Don't try to optimize by not calling the cycle detection logic under +* certain conditions. There's always some corner case that won't get +* detected. */ -if (!device_link_flag_is_sync_state_only (flags) || - flags &DL_FLAG_CYCLE ) { -device_links_write_lock (); -if (__fw_devlink_relax_cycles (con, sup_handle)) { -__fwnode_link_cycle (link); - flags =fw_devlink_get_flags (link->flags); -pr_debug ("----- cycle: end -----\n" ); -dev_info (con,"Fixed dependency cycle(s) with %pfwf\n" , - sup_handle); - } -device_links_write_unlock (); +device_links_write_lock (); +if (__fw_devlink_relax_cycles (link->consumer, sup_handle)) { +__fwnode_link_cycle (link); +pr_debug ("----- cycle: end -----\n" ); +pr_info ("%pfwf: Fixed dependency cycle(s) with %pfwf\n" , + link->consumer, sup_handle); } +device_links_write_unlock (); + +if (con->fwnode == link->consumer) + flags =fw_devlink_get_flags (link->flags); +else + flags =FW_DEVLINK_FLAGS_PERMISSIVE ;if (sup_handle->flags &FWNODE_FLAG_NOT_DEVICE ) sup_dev =fwnode_get_next_parent_dev (sup_handle);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 567/772 i3c: Make i3c_master_unregister() return void
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 0f74f8b6675cc36d689abb4d9b3d75ab4049b7d7 ]
The function returned zero unconditionally. Switch the return type to void and simplify the callers accordingly.
Stable-dep-of: 25bc99be5fe5 ("i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter")
--- drivers/i3c/master.c | 6 +----- drivers/i3c/master/dw-i3c-master.c | 5 +---- drivers/i3c/master/i3c-master-cdns.c | 5 +---- drivers/i3c/master/mipi-i3c-hci/core.c | 4 +++- drivers/i3c/master/svc-i3c-master.c | 5 +---- include/linux/i3c/master.h | 2 +- 6 files changed, 8 insertions(+), 19 deletions(-)
drivers/i3c/master.c +1 -5
@@ -2696,17 +2696,13 @@ EXPORT_SYMBOL_GPL(i3c_master_register);* @master: master used to send frames on the bus * * Basically undo everything done in i3c_master_register(). -* -* Return: 0 in case of success, a negative error code otherwise. */ -int i3c_master_unregister (struct i3c_master_controller *master) +void i3c_master_unregister (struct i3c_master_controller *master) {i3c_master_i2c_adapter_cleanup (master);i3c_master_unregister_i3c_devs (master);i3c_master_bus_cleanup (master);device_unregister (&master->dev); - -return 0 ; }EXPORT_SYMBOL_GPL (i3c_master_unregister);
drivers/i3c/master/dw-i3c-master.c +1 -4
@@ -1184,11 +1184,8 @@ static int dw_i3c_probe(struct platform_device *pdev)static int dw_i3c_remove (struct platform_device *pdev) {struct dw_i3c_master *master =platform_get_drvdata (pdev); -int ret; - ret =i3c_master_unregister (&master->base); -if (ret) -return ret; +i3c_master_unregister (&master->base);reset_control_assert (master->core_rst);
drivers/i3c/master/i3c-master-cdns.c +1 -4
@@ -1666,11 +1666,8 @@ static int cdns_i3c_master_probe(struct platform_device *pdev)static int cdns_i3c_master_remove (struct platform_device *pdev) {struct cdns_i3c_master *master =platform_get_drvdata (pdev); -int ret; - ret =i3c_master_unregister (&master->base); -if (ret) -return ret; +i3c_master_unregister (&master->base);clk_disable_unprepare (master->sysclk);clk_disable_unprepare (master->pclk);
drivers/i3c/master/mipi-i3c-hci/core.c +3 -1
@@ -769,7 +769,9 @@ static int i3c_hci_remove(struct platform_device *pdev) {struct i3c_hci *hci =platform_get_drvdata (pdev); -return i3c_master_unregister (&hci->master); +i3c_master_unregister (&hci->master); + +return 0 ; }static const __maybe_unused struct of_device_id i3c_hci_of_match[] = {
drivers/i3c/master/svc-i3c-master.c +1 -4
@@ -1651,11 +1651,8 @@ static int svc_i3c_master_probe(struct platform_device *pdev)static int svc_i3c_master_remove (struct platform_device *pdev) {struct svc_i3c_master *master =platform_get_drvdata (pdev); -int ret; - ret =i3c_master_unregister (&master->base); -if (ret) -return ret; +i3c_master_unregister (&master->base);pm_runtime_dont_use_autosuspend (&pdev->dev);pm_runtime_disable (&pdev->dev);
include/linux/i3c/master.h +1 -1
@@ -541,7 +541,7 @@ int i3c_master_register(struct i3c_master_controller *master,struct device *parent, const struct i3c_master_controller_ops *ops, bool secondary); -int i3c_master_unregister (struct i3c_master_controller *master); +void i3c_master_unregister (struct i3c_master_controller *master);/** * i3c_dev_get_master_data() - get master private data attached to an I3C
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 568/772 i3c: master: add enable(disable) hot join in sys entry
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 317bacf960a4879af22d12175f47d284930b3273 ]
Add hotjoin entry in sys file system allow user enable/disable hotjoin feature.
Add (*enable(disable)_hotjoin)() to i3c_master_controller_ops. Add api i3c_master_enable(disable)_hotjoin();
Stable-dep-of: 25bc99be5fe5 ("i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter")
--- drivers/i3c/master.c | 83 ++++++++++++++++++++++++++++++++++++++ include/linux/i3c/master.h | 5 +++ 2 files changed, 88 insertions(+)
drivers/i3c/master.c +83 -0
@@ -514,6 +514,88 @@ static ssize_t i2c_scl_frequency_show(struct device *dev, }static DEVICE_ATTR_RO (i2c_scl_frequency); +static int i3c_set_hotjoin (struct i3c_master_controller *master,bool enable) +{ +int ret; + +if (!master || !master->ops) +return -EINVAL ; + +if (!master->ops->enable_hotjoin || !master->ops->disable_hotjoin) +return -EINVAL ; + +i3c_bus_normaluse_lock (&master->bus); + +if (enable) + ret = master->ops->enable_hotjoin (master); +else + ret = master->ops->disable_hotjoin (master); + + master->hotjoin = enable; + +i3c_bus_normaluse_unlock (&master->bus); + +return ret; +} + +static ssize_t hotjoin_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct i3c_bus *i3cbus =dev_to_i3cbus (dev); +int ret; +bool res; + +if (!i3cbus->cur_master) +return -EINVAL ; + +if (kstrtobool (buf, &res)) +return -EINVAL ; + + ret =i3c_set_hotjoin (i3cbus->cur_master->common.master, res); +if (ret) +return ret; + +return count; +} + +/* +* i3c_master_enable_hotjoin - Enable hotjoin +* @master: I3C master object +* +* Return: a 0 in case of success, an negative error code otherwise. +*/ +int i3c_master_enable_hotjoin (struct i3c_master_controller *master) +{ +return i3c_set_hotjoin (master, true); +} +EXPORT_SYMBOL_GPL (i3c_master_enable_hotjoin); + +/* +* i3c_master_disable_hotjoin - Disable hotjoin +* @master: I3C master object +* +* Return: a 0 in case of success, an negative error code otherwise. +*/ +int i3c_master_disable_hotjoin (struct i3c_master_controller *master) +{ +return i3c_set_hotjoin (master, false); +} +EXPORT_SYMBOL_GPL (i3c_master_disable_hotjoin); + +static ssize_t hotjoin_show (struct device *dev,struct device_attribute *da,char *buf) +{ +struct i3c_bus *i3cbus =dev_to_i3cbus (dev); +ssize_t ret; + +i3c_bus_normaluse_lock (i3cbus); + ret =sysfs_emit (buf,"%d\n" , i3cbus->cur_master->common.master->hotjoin); +i3c_bus_normaluse_unlock (i3cbus); + +return ret; +} + +static DEVICE_ATTR_RW (hotjoin); +static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_mode.attr, &dev_attr_current_master.attr,
@@ -524,6 +606,7 @@ static struct attribute *i3c_masterdev_attrs[] = { &dev_attr_pid.attr, &dev_attr_dynamic_address.attr, &dev_attr_hdrcap.attr, + &dev_attr_hotjoin.attr,NULL , };ATTRIBUTE_GROUPS (i3c_masterdev);
include/linux/i3c/master.h +5 -0
@@ -451,6 +451,8 @@ struct i3c_master_controller_ops {int (*disable_ibi)(struct i3c_dev_desc *dev);void (*recycle_ibi_slot)(struct i3c_dev_desc *dev,struct i3c_ibi_slot *slot); +int (*enable_hotjoin)(struct i3c_master_controller *master); +int (*disable_hotjoin)(struct i3c_master_controller *master); };/**
@@ -486,6 +488,7 @@ struct i3c_master_controller {const struct i3c_master_controller_ops *ops; unsigned int secondary : 1; unsigned int init_done : 1; + unsigned int hotjoin: 1;struct {struct list_head i3c;struct list_head i2c;
@@ -542,6 +545,8 @@ int i3c_master_register(struct i3c_master_controller *master,const struct i3c_master_controller_ops *ops, bool secondary);void i3c_master_unregister (struct i3c_master_controller *master); +int i3c_master_enable_hotjoin (struct i3c_master_controller *master); +int i3c_master_disable_hotjoin (struct i3c_master_controller *master);/** * i3c_dev_get_master_data() - get master private data attached to an I3C
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 569/772 i3c: master: svc: add hot join support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 05b26c31a4859af9e75b7de77458e99358364fe1 ]
Add hot join support for svc master controller. Disable hot join by default.
User can use sysfs entry to enable hot join.
Stable-dep-of: 25bc99be5fe5 ("i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter")
--- drivers/i3c/master/svc-i3c-master.c | 61 +++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 4 deletions(-)
drivers/i3c/master/svc-i3c-master.c +57 -4
@@ -128,6 +128,9 @@/* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16 +#define SVC_I3C_EVENT_IBI BIT(0) +#define SVC_I3C_EVENT_HOTJOIN BIT(1) +struct svc_i3c_cmd {u8 addr;bool rnw;
@@ -171,6 +174,7 @@ struct svc_i3c_xfer {* @ibi.tbq_slot: To be queued IBI slot * @ibi.lock: IBI lock * @lock: Transfer lock, protect between IBI work thread and callbacks from master +* @enabled_events: Bit masks for enable events (IBI, HotJoin). */ struct svc_i3c_master {struct i3c_master_controller base;
@@ -199,6 +203,7 @@ struct svc_i3c_master {spinlock_t lock; } ibi;struct mutex lock; +int enabled_events; };/**
@@ -213,6 +218,11 @@ struct svc_i3c_i2c_dev_data {struct i3c_generic_ibi_pool *ibi_pool; }; +static inline bool is_events_enabled (struct svc_i3c_master *master,u32 mask) +{ +return !!(master->enabled_events & mask); +} +static bool svc_i3c_master_error (struct svc_i3c_master *master) {u32 mstatus, merrwarn;
@@ -432,13 +442,16 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)switch (ibitype) {case SVC_I3C_MSTATUS_IBITYPE_IBI : dev =svc_i3c_master_dev_from_addr (master, ibiaddr); -if (!dev) +if (!dev || !is_events_enabled (master,SVC_I3C_EVENT_IBI ))svc_i3c_master_nack_ibi (master);else svc_i3c_master_handle_ibi (master, dev);break ;case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN : -svc_i3c_master_ack_ibi (master, false); +if (is_events_enabled (master,SVC_I3C_EVENT_HOTJOIN )) +svc_i3c_master_ack_ibi (master, false); +else +svc_i3c_master_nack_ibi (master);break ;case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST :svc_i3c_master_nack_ibi (master);
@@ -475,7 +488,9 @@ static void svc_i3c_master_ibi_work(struct work_struct *work)svc_i3c_master_emit_stop (master);break ;case SVC_I3C_MSTATUS_IBITYPE_HOT_JOIN : -queue_work (master->base.wq, &master->hj_work); +svc_i3c_master_emit_stop (master); +if (is_events_enabled (master,SVC_I3C_EVENT_HOTJOIN )) +queue_work (master->base.wq, &master->hj_work);break ;case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST :default :
@@ -1475,6 +1490,7 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)return ret; } + master->enabled_events |=SVC_I3C_EVENT_IBI ;svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART );return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );
@@ -1486,7 +1502,9 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)struct svc_i3c_master *master =to_svc_i3c_master (m);int ret; -svc_i3c_master_disable_interrupts (master); + master->enabled_events &= ~SVC_I3C_EVENT_IBI ; +if (!master->enabled_events) +svc_i3c_master_disable_interrupts (master); ret =i3c_master_disec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );
@@ -1496,6 +1514,39 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)return ret; } +static int svc_i3c_master_enable_hotjoin (struct i3c_master_controller *m) +{ +struct svc_i3c_master *master =to_svc_i3c_master (m); +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + } + + master->enabled_events |=SVC_I3C_EVENT_HOTJOIN ; + +svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART ); + +return 0 ; +} + +static int svc_i3c_master_disable_hotjoin (struct i3c_master_controller *m) +{ +struct svc_i3c_master *master =to_svc_i3c_master (m); + + master->enabled_events &= ~SVC_I3C_EVENT_HOTJOIN ; + +if (!master->enabled_events) +svc_i3c_master_disable_interrupts (master); + +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return 0 ; +} +static void svc_i3c_master_recycle_ibi_slot (struct i3c_dev_desc *dev,struct i3c_ibi_slot *slot) {
@@ -1522,6 +1573,8 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .recycle_ibi_slot = svc_i3c_master_recycle_ibi_slot, .enable_ibi = svc_i3c_master_enable_ibi, .disable_ibi = svc_i3c_master_disable_ibi, + .enable_hotjoin = svc_i3c_master_enable_hotjoin, + .disable_hotjoin = svc_i3c_master_disable_hotjoin, };static int svc_i3c_master_prepare_clks (struct svc_i3c_master *master)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 570/772 i3c: master: fix kernel-doc check warning
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 34d946b723b53488ab39d8ac540ddf9db255317a ]
Fix warning found by
'scripts/kernel-doc -v -none include/linux/i3c/master.h'
include/linux/i3c/master.h:457: warning: Function parameter or member 'enable_hotjoin' not described in 'i3c_master_controller_ops' include/linux/i3c/master.h:457: warning: Function parameter or member 'disable_hotjoin' not described in 'i3c_master_controller_ops' include/linux/i3c/master.h:499: warning: Function parameter or member 'hotjoin' not described in 'i3c_master_controller'
Stable-dep-of: 25bc99be5fe5 ("i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter")
--- include/linux/i3c/master.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/i3c/master.h +3 -0
@@ -425,6 +425,8 @@ struct i3c_bus {* for a future IBI * This method is mandatory only if ->request_ibi is not * NULL. +* @enable_hotjoin: enable hot join event detect. +* @disable_hotjoin: disable hot join event detect. */ struct i3c_master_controller_ops {int (*bus_init)(struct i3c_master_controller *master);
@@ -466,6 +468,7 @@ struct i3c_master_controller_ops {* @ops: master operations. See &struct i3c_master_controller_ops * @secondary: true if the master is a secondary master * @init_done: true when the bus initialization is done +* @hotjoin: true if the master support hotjoin * @boardinfo.i3c: list of I3C boardinfo objects * @boardinfo.i2c: list of I2C boardinfo objects * @boardinfo: board-level information attached to devices connected on the bus
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 571/772 i3c: master: support to adjust first broadcast address speed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Song <[email protected]>
[ Upstream commit aef79e189ba2b32f78bd35daf2c0b41f3868a321 ]
According to I3C spec 6.2 Timing Specification, the Open Drain High Period of SCL Clock timing for first broadcast address should be adjusted to 200ns at least. I3C device working as i2c device will see the broadcast to close its Spike Filter then change to work at I3C mode. After that I3C open drain SCL high level should be adjusted back.
Stable-dep-of: 25bc99be5fe5 ("i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter")
--- drivers/i3c/master.c | 12 ++++++++++++ include/linux/i3c/master.h | 16 ++++++++++++++++ 2 files changed, 28 insertions(+)
drivers/i3c/master.c +12 -0
@@ -1810,6 +1810,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) goto err_bus_cleanup; } +if (master->ops->set_speed) { + ret = master->ops->set_speed (master,I3C_OPEN_DRAIN_SLOW_SPEED ); +if (ret) + goto err_bus_cleanup; + } +/* * Reset all dynamic address that may have been assigned before * (assigned by the bootloader for example).
@@ -1818,6 +1824,12 @@ static int i3c_master_bus_init(struct i3c_master_controller *master)if (ret && ret !=I3C_ERROR_M2 ) goto err_bus_cleanup; +if (master->ops->set_speed) { + master->ops->set_speed (master,I3C_OPEN_DRAIN_NORMAL_SPEED ); +if (ret) + goto err_bus_cleanup; + } +/* Disable all slave events before starting DAA. */ ret = i3c_master_disec_locked(master, I3C_BROADCAST_ADDR, I3C_CCC_EVENT_SIR | I3C_CCC_EVENT_MR |
include/linux/i3c/master.h +16 -0
@@ -268,6 +268,20 @@ enum i3c_bus_mode { I3C_BUS_MODE_MIXED_SLOW, }; +/** +* enum i3c_open_drain_speed - I3C open-drain speed +* @I3C_OPEN_DRAIN_SLOW_SPEED: Slow open-drain speed for sending the first +* broadcast address. The first broadcast address at this speed +* will be visible to all devices on the I3C bus. I3C devices +* working in I2C mode will turn off their spike filter when +* switching into I3C mode. +* @I3C_OPEN_DRAIN_NORMAL_SPEED: Normal open-drain speed in I3C bus mode. +*/ +enum i3c_open_drain_speed { +I3C_OPEN_DRAIN_SLOW_SPEED , +I3C_OPEN_DRAIN_NORMAL_SPEED , +}; +/** * enum i3c_addr_slot_status - I3C address slot status * @I3C_ADDR_SLOT_FREE: address is free
@@ -427,6 +441,7 @@ struct i3c_bus {* NULL. * @enable_hotjoin: enable hot join event detect. * @disable_hotjoin: disable hot join event detect. +* @set_speed: adjust I3C open drain mode timing. */ struct i3c_master_controller_ops {int (*bus_init)(struct i3c_master_controller *master);
@@ -455,6 +470,7 @@ struct i3c_master_controller_ops { struct i3c_ibi_slot *slot);int (*enable_hotjoin)(struct i3c_master_controller *master);int (*disable_hotjoin)(struct i3c_master_controller *master); +int (*set_speed)(struct i3c_master_controller *master,enum i3c_open_drain_speed speed); };/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 572/772 i3c: master: svc: use slow speed for first broadcast address
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Song <[email protected]>
[ Upstream commit 20ade67bb1645f5ce8f37fa79ddfebbc5b5b24ef ]
I3C controller should support adjusting open drain timing for the first broadcast address to make I3C device working as a i2c device can see slow broadcast address to close its Spike Filter to change working at i3c mode.
Stable-dep-of: 25bc99be5fe5 ("i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter")
--- drivers/i3c/master/svc-i3c-master.c | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
drivers/i3c/master/svc-i3c-master.c +52 -0
@@ -175,6 +175,7 @@ struct svc_i3c_xfer {* @ibi.lock: IBI lock * @lock: Transfer lock, protect between IBI work thread and callbacks from master * @enabled_events: Bit masks for enable events (IBI, HotJoin). +* @mctrl_config: Configuration value in SVC_I3C_MCTRL for setting speed back. */ struct svc_i3c_master {struct i3c_master_controller base;
@@ -204,6 +205,7 @@ struct svc_i3c_master { } ibi;struct mutex lock;int enabled_events; +u32 mctrl_config; };/**
@@ -521,6 +523,54 @@ static irqreturn_t svc_i3c_master_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } +static int svc_i3c_master_set_speed (struct i3c_master_controller *m, +enum i3c_open_drain_speed speed) +{ +struct svc_i3c_master *master =to_svc_i3c_master (m); +struct i3c_bus *bus =i3c_master_get_bus (&master->base); +u32 ppbaud, odbaud, odhpp, mconfig; +unsigned long fclk_rate; +int ret; + + ret =pm_runtime_resume_and_get (master->dev); +if (ret <0 ) { +dev_err (master->dev,"<%s> Cannot get runtime PM.\n" , __func__); +return ret; + } + +switch (speed) { +case I3C_OPEN_DRAIN_SLOW_SPEED : + fclk_rate =clk_get_rate (master->fclk); +if (!fclk_rate) { + ret = -EINVAL ; + goto rpm_out; + } +/* +* Set 50% duty-cycle I2C speed to I3C OPEN-DRAIN mode, so the first +* broadcast address is visible to all I2C/I3C devices on the I3C bus. +* I3C device working as a I2C device will turn off its 50ns Spike +* Filter to change to I3C mode. +*/ + mconfig = master->mctrl_config; + ppbaud =FIELD_GET (GENMASK (11 ,8 ), mconfig); + odhpp =0 ; + odbaud =DIV_ROUND_UP (fclk_rate, bus->scl_rate.i2c * (2 +2 * ppbaud)) -1 ; + mconfig &= ~GENMASK (24 ,16 ); + mconfig |=SVC_I3C_MCONFIG_ODBAUD (odbaud) |SVC_I3C_MCONFIG_ODHPP (odhpp); +writel (mconfig, master->regs +SVC_I3C_MCONFIG ); +break ; +case I3C_OPEN_DRAIN_NORMAL_SPEED : +writel (master->mctrl_config, master->regs +SVC_I3C_MCONFIG ); +break ; + } + +rpm_out: +pm_runtime_mark_last_busy (master->dev); +pm_runtime_put_autosuspend (master->dev); + +return ret; +} +static int svc_i3c_master_bus_init (struct i3c_master_controller *m) {struct svc_i3c_master *master =to_svc_i3c_master (m);
@@ -603,6 +653,7 @@ static int svc_i3c_master_bus_init(struct i3c_master_controller *m)SVC_I3C_MCONFIG_I2CBAUD (i2cbaud);writel (reg, master->regs +SVC_I3C_MCONFIG ); + master->mctrl_config = reg;/* Master core's registration */ ret =i3c_master_get_free_addr (m,0 );if (ret <0 )
@@ -1575,6 +1626,7 @@ static const struct i3c_master_controller_ops svc_i3c_master_ops = { .disable_ibi = svc_i3c_master_disable_ibi, .enable_hotjoin = svc_i3c_master_enable_hotjoin, .disable_hotjoin = svc_i3c_master_disable_hotjoin, + .set_speed = svc_i3c_master_set_speed, };static int svc_i3c_master_prepare_clks (struct svc_i3c_master *master)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 573/772 i3c: master: svc: Modify enabled_events bit 7:0 to act as IBI enable counter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 25bc99be5fe53853053ceeaa328068c49dc1e799 ]
Fix issue where disabling IBI on one device disables the entire IBI interrupt. Modify bit 7:0 of enabled_events to serve as an IBI enable counter, ensuring that the system IBI interrupt is disabled only when all I3C devices have IBI disabled.
--- drivers/i3c/master/svc-i3c-master.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/i3c/master/svc-i3c-master.c +5 -5
@@ -128,8 +128,8 @@/* This parameter depends on the implementation and may be tuned */ #define SVC_I3C_FIFO_SIZE 16 -#define SVC_I3C_EVENT_IBI BIT(0) -#define SVC_I3C_EVENT_HOTJOIN BIT(1) +#define SVC_I3C_EVENT_IBI GENMASK(7, 0) +#define SVC_I3C_EVENT_HOTJOIN BIT(31)struct svc_i3c_cmd {u8 addr;
@@ -204,7 +204,7 @@ struct svc_i3c_master {spinlock_t lock; } ibi;struct mutex lock; -int enabled_events; +u32 enabled_events;u32 mctrl_config; };
@@ -1541,7 +1541,7 @@ static int svc_i3c_master_enable_ibi(struct i3c_dev_desc *dev)return ret; } - master->enabled_events |=SVC_I3C_EVENT_IBI ; + master->enabled_events++;svc_i3c_master_enable_interrupts (master,SVC_I3C_MINT_SLVSTART );return i3c_master_enec_locked (m, dev->info.dyn_addr,I3C_CCC_EVENT_SIR );
@@ -1553,7 +1553,7 @@ static int svc_i3c_master_disable_ibi(struct i3c_dev_desc *dev)struct svc_i3c_master *master =to_svc_i3c_master (m);int ret; - master->enabled_events &= ~SVC_I3C_EVENT_IBI ; + master->enabled_events--;if (!master->enabled_events)svc_i3c_master_disable_interrupts (master);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 574/772 i3c: master: Replace hard code 2 with macro I3C_ADDR_SLOT_STATUS_BITS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 16aed0a6520ba01b7d22c32e193fc1ec674f92d4 ]
Replace the hardcoded value 2, which indicates 2 bits for I3C address status, with the predefined macro I3C_ADDR_SLOT_STATUS_BITS.
Improve maintainability and extensibility of the code.
Stable-dep-of: 851bd21cdb55 ("i3c: master: Fix dynamic address leak when 'assigned-address' is present")
--- drivers/i3c/master.c | 4 ++-- include/linux/i3c/master.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/i3c/master.c +2 -2
@@ -344,7 +344,7 @@ static enum i3c_addr_slot_status i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) {unsigned long status; -int bitpos = addr *2 ; +int bitpos = addr *I3C_ADDR_SLOT_STATUS_BITS ;if (addr >I2C_MAX_ADDR )return I3C_ADDR_SLOT_RSVD ;
@@ -358,7 +358,7 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr)static void i3c_bus_set_addr_slot_status (struct i3c_bus *bus,u16 addr,enum i3c_addr_slot_status status) { -int bitpos = addr *2 ; +int bitpos = addr *I3C_ADDR_SLOT_STATUS_BITS ;unsigned long *ptr;if (addr >I2C_MAX_ADDR )
include/linux/i3c/master.h +3 -1
@@ -304,6 +304,8 @@ enum i3c_addr_slot_status { I3C_ADDR_SLOT_STATUS_MASK = 3, }; +#define I3C_ADDR_SLOT_STATUS_BITS 2 +/** * struct i3c_bus - I3C bus object * @cur_master: I3C master currently driving the bus. Since I3C is multi-master
@@ -345,7 +347,7 @@ enum i3c_addr_slot_status {struct i3c_bus {struct i3c_dev_desc *cur_master;int id; -unsigned long addrslots[((I2C_MAX_ADDR +1 ) *2 ) /BITS_PER_LONG ]; +unsigned long addrslots[((I2C_MAX_ADDR +1 ) *I3C_ADDR_SLOT_STATUS_BITS ) /BITS_PER_LONG ];enum i3c_bus_mode mode;struct {unsigned long i3c;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 575/772 i3c: master: Extend address status bit to 4 and add I3C_ADDR_SLOT_EXT_DESIRED
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 2f552fa280590e61bd3dbe66a7b54b99caa642a4 ]
Extend the address status bit to 4 and introduce the I3C_ADDR_SLOT_EXT_DESIRED macro to indicate that a device prefers a specific address. This is generally set by the 'assigned-address' in the device tree source (dts) file.
┌────┬─────────────┬───┬─────────┬───┐
│S/Sr│ 7'h7E RnW=0 │ACK│ ENTDAA │ T ├────┐
└────┴─────────────┴───┴─────────┴───┘ │
┌─────────────────────────────────────────┘
│ ┌──┬─────────────┬───┬─────────────────┬────────────────┬───┬─────────┐
└─►│Sr│7'h7E RnW=1 │ACK│48bit UID BCR DCR│Assign 7bit Addr│PAR│ ACK/NACK│
└──┴─────────────┴───┴─────────────────┴────────────────┴───┴─────────┘Some master controllers (such as HCI) need to prepare the entire above transaction before sending it out to the I3C bus. This means that a 7-bit dynamic address needs to be allocated before knowing the target device's UID information.
However, some I3C targets may request specific addresses (called as "init_dyn_addr"), which is typically specified by the DT-'s assigned-address property. Lower addresses having higher IBI priority. If it is available, i3c_bus_get_free_addr() preferably return a free address that is not in the list of desired addresses (called as "init_dyn_addr"). This allows the device with the "init_dyn_addr" to switch to its "init_dyn_addr" when it hot-joins the I3C bus. Otherwise, if the "init_dyn_addr" is already in use by another I3C device, the target device will not be able to switch to its desired address.
If the previous step fails, fallback returning one of the remaining unassigned address, regardless of its state in the desired list.
Stable-dep-of: 851bd21cdb55 ("i3c: master: Fix dynamic address leak when 'assigned-address' is present")
--- drivers/i3c/master.c | 65 +++++++++++++++++++++++++++++++------- include/linux/i3c/master.h | 7 ++-- 2 files changed, 59 insertions(+), 13 deletions(-)
drivers/i3c/master.c +54 -11
@@ -341,7 +341,7 @@ struct bus_type i3c_bus_type = { };static enum i3c_addr_slot_status -i3c_bus_get_addr_slot_status (struct i3c_bus *bus,u16 addr) +i3c_bus_get_addr_slot_status_mask (struct i3c_bus *bus,u16 addr,u32 mask) {unsigned long status;int bitpos = addr *I3C_ADDR_SLOT_STATUS_BITS ;
@@ -352,11 +352,17 @@ i3c_bus_get_addr_slot_status(struct i3c_bus *bus, u16 addr) status = bus->addrslots[bitpos /BITS_PER_LONG ]; status >>= bitpos %BITS_PER_LONG ; -return status &I3C_ADDR_SLOT_STATUS_MASK ; +return status & mask; } -static void i3c_bus_set_addr_slot_status (struct i3c_bus *bus,u16 addr, -enum i3c_addr_slot_status status) +static enum i3c_addr_slot_status +i3c_bus_get_addr_slot_status (struct i3c_bus *bus,u16 addr) +{ +return i3c_bus_get_addr_slot_status_mask (bus, addr,I3C_ADDR_SLOT_STATUS_MASK ); +} + +static void i3c_bus_set_addr_slot_status_mask (struct i3c_bus *bus,u16 addr, +enum i3c_addr_slot_status status,u32 mask) {int bitpos = addr *I3C_ADDR_SLOT_STATUS_BITS ;unsigned long *ptr;
@@ -365,9 +371,14 @@ static void i3c_bus_set_addr_slot_status(struct i3c_bus *bus, u16 addr,return ; ptr = bus->addrslots + (bitpos /BITS_PER_LONG ); - *ptr &= ~((unsigned long )I3C_ADDR_SLOT_STATUS_MASK << - (bitpos %BITS_PER_LONG )); - *ptr |= (unsigned long )status << (bitpos %BITS_PER_LONG ); + *ptr &= ~((unsigned long )mask << (bitpos %BITS_PER_LONG )); + *ptr |= ((unsigned long )status & mask) << (bitpos %BITS_PER_LONG ); +} + +static void i3c_bus_set_addr_slot_status (struct i3c_bus *bus,u16 addr, +enum i3c_addr_slot_status status) +{ +i3c_bus_set_addr_slot_status_mask (bus, addr, status,I3C_ADDR_SLOT_STATUS_MASK ); }static bool i3c_bus_dev_addr_is_avail (struct i3c_bus *bus,u8 addr)
@@ -379,13 +390,44 @@ static bool i3c_bus_dev_addr_is_avail(struct i3c_bus *bus, u8 addr)return status ==I3C_ADDR_SLOT_FREE ; } +/* +* ┌────┬─────────────┬───┬─────────┬───┐ +* │S/Sr│ 7'h7E RnW=0 │ACK│ ENTDAA │ T ├────┐ +* └────┴─────────────┴───┴─────────┴───┘ │ +* ┌─────────────────────────────────────────┘ +* │ ┌──┬─────────────┬───┬─────────────────┬────────────────┬───┬─────────┐ +* └─►│Sr│7'h7E RnW=1 │ACK│48bit UID BCR DCR│Assign 7bit Addr│PAR│ ACK/NACK│ +* └──┴─────────────┴───┴─────────────────┴────────────────┴───┴─────────┘ +* Some master controllers (such as HCI) need to prepare the entire above transaction before +* sending it out to the I3C bus. This means that a 7-bit dynamic address needs to be allocated +* before knowing the target device's UID information. +* +* However, some I3C targets may request specific addresses (called as "init_dyn_addr"), which is +* typically specified by the DT-'s assigned-address property. Lower addresses having higher IBI +* priority. If it is available, i3c_bus_get_free_addr() preferably return a free address that is +* not in the list of desired addresses (called as "init_dyn_addr"). This allows the device with +* the "init_dyn_addr" to switch to its "init_dyn_addr" when it hot-joins the I3C bus. Otherwise, +* if the "init_dyn_addr" is already in use by another I3C device, the target device will not be +* able to switch to its desired address. +* +* If the previous step fails, fallback returning one of the remaining unassigned address, +* regardless of its state in the desired list. +*/ static int i3c_bus_get_free_addr (struct i3c_bus *bus,u8 start_addr) {enum i3c_addr_slot_status status;u8 addr;for (addr = start_addr; addr <I3C_MAX_ADDR ; addr++) { - status =i3c_bus_get_addr_slot_status (bus, addr); + status =i3c_bus_get_addr_slot_status_mask (bus, addr, +I3C_ADDR_SLOT_EXT_STATUS_MASK ); +if (status ==I3C_ADDR_SLOT_FREE ) +return addr; + } + +for (addr = start_addr; addr <I3C_MAX_ADDR ; addr++) { + status =i3c_bus_get_addr_slot_status_mask (bus, addr, +I3C_ADDR_SLOT_STATUS_MASK );if (status ==I3C_ADDR_SLOT_FREE )return addr; }
@@ -1860,9 +1902,10 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) goto err_rstdaa; } -i3c_bus_set_addr_slot_status (&master->bus, - i3cboardinfo->init_dyn_addr, -I3C_ADDR_SLOT_I3C_DEV ); +i3c_bus_set_addr_slot_status_mask (&master->bus, + i3cboardinfo->init_dyn_addr, +I3C_ADDR_SLOT_I3C_DEV |I3C_ADDR_SLOT_EXT_DESIRED , +I3C_ADDR_SLOT_EXT_STATUS_MASK );/* * Only try to create/attach devices that have a static
include/linux/i3c/master.h +5 -2
@@ -289,7 +289,8 @@ enum i3c_open_drain_speed {* @I3C_ADDR_SLOT_I2C_DEV: address is assigned to an I2C device * @I3C_ADDR_SLOT_I3C_DEV: address is assigned to an I3C device * @I3C_ADDR_SLOT_STATUS_MASK: address slot mask -* +* @I3C_ADDR_SLOT_EXT_DESIRED: the bitmask represents addresses that are preferred by some devices, +* such as the "assigned-address" property in a device tree source. * On an I3C bus, addresses are assigned dynamically, and we need to know which * addresses are free to use and which ones are already assigned. *
@@ -302,9 +303,11 @@ enum i3c_addr_slot_status {I3C_ADDR_SLOT_I2C_DEV ,I3C_ADDR_SLOT_I3C_DEV ,I3C_ADDR_SLOT_STATUS_MASK =3 , +I3C_ADDR_SLOT_EXT_STATUS_MASK =7 , + I3C_ADDR_SLOT_EXT_DESIRED = BIT(2), }; -#define I3C_ADDR_SLOT_STATUS_BITS 2 +#define I3C_ADDR_SLOT_STATUS_BITS 4/** * struct i3c_bus - I3C bus object
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 576/772 i3c: master: Fix dynamic address leak when assigned-address is present
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit 851bd21cdb55e727ab29280bc9f6b678164f802a ]
If the DTS contains 'assigned-address', a dynamic address leak occurs during hotjoin events.
Assume a device have assigned-address 0xb.
- Device issue Hotjoin
- Call i3c_master_do_daa()
- Call driver xxx_do_daa()
- Call i3c_master_get_free_addr() to get dynamic address 0x9
- i3c_master_add_i3c_dev_locked(0x9)
- expected_dyn_addr = newdev->boardinfo->init_dyn_addr (0xb);
- i3c_master_reattach_i3c_dev(newdev(0xb), old_dyn_addr(0x9));
- if (dev->info.dyn_addr != old_dyn_addr &&
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0xb != 0x9 -> TRUE
(!dev->boardinfo ||
^^^^^^^^^^^^^^^ -> FALSE
dev->info.dyn_addr != dev->boardinfo->init_dyn_addr)) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
0xb != 0xb -> FALSE
...
i3c_bus_set_addr_slot_status(&master->bus, old_dyn_addr,
I3C_ADDR_SLOT_FREE);
^^^
This will be skipped. So old_dyn_addr never free
} - i3c_master_get_free_addr() will return increased sequence number.
Remove dev->info.dyn_addr != dev->boardinfo->init_dyn_addr condition check. dev->info.dyn_addr should be checked before calling this function because i3c_master_setnewda_locked() has already been called and the target device has already accepted dyn_addr. It is too late to check if dyn_addr is free in i3c_master_reattach_i3c_dev().
Add check to ensure expected_dyn_addr is free before i3c_master_setnewda_locked().
--- drivers/i3c/master.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/i3c/master.c +5 -10
@@ -1491,16 +1491,9 @@ static int i3c_master_reattach_i3c_dev(struct i3c_dev_desc *dev, u8 old_dyn_addr) {struct i3c_master_controller *master =i3c_dev_get_master (dev); -enum i3c_addr_slot_status status;int ret; -if (dev->info.dyn_addr != old_dyn_addr && - (!dev->boardinfo || - dev->info.dyn_addr != dev->boardinfo->init_dyn_addr)) { - status =i3c_bus_get_addr_slot_status (&master->bus, - dev->info.dyn_addr); -if (status !=I3C_ADDR_SLOT_FREE ) -return -EBUSY ; +if (dev->info.dyn_addr != old_dyn_addr) {i3c_bus_set_addr_slot_status (&master->bus, dev->info.dyn_addr,I3C_ADDR_SLOT_I3C_DEV );
@@ -1902,9 +1895,10 @@ static int i3c_master_bus_init(struct i3c_master_controller *master) goto err_rstdaa; } +/* Do not mark as occupied until real device exist in bus */ i3c_bus_set_addr_slot_status_mask (&master->bus, i3cboardinfo->init_dyn_addr, -I3C_ADDR_SLOT_I3C_DEV |I3C_ADDR_SLOT_EXT_DESIRED , +I3C_ADDR_SLOT_EXT_DESIRED ,I3C_ADDR_SLOT_EXT_STATUS_MASK );/*
@@ -2068,7 +2062,8 @@ int i3c_master_add_i3c_dev_locked(struct i3c_master_controller *master,else expected_dyn_addr = newdev->info.dyn_addr; -if (newdev->info.dyn_addr != expected_dyn_addr) { +if (newdev->info.dyn_addr != expected_dyn_addr && +i3c_bus_get_addr_slot_status (&master->bus, expected_dyn_addr) ==I3C_ADDR_SLOT_FREE ) {/* * Try to apply the expected dynamic address. If it fails, keep * the address assigned by the master.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 577/772 PCI: endpoint: Use a separate lock for protecting epc->pci_epf list
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit d6dd5bafaabf98a99a76227ab8dc9a89e76a198f ]
The EPC controller maintains a list of EPF drivers added to it. For protecting this list against the concurrent accesses, the epc->lock (used for protecting epc_ops) has been used so far. Since there were no users trying to use epc_ops and modify the pci_epf list simultaneously, this was not an issue.
But with the addition of callback mechanism for passing the events, this will be a problem. Because the pci_epf list needs to be iterated first for getting hold of the EPF driver and then the relevant event specific callback needs to be called for the driver.
If the same epc->lock is used, then it will result in a deadlock scenario.
For instance,
...
mutex_lock(&epc->lock);
list_for_each_entry(epf, &epc->pci_epf, list) {
epf->event_ops->core_init(epf);
|
|-> pci_epc_set_bar();
|
|-> mutex_lock(&epc->lock) # DEADLOCK...
So to fix this issue, use a separate lock called "list_lock" for protecting the pci_epf list against the concurrent accesses. This lock will also be used by the callback mechanism.
Stable-dep-of: 688d2eb4c6fc ("PCI: endpoint: Clear secondary (not primary) EPC in pci_epc_remove_epf()")
--- drivers/pci/endpoint/pci-epc-core.c | 9 +++++---- include/linux/pci-epc.h | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/pci/endpoint/pci-epc-core.c +5 -4
@@ -613,7 +613,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,if (type ==SECONDARY_INTERFACE && epf->sec_epc)return -EBUSY ; -mutex_lock (&epc->lock); +mutex_lock (&epc->list_lock); func_no =find_first_zero_bit (&epc->function_num_map,BITS_PER_LONG );if (func_no >=BITS_PER_LONG ) {
@@ -640,7 +640,7 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf,list_add_tail (list, &epc->pci_epf); ret: -mutex_unlock (&epc->lock); +mutex_unlock (&epc->list_lock);return ret; }
@@ -672,11 +672,11 @@ void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf, list = &epf->sec_epc_list; } -mutex_lock (&epc->lock); +mutex_lock (&epc->list_lock);clear_bit (func_no, &epc->function_num_map);list_del (list); epf->epc =NULL ; -mutex_unlock (&epc->lock); +mutex_unlock (&epc->list_lock); }EXPORT_SYMBOL_GPL (pci_epc_remove_epf);
@@ -773,6 +773,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, }mutex_init (&epc->lock); +mutex_init (&epc->list_lock);INIT_LIST_HEAD (&epc->pci_epf);ATOMIC_INIT_NOTIFIER_HEAD (&epc->notifier);
include/linux/pci-epc.h +2 -0
@@ -122,6 +122,7 @@ struct pci_epc_mem {* struct pci_epc - represents the PCI EPC device * @dev: PCI EPC device * @pci_epf: list of endpoint functions present in this EPC device +* list_lock: Mutex for protecting pci_epf list * @ops: function pointers for performing endpoint operations * @windows: array of address space of the endpoint controller * @mem: first window of the endpoint controller, which corresponds to
@@ -139,6 +140,7 @@ struct pci_epc_mem {struct pci_epc {struct device dev;struct list_head pci_epf; +struct mutex list_lock;const struct pci_epc_ops *ops;struct pci_epc_mem **windows;struct pci_epc_mem *mem;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 578/772 PCI: endpoint: Clear secondary (not primary) EPC in pci_epc_remove_epf()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 688d2eb4c6fcfdcdaed0592f9df9196573ff5ce2 ]
In addition to a primary endpoint controller, an endpoint function may be associated with a secondary endpoint controller, epf->sec_epc, to provide NTB (non-transparent bridge) functionality.
Previously, pci_epc_remove_epf() incorrectly cleared epf->epc instead of epf->sec_epc when removing from the secondary endpoint controller.
Extend the epc->list_lock coverage and clear either epf->epc or epf->sec_epc as indicated.
--- drivers/pci/endpoint/pci-epc-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/endpoint/pci-epc-core.c +3 -3
@@ -664,18 +664,18 @@ void pci_epc_remove_epf(struct pci_epc *epc, struct pci_epf *epf,if (!epc ||IS_ERR (epc) || !epf)return ; +mutex_lock (&epc->list_lock);if (type ==PRIMARY_INTERFACE ) { func_no = epf->func_no; list = &epf->list; + epf->epc =NULL ; }else { func_no = epf->sec_epc_func_no; list = &epf->sec_epc_list; + epf->sec_epc =NULL ; } - -mutex_lock (&epc->list_lock);clear_bit (func_no, &epc->function_num_map);list_del (list); - epf->epc =NULL ;mutex_unlock (&epc->list_lock); }EXPORT_SYMBOL_GPL (pci_epc_remove_epf);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 579/772 device property: Constify device child node APIs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 7952cd2b8213f20a1752634c25dfd215da537722 ]
The device parameter is not altered in the device child node APIs, constify them.
Stable-dep-of: 73b03b27736e ("leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths")
--- drivers/base/property.c | 6 +++--- include/linux/property.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/base/property.c +3 -3
@@ -790,7 +790,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node);* fwnode pointer. Note that this function also puts a reference to @child * unconditionally. */ -struct fwnode_handle *device_get_next_child_node (struct device *dev, +struct fwnode_handle *device_get_next_child_node (const struct device *dev,struct fwnode_handle *child) {const struct fwnode_handle *fwnode =dev_fwnode (dev);
@@ -833,7 +833,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_named_child_node);* The caller is responsible for calling fwnode_handle_put() on the returned * fwnode pointer. */ -struct fwnode_handle *device_get_named_child_node (struct device *dev, +struct fwnode_handle *device_get_named_child_node (const struct device *dev,const char *childname) {return fwnode_get_named_child_node (dev_fwnode (dev), childname);
@@ -899,7 +899,7 @@ EXPORT_SYMBOL_GPL(fwnode_device_is_available);* * Return: the number of child nodes for a given device. */ -unsigned int device_get_child_node_count (struct device *dev) +unsigned int device_get_child_node_count (const struct device *dev) {struct fwnode_handle *child;unsigned int count =0 ;
include/linux/property.h +6 -6
@@ -114,16 +114,16 @@ struct fwnode_handle *fwnode_get_next_available_child_node(for (child =fwnode_get_next_available_child_node (fwnode,NULL ); child;\ child =fwnode_get_next_available_child_node (fwnode, child)) -struct fwnode_handle *device_get_next_child_node( -struct device *dev,struct fwnode_handle *child); +struct fwnode_handle *device_get_next_child_node(const struct device *dev, +struct fwnode_handle *child);#define device_for_each_child_node (dev, child) \ for (child = device_get_next_child_node(dev, NULL); child; \ child = device_get_next_child_node(dev, child)) -struct fwnode_handle *fwnode_get_named_child_node ( -const struct fwnode_handle *fwnode,const char *childname); -struct fwnode_handle *device_get_named_child_node (struct device *dev, +struct fwnode_handle *fwnode_get_named_child_node (const struct fwnode_handle *fwnode, +const char *childname); +struct fwnode_handle *device_get_named_child_node (const struct device *dev,const char *childname);struct fwnode_handle *fwnode_handle_get (struct fwnode_handle *fwnode);
@@ -132,7 +132,7 @@ void fwnode_handle_put(struct fwnode_handle *fwnode);int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index);int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name); -unsigned int device_get_child_node_count (struct device *dev); +unsigned int device_get_child_node_count (const struct device *dev);static inline bool device_property_read_bool (struct device *dev,const char *propname)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 580/772 device property: Add cleanup.h based fwnode_handle_put() scope based cleanup.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 59ed5e2d505bf5f9b4af64d0021cd0c96aec1f7c ]
Useful where the fwnode_handle was obtained from a call such as fwnode_find_reference() as it will safely do nothing if IS_ERR() is true and will automatically release the reference on the variable leaving scope.
Stable-dep-of: 73b03b27736e ("leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths")
--- include/linux/property.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/property.h +3 -0
@@ -11,6 +11,7 @@#define _LINUX_PROPERTY_H_#include <linux/bits.h> +#include <linux/cleanup.h> #include <linux/fwnode.h> #include <linux/types.h>
@@ -129,6 +130,8 @@ struct fwnode_handle *device_get_named_child_node(const struct device *dev,struct fwnode_handle *fwnode_handle_get (struct fwnode_handle *fwnode);void fwnode_handle_put (struct fwnode_handle *fwnode); +DEFINE_FREE(fwnode_handle, struct fwnode_handle *, fwnode_handle_put(_T)) +int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index);int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 581/772 device property: Introduce device_for_each_child_node_scoped()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan Cameron <[email protected]>
[ Upstream commit 365130fd47af6d4317aa16a407874b699ab8d8cb ]
Similar to recently propose for_each_child_of_node_scoped() this new version of the loop macro instantiates a new local struct fwnode_handle * that uses the __free(fwnode_handle) auto cleanup handling so that if a reference to a node is held on early exit from the loop the reference will be released. If the loop runs to completion, the child pointer will be NULL and no action will be taken.
The reason this is useful is that it removes the need for fwnode_handle_put() on early loop exits. If there is a need to retain the reference, then return_ptr(child) or no_free_ptr(child) may be used to safely disable the auto cleanup.
Stable-dep-of: 73b03b27736e ("leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths")
--- include/linux/property.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/property.h +5 -0
@@ -122,6 +122,11 @@ struct fwnode_handle *device_get_next_child_node(const struct device *dev,for (child =device_get_next_child_node (dev,NULL ); child; \ child = device_get_next_child_node(dev, child)) +#define device_for_each_child_node_scoped (dev, child) \ + for (struct fwnode_handle *child __free(fwnode_handle) = \ + device_get_next_child_node(dev, NULL); \ + child; child = device_get_next_child_node(dev, child)) +struct fwnode_handle *fwnode_get_named_child_node (const struct fwnode_handle *fwnode,const char *childname); struct fwnode_handle *device_get_named_child_node(const struct device *dev,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 582/772 leds: flash: mt6360: Fix device_for_each_child_node() refcounting in error paths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
[ Upstream commit 73b03b27736e440e3009fe1319cbc82d2cd1290c ]
The device_for_each_child_node() macro requires explicit calls to fwnode_handle_put() upon early exits to avoid memory leaks, and in this case the error paths are handled after jumping to 'out_flash_realease', which misses that required call to to decrement the refcount of the child node.
A more elegant and robust solution is using the scoped variant of the loop, which automatically handles such early exits.
Fix the child node refcounting in the error paths by using device_for_each_child_node_scoped().
--- drivers/leds/flash/leds-mt6360.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/leds/flash/leds-mt6360.c +1 -2
@@ -797,7 +797,6 @@ static void mt6360_v4l2_flash_release(struct mt6360_priv *priv)static int mt6360_led_probe (struct platform_device *pdev) {struct mt6360_priv *priv; -struct fwnode_handle *child;size_t count;int i =0 , ret;
@@ -824,7 +823,7 @@ static int mt6360_led_probe(struct platform_device *pdev)return -ENODEV ; } -device_for_each_child_node (&pdev->dev, child) { +device_for_each_child_node_scoped (&pdev->dev, child) {struct mt6360_led *led = priv->leds + i;struct led_init_data init_data = { .fwnode = child, };u32 reg, led_color;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 583/772 drm/bridge: it6505: update usleep_range for RC circuit charge time
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuro Chung <[email protected]>
[ Upstream commit 8814444e62b8a8b573fba2cbbb327d5817b74eb0 ]
The spec of timing between IVDD/OVDD and SYSRTEN is 10ms, but SYSRSTN RC circuit need at least 25ms for rising time, update for match spec
Stable-dep-of: c5f3f21728b0 ("drm/bridge: it6505: Fix inverted reset polarity")
--- drivers/gpu/drm/bridge/ite-it6505.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/ite-it6505.c +1 -1
@@ -2563,7 +2563,7 @@ static int it6505_poweron(struct it6505 *it6505)gpiod_set_value_cansleep (pdata->gpiod_reset,0 );usleep_range (1000 ,2000 );gpiod_set_value_cansleep (pdata->gpiod_reset,1 ); -usleep_range (10000 ,20000 ); +usleep_range (25000 ,35000 ); } it6505->powered = true;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 584/772 drm/bridge: it6505: Fix inverted reset polarity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit c5f3f21728b069412e8072b8b1d0a3d9d3ab0265 ]
The IT6505 bridge chip has a active low reset line. Since it is a "reset" and not an "enable" line, the GPIO should be asserted to put it in reset and deasserted to bring it out of reset during the power on sequence.
The polarity was inverted when the driver was first introduced, likely because the device family that was targeted had an inverting level shifter on the reset line.
The MT8186 Corsola devices already have the IT6505 in their device tree, but the whole display pipeline is actually disabled and won't be enabled until some remaining issues are sorted out. The other known user is the MT8183 Kukui / Jacuzzi family; their device trees currently do not have the IT6505 included.
Fix the polarity in the driver while there are no actual users.
--- drivers/gpu/drm/bridge/ite-it6505.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +4 -4
@@ -2560,9 +2560,9 @@ static int it6505_poweron(struct it6505 *it6505)/* time interval between OVDD and SYSRSTN at least be 10ms */ if (pdata->gpiod_reset) {usleep_range (10000 ,20000 ); -gpiod_set_value_cansleep (pdata->gpiod_reset,0 ); -usleep_range (1000 ,2000 );gpiod_set_value_cansleep (pdata->gpiod_reset,1 ); +usleep_range (1000 ,2000 ); +gpiod_set_value_cansleep (pdata->gpiod_reset,0 );usleep_range (25000 ,35000 ); }
@@ -2589,7 +2589,7 @@ static int it6505_poweroff(struct it6505 *it6505) }if (pdata->gpiod_reset) -gpiod_set_value_cansleep (pdata->gpiod_reset,0 ); +gpiod_set_value_cansleep (pdata->gpiod_reset,1 );if (pdata->pwr18) { err =regulator_disable (pdata->pwr18);
@@ -3050,7 +3050,7 @@ static int it6505_init_pdata(struct it6505 *it6505)return PTR_ERR (pdata->ovdd); } - pdata->gpiod_reset =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_LOW ); + pdata->gpiod_reset =devm_gpiod_get (dev,"reset" ,GPIOD_OUT_HIGH );if (IS_ERR (pdata->gpiod_reset)) {dev_err (dev,"gpiod_reset gpio not found" );return PTR_ERR (pdata->gpiod_reset);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 585/772 xsk: always clear DMA mapping information when unmapping the pool
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larysa Zaremba <[email protected]>
[ Upstream commit ac9a48a6f1610b094072b815e884e1668aea4401 ]
When the umem is shared, the DMA mapping is also shared between the xsk pools, therefore it should stay valid as long as at least 1 user remains. However, the pool also keeps the copies of DMA-related information that are initialized in the same way in xp_init_dma_info(), but cleared by xp_dma_unmap() only for the last remaining pool, this causes the problems below.
The first one is that the commit adbf5a42341f ("ice: remove af_xdp_zc_qps bitmap") relies on pool->dev to determine the presence of a ZC pool on a given queue, avoiding internal bookkeeping. This works perfectly fine if the UMEM is not shared, but reliably fails otherwise as stated in the linked report.
The second one is pool->dma_pages which is dynamically allocated and only freed in xp_dma_unmap(), this leads to a small memory leak. kmemleak does not catch it, but by printing the allocation results after terminating the userspace program it is possible to see that all addresses except the one belonging to the last detached pool are still accessible through the kmemleak dump functionality.
Always clear the DMA mapping information from the pool and free pool->dma_pages when unmapping the pool, so that the only difference between results of the last remaining user's call and the ones before would be the destruction of the DMA mapping.
--- net/xdp/xsk_buff_pool.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
net/xdp/xsk_buff_pool.c +2 -3
@@ -356,10 +356,9 @@ void xp_dma_unmap(struct xsk_buff_pool *pool, unsigned long attrs)return ; } -if (!refcount_dec_and_test (&dma_map->users)) -return ; +if (refcount_dec_and_test (&dma_map->users)) +__xp_dma_unmap (dma_map, attrs); -__xp_dma_unmap (dma_map, attrs);kvfree (pool->dma_pages); pool->dma_pages_cnt =0 ; pool->dev =NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 586/772 bpftool: Remove asserts from JIT disassembler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quentin Monnet <[email protected]>
[ Upstream commit 55b4de58d0e2aca810ed2b198a0173640300acf8 ]
The JIT disassembler in bpftool is the only components (with the JSON writer) using asserts to check the return values of functions. But it does not do so in a consistent way, and diasm_print_insn() returns no value, although sometimes the operation failed.
Remove the asserts, and instead check the return values, print messages on errors, and propagate the error to the caller from prog.c.
Remove the inclusion of assert.h from jit_disasm.c, and also from map.c where it is unused.
Stable-dep-of: ef3ba8c258ee ("bpftool: fix potential NULL pointer dereferencing in prog_dump()")
--- tools/bpf/bpftool/jit_disasm.c | 51 +++++++++++++++++++++++----------- tools/bpf/bpftool/main.h | 25 +++++++++-------- tools/bpf/bpftool/map.c | 1 - tools/bpf/bpftool/prog.c | 15 ++++++---- 4 files changed, 57 insertions(+), 35 deletions(-)
tools/bpf/bpftool/jit_disasm.c +35 -16
@@ -16,7 +16,6 @@#include <stdarg.h> #include <stdint.h> #include <stdlib.h> -#include <assert.h> #include <unistd.h> #include <string.h> #include <bfd.h>
@@ -29,14 +28,18 @@#include "json_writer.h" #include "main.h" -static void get_exec_path (char *tpath,size_t size) +static int get_exec_path (char *tpath,size_t size) {const char *path ="/proc/self/exe" ;ssize_t len; len =readlink (path, tpath, size -1 ); -assert (len >0 ); +if (len <=0 ) +return -1 ; + tpath[len] =0 ; + +return 0 ; }static int oper_count;
@@ -97,30 +100,39 @@ static int fprintf_json_styled(void *out,return r; } -void disasm_print_insn (unsigned char *image,ssize_t len,int opcodes, -const char *arch,const char *disassembler_options, -const struct btf *btf, -const struct bpf_prog_linfo *prog_linfo, -__u64 func_ksym,unsigned int func_idx, -bool linum) +int disasm_print_insn (unsigned char *image,ssize_t len,int opcodes, +const char *arch,const char *disassembler_options, +const struct btf *btf, +const struct bpf_prog_linfo *prog_linfo, +__u64 func_ksym,unsigned int func_idx, +bool linum) {const struct bpf_line_info *linfo =NULL ;disassembler_ftype disassemble; +int count, i, pc =0 , err =-1 ;struct disassemble_info info;unsigned int nr_skip =0 ; -int count, i, pc =0 ;char tpath[PATH_MAX ];bfd *bfdf;if (!len) -return ; +return -1 ;memset (tpath,0 ,sizeof (tpath)); -get_exec_path (tpath,sizeof (tpath)); +if (get_exec_path (tpath,sizeof (tpath))) { +p_err ("failed to create disasembler (get_exec_path)" ); +return -1 ; + } bfdf =bfd_openr (tpath,NULL ); -assert (bfdf); -assert (bfd_check_format (bfdf, bfd_object)); +if (!bfdf) { +p_err ("failed to create disassembler (bfd_openr)" ); +return -1 ; + } +if (!bfd_check_format (bfdf, bfd_object)) { +p_err ("failed to create disassembler (bfd_check_format)" ); + goto exit_close; + }if (json_output) init_disassemble_info_compat(&info, stdout,
@@ -139,7 +151,7 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes, bfdf->arch_info = inf; }else {p_err ("No libbfd support for %s" , arch); -return ; + goto exit_close; } }
@@ -160,7 +172,10 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,#else disassemble =disassembler (bfdf);#endif -assert (disassemble); +if (!disassemble) { +p_err ("failed to create disassembler" ); + goto exit_close; + }if (json_output)jsonw_start_array (json_wtr);
@@ -224,7 +239,11 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,if (json_output)jsonw_end_array (json_wtr); + err =0 ; + +exit_close:bfd_close (bfdf); +return err; }int disasm_init (void )
tools/bpf/bpftool/main.h +13 -12
@@ -173,22 +173,23 @@ int map_parse_fd_and_info(int *argc, char ***argv, void *info, __u32 *info_len);struct bpf_prog_linfo ;#ifdef HAVE_LIBBFD_SUPPORT -void disasm_print_insn (unsigned char *image,ssize_t len,int opcodes, -const char *arch,const char *disassembler_options, -const struct btf *btf, -const struct bpf_prog_linfo *prog_linfo, -__u64 func_ksym,unsigned int func_idx, -bool linum); +int disasm_print_insn (unsigned char *image,ssize_t len,int opcodes, +const char *arch,const char *disassembler_options, +const struct btf *btf, +const struct bpf_prog_linfo *prog_linfo, +__u64 func_ksym,unsigned int func_idx, +bool linum);int disasm_init (void );#else static inline -void disasm_print_insn (unsigned char *image,ssize_t len,int opcodes, -const char *arch,const char *disassembler_options, -const struct btf *btf, -const struct bpf_prog_linfo *prog_linfo, -__u64 func_ksym,unsigned int func_idx, -bool linum) +int disasm_print_insn (unsigned char *image,ssize_t len,int opcodes, +const char *arch,const char *disassembler_options, +const struct btf *btf, +const struct bpf_prog_linfo *prog_linfo, +__u64 func_ksym,unsigned int func_idx, +bool linum) { +return 0 ; }static inline int disasm_init (void ) {
tools/bpf/bpftool/map.c +0 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) /* Copyright (C) 2017-2018 Netronome Systems, Inc. */ -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <linux/err.h>
tools/bpf/bpftool/prog.c +9 -6
@@ -820,10 +820,11 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,printf ("%s:\n" , sym_name); } -disasm_print_insn (img, lens[i], opcodes, - name, disasm_opt, btf, - prog_linfo, ksyms[i], i, - linum); +if (disasm_print_insn (img, lens[i], opcodes, + name, disasm_opt, btf, + prog_linfo, ksyms[i], i, + linum)) + goto exit_free; img += lens[i];
@@ -836,8 +837,10 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,if (json_output)jsonw_end_array (json_wtr); }else { -disasm_print_insn (buf, member_len, opcodes, name, - disasm_opt, btf,NULL ,0 ,0 , false); +if (disasm_print_insn (buf, member_len, opcodes, name, + disasm_opt, btf,NULL ,0 ,0 , + false)) + goto exit_free; } }else if (visual) {if (json_output)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 587/772 bpftool: fix potential NULL pointer dereferencing in prog_dump()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Mohammadi <[email protected]>
[ Upstream commit ef3ba8c258ee368a5343fa9329df85b4bcb9e8b5 ]
A NULL pointer dereference could occur if ksyms
is not properly checked before usage in the prog_dump() function.
--- tools/bpf/bpftool/prog.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
tools/bpf/bpftool/prog.c +12 -5
@@ -820,11 +820,18 @@ prog_dump(struct bpf_prog_info *info, enum dump_mode mode,printf ("%s:\n" , sym_name); } -if (disasm_print_insn (img, lens[i], opcodes, - name, disasm_opt, btf, - prog_linfo, ksyms[i], i, - linum)) - goto exit_free; +if (ksyms) { +if (disasm_print_insn (img, lens[i], opcodes, + name, disasm_opt, btf, + prog_linfo, ksyms[i], i, + linum)) + goto exit_free; + }else { +if (disasm_print_insn (img, lens[i], opcodes, + name, disasm_opt, btf, +NULL ,0 ,0 , false)) + goto exit_free; + } img += lens[i];
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 588/772 drm/sti: Add __iomem for mixer_dbg_mxns parameter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 86e8f94789dd6f3e705bfa821e1e416f97a2f863 ]
Sparse complains about incorrect type in argument 1. expected void const volatile __iomem *ptr but got void *. so modify mixer_dbg_mxn's addr parameter.
--- drivers/gpu/drm/sti/sti_mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sti/sti_mixer.c +1 -1
@@ -137,7 +137,7 @@ static void mixer_dbg_crb(struct seq_file *s, int val) } } -static void mixer_dbg_mxn (struct seq_file *s,void *addr) +static void mixer_dbg_mxn (struct seq_file *s,void __iomem *addr) {int i;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 589/772 tcp_bpf: Fix the sk_mem_uncharge logic in tcp_bpf_sendmsg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijian Zhang <[email protected]>
[ Upstream commit ca70b8baf2bd125b2a4d96e76db79375c07d7ff2 ]
The current sk memory accounting logic in __SK_REDIRECT is pre-uncharging tosend bytes, which is either msg->sg.size or a smaller value apply_bytes.
Potential problems with this strategy are as follows:
- If the actual sent bytes are smaller than tosend, we need to charge some bytes back, as in line 487, which is okay but seems not clean.
- When tosend is set to apply_bytes, as in line 417, and (ret < 0), we may miss uncharging (msg->sg.size - apply_bytes) bytes.
[...]
415 tosend = msg->sg.size;
416 if (psock->apply_bytes && psock->apply_bytes < tosend)
417 tosend = psock->apply_bytes;
[...]
443 sk_msg_return(sk, msg, tosend);
444 release_sock(sk);
446 origsize = msg->sg.size;
447 ret = tcp_bpf_sendmsg_redir(sk_redir, redir_ingress,
448 msg, tosend, flags);
449 sent = origsize - msg->sg.size;
[...]
454 lock_sock(sk);
455 if (unlikely(ret < 0)) {
456 int free = sk_msg_free_nocharge(sk, msg);
458 if (!cork)
459 *copied -= free;
460 }
[...]
487 if (eval == __SK_REDIRECT)
488 sk_mem_charge(sk, tosend - sent);
[...]
When running the selftest test_txmsg_redir_wait_sndmem with txmsg_apply, the following warning will be reported:
------------[ cut here ]------------ WARNING: CPU: 6 PID: 57 at net/ipv4/af_inet.c:156 inet_sock_destruct+0x190/0x1a0 Modules linked in: CPU: 6 UID: 0 PID: 57 Comm: kworker/6:0 Not tainted 6.12.0-rc1.bm.1-amd64+ #43 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014 Workqueue: events sk_psock_destroy RIP: 0010:inet_sock_destruct+0x190/0x1a0 RSP: 0018:ffffad0a8021fe08 EFLAGS: 00010206 RAX: 0000000000000011 RBX: ffff9aab4475b900 RCX: ffff9aab481a0800 RDX: 0000000000000303 RSI: 0000000000000011 RDI: ffff9aab4475b900 RBP: ffff9aab4475b990 R08: 0000000000000000 R09: ffff9aab40050ec0 R10: 0000000000000000 R11: ffff9aae6fdb1d01 R12: ffff9aab49c60400 R13: ffff9aab49c60598 R14: ffff9aab49c60598 R15: dead000000000100 FS: 0000000000000000(0000) GS:ffff9aae6fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffec7e47bd8 CR3: 00000001a1a1c004 CR4: 0000000000770ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> ? __warn+0x89/0x130 ? inet_sock_destruct+0x190/0x1a0 ? report_bug+0xfc/0x1e0 ? handle_bug+0x5c/0xa0 ? exc_invalid_op+0x17/0x70 ? asm_exc_invalid_op+0x1a/0x20 ? inet_sock_destruct+0x190/0x1a0 __sk_destruct+0x25/0x220 sk_psock_destroy+0x2b2/0x310 process_scheduled_works+0xa3/0x3e0 worker_thread+0x117/0x240 ? __pfx_worker_thread+0x10/0x10 kthread+0xcf/0x100 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x31/0x40 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> ---[ end trace 0000000000000000 ]---
In __SK_REDIRECT, a more concise way is delaying the uncharging after sent bytes are finalized, and uncharge this value. When (ret < 0), we shall invoke sk_msg_free.
Same thing happens in case __SK_DROP, when tosend is set to apply_bytes, we may miss uncharging (msg->sg.size - apply_bytes) bytes. The same warning will be reported in selftest.
[...]
468 case __SK_DROP:
469 default:
470 sk_msg_free_partial(sk, msg, tosend);
471 sk_msg_apply_bytes(psock, tosend);
472 *copied -= (tosend + delta);
473 return -EACCES;
[...]
So instead of sk_msg_free_partial we can do sk_msg_free here.
--- net/ipv4/tcp_bpf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
net/ipv4/tcp_bpf.c +4 -7
@@ -436,7 +436,6 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, cork = true; psock->cork =NULL ; } -sk_msg_return (sk, msg, tosend);release_sock (sk); origsize = msg->sg.size;
@@ -448,8 +447,9 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,sock_put (sk_redir);lock_sock (sk); +sk_mem_uncharge (sk, sent);if (unlikely (ret <0 )) { -int free =sk_msg_free_nocharge (sk, msg); +int free =sk_msg_free (sk, msg);if (!cork) *copied -= free;
@@ -463,7 +463,7 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,break ;case __SK_DROP:default : -sk_msg_free_partial (sk, msg, tosend); +sk_msg_free (sk, msg);sk_msg_apply_bytes (psock, tosend); *copied -= (tosend + delta);return -EACCES ;
@@ -479,11 +479,8 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, }if (msg && msg->sg.data[msg->sg.start].page_link && - msg->sg.data[msg->sg.start].length) { -if (eval == __SK_REDIRECT) -sk_mem_charge (sk, tosend - sent); + msg->sg.data[msg->sg.start].length) goto more_data; - } }return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 590/772 ALSA: usb-audio: Notify xrun for low-latency mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 4f9d674377d090e38d93360bd4df21b67534d622 ]
The low-latency mode of USB-audio driver uses a similar approach like the implicit feedback mode but it has an explicit queuing at the trigger start time. The difference is, however, that no packet will be handled any longer after all queued packets are handled but no enough data is fed. In the case of implicit feedback mode, the capture-side packet handling triggers the re-queuing, and this checks the XRUN. OTOH, in the low-latency mode, it just stops without XRUN notification unless any new action is taken from user-space via ack callback. For example, when you stop the stream in aplay, no XRUN is reported.
This patch adds the XRUN check at the packet complete callback in the case all pending URBs are exhausted. Strictly speaking, this state doesn't match really with XRUN; in theory the application may queue immediately after this happens. But such behavior is only for 1-period configuration, which the USB-audio driver doesn't support. So we may conclude that this situation leads certainly to XRUN.
A caveat is that the XRUN should be triggered only for the PCM RUNNING state, and not during DRAINING. This additional state check is put in notify_xrun(), too.
--- sound/usb/endpoint.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/usb/endpoint.c +11 -3
@@ -403,10 +403,15 @@ static int prepare_inbound_urb(struct snd_usb_endpoint *ep,static void notify_xrun (struct snd_usb_endpoint *ep) {struct snd_usb_substream *data_subs; +struct snd_pcm_substream *psubs; data_subs =READ_ONCE (ep->data_subs); -if (data_subs && data_subs->pcm_substream) -snd_pcm_stop_xrun (data_subs->pcm_substream); +if (!data_subs) +return ; + psubs = data_subs->pcm_substream; +if (psubs && psubs->runtime && + psubs->runtime->state ==SNDRV_PCM_STATE_RUNNING ) +snd_pcm_stop_xrun (psubs); } static struct snd_usb_packet_info *
@@ -557,7 +562,10 @@ static void snd_complete_urb(struct urb *urb)push_back_to_ready_list (ep, ctx);clear_bit (ctx->index, &ep->active_mask);snd_usb_queue_pending_output_urbs (ep, false); -atomic_dec (&ep->submitted_urbs);/* decrement at last */ +/* decrement at last, and check xrun */ +if (atomic_dec_and_test (&ep->submitted_urbs) && + !snd_usb_endpoint_implicit_feedback_sink (ep)) +notify_xrun (ep);return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 591/772 tools: Override makefile ARCH variable if defined, but empty
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Björn Töpel <[email protected]>
[ Upstream commit 537a2525eaf76ea9b0dca62b994500d8670b39d5 ]
There are a number of tools (bpftool, selftests), that require a "bootstrap" build. Here, a bootstrap build is a build host variant of a target. E.g., assume that you're performing a bpftool cross-build on x86 to riscv, a bootstrap build would then be an x86 variant of bpftool. The typical way to perform the host build variant, is to pass "ARCH=" in a sub-make. However, if a variable has been set with a command argument, then ordinary assignments in the makefile are ignored.
This side-effect results in that ARCH, and variables depending on ARCH are not set. Workaround by overriding ARCH to the host arch, if ARCH is empty.
--- tools/scripts/Makefile.arch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/scripts/Makefile.arch +2 -2
@@ -7,8 +7,8 @@ HOSTARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ -e s/riscv.*/riscv/) -ifndef ARCH -ARCH := $(HOSTARCH) +ifeq ($(strip $(ARCH)),) +override ARCH := $(HOSTARCH) endif SRCARCH := $(ARCH)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 592/772 spi: mpc52xx: Add cancel_work_sync before module remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 984836621aad98802d92c4a3047114cf518074c8 ]
If we remove the module which will call mpc52xx_spi_remove it will free 'ms' through spi_unregister_controller. while the work ms->work will be used. The sequence of operations that may lead to a UAF bug.
Fix it by ensuring that the work is canceled before proceeding with the cleanup in mpc52xx_spi_remove.
--- drivers/spi/spi-mpc52xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-mpc52xx.c +1 -0
@@ -519,6 +519,7 @@ static int mpc52xx_spi_remove(struct platform_device *op)struct mpc52xx_spi *ms =spi_master_get_devdata (master);int i; +cancel_work_sync (&ms->work);free_irq (ms->irq0, ms);free_irq (ms->irq1, ms);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 593/772 scsi: scsi_debug: Fix hrtimer support for ndelay
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
[ Upstream commit 6918141d815acef056a0d10e966a027d869a922d ]
Since commit 771f712ba5b0 ("scsi: scsi_debug: Fix cmd duration calculation"), ns_from_boot value is only evaluated in schedule_resp() for polled requests.
However, ns_from_boot is also required for hrtimer support for when ndelay is less than INCLUSIVE_TIMING_MAX_NS, so fix up the logic to decide when to evaluate ns_from_boot.
--- drivers/scsi/scsi_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
@@ -5672,7 +5672,7 @@ static int schedule_resp(struct scsi_cmnd *cmnd, struct sdebug_dev_info *devip,if (sdebug_host_max_queue) sd_dp->hc_idx =get_tag (cmnd); -if (polled) +if (polled || (ndelay >0 && ndelay <INCLUSIVE_TIMING_MAX_NS )) ns_from_boot =ktime_get_boottime_ns ();/* one of the resp_*() response functions is called here */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 594/772 drm/v3d: Enable Performance Counters before clearing them
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maíra Canal <[email protected]>
[ Upstream commit c98b10496b2f3c4f576af3482c71aadcfcbf765e ]
On the Raspberry Pi 5, performance counters are not being cleared when v3d_perfmon_start() is called, even though we write to the CLR register. As a result, their values accumulate until they overflow.
The expected behavior is for performance counters to reset to zero at the start of a job. When the job finishes and the perfmon is stopped, the counters should accurately reflect the values for that specific job.
To ensure this behavior, the performance counters are now enabled before being cleared. This allows the CLR register to function as intended, zeroing the counter values when the job begins.
--- drivers/gpu/drm/v3d/v3d_perfmon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_perfmon.c +1 -1
@@ -49,9 +49,9 @@ void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon)V3D_CORE_WRITE (0 ,V3D_V4_PCTR_0_SRC_X (source), channel); } +V3D_CORE_WRITE (0 ,V3D_V4_PCTR_0_EN , mask);V3D_CORE_WRITE (0 ,V3D_V4_PCTR_0_CLR , mask);V3D_CORE_WRITE (0 ,V3D_PCTR_0_OVERFLOW , mask); -V3D_CORE_WRITE (0 ,V3D_V4_PCTR_0_EN , mask); v3d->active_perfmon = perfmon; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 595/772 ocfs2: free inode when ocfs2_get_init_inode() fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
[ Upstream commit 965b5dd1894f4525f38c1b5f99b0106a07dbb5db ]
syzbot is reporting busy inodes after unmount, for commit 9c89fe0af826 ("ocfs2: Handle error from dquot_initialize()") forgot to call iput() when new_inode() succeeded and dquot_initialize() failed.
--- fs/ocfs2/namei.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ocfs2/namei.c +3 -1
@@ -200,8 +200,10 @@ static struct inode *ocfs2_get_init_inode(struct inode *dir, umode_t mode) mode =mode_strip_sgid (&init_user_ns, dir, mode);inode_init_owner (&init_user_ns, inode, dir, mode); status =dquot_initialize (inode); -if (status) +if (status) { +iput (inode);return ERR_PTR (status); + }return inode; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 596/772 scatterlist: fix incorrect func name in kernel-doc
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit d89c8ec0546184267cb211b579514ebaf8916100 ]
Fix a kernel-doc warning by making the kernel-doc function description match the function name:
include/linux/scatterlist.h:323: warning: expecting prototype for sg_unmark_bus_address(). Prototype was for sg_dma_unmark_bus_address() instead
--- include/linux/scatterlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/scatterlist.h +1 -1
@@ -288,7 +288,7 @@ static inline void sg_dma_mark_bus_address(struct scatterlist *sg) }/** -* sg_unmark_bus_address - Unmark the scatterlist entry as a bus address +* sg_dma_unmark_bus_address - Unmark the scatterlist entry as a bus address * @sg: SG entry * * Description:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 597/772 iio: magnetometer: yas530: use signed integer type for clamp limits
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakob Hauser <[email protected]>
[ Upstream commit f1ee5483e40881d8ad5a63aa148b753b5c6a839b ]
In the function yas537_measure() there is a clamp_val() with limits of -BIT(13) and BIT(13) - 1. The input clamp value h[] is of type s32. The BIT() is of type unsigned long integer due to its define in include/vdso/bits.h. The lower limit -BIT(13) is recognized as -8192 but expressed as an unsigned long integer. The size of an unsigned long integer differs between 32-bit and 64-bit architectures. Converting this to type s32 may lead to undesired behavior.
Additionally, in the calculation lines h[0], h[1] and h[2] the unsigned long integer divisor BIT(13) causes an unsigned division, shifting the left-hand side of the equation back and forth, possibly ending up in large positive values instead of negative values on 32-bit architectures.
To solve those two issues, declare a signed integer with a value of BIT(13).
There is another omission in the clamp line: clamp_val() returns a value and it's going nowhere here. Self-assign it to h[i] to make use of the clamp macro.
Finally, replace clamp_val() macro by clamp() because after changing the limits from type unsigned long integer to signed integer it's fine that way.
--- drivers/iio/magnetometer/yamaha-yas530.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/iio/magnetometer/yamaha-yas530.c +7 -6
@@ -372,6 +372,7 @@ static int yas537_measure(struct yas5xx *yas5xx, u16 *t, u16 *x, u16 *y1, u16 *yu8 data[8 ];u16 xy1y2[3 ];s32 h[3 ], s[3 ]; +int half_range =BIT (13 );int i, ret;mutex_lock (&yas5xx->lock);
@@ -406,13 +407,13 @@ static int yas537_measure(struct yas5xx *yas5xx, u16 *t, u16 *x, u16 *y1, u16 *y/* The second version of YAS537 needs to include calibration coefficients */ if (yas5xx->version ==YAS537_VERSION_1 ) {for (i =0 ; i <3 ; i++) - s[i] = xy1y2[i] -BIT (13 ); - h[0 ] = (c->k * (128 * s[0 ] + c->a2 * s[1 ] + c->a3 * s[2 ])) /BIT (13 ); - h[1 ] = (c->k * (c->a4 * s[0 ] + c->a5 * s[1 ] + c->a6 * s[2 ])) /BIT (13 ); - h[2 ] = (c->k * (c->a7 * s[0 ] + c->a8 * s[1 ] + c->a9 * s[2 ])) /BIT (13 ); + s[i] = xy1y2[i] - half_range; + h[0 ] = (c->k * (128 * s[0 ] + c->a2 * s[1 ] + c->a3 * s[2 ])) / half_range; + h[1 ] = (c->k * (c->a4 * s[0 ] + c->a5 * s[1 ] + c->a6 * s[2 ])) / half_range; + h[2 ] = (c->k * (c->a7 * s[0 ] + c->a8 * s[1 ] + c->a9 * s[2 ])) / half_range;for (i =0 ; i <3 ; i++) { -clamp_val (h[i], -BIT (13 ),BIT (13 ) -1 ); - xy1y2[i] = h[i] +BIT (13 ); + h[i] =clamp (h[i], -half_range, half_range -1 ); + xy1y2[i] = h[i] + half_range; } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 598/772 bpf: Handle BPF_EXIST and BPF_NOEXIST for LPM trie
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit eae6a075e9537dd69891cf77ca5a88fa8a28b4a1 ]
Add the currently missing handling for the BPF_EXIST and BPF_NOEXIST flags. These flags can be specified by users and are relevant since LPM trie supports exact matches during update.
--- kernel/bpf/lpm_trie.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
kernel/bpf/lpm_trie.c +20 -3
@@ -368,6 +368,10 @@ static int trie_update_elem(struct bpf_map *map,* simply assign the @new_node to that slot and be done. */ if (!node) { +if (flags ==BPF_EXIST ) { + ret = -ENOENT ; + goto out; + }rcu_assign_pointer (*slot, new_node); goto out; }
@@ -376,18 +380,31 @@ static int trie_update_elem(struct bpf_map *map,* which already has the correct data array set. */ if (node->prefixlen == matchlen) { +if (!(node->flags &LPM_TREE_NODE_FLAG_IM )) { +if (flags ==BPF_NOEXIST ) { + ret = -EEXIST ; + goto out; + } + trie->n_entries--; + }else if (flags ==BPF_EXIST ) { + ret = -ENOENT ; + goto out; + } + new_node->child[0 ] = node->child[0 ]; new_node->child[1 ] = node->child[1 ]; -if (!(node->flags &LPM_TREE_NODE_FLAG_IM )) - trie->n_entries--; -rcu_assign_pointer (*slot, new_node); free_node = node; goto out; } +if (flags ==BPF_EXIST ) { + ret = -ENOENT ; + goto out; + } +/* If the new node matches the prefix completely, it must be inserted * as an ancestor. Simply insert it between @node and *@slot. */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 599/772 bpf: Remove unnecessary kfree(im_node) in lpm_trie_update_elem
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit 3d5611b4d7efbefb85a74fcdbc35c603847cc022 ]
There is no need to call kfree(im_node) when updating element fails, because im_node must be NULL. Remove the unnecessary kfree() for im_node.
Stable-dep-of: 532d6b36b2bf ("bpf: Handle in-place update for full LPM trie correctly")
--- kernel/bpf/lpm_trie.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/bpf/lpm_trie.c +1 -3
@@ -307,7 +307,7 @@ static int trie_update_elem(struct bpf_map *map, void *_key, void *value, u64 flags) { struct lpm_trie *trie = container_of(map, struct lpm_trie, map); -struct lpm_trie_node *node, *im_node =NULL , *new_node =NULL ; +struct lpm_trie_node *node, *im_node, *new_node =NULL ;struct lpm_trie_node *free_node =NULL ;struct lpm_trie_node __rcu **slot;struct bpf_lpm_trie_key_u8 *key = _key;
@@ -441,9 +441,7 @@ static int trie_update_elem(struct bpf_map *map,if (ret) {if (new_node) trie->n_entries--; -kfree (new_node); -kfree (im_node); }spin_unlock_irqrestore (&trie->lock, irq_flags);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 600/772 bpf: Handle in-place update for full LPM trie correctly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit 532d6b36b2bfac5514426a97a4df8d103d700d43 ]
When a LPM trie is full, in-place updates of existing elements incorrectly return -ENOSPC.
Fix this by deferring the check of trie->n_entries. For new insertions, n_entries must not exceed max_entries. However, in-place updates are allowed even when the trie is full.
--- kernel/bpf/lpm_trie.c | 44 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 23 deletions(-)
kernel/bpf/lpm_trie.c +21 -23
@@ -302,6 +302,16 @@ static struct lpm_trie_node *lpm_trie_node_alloc(const struct lpm_trie *trie,return node; } +static int trie_check_add_elem (struct lpm_trie *trie,u64 flags) +{ +if (flags ==BPF_EXIST ) +return -ENOENT ; +if (trie->n_entries == trie->map.max_entries) +return -ENOSPC ; + trie->n_entries++; +return 0 ; +} +/* Called from syscall or from eBPF program */ static int trie_update_elem (struct bpf_map *map,void *_key,void *value,u64 flags)
@@ -325,20 +335,12 @@ static int trie_update_elem(struct bpf_map *map,spin_lock_irqsave (&trie->lock, irq_flags);/* Allocate and fill a new node */ - -if (trie->n_entries == trie->map.max_entries) { - ret = -ENOSPC ; - goto out; - } - new_node =lpm_trie_node_alloc (trie, value);if (!new_node) { ret = -ENOMEM ; goto out; } - trie->n_entries++; - new_node->prefixlen = key->prefixlen;RCU_INIT_POINTER (new_node->child[0 ],NULL );RCU_INIT_POINTER (new_node->child[1 ],NULL );
@@ -368,10 +370,10 @@ static int trie_update_elem(struct bpf_map *map,* simply assign the @new_node to that slot and be done. */ if (!node) { -if (flags ==BPF_EXIST ) { - ret = -ENOENT ; + ret =trie_check_add_elem (trie, flags); +if (ret) goto out; - } +rcu_assign_pointer (*slot, new_node); goto out; }
@@ -385,10 +387,10 @@ static int trie_update_elem(struct bpf_map *map, ret = -EEXIST ; goto out; } - trie->n_entries--; - }else if (flags ==BPF_EXIST ) { - ret = -ENOENT ; - goto out; + }else { + ret =trie_check_add_elem (trie, flags); +if (ret) + goto out; } new_node->child[0 ] = node->child[0 ];
@@ -400,10 +402,9 @@ static int trie_update_elem(struct bpf_map *map, goto out; } -if (flags ==BPF_EXIST ) { - ret = -ENOENT ; + ret =trie_check_add_elem (trie, flags); +if (ret) goto out; - }/* If the new node matches the prefix completely, it must be inserted * as an ancestor. Simply insert it between @node and *@slot.
@@ -417,6 +418,7 @@ static int trie_update_elem(struct bpf_map *map, im_node =lpm_trie_node_alloc (trie,NULL );if (!im_node) { + trie->n_entries--; ret = -ENOMEM ; goto out; }
@@ -438,12 +440,8 @@ static int trie_update_elem(struct bpf_map *map,rcu_assign_pointer (*slot, im_node); out: -if (ret) { -if (new_node) - trie->n_entries--; +if (ret)kfree (new_node); - } -spin_unlock_irqrestore (&trie->lock, irq_flags);kfree_rcu (free_node, rcu);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 601/772 bpf: Fix exact match conditions in trie_get_next_key()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit 27abc7b3fa2e09bbe41e2924d328121546865eda ]
trie_get_next_key() uses node->prefixlen == key->prefixlen to identify an exact match, However, it is incorrect because when the target key doesn't fully match the found node (e.g., node->prefixlen != matchlen), these two nodes may also have the same prefixlen. It will return expected result when the passed key exist in the trie. However when a recently-deleted key or nonexistent key is passed to trie_get_next_key(), it may skip keys and return incorrect result.
Fix it by using node->prefixlen == matchlen to identify exact matches. When the condition is true after the search, it also implies node->prefixlen equals key->prefixlen, otherwise, the search would return NULL instead.
--- kernel/bpf/lpm_trie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/lpm_trie.c +2 -2
@@ -641,7 +641,7 @@ static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key)struct lpm_trie_node **node_stack =NULL ;int err =0 , stack_ptr =-1 ;unsigned int next_bit; -size_t matchlen; +size_t matchlen =0 ;/* The get_next_key follows postorder. For the 4 node example in * the top of this file, the trie_get_next_key() returns the following
@@ -680,7 +680,7 @@ static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) next_bit =extract_bit (key->data, node->prefixlen); node =rcu_dereference (node->child[next_bit]); } -if (!node || node->prefixlen != key->prefixlen || +if (!node || node->prefixlen != matchlen || (node->flags &LPM_TREE_NODE_FLAG_IM )) goto find_leftmost;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 602/772 mm: page_alloc: move mlocked flag clearance into free_pages_prepare()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Gushchin <[email protected]>
commit 66edc3a5894c74f8887c8af23b97593a0dd0df4d upstream.
Syzbot reported a bad page state problem caused by a page being freed using free_page() still having a mlocked flag at free_pages_prepare() stage:
BUG: Bad page state in process syz.5.504 pfn:61f45 page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x61f45 flags: 0xfff00000080204(referenced|workingset|mlocked|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000080204 0000000000000000 dead000000000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x400dc0(GFP_KERNEL_ACCOUNT|__GFP_ZERO), pid 8443, tgid 8442 (syz.5.504), ts 201884660643, free_ts 201499827394 set_page_owner include/linux/page_owner.h:32 [inline] post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1537 prep_new_page mm/page_alloc.c:1545 [inline] get_page_from_freelist+0x303f/0x3190 mm/page_alloc.c:3457 __alloc_pages_noprof+0x292/0x710 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2265 kvm_coalesced_mmio_init+0x1f/0xf0 virt/kvm/coalesced_mmio.c:99 kvm_create_vm virt/kvm/kvm_main.c:1235 [inline] kvm_dev_ioctl_create_vm virt/kvm/kvm_main.c:5488 [inline] kvm_dev_ioctl+0x12dc/0x2240 virt/kvm/kvm_main.c:5530 __do_compat_sys_ioctl fs/ioctl.c:1007 [inline] __se_compat_sys_ioctl+0x510/0xc90 fs/ioctl.c:950 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0xb4/0x110 arch/x86/entry/common.c:386 do_fast_syscall_32+0x34/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e page last free pid 8399 tgid 8399 stack trace: reset_page_owner include/linux/page_owner.h:25 [inline] free_pages_prepare mm/page_alloc.c:1108 [inline] free_unref_folios+0xf12/0x18d0 mm/page_alloc.c:2686 folios_put_refs+0x76c/0x860 mm/swap.c:1007 free_pages_and_swap_cache+0x5c8/0x690 mm/swap_state.c:335 __tlb_batch_free_encoded_pages mm/mmu_gather.c:136 [inline] tlb_batch_pages_flush mm/mmu_gather.c:149 [inline] tlb_flush_mmu_free mm/mmu_gather.c:366 [inline] tlb_flush_mmu+0x3a3/0x680 mm/mmu_gather.c:373 tlb_finish_mmu+0xd4/0x200 mm/mmu_gather.c:465 exit_mmap+0x496/0xc40 mm/mmap.c:1926 __mmput+0x115/0x390 kernel/fork.c:1348 exit_mm+0x220/0x310 kernel/exit.c:571 do_exit+0x9b2/0x28e0 kernel/exit.c:926 do_group_exit+0x207/0x2c0 kernel/exit.c:1088 __do_sys_exit_group kernel/exit.c:1099 [inline] __se_sys_exit_group kernel/exit.c:1097 [inline] __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:1097 x64_sys_call+0x2634/0x2640 arch/x86/include/generated/asm/syscalls_64.h:232 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f Modules linked in: CPU: 0 UID: 0 PID: 8442 Comm: syz.5.504 Not tainted 6.12.0-rc6-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 bad_page+0x176/0x1d0 mm/page_alloc.c:501 free_page_is_bad mm/page_alloc.c:918 [inline] free_pages_prepare mm/page_alloc.c:1100 [inline] free_unref_page+0xed0/0xf20 mm/page_alloc.c:2638 kvm_destroy_vm virt/kvm/kvm_main.c:1327 [inline] kvm_put_kvm+0xc75/0x1350 virt/kvm/kvm_main.c:1386 kvm_vcpu_release+0x54/0x60 virt/kvm/kvm_main.c:4143 __fput+0x23f/0x880 fs/file_table.c:431 task_work_run+0x24f/0x310 kernel/task_work.c:239 exit_task_work include/linux/task_work.h:43 [inline] do_exit+0xa2f/0x28e0 kernel/exit.c:939 do_group_exit+0x207/0x2c0 kernel/exit.c:1088 __do_sys_exit_group kernel/exit.c:1099 [inline] __se_sys_exit_group kernel/exit.c:1097 [inline] __ia32_sys_exit_group+0x3f/0x40 kernel/exit.c:1097 ia32_sys_call+0x2624/0x2630 arch/x86/include/generated/asm/syscalls_32.h:253 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline] __do_fast_syscall_32+0xb4/0x110 arch/x86/entry/common.c:386 do_fast_syscall_32+0x34/0x80 arch/x86/entry/common.c:411 entry_SYSENTER_compat_after_hwframe+0x84/0x8e RIP: 0023:0xf745d579 Code: Unable to access opcode bytes at 0xf745d54f. RSP: 002b:00000000f75afd6c EFLAGS: 00000206 ORIG_RAX: 00000000000000fc RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 00000000ffffff9c RDI: 00000000f744cff4 RBP: 00000000f717ae61 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 </TASK>
The problem was originally introduced by commit b109b87050df ("mm/munlock:
replace clear_page_mlock() by final clearance"): it was focused on handling pagecache and anonymous memory and wasn't suitable for lower level get_page()/free_page() API's used for example by KVM, as with this reproducer.
Fix it by moving the mlocked flag clearance down to free_page_prepare().
The bug itself if fairly old and harmless (aside from generating these warnings), aside from a small memory leak - "bad" pages are stopped from being allocated again.
--- mm/page_alloc.c | 15 +++++++++++++++ mm/swap.c | 20 -------------------- 2 files changed, 15 insertions(+), 20 deletions(-)
mm/page_alloc.c +15 -0
@@ -1388,12 +1388,27 @@ static __always_inline bool free_pages_pint bad =0 ;bool skip_kasan_poison =should_skip_kasan_poison (page, fpi_flags);bool init =want_init_on_free (); +struct folio *folio =page_folio (page);VM_BUG_ON_PAGE (PageTail (page), page);trace_mm_page_free (page, order);kmsan_free_page (page, order); +/* +* In rare cases, when truncation or holepunching raced with +* munlock after VM_LOCKED was cleared, Mlocked may still be +* found set here. This does not indicate a problem, unless +* "unevictable_pgs_cleared" appears worryingly large. +*/ +if (unlikely (folio_test_mlocked (folio))) { +long nr_pages =folio_nr_pages (folio); + +__folio_clear_mlocked (folio); +zone_stat_mod_folio (folio,NR_MLOCK , -nr_pages); +count_vm_events (UNEVICTABLE_PGCLEARED , nr_pages); + } +if (unlikely (PageHWPoison (page)) && !order) {/* * Do not let hwpoison pages hit pcplists/buddy
mm/swap.c +0 -20
@@ -88,14 +88,6 @@ static void __page_cache_release(struct__folio_clear_lru_flags (folio);unlock_page_lruvec_irqrestore (lruvec, flags); } -/* See comment on folio_test_mlocked in release_pages() */ -if (unlikely (folio_test_mlocked (folio))) { -long nr_pages =folio_nr_pages (folio); - -__folio_clear_mlocked (folio); -zone_stat_mod_folio (folio,NR_MLOCK , -nr_pages); -count_vm_events (UNEVICTABLE_PGCLEARED , nr_pages); - } }static void __folio_put_small (struct folio *folio)
@@ -1034,18 +1026,6 @@ void release_pages(struct page **pages,__folio_clear_lru_flags (folio); } -/* -* In rare cases, when truncation or holepunching raced with -* munlock after VM_LOCKED was cleared, Mlocked may still be -* found set here. This does not indicate a problem, unless -* "unevictable_pgs_cleared" appears worryingly large. -*/ -if (unlikely (folio_test_mlocked (folio))) { -__folio_clear_mlocked (folio); -zone_stat_sub_folio (folio,NR_MLOCK ); -count_vm_event (UNEVICTABLE_PGCLEARED ); - } -list_add (&folio->lru, &pages_to_free); }if (lruvec)
Greg Kroah-Hartman
maintainerPATCH 603/772 HID: wacom: fix when get product name maybe null pointer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 59548215b76be98cf3422eea9a67d6ea578aca3d upstream.
Due to incorrect dev->product reporting by certain devices, null pointer dereferences occur when dev->product is empty, leading to potential system crashes.
This issue was found on EXCELSIOR DL37-D05 device with Loongson-LS3A6000-7A2000-DL37 motherboard.
Kernel logs:
[ 56.470885] usb 4-3: new full-speed USB device number 4 using ohci-pci [ 56.671638] usb 4-3: string descriptor 0 read error: -22 [ 56.671644] usb 4-3: New USB device found, idVendor=056a, idProduct=0374, bcdDevice= 1.07 [ 56.671647] usb 4-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 56.678839] hid-generic 0003:056A:0374.0004: hiddev0,hidraw3: USB HID v1.10 Device [HID 056a:0374] on usb-0000:00:05.0-3/input0 [ 56.697719] CPU 2 Unable to handle kernel paging request at virtual address 0000000000000000, era == 90000000066e35c8, ra == ffff800004f98a80 [ 56.697732] Oops[#1]: [ 56.697734] CPU: 2 PID: 2742 Comm: (udev-worker) Tainted: G OE 6.6.0-loong64-desktop #25.00.2000.015 [ 56.697737] Hardware name: Inspur CE520L2/C09901N000000000, BIOS 2.09.00 10/11/2024 [ 56.697739] pc 90000000066e35c8 ra ffff800004f98a80 tp 9000000125478000 sp 900000012547b8a0 [ 56.697741] a0 0000000000000000 a1 ffff800004818b28 a2 0000000000000000 a3 0000000000000000 [ 56.697743] a4 900000012547b8f0 a5 0000000000000000 a6 0000000000000000 a7 0000000000000000 [ 56.697745] t0 ffff800004818b2d t1 0000000000000000 t2 0000000000000003 t3 0000000000000005 [ 56.697747] t4 0000000000000000 t5 0000000000000000 t6 0000000000000000 t7 0000000000000000 [ 56.697748] t8 0000000000000000 u0 0000000000000000 s9 0000000000000000 s0 900000011aa48028 [ 56.697750] s1 0000000000000000 s2 0000000000000000 s3 ffff800004818e80 s4 ffff800004810000 [ 56.697751] s5 90000001000b98d0 s6 ffff800004811f88 s7 ffff800005470440 s8 0000000000000000 [ 56.697753] ra: ffff800004f98a80 wacom_update_name+0xe0/0x300 [wacom] [ 56.697802] ERA: 90000000066e35c8 strstr+0x28/0x120 [ 56.697806] CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE) [ 56.697816] PRMD: 0000000c (PPLV0 +PIE +PWE) [ 56.697821] EUEN: 00000000 (-FPE -SXE -ASXE -BTE) [ 56.697827] ECFG: 00071c1d (LIE=0,2-4,10-12 VS=7) [ 56.697831] ESTAT: 00010000 [PIL] (IS= ECode=1 EsubCode=0) [ 56.697835] BADV: 0000000000000000 [ 56.697836] PRID: 0014d000 (Loongson-64bit, Loongson-3A6000) [ 56.697838] Modules linked in: wacom(+) bnep bluetooth rfkill qrtr nls_iso8859_1 nls_cp437 snd_hda_codec_conexant snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel snd_intel_dspcfg snd_hda_codec snd_hda_core snd_hwdep snd_pcm snd_timer snd soundcore input_leds mousedev led_class joydev deepin_netmonitor(OE) fuse nfnetlink dmi_sysfs ip_tables x_tables overlay amdgpu amdxcp drm_exec gpu_sched drm_buddy radeon drm_suballoc_helper i2c_algo_bit drm_ttm_helper r8169 ttm drm_display_helper spi_loongson_pci xhci_pci cec xhci_pci_renesas spi_loongson_core hid_generic realtek gpio_loongson_64bit [ 56.697887] Process (udev-worker) (pid: 2742, threadinfo=00000000aee0d8b4, task=00000000a9eff1f3) [ 56.697890] Stack : 0000000000000000 ffff800004817e00 0000000000000000 0000251c00000000 [ 56.697896] 0000000000000000 00000011fffffffd 0000000000000000 0000000000000000 [ 56.697901] 0000000000000000 1b67a968695184b9 0000000000000000 90000001000b98d0 [ 56.697906] 90000001000bb8d0 900000011aa48028 0000000000000000 ffff800004f9d74c [ 56.697911] 90000001000ba000 ffff800004f9ce58 0000000000000000 ffff800005470440 [ 56.697916] ffff800004811f88 90000001000b98d0 9000000100da2aa8 90000001000bb8d0 [ 56.697921] 0000000000000000 90000001000ba000 900000011aa48028 ffff800004f9d74c [ 56.697926] ffff8000054704e8 90000001000bb8b8 90000001000ba000 0000000000000000 [ 56.697931] 90000001000bb8d0 9000000006307564 9000000005e666e0 90000001752359b8 [ 56.697936] 9000000008cbe400 900000000804d000 9000000005e666e0 0000000000000000 [ 56.697941] ... [ 56.697944] Call Trace: [ 56.697945] [<90000000066e35c8>] strstr+0x28/0x120 [ 56.697950] [<ffff800004f98a80>] wacom_update_name+0xe0/0x300 [wacom] [ 56.698000] [<ffff800004f9ce58>] wacom_parse_and_register+0x338/0x900 [wacom] [ 56.698050] [<ffff800004f9d74c>] wacom_probe+0x32c/0x420 [wacom] [ 56.698099] [<9000000006307564>] hid_device_probe+0x144/0x260 [ 56.698103] [<9000000005e65d68>] really_probe+0x208/0x540 [ 56.698109] [<9000000005e661dc>] __driver_probe_device+0x13c/0x1e0 [ 56.698112] [<9000000005e66620>] driver_probe_device+0x40/0x100 [ 56.698116] [<9000000005e6680c>] __device_attach_driver+0x12c/0x180 [ 56.698119] [<9000000005e62bc8>] bus_for_each_drv+0x88/0x160 [ 56.698123] [<9000000005e66468>] __device_attach+0x108/0x260 [ 56.698126] [<9000000005e63918>] device_reprobe+0x78/0x100 [ 56.698129] [<9000000005e62a68>] bus_for_each_dev+0x88/0x160 [ 56.698132] [<9000000006304e54>] __hid_bus_driver_added+0x34/0x80 [ 56.698134] [<9000000005e62bc8>] bus_for_each_drv+0x88/0x160 [ 56.698137] [<9000000006304df0>] __hid_register_driver+0x70/0xa0 [ 56.698142] [<9000000004e10fe4>] do_one_initcall+0x104/0x320 [ 56.698146] [<9000000004f38150>] do_init_module+0x90/0x2c0 [ 56.698151] [<9000000004f3a3d8>] init_module_from_file+0xb8/0x120 [ 56.698155] [<9000000004f3a590>] idempotent_init_module+0x150/0x3a0 [ 56.698159] [<9000000004f3a890>] sys_finit_module+0xb0/0x140 [ 56.698163] [<900000000671e4e8>] do_syscall+0x88/0xc0 [ 56.698166] [<9000000004e12404>] handle_syscall+0xc4/0x160 [ 56.698171] Code: 0011958f 00150224 5800cd85 <2a00022c> 00150004 4000c180 0015022c 03400000 03400000 [ 56.698192] ---[ end trace 0000000000000000 ]---
--- drivers/hid/wacom_sys.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/wacom_sys.c +2 -1
@@ -2234,7 +2234,8 @@ static void wacom_update_name(struct wacif (hid_is_usb (wacom->hdev)) {struct usb_interface *intf =to_usb_interface (wacom->hdev->dev.parent);struct usb_device *dev =interface_to_usbdev (intf); - product_name = dev->product; +if (dev->product !=NULL ) + product_name = dev->product; }if (wacom->hdev->bus ==BUS_I2C ) {
Greg Kroah-Hartman
maintainerPATCH 604/772 LoongArch: Add architecture specific huge_pte_clear()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bibo Mao <[email protected]>
commit 7cd1f5f77925ae905a57296932f0f9ef0dc364f8 upstream.
When executing mm selftests run_vmtests.sh, there is such an error:
BUG: Bad page state in process uffd-unit-tests pfn:00000
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x0
flags: 0xffff0000002000(reserved|node=0|zone=0|lastcpupid=0xffff)
raw: 00ffff0000002000 ffffbf0000000008 ffffbf0000000008 0000000000000000
raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: PAGE_FLAGS_CHECK_AT_FREE flag(s) set
Modules linked in: snd_seq_dummy snd_seq snd_seq_device rfkill vfat fat
virtio_balloon efi_pstore virtio_net pstore net_failover failover fuse
nfnetlink virtio_scsi virtio_gpu virtio_dma_buf dm_multipath efivarfs
CPU: 2 UID: 0 PID: 1913 Comm: uffd-unit-tests Not tainted 6.12.0 #184
Hardware name: QEMU QEMU Virtual Machine, BIOS unknown 2/2/2022
Stack : 900000047c8ac000 0000000000000000 9000000000223a7c 900000047c8ac000
900000047c8af690 900000047c8af698 0000000000000000 900000047c8af7d8
900000047c8af7d0 900000047c8af7d0 900000047c8af5b0 0000000000000001
0000000000000001 900000047c8af698 10b3c7d53da40d26 0000010000000000
0000000000000022 0000000fffffffff fffffffffe000000 ffff800000000000
000000000000002f 0000800000000000 000000017a6d4000 90000000028f8940
0000000000000000 0000000000000000 90000000025aa5e0 9000000002905000
0000000000000000 90000000028f8940 ffff800000000000 0000000000000000
0000000000000000 0000000000000000 9000000000223a94 000000012001839c
00000000000000b0 0000000000000004 0000000000000000 0000000000071c1d
...
Call Trace:
[<9000000000223a94>] show_stack+0x5c/0x180
[<9000000001c3fd64>] dump_stack_lvl+0x6c/0xa0
[<900000000056aa08>] bad_page+0x1a0/0x1f0
[<9000000000574978>] free_unref_folios+0xbf0/0xd20
[<90000000004e65cc>] folios_put_refs+0x1a4/0x2b8
[<9000000000599a0c>] free_pages_and_swap_cache+0x164/0x260
[<9000000000547698>] tlb_batch_pages_flush+0xa8/0x1c0
[<9000000000547f30>] tlb_finish_mmu+0xa8/0x218
[<9000000000543cb8>] exit_mmap+0x1a0/0x360
[<9000000000247658>] __mmput+0x78/0x200
[<900000000025583c>] do_exit+0x43c/0xde8
[<9000000000256490>] do_group_exit+0x68/0x110
[<9000000000256554>] sys_exit_group+0x1c/0x20
[<9000000001c413b4>] do_syscall+0x94/0x130
[<90000000002216d8>] handle_syscall+0xb8/0x158
Disabling lock debugging due to kernel taint
BUG: non-zero pgtables_bytes on freeing mm: -16384On LoongArch system, invalid huge pte entry should be invalid_pte_table or a single _PAGE_HUGE bit rather than a zero value. And it should be the same with invalid pmd entry, since pmd_none() is called by function free_pgd_range() and pmd_none() return 0 by huge_pte_clear(). So single _PAGE_HUGE bit is also treated as a valid pte table and free_pte_range() will be called in free_pmd_range().
free_pmd_range()
pmd = pmd_offset(pud, addr);
do {
next = pmd_addr_end(addr, end);
if (pmd_none_or_clear_bad(pmd))
continue;
free_pte_range(tlb, pmd, addr);
} while (pmd++, addr = next, addr != end);Here invalid_pte_table is used for both invalid huge pte entry and pmd entry.
--- arch/loongarch/include/asm/hugetlb.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/loongarch/include/asm/hugetlb.h +10 -0
@@ -29,6 +29,16 @@ static inline int prepare_hugepage_rangereturn 0 ; } +#define __HAVE_ARCH_HUGE_PTE_CLEAR +static inline void huge_pte_clear (struct mm_struct *mm,unsigned long addr, +pte_t *ptep,unsigned long sz) +{ +pte_t clear; + +pte_val (clear) = (unsigned long )invalid_pte_table; +set_pte_at (mm, addr, ptep, clear); +} +#define __HAVE_ARCH_HUGE_PTEP_GET_AND_CLEARstatic inline pte_t huge_ptep_get_and_clear (struct mm_struct *mm,unsigned long addr,pte_t *ptep)
Greg Kroah-Hartman
maintainerPATCH 605/772 ksmbd: fix Out-of-Bounds Read in ksmbd_vfs_stream_read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordy Zomer <[email protected]>
commit fc342cf86e2dc4d2edb0fc2ff5e28b6c7845adb9 upstream.
An offset from client could be a negative value, It could lead to an out-of-bounds read from the stream_buf.
Note that this issue is coming when setting
'vfs objects = streams_xattr parameter' in ksmbd.conf.
--- fs/smb/server/smb2pdu.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/smb/server/smb2pdu.c +4 -0
@@ -6370,6 +6370,10 @@ int smb2_read(struct ksmbd_work *work) } offset =le64_to_cpu (req->Offset); +if (offset <0 ) { + err = -EINVAL ; + goto out; + } length =le32_to_cpu (req->Length); mincount =le32_to_cpu (req->MinimumCount);
Greg Kroah-Hartman
maintainerPATCH 606/772 ksmbd: fix Out-of-Bounds Write in ksmbd_vfs_stream_write
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordy Zomer <[email protected]>
commit 313dab082289e460391c82d855430ec8a28ddf81 upstream.
An offset from client could be a negative value, It could allows to write data outside the bounds of the allocated buffer. Note that this issue is coming when setting
'vfs objects = streams_xattr parameter' in ksmbd.conf.
--- fs/smb/server/smb2pdu.c | 2 ++ 1 file changed, 2 insertions(+)
fs/smb/server/smb2pdu.c +2 -0
@@ -6587,6 +6587,8 @@ int smb2_write(struct ksmbd_work *work) } offset =le64_to_cpu (req->Offset); +if (offset <0 ) +return -EINVAL ; length =le32_to_cpu (req->Length); if (req->Channel == SMB2_CHANNEL_RDMA_V1 ||
Greg Kroah-Hartman
maintainerPATCH 607/772 watchdog: rti: of: honor timeout-sec property
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
commit 4962ee045d8f06638714d801ab0fb72f89c16690 upstream.
Currently "timeout-sec" Device Tree property is being silently ignored:
even though watchdog_init_timeout() is being used, the driver always passes "heartbeat" == DEFAULT_HEARTBEAT == 60 as argument.
Fix this by setting struct watchdog_device::timeout to DEFAULT_HEARTBEAT and passing real module parameter value to watchdog_init_timeout() (which may now be 0 if not specified).
--- drivers/watchdog/rti_wdt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/watchdog/rti_wdt.c +2 -1
@@ -54,7 +54,7 @@#define MAX_HW_ERROR 250 -static int heartbeat =DEFAULT_HEARTBEAT ; +static int heartbeat;/* * struct to hold data for each WDT device
@@ -240,6 +240,7 @@ static int rti_wdt_probe(struct platform wdd->min_timeout =1 ; wdd->max_hw_heartbeat_ms = (WDT_PRELOAD_MAX <<WDT_PRELOAD_SHIFT ) / wdt->freq *1000 ; + wdd->timeout =DEFAULT_HEARTBEAT ; wdd->parent = dev;watchdog_set_drvdata (wdd, wdt);
Greg Kroah-Hartman
maintainerPATCH 608/772 can: dev: can_set_termination(): allow sleeping GPIOs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
commit ee1dfbdd8b4b6de85e96ae2059dc9c1bdb6b49b5 upstream.
In commit 6e86a1543c37 ("can: dev: provide optional GPIO based termination support") GPIO based termination support was added.
For no particular reason that patch uses gpiod_set_value() to set the GPIO. This leads to the following warning, if the systems uses a sleeping GPIO, i.e. behind an I2C port expander:
| WARNING: CPU: 0 PID: 379 at /drivers/gpio/gpiolib.c:3496 gpiod_set_value+0x50/0x6c
| CPU: 0 UID: 0 PID: 379 Comm: ip Not tainted 6.11.0-20241016-1 #1 823affae360cc91126e4d316d7a614a8bf86236c
Replace gpiod_set_value() by gpiod_set_value_cansleep() to allow the use of sleeping GPIOs.
--- drivers/net/can/dev/dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev/dev.c +1 -1
@@ -452,7 +452,7 @@ static int can_set_termination(struct neelse set =0 ; -gpiod_set_value (priv->termination_gpio, set); +gpiod_set_value_cansleep (priv->termination_gpio, set);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 609/772 can: mcp251xfd: mcp251xfd_get_tef_len(): work around erratum DS80000789E 6.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
commit 30447a1bc0e066e492552b3e5ffeb63c1605dfe2 upstream.
Commit b8e0ddd36ce9 ("can: mcp251xfd: tef: prepare to workaround broken TEF FIFO tail index erratum") introduced mcp251xfd_get_tef_len() to get the number of unhandled transmit events from the Transmit Event FIFO (TEF).
As the TEF has no head index, the driver uses the TX-FIFO's tail index instead, assuming that send frames are completed.
When calculating the number of unhandled TEF events, that commit didn't take mcp2518fd erratum DS80000789E 6. into account. According to that erratum, the FIFOCI bits of a FIFOSTA register, here the TX-FIFO tail index might be corrupted.
However here it seems the bit indicating that the TX-FIFO is empty (MCP251XFD_REG_FIFOSTA_TFERFFIF) is not correct while the TX-FIFO tail index is.
Assume that the TX-FIFO is indeed empty if:
- Chip's head and tail index are equal (len == 0).
- The TX-FIFO is less than half full.
(The TX-FIFO empty case has already been checked at the
beginning of this function.)
- No free buffers in the TX ring.
If the TX-FIFO is assumed to be empty, assume that the TEF is full and return the number of elements in the TX-FIFO (which equals the number of TEF elements).
If these assumptions are false, the driver might read to many objects from the TEF. mcp251xfd_handle_tefif_one() checks the sequence numbers and will refuse to process old events.
--- drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/net/can/spi/mcp251xfd/mcp251xfd-tef.c +28 -1
@@ -21,6 +21,11 @@ static inline bool mcp251xfd_tx_fifo_sta_empty(u32 fifo_sta)return fifo_sta &MCP251XFD_REG_FIFOSTA_TFERFFIF ; } +static inline bool mcp251xfd_tx_fifo_sta_less_than_half_full (u32 fifo_sta) +{ +return fifo_sta &MCP251XFD_REG_FIFOSTA_TFHRFHIF ; +} +static inline int mcp251xfd_tef_tail_get_from_chip (const struct mcp251xfd_priv *priv,u8 *tef_tail)
@@ -147,7 +152,29 @@ mcp251xfd_get_tef_len(struct mcp251xfd_priv *priv, u8 *len_p)BUILD_BUG_ON (sizeof (tx_ring->obj_num) !=sizeof (len)); len = (chip_tx_tail << shift) - (tail << shift); - *len_p = len >> shift; + len >>= shift; + +/* According to mcp2518fd erratum DS80000789E 6. the FIFOCI +* bits of a FIFOSTA register, here the TX-FIFO tail index +* might be corrupted. +* +* However here it seems the bit indicating that the TX-FIFO +* is empty (MCP251XFD_REG_FIFOSTA_TFERFFIF) is not correct +* while the TX-FIFO tail index is. +* +* We assume the TX-FIFO is empty, i.e. all pending CAN frames +* haven been send, if: +* - Chip's head and tail index are equal (len == 0). +* - The TX-FIFO is less than half full. +* (The TX-FIFO empty case has already been checked at the +* beginning of this function.) +* - No free buffers in the TX ring. +*/ +if (len ==0 &&mcp251xfd_tx_fifo_sta_less_than_half_full (fifo_sta) && +mcp251xfd_get_tx_free (tx_ring) ==0 ) + len = tx_ring->obj_num; + + *len_p = len;return 0 ; }
Signature · 1 line
2.47.1
Greg Kroah-Hartman
maintainerPATCH 610/772 tracing: Fix cmp_entries_dup() to respect sort() comparison rules
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Wei Chiu <[email protected]>
commit e63fbd5f6810ed756bbb8a1549c7d4132968baa9 upstream.
The cmp_entries_dup() function used as the comparator for sort() violated the symmetry and transitivity properties required by the sorting algorithm. Specifically, it returned 1 whenever memcmp() was non-zero, which broke the following expectations:
* Symmetry: If x < y, then y > x.
* Transitivity: If x < y and y < z, then x < z.
These violations could lead to incorrect sorting and failure to correctly identify duplicate elements.
Fix the issue by directly returning the result of memcmp(), which adheres to the required comparison properties.
--- kernel/trace/tracing_map.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
kernel/trace/tracing_map.c +1 -5
@@ -845,15 +845,11 @@ int tracing_map_init(struct tracing_mapstatic int cmp_entries_dup (const void *A ,const void *B ) {const struct tracing_map_sort_entry *a, *b; -int ret =0 ; a = *(const struct tracing_map_sort_entry **)A ; b = *(const struct tracing_map_sort_entry **)B ; -if (memcmp (a->key, b->key, a->elt->map->key_size)) - ret =1 ; - -return ret; +return memcmp (a->key, b->key, a->elt->map->key_size); }static int cmp_entries_sum (const void *A ,const void *B )
Greg Kroah-Hartman
maintainerPATCH 611/772 arm64: Ensure bits ASID[15:8] are masked out when the kernel uses 8-bit ASIDs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit c0900d15d31c2597dd9f634c8be2b71762199890 upstream.
Linux currently sets the TCR_EL1.AS bit unconditionally during CPU bring-up. On an 8-bit ASID CPU, this is RES0 and ignored, otherwise 16-bit ASIDs are enabled. However, if running in a VM and the hypervisor reports 8-bit ASIDs (ID_AA64MMFR0_EL1.ASIDBits == 0) on a 16-bit ASIDs CPU, Linux uses bits 8 to 63 as a generation number for tracking old process ASIDs. The bottom 8 bits of this generation end up being written to TTBR1_EL1 and also used for the ASID-based TLBI operations as the upper 8 bits of the ASID. Following an ASID roll-over event we can have threads of the same application with the same 8-bit ASID but different generation numbers running on separate CPUs. Both TLB caching and the TLBI operations will end up using different actual 16-bit ASIDs for the same process.
A similar scenario can happen in a big.LITTLE configuration if the boot CPU only uses 8-bit ASIDs while secondary CPUs have 16-bit ASIDs.
Ensure that the ASID generation is only tracked by bits 16 and up, leaving bits 15:8 as 0 if the kernel uses 8-bit ASIDs. Note that clearing TCR_EL1.AS is not sufficient since the architecture requires that the top 8 bits of the ASID passed to TLBI instructions are 0 rather than ignored in such configuration.
--- arch/arm64/mm/context.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/mm/context.c +2 -2
@@ -32,9 +32,9 @@ static unsigned long nr_pinned_asids;static unsigned long *pinned_asid_map;#define ASID_MASK (~GENMASK(asid_bits - 1, 0)) -#define ASID_FIRST_VERSION (1UL << asid_bits) +#define ASID_FIRST_VERSION (1UL << 16) -#define NUM_USER_ASIDS ASID_FIRST_VERSION +#define NUM_USER_ASIDS (1UL << asid_bits)#define ctxid2asid (asid) ((asid) & ~ASID_MASK)#define asid2ctxid (asid, genid) ((asid) | (genid))
Greg Kroah-Hartman
maintainerPATCH 612/772 arm64: ptrace: fix partial SETREGSET for NT_ARM_TAGGED_ADDR_CTRL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit ca62d90085f4af36de745883faab9f8a7cbb45d3 upstream.
Currently tagged_addr_ctrl_set() doesn't initialize the temporary 'ctrl' variable, and a SETREGSET call with a length of zero will leave this uninitialized. Consequently tagged_addr_ctrl_set() will consume an arbitrary value, potentially leaking up to 64 bits of memory from the kernel stack. The read is limited to a specific slot on the stack, and the issue does not provide a write mechanism.
As set_tagged_addr_ctrl() only accepts values where bits [63:4] zero and rejects other values, a partial SETREGSET attempt will randomly succeed or fail depending on the value of the uninitialized value, and the exposure is significantly limited.
Fix this by initializing the temporary value before copying the regset from userspace, as for other regsets (e.g. NT_PRSTATUS, NT_PRFPREG, NT_ARM_SYSTEM_CALL). In the case of a zero-length write, the existing value of the tagged address ctrl will be retained.
The NT_ARM_TAGGED_ADDR_CTRL regset is only visible in the user_aarch64_view used by a native AArch64 task to manipulate another native AArch64 task. As get_tagged_addr_ctrl() only returns an error value when called for a compat task, tagged_addr_ctrl_get() and tagged_addr_ctrl_set() should never observe an error value from get_tagged_addr_ctrl(). Add a WARN_ON_ONCE() to both to indicate that such an error would be unexpected, and error handlnig is not missing in either case.
--- arch/arm64/kernel/ptrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm64/kernel/ptrace.c +5 -1
@@ -1340,7 +1340,7 @@ static int tagged_addr_ctrl_get(struct t {long ctrl =get_tagged_addr_ctrl (target); -if (IS_ERR_VALUE (ctrl)) +if (WARN_ON_ONCE (IS_ERR_VALUE (ctrl)))return ctrl;return membuf_write (&to, &ctrl,sizeof (ctrl));
@@ -1354,6 +1354,10 @@ static int tagged_addr_ctrl_set(struct tint ret;long ctrl; + ctrl =get_tagged_addr_ctrl (target); +if (WARN_ON_ONCE (IS_ERR_VALUE (ctrl))) +return ctrl; + ret =user_regset_copyin (&pos, &count, &kbuf, &ubuf, &ctrl,0 ,-1 );if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 613/772 ALSA: usb-audio: add mixer mapping for Corsair HS80
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marie Ramlow <[email protected]>
commit a7de2b873f3dbcda02d504536f1ec6dc50e3f6c4 upstream.
The Corsair HS80 RGB Wireless is a USB headset with a mic and a sidetone feature. It has the same quirk as the Virtuoso series.
This labels the mixers appropriately, so applications don't move the sidetone volume when they actually intend to move the main headset volume.
--- sound/usb/mixer_maps.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/mixer_maps.c +10 -0
@@ -621,6 +621,16 @@ static const struct usbmix_ctl_map usbmi .id = USB_ID(0x1b1c, 0x0a42), .map = corsair_virtuoso_map, }, + { + /* Corsair HS80 RGB Wireless (wired mode) */ + .id = USB_ID(0x1b1c, 0x0a6a), + .map = corsair_virtuoso_map, + }, + { + /* Corsair HS80 RGB Wireless (wireless mode) */ + .id = USB_ID(0x1b1c, 0x0a6b), + .map = corsair_virtuoso_map, + }, { /* Gigabyte TRX40 Aorus Master (rear panel + front mic) */ .id = USB_ID(0x0414, 0xa001), .map = aorus_master_alc1220vb_map,
Greg Kroah-Hartman
maintainerPATCH 614/772 ALSA: hda/realtek: Enable mute and micmute LED on HP ProBook 430 G8
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nazar Bilinskyi <[email protected]>
commit 3a83f7baf1346aca885cb83cb888e835fef7c472 upstream.
HP ProBook 430 G8 has a mute and micmute LEDs that can be made to work using quirk ALC236_FIXUP_HP_GPIO_LED. Enable already existing quirk.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9766,6 +9766,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x87b7 ,"HP Laptop 14-fq0xxx" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x87c8 ,"HP" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x87d3 ,"HP Laptop 15-gw0xxx" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ), +SND_PCI_QUIRK (0x103c ,0x87df ,"HP ProBook 430 G8 Notebook PC" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x87e5 ,"HP ProBook 440 G8 Notebook PC" ,ALC236_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x87e7 ,"HP ProBook 450 G8 Notebook PC" ,ALC236_FIXUP_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x87f1, "HP ProBook 630 G8 Notebook PC", ALC236_FIXUP_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 615/772 ALSA: hda/realtek: Add support for Samsung Galaxy Book3 360 (NP730QFG)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sahas Leelodharry <[email protected]>
commit e2974a220594c06f536e65dfd7b2447e0e83a1cb upstream.
Fixes the 3.5mm headphone jack on the Samsung Galaxy Book 3 360 NP730QFG laptop.
Unlike the other Galaxy Book3 series devices, this device only needs the ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET quirk. Verified changes on the device and compared with codec state in Windows.
[ white-space fixes by tiwai ]
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -10016,6 +10016,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x144d ,0xc830 ,"Samsung Galaxy Book Ion (NT950XCJ-X716A)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x144d ,0xc832 ,"Samsung Galaxy Book Flex Alpha (NP730QCJ)" ,ALC256_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ),SND_PCI_QUIRK (0x144d ,0xca03 ,"Samsung Galaxy Book2 Pro 360 (NP930QED)" ,ALC298_FIXUP_SAMSUNG_AMP ), +SND_PCI_QUIRK (0x144d ,0xca06 ,"Samsung Galaxy Book3 360 (NP730QFG)" ,ALC298_FIXUP_SAMSUNG_HEADPHONE_VERY_QUIET ),SND_PCI_QUIRK (0x144d ,0xc868 ,"Samsung Galaxy Book2 Pro (NP930XED)" ,ALC298_FIXUP_SAMSUNG_AMP ),SND_PCI_QUIRK (0x1458 ,0xfa53 ,"Gigabyte BXBT-2807" ,ALC283_FIXUP_HEADSET_MIC ), SND_PCI_QUIRK(0x1462, 0xb120, "MSI Cubi MS-B120", ALC283_FIXUP_HEADSET_MIC),
Greg Kroah-Hartman
maintainerPATCH 616/772 scsi: qla2xxx: Fix abort in bsg timeout
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit c423263082ee8ccfad59ab33e3d5da5dc004c21e upstream.
Current abort of bsg on timeout prematurely clears the outstanding_cmds[]. Abort does not allow FW to return the IOCB/SRB. In addition, bsg_job_done() is not called to return the BSG (i.e. leak).
Abort the outstanding bsg/SRB and wait for the completion. The completion IOCB will wake up the bsg_timeout thread. If abort is not successful, then driver will forcibly call bsg_job_done() and free the srb.
Err Inject:
- qaucli -z
- assign CT Passthru IOCB's NportHandle with another initiator nport handle to trigger timeout. Remote port will drop CT request.
- bsg_job_done is properly called as part of cleanup
kernel: qla2xxx [0000:21:00.1]-7012:7: qla2x00_process_ct : 286 : Error Inject.
kernel: qla2xxx [0000:21:00.1]-7016:7: bsg rqst type: FC_BSG_HST_CT else type: 101 - loop-id=1 portid=fffffa.
kernel: qla2xxx [0000:21:00.1]-70bb:7: qla24xx_bsg_timeout CMD timeout. bsg ptr ffff9971a42f0838 msgcode 80000004 vendor cmd fa010000
kernel: qla2xxx [0000:21:00.1]-507c:7: Abort command issued - hdl=4b, type=5
kernel: qla2xxx [0000:21:00.1]-5040:7: ELS-CT pass-through-ct pass-through error hdl=4b comp_status-status=0x5 error subcode 1=0x0 error subcode 2=0xaf882e80.
kernel: qla2xxx [0000:21:00.1]-7009:7: qla2x00_bsg_job_done: sp hdl 4b, result=70000 bsg ptr ffff9971a42f0838
kernel: qla2xxx [0000:21:00.1]-802c:7: Aborting bsg ffff9971a42f0838 sp=ffff99760b87ba80 handle=4b rval=0
kernel: qla2xxx [0000:21:00.1]-708a:7: bsg abort success. bsg ffff9971a42f0838 sp=ffff99760b87ba80 handle=0x4b
kernel: qla2xxx [0000:21:00.1]-7012:7: qla2x00_process_ct : 286 : Error Inject.
kernel: qla2xxx [0000:21:00.1]-7016:7: bsg rqst type: FC_BSG_HST_CT else type: 101 - loop-id=1 portid=fffffa.
kernel: qla2xxx [0000:21:00.1]-70bb:7: qla24xx_bsg_timeout CMD timeout. bsg ptr ffff9971a42f43b8 msgcode 80000004 vendor cmd fa010000
kernel: qla2xxx [0000:21:00.1]-7012:7: qla_bsg_found : 2206 : Error Inject 2.
kernel: qla2xxx [0000:21:00.1]-802c:7: Aborting bsg ffff9971a42f43b8 sp=ffff99762c304440 handle=5e rval=5
kernel: qla2xxx [0000:21:00.1]-704f:7: bsg abort fail. bsg=ffff9971a42f43b8 sp=ffff99762c304440 rval=5.
kernel: qla2xxx [0000:21:00.1]-7051:7: qla_bsg_found bsg_job_done : bsg ffff9971a42f43b8 result 0xfffffffa sp ffff99762c304440.
--- drivers/scsi/qla2xxx/qla_bsg.c | 114 +++++++++++++++++++++++++++++++++-------- 1 file changed, 92 insertions(+), 22 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +92 -22
@@ -24,6 +24,7 @@ void qla2x00_bsg_job_done(srb_t *sp, int {struct bsg_job *bsg_job = sp->u.bsg_job;struct fc_bsg_reply *bsg_reply = bsg_job->reply; +struct completion *comp = sp->comp; ql_dbg(ql_dbg_user, sp->vha, 0x7009, "%s: sp hdl %x, result=%x bsg ptr %p\n",
@@ -35,6 +36,9 @@ void qla2x00_bsg_job_done(srb_t *sp, int bsg_reply->result = res;bsg_job_done (bsg_job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); + +if (comp) +complete (comp); }void qla2x00_bsg_sp_free (srb_t *sp)
@@ -3061,7 +3065,7 @@ skip_chip_chk:static bool qla_bsg_found (struct qla_qpair *qpair,struct bsg_job *bsg_job) { -bool found = false; +bool found, do_bsg_done;struct fc_bsg_reply *bsg_reply = bsg_job->reply;scsi_qla_host_t *vha =shost_priv (fc_bsg_to_shost (bsg_job));struct qla_hw_data *ha = vha->hw;
@@ -3069,6 +3073,11 @@ static bool qla_bsg_found(struct qla_qpaint cnt;unsigned long flags;struct req_que *req; +int rval; +DECLARE_COMPLETION_ONSTACK (comp); +uint32_t ratov_j; + + found = do_bsg_done = false;spin_lock_irqsave (qpair->qp_lock_ptr, flags); req = qpair->req;
@@ -3080,42 +3089,104 @@ static bool qla_bsg_found(struct qla_qpa sp->type == SRB_ELS_CMD_HST || sp->type == SRB_ELS_CMD_HST_NOLOGIN) && sp->u.bsg_job == bsg_job) { - req->outstanding_cmds[cnt] = NULL; -spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); - -if (!ha->flags.eeh_busy && ha->isp_ops->abort_command (sp)) { -ql_log (ql_log_warn, vha,0x7089 , -"mbx abort_command failed.\n" ); - bsg_reply->result = -EIO ; - }else { -ql_dbg (ql_dbg_user, vha,0x708a , -"mbx abort_command success.\n" ); - bsg_reply->result =0 ; - } -/* ref: INIT */ -kref_put (&sp->cmd_kref, qla2x00_sp_release); found = true; - goto done; + sp->comp = ∁ +break ; } }spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); -done: -return found; +if (!found) +return false; + +if (ha->flags.eeh_busy) { +/* skip over abort. EEH handling will return the bsg. Wait for it */ + rval =QLA_SUCCESS ; +ql_dbg (ql_dbg_user, vha,0x802c , +"eeh encounter. bsg %p sp=%p handle=%x \n" , + bsg_job, sp, sp->handle); + }else { + rval = ha->isp_ops->abort_command (sp); +ql_dbg (ql_dbg_user, vha,0x802c , +"Aborting bsg %p sp=%p handle=%x rval=%x\n" , + bsg_job, sp, sp->handle, rval); + } + +switch (rval) { +case QLA_SUCCESS : +/* Wait for the command completion. */ + ratov_j = ha->r_a_tov /10 *4 *1000 ; + ratov_j =msecs_to_jiffies (ratov_j); + +if (!wait_for_completion_timeout (&comp, ratov_j)) { +ql_log (ql_log_info, vha,0x7089 , +"bsg abort timeout. bsg=%p sp=%p handle %#x .\n" , + bsg_job, sp, sp->handle); + + do_bsg_done = true; + }else { +/* fw had returned the bsg */ +ql_dbg (ql_dbg_user, vha,0x708a , +"bsg abort success. bsg %p sp=%p handle=%#x\n" , + bsg_job, sp, sp->handle); + do_bsg_done = false; + } +break ; +default : +ql_log (ql_log_info, vha,0x704f , +"bsg abort fail. bsg=%p sp=%p rval=%x.\n" , + bsg_job, sp, rval); + + do_bsg_done = true; +break ; + } + +if (!do_bsg_done) +return true; + +spin_lock_irqsave (qpair->qp_lock_ptr, flags); +/* +* recheck to make sure it's still the same bsg_job due to +* qp_lock_ptr was released earlier. +*/ +if (req->outstanding_cmds[cnt] && + req->outstanding_cmds[cnt]->u.bsg_job != bsg_job) { +/* fw had returned the bsg */ +spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); +return true; + } + req->outstanding_cmds[cnt] =NULL ; +spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); + +/* ref: INIT */ + sp->comp =NULL ; +kref_put (&sp->cmd_kref, qla2x00_sp_release); + bsg_reply->result = -ENXIO ; + bsg_reply->reply_payload_rcv_len =0 ; + +ql_dbg (ql_dbg_user, vha,0x7051 , +"%s bsg_job_done : bsg %p result %#x sp %p.\n" , + __func__, bsg_job, bsg_reply->result, sp); + +bsg_job_done (bsg_job, bsg_reply->result, bsg_reply->reply_payload_rcv_len); + +return true; }int qla24xx_bsg_timeout (struct bsg_job *bsg_job) { -struct fc_bsg_reply *bsg_reply = bsg_job->reply; +struct fc_bsg_request *bsg_request = bsg_job->request;scsi_qla_host_t *vha =shost_priv (fc_bsg_to_shost (bsg_job));struct qla_hw_data *ha = vha->hw;int i;struct qla_qpair *qpair; -ql_log (ql_log_info, vha,0x708b ,"%s CMD timeout. bsg ptr %p.\n" , - __func__, bsg_job); +ql_log (ql_log_info, vha,0x708b , +"%s CMD timeout. bsg ptr %p msgcode %x vendor cmd %x\n" , + __func__, bsg_job, bsg_request->msgcode, + bsg_request->rqst_data.h_vendor.vendor_cmd[0 ]);if (qla2x00_isp_reg_stat (ha)) { ql_log(ql_log_info, vha, 0x9007,
@@ -3136,7 +3207,6 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_ }ql_log (ql_log_info, vha,0x708b ,"SRB not found to abort.\n" ); - bsg_reply->result = -ENXIO ; done:return 0 ;
Greg Kroah-Hartman
maintainerPATCH 617/772 scsi: qla2xxx: Fix NVMe and NPIV connect issue
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 4812b7796c144f63a1094f79a5eb8fbdad8d7ebc upstream.
NVMe controller fails to send connect command due to failure to locate hw context buffer for NVMe queue 0 (blk_mq_hw_ctx, hctx_idx=0). The cause of the issue is NPIV host did not initialize the vha->irq_offset field. This field is given to blk-mq (blk_mq_pci_map_queues) to help locate the beginning of IO Queues which in turn help locate NVMe queue 0.
Initialize this field to allow NVMe to work properly with NPIV host.
kernel: nvme nvme5: Connect command failed, errno: -18
kernel: nvme nvme5: qid 0: secure concatenation is not supported
kernel: nvme nvme5: NVME-FC{5}: create_assoc failed, assoc_id 2e9100 ret 401
kernel: nvme nvme5: NVME-FC{5}: reset: Reconnect attempt failed (401)
kernel: nvme nvme5: NVME-FC{5}: Reconnect attempt in 2 seconds
--- drivers/scsi/qla2xxx/qla_mid.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_mid.c +1 -0
@@ -515,6 +515,7 @@ qla24xx_create_vhost(struct fc_vport *fcreturn (NULL ); } + vha->irq_offset =QLA_BASE_VECTORS ; host = vha->host; fc_vport->dd_data = vha;/* New host info */
Greg Kroah-Hartman
maintainerPATCH 618/772 scsi: qla2xxx: Supported speed displayed incorrectly for VPorts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anil Gurumurthy <[email protected]>
commit e4e268f898c8a08f0a1188677e15eadbc06e98f6 upstream.
The fc_function_template for vports was missing the .show_host_supported_speeds. The base port had the same.
Add .show_host_supported_speeds to the vport template as well.
--- drivers/scsi/qla2xxx/qla_attr.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/qla2xxx/qla_attr.c +1 -0
@@ -3312,6 +3312,7 @@ struct fc_function_template qla2xxx_tran .show_host_node_name = 1, .show_host_port_name = 1, .show_host_supported_classes = 1, + .show_host_supported_speeds = 1, .get_host_port_id = qla2x00_get_host_port_id, .show_host_port_id = 1,
Greg Kroah-Hartman
maintainerPATCH 619/772 scsi: qla2xxx: Fix use after free on unload
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 07c903db0a2ff84b68efa1a74a4de353ea591eb0 upstream.
System crash is observed with stack trace warning of use after free. There are 2 signals to tell dpc_thread to terminate (UNLOADING flag and kthread_stop).
On setting the UNLOADING flag when dpc_thread happens to run at the time and sees the flag, this causes dpc_thread to exit and clean up itself. When kthread_stop is called for final cleanup, this causes use after free.
Remove UNLOADING signal to terminate dpc_thread. Use the kthread_stop as the main signal to exit dpc_thread.
[596663.812935] kernel BUG at mm/slub.c:294! [596663.812950] invalid opcode: 0000 [#1] SMP PTI [596663.812957] CPU: 13 PID: 1475935 Comm: rmmod Kdump: loaded Tainted: G IOE --------- - - 4.18.0-240.el8.x86_64 #1 [596663.812960] Hardware name: HP ProLiant DL380p Gen8, BIOS P70 08/20/2012 [596663.812974] RIP: 0010:__slab_free+0x17d/0x360
...
[596663.813008] Call Trace: [596663.813022] ? __dentry_kill+0x121/0x170 [596663.813030] ? _cond_resched+0x15/0x30 [596663.813034] ? _cond_resched+0x15/0x30 [596663.813039] ? wait_for_completion+0x35/0x190 [596663.813048] ? try_to_wake_up+0x63/0x540 [596663.813055] free_task+0x5a/0x60 [596663.813061] kthread_stop+0xf3/0x100 [596663.813103] qla2x00_remove_one+0x284/0x440 [qla2xxx]
--- drivers/scsi/qla2xxx/qla_os.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +8 -7
@@ -6883,12 +6883,15 @@ qla2x00_do_dpc(void *data)set_user_nice (current,MIN_NICE );set_current_state (TASK_INTERRUPTIBLE ); -while (!kthread_should_stop ()) { +while (1 ) {ql_dbg (ql_dbg_dpc, base_vha,0x4000 ,"DPC handler sleeping.\n" );schedule (); +if (kthread_should_stop ()) +break ; +if (test_and_clear_bit (DO_EEH_RECOVERY , &base_vha->dpc_flags))qla_pci_set_eeh_busy (base_vha);
@@ -6901,15 +6904,16 @@ qla2x00_do_dpc(void *data) goto end_loop; } +if (test_bit (UNLOADING , &base_vha->dpc_flags)) +/* don't do any work. Wait to be terminated by kthread_stop */ + goto end_loop; + ha->dpc_active =1 ;ql_dbg (ql_dbg_dpc + ql_dbg_verbose, base_vha,0x4001 ,"DPC handler waking up, dpc_flags=0x%lx.\n" , base_vha->dpc_flags); -if (test_bit (UNLOADING , &base_vha->dpc_flags)) -break ; -if (IS_P3P_TYPE (ha)) {if (IS_QLA8044 (ha)) { if (test_and_clear_bit(ISP_UNRECOVERABLE,
@@ -7227,9 +7231,6 @@ end_loop:*/ ha->dpc_active =0 ; -/* Cleanup any residual CTX SRBs. */ -qla2x00_abort_all_cmds (base_vha,DID_NO_CONNECT <<16 ); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 620/772 scsi: qla2xxx: Remove check req_sg_cnt should be equal to rsp_sg_cnt
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit 833c70e212fc40d3e98da941796f4c7bcaecdf58 upstream.
Firmware supports multiple sg_cnt for request and response for CT commands, so remove the redundant check. A check is there where sg_cnt for request and response should be same. This is not required as driver and FW have code to handle multiple and different sg_cnt on request and response.
--- drivers/scsi/qla2xxx/qla_bsg.c | 10 ---------- 1 file changed, 10 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +0 -10
@@ -494,16 +494,6 @@ qla2x00_process_ct(struct bsg_job *bsg_j goto done; } -if ((req_sg_cnt != bsg_job->request_payload.sg_cnt) || - (rsp_sg_cnt != bsg_job->reply_payload.sg_cnt)) { -ql_log (ql_log_warn, vha,0x7011 , -"request_sg_cnt: %x dma_request_sg_cnt: %x reply_sg_cnt:%x " -"dma_reply_sg_cnt: %x\n" , bsg_job->request_payload.sg_cnt, - req_sg_cnt, bsg_job->reply_payload.sg_cnt, rsp_sg_cnt); - rval = -EAGAIN ; - goto done_unmap_sg; - } -if (!vha->flags.online) {ql_log (ql_log_warn, vha,0x7012 ,"Host is not online.\n" );
Greg Kroah-Hartman
maintainerPATCH 621/772 scsi: ufs: core: sysfs: Prevent div by zero
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gwendal Grignou <[email protected]>
commit eb48e9fc0028bed94a40a9352d065909f19e333c upstream.
Prevent a division by 0 when monitoring is not enabled.
--- drivers/ufs/core/ufs-sysfs.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/ufs/core/ufs-sysfs.c +6 -0
@@ -452,6 +452,9 @@ static ssize_t read_req_latency_avg_showstruct ufs_hba *hba =dev_get_drvdata (dev);struct ufs_hba_monitor *m = &hba->monitor; +if (!m->nr_req[READ ]) +return sysfs_emit (buf,"0\n" ); +return sysfs_emit (buf,"%llu\n" ,div_u64 (ktime_to_us (m->lat_sum[READ ]), m->nr_req[READ ])); }
@@ -519,6 +522,9 @@ static ssize_t write_req_latency_avg_shostruct ufs_hba *hba =dev_get_drvdata (dev);struct ufs_hba_monitor *m = &hba->monitor; +if (!m->nr_req[WRITE ]) +return sysfs_emit (buf,"0\n" ); +return sysfs_emit (buf,"%llu\n" ,div_u64 (ktime_to_us (m->lat_sum[WRITE ]), m->nr_req[WRITE ])); }
Greg Kroah-Hartman
maintainerPATCH 622/772 scsi: ufs: core: Add missing post notify for power mode change
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Wang <[email protected]>
commit 7f45ed5f0cd5ccbbec79adc6c48a67d6a85fba56 upstream.
When the power mode change is successful but the power mode hasn't actually changed, the post notification was missed. Similar to the approach with hibernate/clock scale/hce enable, having pre/post notifications in the same function will make it easier to maintain.
Additionally, supplement the description of power parameters for the pwr_change_notify callback.
--- drivers/ufs/core/ufshcd.c | 7 ++++--- include/ufs/ufshcd.h | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/ufs/core/ufshcd.c +4 -3
@@ -4449,9 +4449,6 @@ static int ufshcd_change_power_mode(strudev_err (hba->dev,"%s: power mode change failed %d\n" , __func__, ret); }else { -ufshcd_vops_pwr_change_notify (hba,POST_CHANGE ,NULL , - pwr_mode); -memcpy (&hba->pwr_info, pwr_mode,sizeof (struct ufs_pa_layer_attr )); }
@@ -4478,6 +4475,10 @@ int ufshcd_config_pwr_mode(struct ufs_hb ret =ufshcd_change_power_mode (hba, &final_params); +if (!ret) +ufshcd_vops_pwr_change_notify (hba,POST_CHANGE ,NULL , + &final_params); +return ret; }EXPORT_SYMBOL_GPL (ufshcd_config_pwr_mode);
include/ufs/ufshcd.h +6 -4
@@ -281,7 +281,9 @@ struct ufs_pwr_mode_info {* to allow variant specific Uni-Pro initialization. * @pwr_change_notify: called before and after a power mode change * is carried out to allow vendor spesific capabilities -* to be set. +* to be set. PRE_CHANGE can modify final_params based +* on desired_pwr_mode, but POST_CHANGE must not alter +* the final_params parameter * @setup_xfer_req: called before any transfer request is issued * to set some things * @setup_task_mgmt: called before any task management request is issued
@@ -312,9 +314,9 @@ struct ufs_hba_variant_ops {int (*link_startup_notify)(struct ufs_hba *,enum ufs_notify_change_status );int (*pwr_change_notify)(struct ufs_hba *, -enum ufs_notify_change_status status, -struct ufs_pa_layer_attr *, -struct ufs_pa_layer_attr *); +enum ufs_notify_change_status status, +struct ufs_pa_layer_attr *desired_pwr_mode, +struct ufs_pa_layer_attr *final_params);void (*setup_xfer_req)(struct ufs_hba *hba,int tag,bool is_scsi_cmd);void (*setup_task_mgmt)(struct ufs_hba *,int ,u8 );
Greg Kroah-Hartman
maintainerPATCH 623/772 nilfs2: fix potential out-of-bounds memory access in nilfs_find_entry()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
commit 985ebec4ab0a28bb5910c3b1481a40fbf7f9e61d upstream.
Syzbot reported that when searching for records in a directory where the inode's i_size is corrupted and has a large value, memory access outside the folio/page range may occur, or a use-after-free bug may be detected if KASAN is enabled.
This is because nilfs_last_byte(), which is called by nilfs_find_entry() and others to calculate the number of valid bytes of directory data in a page from i_size and the page index, loses the upper 32 bits of the 64-bit size information due to an inappropriate type of local variable to which the i_size value is assigned.
This caused a large byte offset value due to underflow in the end address calculation in the calling nilfs_find_entry(), resulting in memory access that exceeds the folio/page size.
Fix this issue by changing the type of the local variable causing the bit loss from "unsigned int" to "u64". The return value of nilfs_last_byte() is also of type "unsigned int", but it is truncated so as not to exceed PAGE_SIZE and no bit loss occurs, so no change is required.
--- fs/nilfs2/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/dir.c +1 -1
@@ -76,7 +76,7 @@ static inline void nilfs_put_page(struct*/ static unsigned int nilfs_last_byte (struct inode *inode,unsigned long page_nr) { -unsigned int last_byte = inode->i_size; +u64 last_byte = inode->i_size; last_byte -= page_nr <<PAGE_SHIFT ;if (last_byte >PAGE_SIZE )
Greg Kroah-Hartman
maintainerPATCH 624/772 bcache: revert replacing IS_ERR_OR_NULL with IS_ERR again
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liequan Che <[email protected]>
commit b2e382ae12a63560fca35050498e19e760adf8c0 upstream.
Commit 028ddcac477b ("bcache: Remove unnecessary NULL point check in node allocations") leads a NULL pointer deference in cache_set_flush().
1721 if (!IS_ERR_OR_NULL(c->root))
1722 list_add(&c->root->list, &c->btree_cache);
Quoted 1 line
From the above code in
cache_set_flush(), if previous registration code
fails before allocating c->root, it is possible c->root is NULL as what it is initialized. __bch_btree_node_alloc() never returns NULL but c->root is possible to be NULL at above line 1721.
This patch replaces IS_ERR() by IS_ERR_OR_NULL() to fix this.
--- drivers/md/bcache/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/bcache/super.c +1 -1
@@ -1726,7 +1726,7 @@ static void cache_set_flush(struct closuif (!IS_ERR_OR_NULL (c->gc_thread))kthread_stop (c->gc_thread); -if (!IS_ERR (c->root)) +if (!IS_ERR_OR_NULL (c->root))list_add (&c->root->list, &c->btree_cache);/*
Greg Kroah-Hartman
maintainerPATCH 625/772 drm/dp_mst: Fix MST sideband message body length check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit bd2fccac61b40eaf08d9546acc9fef958bfe4763 upstream.
Fix the MST sideband message body length check, which must be at least 1 byte accounting for the message body CRC (aka message data CRC) at the end of the message.
This fixes a case where an MST branch device returns a header with a correct header CRC (indicating a correctly received body length), with the body length being incorrectly set to 0. This will later lead to a memory corruption in drm_dp_sideband_append_payload() and the following errors in dmesg:
UBSAN: array-index-out-of-bounds in drivers/gpu/drm/display/drm_dp_mst_topology.c:786:25
index -1 is out of range for type 'u8 [48]'
Call Trace:
drm_dp_sideband_append_payload+0x33d/0x350 [drm_display_helper]
drm_dp_get_one_sb_msg+0x3ce/0x5f0 [drm_display_helper]
drm_dp_mst_hpd_irq_handle_event+0xc8/0x1580 [drm_display_helper] memcpy: detected field-spanning write (size 18446744073709551615) of single field "&msg->msg[msg->curlen]" at drivers/gpu/drm/display/drm_dp_mst_topology.c:791 (size 256)
Call Trace:
drm_dp_sideband_append_payload+0x324/0x350 [drm_display_helper]
drm_dp_get_one_sb_msg+0x3ce/0x5f0 [drm_display_helper]
drm_dp_mst_hpd_irq_handle_event+0xc8/0x1580 [drm_display_helper]--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/display/drm_dp_mst_topology.c +3 -0
@@ -319,6 +319,9 @@ static bool drm_dp_decode_sideband_msg_h hdr->broadcast = (buf[idx] >>7 ) &0x1 ; hdr->path_msg = (buf[idx] >>6 ) &0x1 ; hdr->msg_len = buf[idx] &0x3f ; +if (hdr->msg_len <1 )/* min space for body CRC */ +return false; + idx++; hdr->somt = (buf[idx] >>7 ) &0x1 ; hdr->eomt = (buf[idx] >>6 ) &0x1 ;
Greg Kroah-Hartman
maintainerPATCH 626/772 drm/dp_mst: Verify request type in the corresponding down message reply
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit 4d49e77a973d3b5d1881663c3f122906a0702940 upstream.
After receiving the response for an MST down request message, the response should be accepted/parsed only if the response type matches that of the request. Ensure this by checking if the request type code stored both in the request and the reply match, dropping the reply in case of a mismatch.
This fixes the topology detection for an MST hub, as described in the Closes link below, where the hub sends an incorrect reply message after a CLEAR_PAYLOAD_TABLE -> LINK_ADDRESS down request message sequence.
--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/gpu/drm/display/drm_dp_mst_topology.c +31 -0
@@ -3862,6 +3862,34 @@ drm_dp_get_one_sb_msg(struct drm_dp_mst_return true; } +static int get_msg_request_type (u8 data) +{ +return data &0x7f ; +} + +static bool verify_rx_request_type (struct drm_dp_mst_topology_mgr *mgr, +const struct drm_dp_sideband_msg_tx *txmsg, +const struct drm_dp_sideband_msg_rx *rxmsg) +{ +const struct drm_dp_sideband_msg_hdr *hdr = &rxmsg->initial_hdr; +const struct drm_dp_mst_branch *mstb = txmsg->dst; +int tx_req_type =get_msg_request_type (txmsg->msg[0 ]); +int rx_req_type =get_msg_request_type (rxmsg->msg[0 ]); +char rad_str[64 ]; + +if (tx_req_type == rx_req_type) +return true; + +drm_dp_mst_rad_to_str (mstb->rad, mstb->lct, rad_str,sizeof (rad_str)); +drm_dbg_kms (mgr->dev, +"Got unexpected MST reply, mstb: %p seqno: %d lct: %d rad: %s rx_req_type: %s (%02x) != tx_req_type: %s (%02x)\n" , + mstb, hdr->seqno, mstb->lct, rad_str, +drm_dp_mst_req_type_str (rx_req_type), rx_req_type, +drm_dp_mst_req_type_str (tx_req_type), tx_req_type); + +return false; +} +static int drm_dp_mst_handle_down_rep (struct drm_dp_mst_topology_mgr *mgr) {struct drm_dp_sideband_msg_tx *txmsg;
@@ -3891,6 +3919,9 @@ static int drm_dp_mst_handle_down_rep(st goto out_clear_reply; } +if (!verify_rx_request_type (mgr, txmsg, msg)) + goto out_clear_reply; +drm_dp_sideband_parse_reply (mgr, msg, &txmsg->reply);if (txmsg->reply.reply_type ==DP_SIDEBAND_REPLY_NAK ) {
Greg Kroah-Hartman
maintainerPATCH 627/772 drm/dp_mst: Fix resetting msg rx state after topology removal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit a6fa67d26de385c3c7a23c1e109a0e23bfda4ec7 upstream.
If the MST topology is removed during the reception of an MST down reply or MST up request sideband message, the drm_dp_mst_topology_mgr::up_req_recv/down_rep_recv states could be reset from one thread via drm_dp_mst_topology_mgr_set_mst(false), racing with the reading/parsing of the message from another thread via drm_dp_mst_handle_down_rep() or drm_dp_mst_handle_up_req(). The race is possible since the reader/parser doesn't hold any lock while accessing the reception state. This in turn can lead to a memory corruption in the reader/parser as described by commit bd2fccac61b4 ("drm/dp_mst: Fix MST sideband message body length check").
Fix the above by resetting the message reception state if needed before reading/parsing a message. Another solution would be to hold the drm_dp_mst_topology_mgr::lock for the whole duration of the message reception/parsing in drm_dp_mst_handle_down_rep() and drm_dp_mst_handle_up_req(), however this would require a bigger change. Since the fix is also needed for stable, opting for the simpler solution in this patch.
--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 21 +++++++++++++++++++-- include/drm/display/drm_dp_mst_helper.h | 7 +++++++ 2 files changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +19 -2
@@ -3655,8 +3655,7 @@ int drm_dp_mst_topology_mgr_set_mst(stru ret =0 ; mgr->payload_id_table_cleared = false; -memset (&mgr->down_rep_recv,0 ,sizeof (mgr->down_rep_recv)); -memset (&mgr->up_req_recv,0 ,sizeof (mgr->up_req_recv)); + mgr->reset_rx_state = true; } out_unlock:
@@ -3784,6 +3783,11 @@ out_fail: }EXPORT_SYMBOL (drm_dp_mst_topology_mgr_resume); +static void reset_msg_rx_state (struct drm_dp_sideband_msg_rx *msg) +{ +memset (msg,0 ,sizeof (*msg)); +} +static bool drm_dp_get_one_sb_msg (struct drm_dp_mst_topology_mgr *mgr,bool up,struct drm_dp_mst_branch **mstb)
@@ -4097,6 +4101,17 @@ out:return 0 ; } +static void update_msg_rx_state (struct drm_dp_mst_topology_mgr *mgr) +{ +mutex_lock (&mgr->lock); +if (mgr->reset_rx_state) { + mgr->reset_rx_state = false; +reset_msg_rx_state (&mgr->down_rep_recv); +reset_msg_rx_state (&mgr->up_req_recv); + } +mutex_unlock (&mgr->lock); +} +/** * drm_dp_mst_hpd_irq_handle_event() - MST hotplug IRQ handle MST event * @mgr: manager to notify irq for.
@@ -4131,6 +4146,8 @@ int drm_dp_mst_hpd_irq_handle_event(stru *handled = true; } +update_msg_rx_state (mgr); +if (esi[1 ] &DP_DOWN_REP_MSG_RDY ) { ret =drm_dp_mst_handle_down_rep (mgr); *handled = true;
include/drm/display/drm_dp_mst_helper.h +7 -0
@@ -695,6 +695,13 @@ struct drm_dp_mst_topology_mgr { bool payload_id_table_cleared : 1;/** +* @reset_rx_state: The down request's reply and up request message +* receiver state must be reset, after the topology manager got +* removed. Protected by @lock. +*/ + bool reset_rx_state : 1; + +/** * @payload_count: The number of currently active payloads in hardware. This value is only * intended to be used internally by MST helpers for payload tracking, and is only safe to * read/write from the atomic commit (not check) context.
Greg Kroah-Hartman
maintainerPATCH 628/772 drm/amdgpu/hdp5.2: do a posting read when flushing HDP
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit f756dbac1ce1d5f9a2b35e3b55fa429cf6336437 upstream.
Need to read back to make sure the write goes through.
--- drivers/gpu/drm/amd/amdgpu/hdp_v5_2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/hdp_v5_2.c +4 -2
@@ -31,13 +31,15 @@static void hdp_v5_2_flush_hdp (struct amdgpu_device *adev,struct amdgpu_ring *ring) { -if (!ring || !ring->funcs->emit_wreg) +if (!ring || !ring->funcs->emit_wreg) {WREG32_NO_KIQ ((adev->rmmio_remap.reg_offset +KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL ) >>2 ,0 ); -else +RREG32_NO_KIQ ((adev->rmmio_remap.reg_offset +KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL ) >>2 ); + }else {amdgpu_ring_emit_wreg (ring, (adev->rmmio_remap.reg_offset +KFD_MMIO_REMAP_HDP_MEM_FLUSH_CNTL ) >>2 ,0 ); + } } static void hdp_v5_2_update_mem_power_gating(struct amdgpu_device *adev,
Greg Kroah-Hartman
maintainerPATCH 629/772 modpost: Add .irqentry.text to OTHER_SECTIONS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 7912405643a14b527cd4a4f33c1d4392da900888 upstream.
The compiler can fully inline the actual handler function of an interrupt entry into the .irqentry.text entry point. If such a function contains an access which has an exception table entry, modpost complains about a section mismatch:
WARNING: vmlinux.o(__ex_table+0x447c): Section mismatch in reference ...
The relocation at __ex_table+0x447c references section ".irqentry.text" which is not in the list of authorized sections.
Add .irqentry.text to OTHER_SECTIONS to cure the issue.
--- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/mod/modpost.c +1 -1
@@ -829,7 +829,7 @@ static void check_section(const char *mo ".ltext", ".ltext.*"#define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ ".fixup", ".entry.text", ".exception.text", \ - ".coldtext", ".softirqentry.text" + ".coldtext", ".softirqentry.text", ".irqentry.text"#define INIT_SECTIONS ".init.*"#define MEM_INIT_SECTIONS ".meminit.*"
Greg Kroah-Hartman
maintainerPATCH 630/772 bpf: fix OOB devmap writes when deleting elements
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Fijalkowski <[email protected]>
commit ab244dd7cf4c291f82faacdc50b45cc0f55b674d upstream.
Jordy reported issue against XSKMAP which also applies to DEVMAP - the index used for accessing map entry, due to being a signed integer, causes the OOB writes. Fix is simple as changing the type from int to u32, however, when compared to XSKMAP case, one more thing needs to be addressed.
When map is released from system via dev_map_free(), we iterate through all of the entries and an iterator variable is also an int, which implies OOB accesses. Again, change it to be u32.
Example splat below:
[ 160.724676] BUG: unable to handle page fault for address: ffffc8fc2c001000 [ 160.731662] #PF: supervisor read access in kernel mode [ 160.736876] #PF: error_code(0x0000) - not-present page [ 160.742095] PGD 0 P4D 0 [ 160.744678] Oops: Oops: 0000 [#1] PREEMPT SMP [ 160.749106] CPU: 1 UID: 0 PID: 520 Comm: kworker/u145:12 Not tainted 6.12.0-rc1+ #487 [ 160.757050] Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.02.01.0008.031920191559 03/19/2019 [ 160.767642] Workqueue: events_unbound bpf_map_free_deferred [ 160.773308] RIP: 0010:dev_map_free+0x77/0x170 [ 160.777735] Code: 00 e8 fd 91 ed ff e8 b8 73 ed ff 41 83 7d 18 19 74 6e 41 8b 45 24 49 8b bd f8 00 00 00 31 db 85 c0 74 48 48 63 c3 48 8d 04 c7 <48> 8b 28 48 85 ed 74 30 48 8b 7d 18 48 85 ff 74 05 e8 b3 52 fa ff [ 160.796777] RSP: 0018:ffffc9000ee1fe38 EFLAGS: 00010202 [ 160.802086] RAX: ffffc8fc2c001000 RBX: 0000000080000000 RCX: 0000000000000024 [ 160.809331] RDX: 0000000000000000 RSI: 0000000000000024 RDI: ffffc9002c001000 [ 160.816576] RBP: 0000000000000000 R08: 0000000000000023 R09: 0000000000000001 [ 160.823823] R10: 0000000000000001 R11: 00000000000ee6b2 R12: dead000000000122 [ 160.831066] R13: ffff88810c928e00 R14: ffff8881002df405 R15: 0000000000000000 [ 160.838310] FS: 0000000000000000(0000) GS:ffff8897e0c40000(0000) knlGS:0000000000000000 [ 160.846528] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 160.852357] CR2: ffffc8fc2c001000 CR3: 0000000005c32006 CR4: 00000000007726f0 [ 160.859604] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 160.866847] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 160.874092] PKRU: 55555554 [ 160.876847] Call Trace: [ 160.879338] <TASK> [ 160.881477] ? __die+0x20/0x60 [ 160.884586] ? page_fault_oops+0x15a/0x450 [ 160.888746] ? search_extable+0x22/0x30 [ 160.892647] ? search_bpf_extables+0x5f/0x80 [ 160.896988] ? exc_page_fault+0xa9/0x140 [ 160.900973] ? asm_exc_page_fault+0x22/0x30 [ 160.905232] ? dev_map_free+0x77/0x170 [ 160.909043] ? dev_map_free+0x58/0x170 [ 160.912857] bpf_map_free_deferred+0x51/0x90 [ 160.917196] process_one_work+0x142/0x370 [ 160.921272] worker_thread+0x29e/0x3b0 [ 160.925082] ? rescuer_thread+0x4b0/0x4b0 [ 160.929157] kthread+0xd4/0x110 [ 160.932355] ? kthread_park+0x80/0x80 [ 160.936079] ret_from_fork+0x2d/0x50 [ 160.943396] ? kthread_park+0x80/0x80 [ 160.950803] ret_from_fork_asm+0x11/0x20 [ 160.958482] </TASK>
--- kernel/bpf/devmap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/bpf/devmap.c +3 -3
@@ -184,7 +184,7 @@ static struct bpf_map *dev_map_alloc(unistatic void dev_map_free (struct bpf_map *map) { struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map); -int i; +u32 i;/* At this point bpf_prog->aux->refcnt == 0 and this map->refcnt == 0, * so the programs (can be more than one that used this map) were
@@ -807,7 +807,7 @@ static int dev_map_delete_elem(struct bp { struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);struct bpf_dtab_netdev *old_dev; -int k = *(u32 *)key; +u32 k = *(u32 *)key;if (k >= map->max_entries)return -EINVAL ;
@@ -822,7 +822,7 @@ static int dev_map_hash_delete_elem(stru { struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);struct bpf_dtab_netdev *old_dev; -int k = *(u32 *)key; +u32 k = *(u32 *)key;unsigned long flags;int ret = -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 631/772 dma-buf: fix dma_fence_array_signaled v4
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 78ac1c3558810486d90aa533b0039aa70487a3da upstream.
The function silently assumed that signaling was already enabled for the dma_fence_array. This meant that without enabling signaling first we would never see forward progress.
Fix that by falling back to testing each individual fence when signaling isn't enabled yet.
v2: add the comment suggested by Boris why this is done this way
v3: fix the underflow pointed out by Tvrtko
v4: atomic_read_acquire() as suggested by Tvrtko
--- drivers/dma-buf/dma-fence-array.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/dma-buf/dma-fence-array.c +27 -1
@@ -103,10 +103,36 @@ static bool dma_fence_array_enable_signastatic bool dma_fence_array_signaled (struct dma_fence *fence) {struct dma_fence_array *array =to_dma_fence_array (fence); +int num_pending; +unsigned int i; -if (atomic_read (&array->num_pending) >0 ) +/* +* We need to read num_pending before checking the enable_signal bit +* to avoid racing with the enable_signaling() implementation, which +* might decrement the counter, and cause a partial check. +* atomic_read_acquire() pairs with atomic_dec_and_test() in +* dma_fence_array_enable_signaling() +* +* The !--num_pending check is here to account for the any_signaled case +* if we race with enable_signaling(), that means the !num_pending check +* in the is_signalling_enabled branch might be outdated (num_pending +* might have been decremented), but that's fine. The user will get the +* right value when testing again later. +*/ + num_pending =atomic_read_acquire (&array->num_pending); +if (test_bit (DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT , &array->base.flags)) { +if (num_pending <=0 ) + goto signal;return false; + } +for (i =0 ; i < array->num_fences; ++i) { +if (dma_fence_is_signaled (array->fences[i]) && !--num_pending) + goto signal; + } +return false; + +signal:dma_fence_array_clear_pending_error (array);return true; }
Greg Kroah-Hartman
maintainerPATCH 632/772 dma-fence: Fix reference leak on fence merge failure path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
commit 949291c5314009b4f6e252391edbb40fdd5d5414 upstream.
Release all fence references if the output dma-fence-array could not be allocated.
--- drivers/dma-buf/dma-fence-unwrap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/dma-buf/dma-fence-unwrap.c +2 -0
@@ -164,6 +164,8 @@ struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,dma_fence_context_alloc (1 ), 1, false);if (!result) { +for (i =0 ; i < count; i++) +dma_fence_put (array[i]); tmp =NULL ; goto return_tmp; }
Signature · 1 line
2.47.1
Greg Kroah-Hartman
maintainerPATCH 633/772 dma-fence: Use kernels sort for merging fences
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
commit fe52c649438b8489c9456681d93a9b3de3d38263 upstream.
One alternative to the fix Christian proposed in
https://lore.kernel.org/dri-devel/[email protected]/
is to replace the rather complex open coded sorting loops with the kernel standard sort followed by a context squashing pass.
Proposed advantage of this would be readability but one concern Christian raised was that there could be many fences, that they are typically mostly sorted, and so the kernel's heap sort would be much worse by the proposed algorithm.
I had a look running some games and vkcube to see what are the typical number of input fences. Tested scenarios:
1) Hogwarts Legacy under Gamescope
450 calls per second to __dma_fence_unwrap_merge.
Percentages per number of fences buckets, before and after checking for signalled status, sorting and flattening:
N Before After
0 0.91%
1 69.40%
2-3 28.72% 9.4% (90.6% resolved to one fence)
4-5 0.93%
6-9 0.03%
10+
2) Cyberpunk 2077 under Gamescope
1050 calls per second, amounting to 0.01% CPU time according to perf top.
N Before After
0 1.13%
1 52.30%
2-3 40.34% 55.57%
4-5 1.46% 0.50% 6-9 2.44% 10+ 2.34%
3) vkcube under Plasma
90 calls per second.
N Before After
0
1
2-3 100% 0% (Ie. all resolved to a single fence)
4-5
6-9
10+
In the case of vkcube all invocations in the 2-3 bucket were actually just two input fences.
Quoted 1 line
From these numbers it looks like the heap sort should not be a
disadvantage, given how the dominant case is <= 2 input fences which heap sort solves with just one compare and swap. (And for the case of one input fence we have a fast path in the previous patch.)
A complementary possibility is to implement a different sorting algorithm under the same API as the kernel's sort() and so keep the simplicity, potentially moving the new sort under lib/ if it would be found more widely useful.
v2:
* Hold on to fence references and reduce commentary. (Christian)
* Record and use latest signaled timestamp in the 2nd loop too.
* Consolidate zero or one fences fast paths.
v3:
* Reverse the seqno sort order for a simpler squashing pass. (Christian)
--- drivers/dma-buf/dma-fence-unwrap.c | 128 ++++++++++++++--------------- 1 file changed, 61 insertions(+), 67 deletions(-)
drivers/dma-buf/dma-fence-unwrap.c +61 -67
@@ -12,6 +12,7 @@#include <linux/dma-fence-chain.h> #include <linux/dma-fence-unwrap.h> #include <linux/slab.h> +#include <linux/sort.h> /* Internal helper to start new array iteration, don't use directly */ static struct dma_fence *
@@ -59,6 +60,25 @@ struct dma_fence *dma_fence_unwrap_next(struct dma_fence_unwrap *cursor) }EXPORT_SYMBOL_GPL (dma_fence_unwrap_next); + +static int fence_cmp (const void *_a,const void *_b) +{ +struct dma_fence *a = *(struct dma_fence **)_a; +struct dma_fence *b = *(struct dma_fence **)_b; + +if (a->context < b->context) +return -1 ; +else if (a->context > b->context) +return 1 ; + +if (dma_fence_is_later (b, a)) +return 1 ; +else if (dma_fence_is_later (a, b)) +return -1 ; + +return 0 ; +} +/* Implementation for the dma_fence_merge() marco, don't use directly */ struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences, struct dma_fence **fences,
@@ -67,8 +87,7 @@ struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,struct dma_fence_array *result;struct dma_fence *tmp, **array;ktime_t timestamp; -unsigned int i; -size_t count; +int i, j, count; count =0 ; timestamp =ns_to_ktime (0 );
@@ -96,80 +115,55 @@ struct dma_fence *__dma_fence_unwrap_merge(unsigned int num_fences,if (!array)return NULL ; -/* -* This trashes the input fence array and uses it as position for the -* following merge loop. This works because the dma_fence_merge() -* wrapper macro is creating this temporary array on the stack together -* with the iterators. -*/ -for (i =0 ; i < num_fences; ++i) - fences[i] =dma_fence_unwrap_first (fences[i], &iter[i]); - count =0 ; -do { -unsigned int sel; - -restart: - tmp =NULL ; -for (i =0 ; i < num_fences; ++i) { -struct dma_fence *next; - -while (fences[i] &&dma_fence_is_signaled (fences[i])) - fences[i] =dma_fence_unwrap_next (&iter[i]); - - next = fences[i]; -if (!next) -continue ; - -/* -* We can't guarantee that inpute fences are ordered by -* context, but it is still quite likely when this -* function is used multiple times. So attempt to order -* the fences by context as we pass over them and merge -* fences with the same context. -*/ -if (!tmp || tmp->context > next->context) { - tmp = next; - sel = i; - - }else if (tmp->context < next->context) { -continue ; - - }else if (dma_fence_is_later (tmp, next)) { - fences[i] =dma_fence_unwrap_next (&iter[i]); - goto restart; +for (i =0 ; i < num_fences; ++i) { +dma_fence_unwrap_for_each (tmp, &iter[i], fences[i]) { +if (!dma_fence_is_signaled (tmp)) { + array[count++] =dma_fence_get (tmp); }else { - fences[sel] =dma_fence_unwrap_next (&iter[sel]); - goto restart; +ktime_t t =dma_fence_timestamp (tmp); + +if (ktime_after (t, timestamp)) + timestamp = t; } } - -if (tmp) { - array[count++] =dma_fence_get (tmp); - fences[sel] =dma_fence_unwrap_next (&iter[sel]); - } - }while (tmp); - -if (count ==0 ) { - tmp =dma_fence_allocate_private_stub (ktime_get ()); - goto return_tmp; } -if (count ==1 ) { - tmp = array[0 ]; - goto return_tmp; - } +if (count ==0 || count ==1 ) + goto return_fastpath; - result =dma_fence_array_create (count, array, -dma_fence_context_alloc (1 ), -1 , false); -if (!result) { -for (i =0 ; i < count; i++) +sort (array, count,sizeof (*array), fence_cmp,NULL ); + +/* +* Only keep the most recent fence for each context. +*/ + j =0 ; +for (i =1 ; i < count; i++) { +if (array[i]->context == array[j]->context)dma_fence_put (array[i]); - tmp =NULL ; - goto return_tmp; +else + array[++j] = array[i]; } -return &result->base; + count = ++j; + +if (count >1 ) { + result =dma_fence_array_create (count, array, +dma_fence_context_alloc (1 ), +1 , false); +if (!result) { +for (i =0 ; i < count; i++) +dma_fence_put (array[i]); + tmp =NULL ; + goto return_tmp; + } +return &result->base; + } + +return_fastpath: +if (count ==0 ) + tmp =dma_fence_allocate_private_stub (timestamp); +else + tmp = array[0 ]; return_tmp:kfree (array);
Signature · 1 line
2.47.1
Greg Kroah-Hartman
maintainerPATCH 634/772 xsk: fix OOB map writes when deleting elements
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej Fijalkowski <[email protected]>
commit 32cd3db7de97c0c7a018756ce66244342fd583f0 upstream.
Jordy says:
"
In the xsk_map_delete_elem function an unsigned integer (map->max_entries) is compared with a user-controlled signed integer (k). Due to implicit type conversion, a large unsigned value for map->max_entries can bypass the intended bounds check:
if (k >= map->max_entries) return -EINVAL;
This allows k to hold a negative value (between -2147483648 and -2), which is then used as an array index in m->xsk_map[k], which results in an out-of-bounds access.
spin_lock_bh(&m->lock); map_entry = &m->xsk_map[k]; // Out-of-bounds map_entry old_xs = unrcu_pointer(xchg(map_entry, NULL)); // Oob write if (old_xs) xsk_map_sock_delete(old_xs, map_entry); spin_unlock_bh(&m->lock);
The xchg operation can then be used to cause an out-of-bounds write. Moreover, the invalid map_entry passed to xsk_map_sock_delete can lead to further memory corruption.
"
It indeed results in following splat:
[76612.897343] BUG: unable to handle page fault for address: ffffc8fc2e461108 [76612.904330] #PF: supervisor write access in kernel mode [76612.909639] #PF: error_code(0x0002) - not-present page [76612.914855] PGD 0 P4D 0 [76612.917431] Oops: Oops: 0002 [#1] PREEMPT SMP [76612.921859] CPU: 11 UID: 0 PID: 10318 Comm: a.out Not tainted 6.12.0-rc1+ #470 [76612.929189] Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.02.01.0008.031920191559 03/19/2019 [76612.939781] RIP: 0010:xsk_map_delete_elem+0x2d/0x60 [76612.944738] Code: 00 00 41 54 55 53 48 63 2e 3b 6f 24 73 38 4c 8d a7 f8 00 00 00 48 89 fb 4c 89 e7 e8 2d bf 05 00 48 8d b4 eb 00 01 00 00 31 ff <48> 87 3e 48 85 ff 74 05 e8 16 ff ff ff 4c 89 e7 e8 3e bc 05 00 31 [76612.963774] RSP: 0018:ffffc9002e407df8 EFLAGS: 00010246 [76612.969079] RAX: 0000000000000000 RBX: ffffc9002e461000 RCX: 0000000000000000 [76612.976323] RDX: 0000000000000001 RSI: ffffc8fc2e461108 RDI: 0000000000000000 [76612.983569] RBP: ffffffff80000001 R08: 0000000000000000 R09: 0000000000000007 [76612.990812] R10: ffffc9002e407e18 R11: ffff888108a38858 R12: ffffc9002e4610f8 [76612.998060] R13: ffff888108a38858 R14: 00007ffd1ae0ac78 R15: ffffc9002e4610c0 [76613.005303] FS: 00007f80b6f59740(0000) GS:ffff8897e0ec0000(0000) knlGS:0000000000000000 [76613.013517] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [76613.019349] CR2: ffffc8fc2e461108 CR3: 000000011e3ef001 CR4: 00000000007726f0 [76613.026595] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [76613.033841] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [76613.041086] PKRU: 55555554 [76613.043842] Call Trace: [76613.046331] <TASK> [76613.048468] ? __die+0x20/0x60 [76613.051581] ? page_fault_oops+0x15a/0x450 [76613.055747] ? search_extable+0x22/0x30 [76613.059649] ? search_bpf_extables+0x5f/0x80 [76613.063988] ? exc_page_fault+0xa9/0x140 [76613.067975] ? asm_exc_page_fault+0x22/0x30 [76613.072229] ? xsk_map_delete_elem+0x2d/0x60 [76613.076573] ? xsk_map_delete_elem+0x23/0x60 [76613.080914] __sys_bpf+0x19b7/0x23c0 [76613.084555] __x64_sys_bpf+0x1a/0x20 [76613.088194] do_syscall_64+0x37/0xb0 [76613.091832] entry_SYSCALL_64_after_hwframe+0x4b/0x53 [76613.096962] RIP: 0033:0x7f80b6d1e88d [76613.100592] Code: 5b 41 5c c3 66 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 73 b5 0f 00 f7 d8 64 89 01 48 [76613.119631] RSP: 002b:00007ffd1ae0ac68 EFLAGS: 00000206 ORIG_RAX: 0000000000000141 [76613.131330] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f80b6d1e88d [76613.142632] RDX: 0000000000000098 RSI: 00007ffd1ae0ad20 RDI: 0000000000000003 [76613.153967] RBP: 00007ffd1ae0adc0 R08: 0000000000000000 R09: 0000000000000000 [76613.166030] R10: 00007f80b6f77040 R11: 0000000000000206 R12: 00007ffd1ae0aed8 [76613.177130] R13: 000055ddf42ce1e9 R14: 000055ddf42d0d98 R15: 00007f80b6fab040 [76613.188129] </TASK>
Fix this by simply changing key type from int to u32.
--- net/xdp/xskmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xdp/xskmap.c +1 -1
@@ -216,7 +216,7 @@ static int xsk_map_delete_elem(struct bp struct xsk_map *m = container_of(map, struct xsk_map, map);struct xdp_sock __rcu **map_entry;struct xdp_sock *old_xs; -int k = *(u32 *)key; +u32 k = *(u32 *)key;if (k >= map->max_entries)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 635/772 regmap: detach regmap from dev on regmap_exit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
commit 3061e170381af96d1e66799d34264e6414d428a7 upstream.
At the end of __regmap_init(), if dev is not NULL, regmap_attach_dev() is called, which adds a devres reference to the regmap, to be able to retrieve a dev's regmap by name using dev_get_regmap().
When calling regmap_exit, the opposite does not happen, and the reference is kept until the dev is detached.
Add a regmap_detach_dev() function and call it in regmap_exit() to make sure that the devres reference is not kept.
Rule: add
--- drivers/base/regmap/regmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/base/regmap/regmap.c +12 -0
@@ -652,6 +652,17 @@ int regmap_attach_dev(struct device *dev }EXPORT_SYMBOL_GPL (regmap_attach_dev); +static int dev_get_regmap_match (struct device *dev,void *res,void *data); + +static int regmap_detach_dev (struct device *dev,struct regmap *map) +{ +if (!dev) +return 0 ; + +return devres_release (dev, dev_get_regmap_release, + dev_get_regmap_match, (void *)map->name); +} +static enum regmap_endian regmap_get_reg_endian (const struct regmap_bus *bus,const struct regmap_config *config) {
@@ -1502,6 +1513,7 @@ int regmap_reinit_cache(struct regmap *m {int ret; +regmap_detach_dev (map->dev, map);regcache_exit (map);regmap_debugfs_exit (map);
Greg Kroah-Hartman
maintainerPATCH 636/772 mmc: sdhci-pci: Add DMI quirk for missing CD GPIO on Vexia Edu Atla 10 tablet
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 7f0fa47ceebcff0e3591bb7e32a71a2cd7846149 upstream.
The Vexia Edu Atla 10 tablet distributed to schools in the Spanish Andalucía region has no ACPI fwnode associated with the SDHCI controller for its microsd-slot and thus has no ACPI GPIO resource info.
This causes the following error to be logged and the slot to not work:
[ 10.572113] sdhci-pci 0000:00:12.0: failed to setup card detect gpio
Add a DMI quirk table for providing gpiod_lookup_tables with manually provided CD GPIO info and use this DMI table to provide the CD GPIO info on this tablet. This fixes the microsd-slot not working.
Message-ID: <[email protected]>
--- drivers/mmc/host/sdhci-pci-core.c | 72 ++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/sdhci-pci.h | 1 2 files changed, 73 insertions(+)
drivers/mmc/host/sdhci-pci-core.c +72 -0
@@ -21,6 +21,7 @@#include <linux/io.h> #include <linux/iopoll.h> #include <linux/gpio.h> +#include <linux/gpio/machine.h> #include <linux/pm_runtime.h> #include <linux/pm_qos.h> #include <linux/debugfs.h>
@@ -1239,6 +1240,29 @@ static const struct sdhci_pci_fixes sdhc .priv_size = sizeof(struct intel_host), }; +/* DMI quirks for devices with missing or broken CD GPIO info */ +static const struct gpiod_lookup_table vexia_edu_atla10_cd_gpios = { + .dev_id ="0000:00:12.0" , + .table = { +GPIO_LOOKUP ("INT33FC:00" ,38 ,"cd" ,GPIO_ACTIVE_HIGH ), + { } + }, +}; + +static const struct dmi_system_id sdhci_intel_byt_cd_gpio_override[] = { + { +/* Vexia Edu Atla 10 tablet 9V version */ + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"AMI Corporation" ), +DMI_MATCH (DMI_BOARD_NAME ,"Aptio CRB" ), +/* Above strings are too generic, also match on BIOS date */ +DMI_MATCH (DMI_BIOS_DATE ,"08/25/2014" ), + }, + .driver_data = (void *)&vexia_edu_atla10_cd_gpios, + }, + { } +}; +static const struct sdhci_pci_fixes sdhci_intel_byt_sd = { #ifdef CONFIG_PM_SLEEP .resume = byt_resume,
@@ -1257,6 +1281,7 @@ static const struct sdhci_pci_fixes sdhc .add_host = byt_add_host, .remove_slot = byt_remove_slot, .ops = &sdhci_intel_byt_ops, + .cd_gpio_override = sdhci_intel_byt_cd_gpio_override, .priv_size = sizeof(struct intel_host), };
@@ -2036,6 +2061,42 @@ static const struct dev_pm_ops sdhci_pci* * \*****************************************************************************/ +static struct gpiod_lookup_table *sdhci_pci_add_gpio_lookup_table ( +struct sdhci_pci_chip *chip) +{ +struct gpiod_lookup_table *cd_gpio_lookup_table; +const struct dmi_system_id *dmi_id =NULL ; +size_t count; + +if (chip->fixes && chip->fixes->cd_gpio_override) + dmi_id =dmi_first_match (chip->fixes->cd_gpio_override); + +if (!dmi_id) +return NULL ; + + cd_gpio_lookup_table = dmi_id->driver_data; +for (count =0 ; cd_gpio_lookup_table->table[count].key; count++) + ; + + cd_gpio_lookup_table =kmemdup (dmi_id->driver_data, +/* count + 1 terminating entry */ +struct_size (cd_gpio_lookup_table, table, count +1 ), +GFP_KERNEL ); +if (!cd_gpio_lookup_table) +return ERR_PTR (-ENOMEM ); + +gpiod_add_lookup_table (cd_gpio_lookup_table); +return cd_gpio_lookup_table; +} + +static void sdhci_pci_remove_gpio_lookup_table (struct gpiod_lookup_table *lookup_table) +{ +if (lookup_table) { +gpiod_remove_lookup_table (lookup_table); +kfree (lookup_table); + } +} +static struct sdhci_pci_slot *sdhci_pci_probe_slot (struct pci_dev *pdev,struct sdhci_pci_chip *chip,int first_bar,int slotno)
@@ -2111,8 +2172,19 @@ static struct sdhci_pci_slot *sdhci_pci_device_init_wakeup (&pdev->dev, true);if (slot->cd_idx >=0 ) { +struct gpiod_lookup_table *cd_gpio_lookup_table; + + cd_gpio_lookup_table =sdhci_pci_add_gpio_lookup_table (chip); +if (IS_ERR (cd_gpio_lookup_table)) { + ret =PTR_ERR (cd_gpio_lookup_table); + goto remove; + } + ret =mmc_gpiod_request_cd (host->mmc,"cd" , slot->cd_idx, slot->cd_override_level,0 ); + +sdhci_pci_remove_gpio_lookup_table (cd_gpio_lookup_table); +if (ret && ret != -EPROBE_DEFER ) ret = mmc_gpiod_request_cd(host->mmc, NULL, slot->cd_idx,
drivers/mmc/host/sdhci-pci.h +1 -0
@@ -151,6 +151,7 @@ struct sdhci_pci_fixes {#endif const struct sdhci_ops *ops; +const struct dmi_system_id *cd_gpio_override;size_t priv_size; };
Greg Kroah-Hartman
maintainerPATCH 637/772 mmc: core: Further prevent card detect during shutdown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit 87a0d90fcd31c0f36da0332428c9e1a1e0f97432 upstream.
Disabling card detect from the host's ->shutdown_pre() callback turned out to not be the complete solution. More precisely, beyond the point when the mmc_bus->shutdown() has been called, to gracefully power off the card, we need to prevent card detect. Otherwise the mmc_rescan work may poll for the card with a CMD13, to see if it's still alive, which then will fail and hang as the card has already been powered off.
To fix this problem, let's disable mmc_rescan prior to power off the card during shutdown.
Message-ID: <[email protected]>
--- drivers/mmc/core/bus.c | 2 ++ drivers/mmc/core/core.c | 3 +++ 2 files changed, 5 insertions(+)
drivers/mmc/core/bus.c +2 -0
@@ -149,6 +149,8 @@ static void mmc_bus_shutdown(struct deviif (dev->driver && drv->shutdown) drv->shutdown (card); +__mmc_stop_host (host); +if (host->bus_ops->shutdown) { ret = host->bus_ops->shutdown (host);if (ret)
drivers/mmc/core/core.c +3 -0
@@ -2291,6 +2291,9 @@ void mmc_start_host(struct mmc_host *hosvoid __mmc_stop_host (struct mmc_host *host) { +if (host->rescan_disable) +return ; +if (host->slot.cd_irq >=0 ) {mmc_gpio_set_cd_wake (host, false);disable_irq (host->slot.cd_irq);
Greg Kroah-Hartman
maintainerPATCH 638/772 ocfs2: update seq_file index in ocfs2_dlm_seq_next
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wengang Wang <[email protected]>
commit 914eec5e980171bc128e7e24f7a22aa1d803570e upstream.
The following INFO level message was seen:
seq_file: buggy .next function ocfs2_dlm_seq_next [ocfs2] did not update position index
Fix:
Update *pos (so m->index) to make seq_read_iter happy though the index its self makes no sense to ocfs2_dlm_seq_next.
--- fs/ocfs2/dlmglue.c | 1 + 1 file changed, 1 insertion(+)
fs/ocfs2/dlmglue.c +1 -0
@@ -3108,6 +3108,7 @@ static void *ocfs2_dlm_seq_next(struct sstruct ocfs2_lock_res *iter = v;struct ocfs2_lock_res *dummy = &priv->p_iter_res; + (*pos)++;spin_lock (&ocfs2_dlm_tracking_lock); iter =ocfs2_dlm_next_res (iter, priv);list_del_init (&dummy->l_debug_list);
Greg Kroah-Hartman
maintainerPATCH 639/772 lib: stackinit: hide never-taken branch from compiler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 5c3793604f91123bf49bc792ce697a0bef4c173c upstream.
The never-taken branch leads to an invalid bounds condition, which is by design. To avoid the unwanted warning from the compiler, hide the variable from the optimizer.
../lib/stackinit_kunit.c: In function 'do_nothing_u16_zero':../lib/stackinit_kunit.c:51:49: error: array subscript 1 is outside array bounds of 'u16[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds=]
51 | #define DO_NOTHING_RETURN_SCALAR(ptr) *(ptr)
| ^~~~~~
../lib/stackinit_kunit.c:219:24: note: in expansion of macro 'DO_NOTHING_RETURN_SCALAR'
219 | return DO_NOTHING_RETURN_ ## which(ptr + 1); \
| ^~~~~~~~~~~~~~~~~~--- lib/stackinit_kunit.c | 1 + 1 file changed, 1 insertion(+)
lib/stackinit_kunit.c +1 -0
@@ -199,6 +199,7 @@ static noinline void test_ ## name (stru static noinline DO_NOTHING_TYPE_ ## which(var_type) \ do_nothing_ ## name(var_type *ptr) \ { \ + OPTIMIZER_HIDE_VAR(ptr); \ /* Will always be true, but compiler doesn't know. */ \if ((unsigned long )ptr >0x2 ) \ return DO_NOTHING_RETURN_ ## which(ptr); \
Greg Kroah-Hartman
maintainerPATCH 640/772 iommu/arm-smmu: Defer probe of clients after smmu device bound
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pratyush Brahma <[email protected]>
commit 229e6ee43d2a160a1592b83aad620d6027084aad upstream.
Null pointer dereference occurs due to a race between smmu driver probe and client driver probe, when of_dma_configure() for client is called after the iommu_device_register() for smmu driver probe has executed but before the driver_bound() for smmu driver has been called.
Following is how the race occurs:
T1:Smmu device probe T2: Client device probe
really_probe()arm_smmu_device_probe()iommu_device_register()
really_probe() platform_dma_configure() of_dma_configure() of_dma_configure_id() of_iommu_configure() iommu_probe_device() iommu_init_device() arm_smmu_probe_device() arm_smmu_get_by_fwnode() driver_find_device_by_fwnode() driver_find_device() next_device() klist_next() /* null ptr assigned to smmu */ /* null ptr dereference while smmu->streamid_mask */
driver_bound()
klist_add_tail()
When this null smmu pointer is dereferenced later in arm_smmu_probe_device, the device crashes.
Fix this by deferring the probe of the client device until the smmu device has bound to the arm smmu driver.
--- drivers/iommu/arm/arm-smmu/arm-smmu.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/iommu/arm/arm-smmu/arm-smmu.c +11 -0
@@ -1363,6 +1363,17 @@ static struct iommu_device *arm_smmu_pro goto out_free; }else if (fwspec && fwspec->ops == &arm_smmu_ops) { smmu =arm_smmu_get_by_fwnode (fwspec->iommu_fwnode); + +/* +* Defer probe if the relevant SMMU instance hasn't finished +* probing yet. This is a fragile hack and we'd ideally +* avoid this race in the core code. Until that's ironed +* out, however, this is the most pragmatic option on the +* table. +*/ +if (!smmu) +return ERR_PTR (dev_err_probe (dev, -EPROBE_DEFER , +"smmu dev has not bound yet\n" )); }else {return ERR_PTR (-ENODEV ); }
Greg Kroah-Hartman
maintainerPATCH 641/772 epoll: annotate racy check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 6474353a5e3d0b2cf610153cea0c61f576a36d0a ]
Epoll relies on a racy fastpath check during __fput() in eventpoll_release() to avoid the hit of pointlessly acquiring a semaphore. Annotate that race by using WRITE_ONCE() and READ_ONCE().
--- fs/eventpoll.c | 6 ++++-- include/linux/eventpoll.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
fs/eventpoll.c +4 -2
@@ -703,7 +703,8 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi) to_free =NULL ; head = file->f_ep;if (head->first == &epi->fllink && !epi->fllink.next) { - file->f_ep =NULL ; +/* See eventpoll_release() for details. */ +WRITE_ONCE (file->f_ep,NULL );if (!is_file_epoll (file)) {struct epitems_head *v; v = container_of(head, struct epitems_head, epitems);
@@ -1467,7 +1468,8 @@ static int attach_epitem(struct file *file, struct epitem *epi)spin_unlock (&file->f_lock); goto allocate; } - file->f_ep = head; +/* See eventpoll_release() for details. */ +WRITE_ONCE (file->f_ep, head); to_free =NULL ; }hlist_add_head_rcu (&epi->fllink, file->f_ep);
include/linux/eventpoll.h +1 -1
@@ -42,7 +42,7 @@ static inline void eventpoll_release(struct file *file)* because the file in on the way to be removed and nobody ( but * eventpoll ) has still a reference to this file. */ -if (likely (!file->f_ep)) +if (likely (!READ_ONCE (file->f_ep)))return ;/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 642/772 s390/cpum_sf: Handle CPU hotplug remove during sampling
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richter <[email protected]>
[ Upstream commit a0bd7dacbd51c632b8e2c0500b479af564afadf3 ]
CPU hotplug remove handling triggers the following function call sequence:
CPUHP_AP_PERF_S390_SF_ONLINE --> s390_pmu_sf_offline_cpu()
...
CPUHP_AP_PERF_ONLINE --> perf_event_exit_cpu()
The s390 CPUMF sampling CPU hotplug handler invokes:
s390_pmu_sf_offline_cpu()
+--> cpusf_pmu_setup()
+--> setup_pmc_cpu()
+--> deallocate_buffers()This function de-allocates all sampling data buffers (SDBs) allocated for that CPU at event initialization. It also clears the PMU_F_RESERVED bit. The CPU is gone and can not be sampled.
With the event still being active on the removed CPU, the CPU event hotplug support in kernel performance subsystem triggers the following function calls on the removed CPU:
perf_event_exit_cpu()
+--> perf_event_exit_cpu_context()
+--> __perf_event_exit_context()
+--> __perf_remove_from_context()
+--> event_sched_out()
+--> cpumsf_pmu_del()
+--> cpumsf_pmu_stop()
+--> hw_perf_event_update()to stop and remove the event. During removal of the event, the sampling device driver tries to read out the remaining samples from the sample data buffers (SDBs). But they have already been freed (and may have been re-assigned). This may lead to a use after free situation in which case the samples are most likely invalid. In the best case the memory has not been reassigned and still contains valid data.
Remedy this situation and check if the CPU is still in reserved state (bit PMU_F_RESERVED set). In this case the SDBs have not been released an contain valid data. This is always the case when the event is removed (and no CPU hotplug off occured). If the PMU_F_RESERVED bit is not set, the SDB buffers are gone.
--- arch/s390/kernel/perf_cpum_sf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/s390/kernel/perf_cpum_sf.c +3 -1
@@ -1896,7 +1896,9 @@ static void cpumsf_pmu_stop(struct perf_event *event, int flags) event->hw.state |=PERF_HES_STOPPED ;if ((flags &PERF_EF_UPDATE ) && !(event->hw.state &PERF_HES_UPTODATE )) { -hw_perf_event_update (event,1 ); +/* CPU hotplug off removes SDBs. No samples to extract. */ +if (cpuhw->flags &PMU_F_RESERVED ) +hw_perf_event_update (event,1 ); event->hw.state |=PERF_HES_UPTODATE ; }perf_pmu_enable (event->pmu);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 643/772 btrfs: avoid unnecessary device path update for the same device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 2e8b6bc0ab41ce41e6dfcc204b6cc01d5abbc952 ]
[PROBLEM]
It is very common for udev to trigger device scan, and every time a mounted btrfs device got re-scan from different soft links, we will get some of unnecessary device path updates, this is especially common for LVM based storage:
# lvs scratch1 test -wi-ao---- 10.00g scratch2 test -wi-a----- 10.00g scratch3 test -wi-a----- 10.00g scratch4 test -wi-a----- 10.00g scratch5 test -wi-a----- 10.00g test test -wi-a----- 10.00g
# mkfs.btrfs -f /dev/test/scratch1 # mount /dev/test/scratch1 /mnt/btrfs # dmesg -c [ 205.705234] BTRFS: device fsid 7be2602f-9e35-4ecf-a6ff-9e91d2c182c9 devid 1 transid 6 /dev/mapper/test-scratch1 (253:4) scanned by mount (1154) [ 205.710864] BTRFS info (device dm-4): first mount of filesystem 7be2602f-9e35-4ecf-a6ff-9e91d2c182c9 [ 205.711923] BTRFS info (device dm-4): using crc32c (crc32c-intel) checksum algorithm [ 205.713856] BTRFS info (device dm-4): using free-space-tree [ 205.722324] BTRFS info (device dm-4): checking UUID tree
So far so good, but even if we just touched any soft link of "dm-4", we will get quite some unnecessary device path updates.
# touch /dev/mapper/test-scratch1 # dmesg -c [ 469.295796] BTRFS info: devid 1 device path /dev/mapper/test-scratch1 changed to /dev/dm-4 scanned by (udev-worker) (1221) [ 469.300494] BTRFS info: devid 1 device path /dev/dm-4 changed to /dev/mapper/test-scratch1 scanned by (udev-worker) (1221)
Such device path rename is unnecessary and can lead to random path change due to the udev race.
[CAUSE]
Inside device_list_add(), we are using a very primitive way checking if the device has changed, strcmp().
Which can never handle links well, no matter if it's hard or soft links.
So every different link of the same device will be treated as a different device, causing the unnecessary device path update.
[FIX]
Introduce a helper, is_same_device(), and use path_equal() to properly detect the same block device.
So that the different soft links won't trigger the rename race.
--- fs/btrfs/volumes.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
fs/btrfs/volumes.c +37 -1
@@ -671,6 +671,42 @@ u8 *btrfs_sb_fsid_ptr(struct btrfs_super_block *sb)return has_metadata_uuid ? sb->metadata_uuid : sb->fsid; } +static bool is_same_device (struct btrfs_device *device,const char *new_path) +{ +struct path old = { .mnt =NULL , .dentry =NULL }; +struct path new = { .mnt =NULL , .dentry =NULL }; +char *old_path =NULL ; +bool is_same = false; +int ret; + +if (!device->name) + goto out; + + old_path =kzalloc (PATH_MAX ,GFP_NOFS ); +if (!old_path) + goto out; + +rcu_read_lock (); + ret =strscpy (old_path,rcu_str_deref (device->name),PATH_MAX ); +rcu_read_unlock (); +if (ret <0 ) + goto out; + + ret =kern_path (old_path,LOOKUP_FOLLOW , &old); +if (ret) + goto out; + ret =kern_path (new_path,LOOKUP_FOLLOW , &new); +if (ret) + goto out; +if (path_equal (&old, &new)) + is_same = true; +out: +kfree (old_path); +path_put (&old); +path_put (&new); +return is_same; +} +/* * Handle scanned device having its CHANGING_FSID_V2 flag set and the fs_devices * being created with a disk that has already completed its fsid change. Such
@@ -889,7 +925,7 @@ static noinline struct btrfs_device *device_list_add(const char *path, disk_super->fsid, devid, found_transid, path, current->comm, task_pid_nr(current)); - }else if (!device->name ||strcmp (device->name->str, path)) { + }else if (!device->name || !is_same_device (device, path)) {/* * When FS is already mounted. * 1. If you are here and if the device->name is NULL that
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 644/772 btrfs: do not clear read-only when adding sprout device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
[ Upstream commit 70958a949d852cbecc3d46127bf0b24786df0130 ]
If you follow the seed/sprout wiki, it suggests the following workflow:
btrfstune -S 1 seed_dev
mount seed_dev mnt
btrfs device add sprout_dev
mount -o remount,rw mnt
The first mount mounts the FS readonly, which results in not setting BTRFS_FS_OPEN, and setting the readonly bit on the sb. The device add somewhat surprisingly clears the readonly bit on the sb (though the mount is still practically readonly, from the users perspective...). Finally, the remount checks the readonly bit on the sb against the flag and sees no change, so it does not run the code intended to run on ro->rw transitions, leaving BTRFS_FS_OPEN unset.
As a result, when the cleaner_kthread runs, it sees no BTRFS_FS_OPEN and does no work. This results in leaking deleted snapshots until we run out of space.
I propose fixing it at the first departure from what feels reasonable:
when we clear the readonly bit on the sb during device add.
A new fstest I have written reproduces the bug and confirms the fix.
--- fs/btrfs/volumes.c | 4 ---- 1 file changed, 4 deletions(-)
fs/btrfs/volumes.c +0 -4
@@ -2767,8 +2767,6 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathset_blocksize (device->bdev,BTRFS_BDEV_BLOCKSIZE );if (seeding_dev) { -btrfs_clear_sb_rdonly (sb); -/* GFP_KERNEL allocation must not be under device_list_mutex */ seed_devices =btrfs_init_sprout (fs_info);if (IS_ERR (seed_devices)) {
@@ -2911,8 +2909,6 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_pathmutex_unlock (&fs_info->chunk_mutex);mutex_unlock (&fs_info->fs_devices->device_list_mutex); error_trans: -if (seeding_dev) -btrfs_set_sb_rdonly (sb);if (trans)btrfs_end_transaction (trans); error_free_zone:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 645/772 kselftest/arm64: Dont leak pipe fds in pac.exec_sign_all()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
[ Upstream commit 27141b690547da5650a420f26ec369ba142a9ebb ]
The PAC exec_sign_all() test spawns some child processes, creating pipes to be stdin and stdout for the child. It cleans up most of the file descriptors that are created as part of this but neglects to clean up the parent end of the child stdin and stdout. Add the missing close() calls.
--- tools/testing/selftests/arm64/pauth/pac.c | 3 +++ 1 file changed, 3 insertions(+)
tools/testing/selftests/arm64/pauth/pac.c +3 -0
@@ -182,6 +182,9 @@ int exec_sign_all(struct signatures *signed_vals, size_t val)return -1 ; } +close (new_stdin[1 ]); +close (new_stdout[0 ]); +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 646/772 kcsan: Turn report_filterlist_lock into a raw_spinlock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Elver <[email protected]>
[ Upstream commit 59458fa4ddb47e7891c61b4a928d13d5f5b00aa0 ]
Ran Xiaokai reports that with a KCSAN-enabled PREEMPT_RT kernel, we can see splats like:
| BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 | in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 0, name: swapper/1 | preempt_count: 10002, expected: 0 | RCU nest depth: 0, expected: 0 | no locks held by swapper/1/0. | irq event stamp: 156674 | hardirqs last enabled at (156673): [<ffffffff81130bd9>] do_idle+0x1f9/0x240 | hardirqs last disabled at (156674): [<ffffffff82254f84>] sysvec_apic_timer_interrupt+0x14/0xc0 | softirqs last enabled at (0): [<ffffffff81099f47>] copy_process+0xfc7/0x4b60 | softirqs last disabled at (0): [<0000000000000000>] 0x0 | Preemption disabled at: | [<ffffffff814a3e2a>] paint_ptr+0x2a/0x90 | CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 6.11.0+ #3 | Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-0-ga698c8995f-prebuilt.qemu.org 04/01/2014 | Call Trace: | <IRQ> | dump_stack_lvl+0x7e/0xc0 | dump_stack+0x1d/0x30 | __might_resched+0x1a2/0x270 | rt_spin_lock+0x68/0x170 | kcsan_skip_report_debugfs+0x43/0xe0 | print_report+0xb5/0x590 | kcsan_report_known_origin+0x1b1/0x1d0 | kcsan_setup_watchpoint+0x348/0x650 | __tsan_unaligned_write1+0x16d/0x1d0 | hrtimer_interrupt+0x3d6/0x430 | __sysvec_apic_timer_interrupt+0xe8/0x3a0 | sysvec_apic_timer_interrupt+0x97/0xc0 | </IRQ>
On a detected data race, KCSAN's reporting logic checks if it should filter the report. That list is protected by the report_filterlist_lock *non-raw* spinlock which may sleep on RT kernels.
Since KCSAN may report data races in any context, convert it to a raw_spinlock.
This requires being careful about when to allocate memory for the filter list itself which can be done via KCSAN's debugfs interface. Concurrent modification of the filter list via debugfs should be rare: the chosen strategy is to optimistically pre-allocate memory before the critical section and discard if unused.
--- kernel/kcsan/debugfs.c | 74 ++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 38 deletions(-)
kernel/kcsan/debugfs.c +36 -38
@@ -46,14 +46,8 @@ static struct {int used;/* number of elements used */ bool sorted;/* if elements are sorted */ bool whitelist;/* if list is a blacklist or whitelist */ -} report_filterlist = { - .addrs = NULL, - .size = 8, /* small initial size */ - .used = 0, - .sorted = false, - .whitelist = false, /* default is blacklist */ -}; -static DEFINE_SPINLOCK (report_filterlist_lock); +} report_filterlist; +static DEFINE_RAW_SPINLOCK (report_filterlist_lock);/* * The microbenchmark allows benchmarking KCSAN core runtime only. To run
@@ -110,7 +104,7 @@ bool kcsan_skip_report_debugfs(unsigned long func_addr)return false; func_addr -= offset;/* Get function start */ -spin_lock_irqsave (&report_filterlist_lock, flags); +raw_spin_lock_irqsave (&report_filterlist_lock, flags);if (report_filterlist.used ==0 ) goto out;
@@ -127,7 +121,7 @@ bool kcsan_skip_report_debugfs(unsigned long func_addr) ret = !ret; out: -spin_unlock_irqrestore (&report_filterlist_lock, flags); +raw_spin_unlock_irqrestore (&report_filterlist_lock, flags);return ret; }
@@ -135,9 +129,9 @@ static void set_report_filterlist_whitelist(bool whitelist) {unsigned long flags; -spin_lock_irqsave (&report_filterlist_lock, flags); +raw_spin_lock_irqsave (&report_filterlist_lock, flags); report_filterlist.whitelist = whitelist; -spin_unlock_irqrestore (&report_filterlist_lock, flags); +raw_spin_unlock_irqrestore (&report_filterlist_lock, flags); }/* Returns 0 on success, error-code otherwise. */
@@ -145,6 +139,9 @@ static ssize_t insert_report_filterlist(const char *func) {unsigned long flags;unsigned long addr =kallsyms_lookup_name (func); +unsigned long *delay_free =NULL ; +unsigned long *new_addrs =NULL ; +size_t new_size =0 ;ssize_t ret =0 ;if (!addr) {
@@ -152,32 +149,33 @@ static ssize_t insert_report_filterlist(const char *func)return -ENOENT ; } -spin_lock_irqsave (&report_filterlist_lock, flags); +retry_alloc: +/* +* Check if we need an allocation, and re-validate under the lock. Since +* the report_filterlist_lock is a raw, cannot allocate under the lock. +*/ +if (data_race (report_filterlist.used == report_filterlist.size)) { + new_size = (report_filterlist.size ?:4 ) *2 ; + delay_free = new_addrs =kmalloc_array (new_size,sizeof (unsigned long ),GFP_KERNEL ); +if (!new_addrs) +return -ENOMEM ; + } -if (report_filterlist.addrs ==NULL ) { -/* initial allocation */ - report_filterlist.addrs = -kmalloc_array (report_filterlist.size, -sizeof (unsigned long ),GFP_ATOMIC ); -if (report_filterlist.addrs ==NULL ) { - ret = -ENOMEM ; - goto out; - } - }else if (report_filterlist.used == report_filterlist.size) { -/* resize filterlist */ -size_t new_size = report_filterlist.size *2 ; -unsigned long *new_addrs = -krealloc (report_filterlist.addrs, - new_size *sizeof (unsigned long ),GFP_ATOMIC ); - -if (new_addrs ==NULL ) { -/* leave filterlist itself untouched */ - ret = -ENOMEM ; - goto out; +raw_spin_lock_irqsave (&report_filterlist_lock, flags); +if (report_filterlist.used == report_filterlist.size) { +/* Check we pre-allocated enough, and retry if not. */ +if (report_filterlist.used >= new_size) { +raw_spin_unlock_irqrestore (&report_filterlist_lock, flags); +kfree (new_addrs);/* kfree(NULL) is safe */ + delay_free = new_addrs =NULL ; + goto retry_alloc; } +if (report_filterlist.used) +memcpy (new_addrs, report_filterlist.addrs, report_filterlist.used *sizeof (unsigned long )); + delay_free = report_filterlist.addrs;/* free the old list */ + report_filterlist.addrs = new_addrs;/* switch to the new list */ report_filterlist.size = new_size; - report_filterlist.addrs = new_addrs; }/* Note: deduplicating should be done in userspace. */
@@ -185,9 +183,9 @@ static ssize_t insert_report_filterlist(const char *func)kallsyms_lookup_name (func); report_filterlist.sorted = false; -out: -spin_unlock_irqrestore (&report_filterlist_lock, flags); +raw_spin_unlock_irqrestore (&report_filterlist_lock, flags); +kfree (delay_free);return ret; }
@@ -204,13 +202,13 @@ static int show_info(struct seq_file *file, void *v) }/* show filter functions, and filter type */ -spin_lock_irqsave (&report_filterlist_lock, flags); +raw_spin_lock_irqsave (&report_filterlist_lock, flags);seq_printf (file,"\n%s functions: %s\n" , report_filterlist.whitelist ?"whitelisted" :"blacklisted" , report_filterlist.used ==0 ?"none" :"" );for (i =0 ; i < report_filterlist.used; ++i)seq_printf (file," %ps\n" , (void *)report_filterlist.addrs[i]); -spin_unlock_irqrestore (&report_filterlist_lock, flags); +raw_spin_unlock_irqrestore (&report_filterlist_lock, flags);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 647/772 perf/x86/amd: Warn only on new bits set
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit de20037e1b3c2f2ca97b8c12b8c7bca8abd509a7 ]
Warning at every leaking bits can cause a flood of message, triggering various stall-warning mechanisms to fire, including CSD locks, which makes the machine to be unusable.
Track the bits that are being leaked, and only warn when a new bit is set.
That said, this patch will help with the following issues:
1) It will tell us which bits are being set, so, it is easy to communicate it back to vendor, and to do a root-cause analyzes.
2) It avoid the machine to be unusable, because, worst case scenario, the user gets less than 60 WARNs (one per unhandled bit).
--- arch/x86/events/amd/core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/x86/events/amd/core.c +8 -2
@@ -881,11 +881,12 @@ static int amd_pmu_handle_irq(struct pt_regs *regs)static int amd_pmu_v2_handle_irq (struct pt_regs *regs) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events); +static atomic64_t status_warned =ATOMIC64_INIT (0 ); +u64 reserved, status, mask, new_bits, prev_bits;struct perf_sample_data data;struct hw_perf_event *hwc;struct perf_event *event;int handled =0 , idx; -u64 reserved, status, mask;bool pmu_enabled;/*
@@ -952,7 +953,12 @@ static int amd_pmu_v2_handle_irq(struct pt_regs *regs)* the corresponding PMCs are expected to be inactive according to the * active_mask */ -WARN_ON (status >0 ); +if (status >0 ) { + prev_bits =atomic64_fetch_or (status, &status_warned); +// A new bit was set for the very first time. + new_bits = status & ~prev_bits; +WARN (new_bits,"New overflows for inactive PMCs: %llx\n" , new_bits); + }/* Clear overflow and freeze bits */ amd_pmu_ack_global_status (~status);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 648/772 media: uvcvideo: Add a quirk for the Kaiweets KTI-W02 infrared camera
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Given <[email protected]>
[ Upstream commit b2ec92bb5605452d539a7aa1e42345b95acd8583 ]
Adds a quirk to make the NXP Semiconductors 1fc9:009b chipset work.
lsusb for the device reports:
Bus 003 Device 011: ID 1fc9:009b NXP Semiconductors IR VIDEO Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 239 Miscellaneous Device
bDeviceSubClass 2 [unknown]
bDeviceProtocol 1 Interface Association
bMaxPacketSize0 64
idVendor 0x1fc9 NXP Semiconductors
idProduct 0x009b IR VIDEO
bcdDevice 1.01
iManufacturer 1 Guide sensmart iProduct 2 IR VIDEO iSerial 0 bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x00c2
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 100mA
Interface Association:
bLength 8
bDescriptorType 11
bFirstInterface 0
bInterfaceCount 2
bFunctionClass 14 Video
bFunctionSubClass 3 Video Interface Collection
bFunctionProtocol 0
iFunction 3 IR Camera
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 1 Video Control
bInterfaceProtocol 0
iInterface 0
VideoControl Interface Descriptor:
bLength 13
bDescriptorType 36
bDescriptorSubtype 1 (HEADER)
bcdUVC 1.00
wTotalLength 0x0033
dwClockFrequency 6.000000MHz
bInCollection 1
baInterfaceNr( 0) 1
VideoControl Interface Descriptor:
bLength 18
bDescriptorType 36
bDescriptorSubtype 2 (INPUT_TERMINAL)
bTerminalID 1
wTerminalType 0x0201 Camera Sensor
bAssocTerminal 0
iTerminal 0
wObjectiveFocalLengthMin 0
wObjectiveFocalLengthMax 0
wOcularFocalLength 0
bControlSize 3
bmControls 0x00000000
VideoControl Interface Descriptor:
bLength 9
bDescriptorType 36
bDescriptorSubtype 3 (OUTPUT_TERMINAL)
bTerminalID 2
wTerminalType 0x0101 USB Streaming
bAssocTerminal 0
bSourceID 1
iTerminal 0
VideoControl Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 5 (PROCESSING_UNIT)
Warning: Descriptor too short
bUnitID 3
bSourceID 1
wMaxMultiplier 0
bControlSize 2
bmControls 0x00000000
iProcessing 0
bmVideoStandards 0x62
NTSC - 525/60
PAL - 525/60
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0008 1x 8 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 0
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
VideoStreaming Interface Descriptor:
bLength 14
bDescriptorType 36
bDescriptorSubtype 1 (INPUT_HEADER)
bNumFormats 1
wTotalLength 0x0055
bEndpointAddress 0x82 EP 2 IN
bmInfo 0
bTerminalLink 2
bStillCaptureMethod 2
bTriggerSupport 0
bTriggerUsage 0
bControlSize 1
bmaControls( 0) 0
VideoStreaming Interface Descriptor:
bLength 27
bDescriptorType 36
bDescriptorSubtype 4 (FORMAT_UNCOMPRESSED)
bFormatIndex 1
bNumFrameDescriptors 1
guidFormat {e436eb7b-524f-11ce-9f53-0020af0ba770}
bBitsPerPixel 16
bDefaultFrameIndex 1
bAspectRatioX 0
bAspectRatioY 0
bmInterlaceFlags 0x00
Interlaced stream or variable: No
Fields per frame: 2 fields
Field 1 first: No
Field pattern: Field 1 only
bCopyProtect 0
VideoStreaming Interface Descriptor:
bLength 34
bDescriptorType 36
bDescriptorSubtype 5 (FRAME_UNCOMPRESSED)
bFrameIndex 1
bmCapabilities 0x00
Still image unsupported
wWidth 240
wHeight 322
dwMinBitRate 12364800
dwMaxBitRate 30912000
dwMaxVideoFrameBufferSize 154560
dwDefaultFrameInterval 400000
bFrameIntervalType 2
dwFrameInterval( 0) 400000
dwFrameInterval( 1) 1000000
VideoStreaming Interface Descriptor:
bLength 10
bDescriptorType 36
bDescriptorSubtype 3 (STILL_IMAGE_FRAME)
bEndpointAddress 0x00 EP 0 OUT
bNumImageSizePatterns 1
wWidth( 0) 240
wHeight( 0) 322
bNumCompressionPatterns 0
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 1
bInterfaceClass 14 Video
bInterfaceSubClass 2 Video Streaming
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0400 1x 1024 bytes
bInterval 1
Device Status: 0x0001
Self Powered
--- drivers/media/usb/uvc/uvc_driver.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/media/usb/uvc/uvc_driver.c +11 -0
@@ -2441,6 +2441,8 @@ static const struct uvc_device_info uvc_quirk_force_y8 = {* The Logitech cameras listed below have their interface class set to * VENDOR_SPEC because they don't announce themselves as UVC devices, even * though they are compliant. +* +* Sort these by vendor/product ID. */ static const struct usb_device_id uvc_ids[] = {/* Quanta USB2.0 HD UVC Webcam */
@@ -2983,6 +2985,15 @@ static const struct usb_device_id uvc_ids[] = { .bInterfaceProtocol = 0, .driver_info = UVC_INFO_QUIRK(UVC_QUIRK_PROBE_MINMAX | UVC_QUIRK_IGNORE_SELECTOR_UNIT) }, +/* NXP Semiconductors IR VIDEO */ + { .match_flags = USB_DEVICE_ID_MATCH_DEVICE + | USB_DEVICE_ID_MATCH_INT_INFO, + .idVendor = 0x1fc9, + .idProduct = 0x009b, + .bInterfaceClass = USB_CLASS_VIDEO, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 0, + .driver_info = (kernel_ulong_t)&uvc_quirk_probe_minmax },/* Oculus VR Positional Tracker DK2 */ { .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_INFO,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 649/772 media: cx231xx: Add support for Dexatek USB Video Grabber 1d19:6108
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rohan Barar <[email protected]>
[ Upstream commit 61a830bc0ea69a05d8a4534f825c6aa618263649 ]
Add Dexatek Technology Ltd USB Video Grabber 1d19:6108 to the cx231xx driver. This device is sold under the name "BAUHN DVD Maker (DK8723)" by ALDI in Australia.
This device is similar to 1d19:6109, which is already included in cx231xx.
Both video and audio capture function correctly after installing the patched cx231xx driver.
Patch Changelog
v1:
- Initial submission.
v2:
- Fix SoB + Improve subject.
v3:
- Rephrase message to not exceed 75 characters per line.
- Removed reference to external GitHub URL.
--- drivers/media/usb/cx231xx/cx231xx-cards.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/cx231xx/cx231xx-cards.c +2 -0
@@ -994,6 +994,8 @@ const unsigned int cx231xx_bcount = ARRAY_SIZE(cx231xx_boards);/* table of devices that work with this driver */ struct usb_device_id cx231xx_id_table[] = { + {USB_DEVICE (0x1D19 ,0x6108 ), + .driver_info =CX231XX_BOARD_PV_XCAPTURE_USB }, {USB_DEVICE (0x1D19 ,0x6109 ), .driver_info =CX231XX_BOARD_PV_XCAPTURE_USB }, {USB_DEVICE (0x0572 ,0x5A3C ),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 650/772 mmc: core: Add SD card quirk for broken poweroff notification
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keita Aihara <[email protected]>
[ Upstream commit cd068d51594d9635bf6688fc78717572b78bce6a ]
GIGASTONE Gaming Plus microSD cards manufactured on 02/2022 report that they support poweroff notification and cache, but they are not working correctly.
Flush Cache bit never gets cleared in sd_flush_cache() and Poweroff Notification Ready bit also never gets set to 1 within 1 second from the end of busy of CMD49 in sd_poweroff_notify().
This leads to I/O error and runtime PM error state.
I observed that the same card manufactured on 01/2024 works as expected.
This problem seems similar to the Kingston cards fixed with commit c467c8f08185 ("mmc: Add MMC_QUIRK_BROKEN_SD_CACHE for Kingston Canvas Go Plus from 11/2019") and should be handled using quirks.
CID for the problematic card is here.
12345641535443002000000145016200
Manufacturer ID is 0x12 and defined as CID_MANFID_GIGASTONE as of now, but would like comments on what naming is appropriate because MID list is not public and not sure it's right.
--- drivers/mmc/core/card.h | 7 +++++++ drivers/mmc/core/quirks.h | 9 +++++++++ drivers/mmc/core/sd.c | 2 +- include/linux/mmc/card.h | 1 + 4 files changed, 18 insertions(+), 1 deletion(-)
drivers/mmc/core/card.h +7 -0
@@ -82,6 +82,7 @@ struct mmc_fixup {#define CID_MANFID_SANDISK_SD 0x3#define CID_MANFID_ATP 0x9#define CID_MANFID_TOSHIBA 0x11 +#define CID_MANFID_GIGASTONE 0x12#define CID_MANFID_MICRON 0x13#define CID_MANFID_SAMSUNG 0x15#define CID_MANFID_APACER 0x27
@@ -284,4 +285,10 @@ static inline int mmc_card_broken_cache_flush(const struct mmc_card *c) {return c->quirks &MMC_QUIRK_BROKEN_CACHE_FLUSH ; } + +static inline int mmc_card_broken_sd_poweroff_notify (const struct mmc_card *c) +{ +return c->quirks &MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY ; +} +#endif
drivers/mmc/core/quirks.h +9 -0
@@ -25,6 +25,15 @@ static const struct mmc_fixup __maybe_unused mmc_sd_fixups[] = { 0, -1ull, SDIO_ANY_ID, SDIO_ANY_ID, add_quirk_sd, MMC_QUIRK_BROKEN_SD_CACHE, EXT_CSD_REV_ANY), +/* +* GIGASTONE Gaming Plus microSD cards manufactured on 02/2022 never +* clear Flush Cache bit and set Poweroff Notification Ready bit. +*/ +_FIXUP_EXT ("ASTC" ,CID_MANFID_GIGASTONE ,0x3456 ,2022 ,2 , +0 ,-1ull ,SDIO_ANY_ID ,SDIO_ANY_ID , add_quirk_sd, +MMC_QUIRK_BROKEN_SD_CACHE |MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY , +EXT_CSD_REV_ANY ), + END_FIXUP };
drivers/mmc/core/sd.c +1 -1
@@ -1118,7 +1118,7 @@ static int sd_parse_ext_reg_power(struct mmc_card *card, u8 fno, u8 page, card->ext_power.rev = reg_buf[0 ] &0xf ;/* Power Off Notification support at bit 4. */ -if (reg_buf[1 ] &BIT (4 )) +if ((reg_buf[1 ] &BIT (4 )) && !mmc_card_broken_sd_poweroff_notify (card)) card->ext_power.feature_support |=SD_EXT_POWER_OFF_NOTIFY ;/* Power Sustenance support at bit 5. */
include/linux/mmc/card.h +1 -0
@@ -296,6 +296,7 @@ struct mmc_card {#define MMC_QUIRK_BROKEN_SD_DISCARD (1<<14)/* Disable broken SD discard support */ #define MMC_QUIRK_BROKEN_SD_CACHE (1<<15)/* Disable broken SD cache support */ #define MMC_QUIRK_BROKEN_CACHE_FLUSH (1<<16)/* Don't flush cache until the write has occurred */ +#define MMC_QUIRK_BROKEN_SD_POWEROFF_NOTIFY (1<<17)/* Disable broken SD poweroff notify support */ bool written_flag;/* Indicates eMMC has been written since power on */ bool reenable_cmdq;/* Re-enable Command Queue */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 651/772 soc: imx8m: Probe the SoC driver as platform driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit 9cc832d37799dbea950c4c8a34721b02b8b5a8ff ]
With driver_async_probe=* on kernel command line, the following trace is produced because on i.MX8M Plus hardware because the soc-imx8m.c driver calls of_clk_get_by_name() which returns -EPROBE_DEFER because the clock driver is not yet probed. This was not detected during regular testing without driver_async_probe.
Convert the SoC code to platform driver and instantiate a platform device in its current device_initcall() to probe the platform driver. Rework .soc_revision callback to always return valid error code and return SoC revision via parameter. This way, if anything in the .soc_revision callback return -EPROBE_DEFER, it gets propagated to .probe and the .probe will get retried later.
"
------------[ cut here ]------------ WARNING: CPU: 1 PID: 1 at drivers/soc/imx/soc-imx8m.c:115 imx8mm_soc_revision+0xdc/0x180 CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.11.0-next-20240924-00002-g2062bb554dea #603 Hardware name: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3) (DT) pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : imx8mm_soc_revision+0xdc/0x180 lr : imx8mm_soc_revision+0xd0/0x180
sp : ffff8000821fbcc0
x29: ffff8000821fbce0 x28: 0000000000000000 x27: ffff800081810120
x26: ffff8000818a9970 x25: 0000000000000006 x24: 0000000000824311
x23: ffff8000817f42c8 x22: ffff0000df8be210 x21: fffffffffffffdfb
x20: ffff800082780000 x19: 0000000000000001 x18: ffffffffffffffff
x17: ffff800081fff418 x16: ffff8000823e1000 x15: ffff0000c03b65e8
x14: ffff0000c00051b0 x13: ffff800082790000 x12: 0000000000000801
x11: ffff80008278ffff x10: ffff80008209d3a6 x9 : ffff80008062e95c x8 : ffff8000821fb9a0 x7 : 0000000000000000 x6 : 00000000000080e3 x5 : ffff0000df8c03d8 x4 : 0000000000000000 x3 : 0000000000000000 x2 : 0000000000000000 x1 : fffffffffffffdfb x0 : fffffffffffffdfb
Call trace: imx8mm_soc_revision+0xdc/0x180 imx8_soc_init+0xb0/0x1e0 do_one_initcall+0x94/0x1a8 kernel_init_freeable+0x240/0x2a8 kernel_init+0x28/0x140 ret_from_fork+0x10/0x20 ---[ end trace 0000000000000000 ]---
SoC: i.MX8MP revision 1.1
"
--- drivers/soc/imx/soc-imx8m.c | 107 ++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 22 deletions(-)
drivers/soc/imx/soc-imx8m.c +85 -22
@@ -30,7 +30,7 @@struct imx8_soc_data {char *name; -u32 (*soc_revision)(void ); +int (*soc_revision)(u32 *socrev); };static u64 soc_uid;
@@ -51,24 +51,29 @@ static u32 imx8mq_soc_revision_from_atf(void)static inline u32 imx8mq_soc_revision_from_atf (void ) {return 0 ; };#endif -static u32 __init imx8mq_soc_revision (void ) +static int imx8mq_soc_revision (u32 *socrev) {struct device_node *np;void __iomem *ocotp_base;u32 magic;u32 rev;struct clk *clk; +int ret; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx8mq-ocotp" );if (!np) -return 0 ; +return -EINVAL ; ocotp_base =of_iomap (np,0 ); -WARN_ON (!ocotp_base); +if (!ocotp_base) { + ret = -EINVAL ; + goto err_iomap; + } + clk =of_clk_get_by_name (np,NULL );if (IS_ERR (clk)) { -WARN_ON (IS_ERR (clk)); -return 0 ; + ret =PTR_ERR (clk); + goto err_clk; }clk_prepare_enable (clk);
@@ -88,32 +93,45 @@ static u32 __init imx8mq_soc_revision(void) soc_uid <<=32 ; soc_uid |=readl_relaxed (ocotp_base +OCOTP_UID_LOW ); + *socrev = rev; +clk_disable_unprepare (clk);clk_put (clk);iounmap (ocotp_base);of_node_put (np); -return rev; +return 0 ; + +err_clk: +iounmap (ocotp_base); +err_iomap: +of_node_put (np); +return ret; } -static void __init imx8mm_soc_uid (void ) +static int imx8mm_soc_uid (void ) {void __iomem *ocotp_base;struct device_node *np;struct clk *clk; +int ret =0 ;u32 offset =of_machine_is_compatible ("fsl,imx8mp" ) ?IMX8MP_OCOTP_UID_OFFSET :0 ; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx8mm-ocotp" );if (!np) -return ; +return -EINVAL ; ocotp_base =of_iomap (np,0 ); -WARN_ON (!ocotp_base); +if (!ocotp_base) { + ret = -EINVAL ; + goto err_iomap; + } + clk =of_clk_get_by_name (np,NULL );if (IS_ERR (clk)) { -WARN_ON (IS_ERR (clk)); -return ; + ret =PTR_ERR (clk); + goto err_clk; }clk_prepare_enable (clk);
@@ -124,31 +142,41 @@ static void __init imx8mm_soc_uid(void)clk_disable_unprepare (clk);clk_put (clk); + +err_clk:iounmap (ocotp_base); +err_iomap:of_node_put (np); + +return ret; } -static u32 __init imx8mm_soc_revision (void ) +static int imx8mm_soc_revision (u32 *socrev) {struct device_node *np;void __iomem *anatop_base; -u32 rev; +int ret; np =of_find_compatible_node (NULL ,NULL ,"fsl,imx8mm-anatop" );if (!np) -return 0 ; +return -EINVAL ; anatop_base =of_iomap (np,0 ); -WARN_ON (!anatop_base); +if (!anatop_base) { + ret = -EINVAL ; + goto err_iomap; + } - rev =readl_relaxed (anatop_base +ANADIG_DIGPROG_IMX8MM ); + *socrev =readl_relaxed (anatop_base +ANADIG_DIGPROG_IMX8MM );iounmap (anatop_base);of_node_put (np); -imx8mm_soc_uid (); +return imx8mm_soc_uid (); -return rev; +err_iomap: +of_node_put (np); +return ret; }static const struct imx8_soc_data imx8mq_soc_data = {
@@ -184,7 +212,7 @@ static __maybe_unused const struct of_device_id imx8_soc_match[] = { kasprintf(GFP_KERNEL, "%d.%d", (soc_rev >> 4) & 0xf, soc_rev & 0xf) : \ "unknown" -static int __init imx8_soc_init(void) +static int imx8m_soc_probe(struct platform_device *pdev) {struct soc_device_attribute *soc_dev_attr;struct soc_device *soc_dev;
@@ -212,8 +240,11 @@ static int __init imx8_soc_init(void) data = id->data;if (data) { soc_dev_attr->soc_id = data->name; -if (data->soc_revision) - soc_rev = data->soc_revision (); +if (data->soc_revision) { + ret = data->soc_revision (&soc_rev); +if (ret) + goto free_soc; + } } soc_dev_attr->revision =imx8_revision (soc_rev);
@@ -251,4 +282,36 @@ static int __init imx8_soc_init(void)kfree (soc_dev_attr);return ret; } + +static struct platform_driver imx8m_soc_driver = { + .probe = imx8m_soc_probe, + .driver = { + .name ="imx8m-soc" , + }, +}; + +static int __init imx8_soc_init (void ) +{ +struct platform_device *pdev; +int ret; + +/* No match means this is non-i.MX8M hardware, do nothing. */ +if (!of_match_node (imx8_soc_match, of_root)) +return 0 ; + + ret =platform_driver_register (&imx8m_soc_driver); +if (ret) { +pr_err ("Failed to register imx8m-soc platform driver: %d\n" , ret); +return ret; + } + + pdev =platform_device_register_simple ("imx8m-soc" ,-1 ,NULL ,0 ); +if (IS_ERR (pdev)) { +pr_err ("Failed to register imx8m-soc platform device: %ld\n" ,PTR_ERR (pdev)); +platform_driver_unregister (&imx8m_soc_driver); +return PTR_ERR (pdev); + } + +return 0 ; +}device_initcall (imx8_soc_init);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 652/772 HID: magicmouse: Apple Magic Trackpad 2 USB-C driver support
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Callahan Kovacs <[email protected]>
[ Upstream commit 87a2f10395c82c2b4687bb8611a6c5663a12f9e7 ]
Adds driver support for the USB-C model of Apple's Magic Trackpad 2.
The 2024 USB-C model is compatible with the existing Magic Trackpad 2 driver but has a different hardware ID.
--- drivers/hid/hid-ids.h | 1 + drivers/hid/hid-magicmouse.c | 56 ++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 15 deletions(-)
drivers/hid/hid-ids.h +1 -0
@@ -94,6 +94,7 @@#define USB_DEVICE_ID_APPLE_MAGICMOUSE2 0x0269#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 0x0265 +#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC 0x0324#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
drivers/hid/hid-magicmouse.c +41 -15
146 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 653/772 drm/vc4: hdmi: Avoid log spam for audio start failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dom Cobley <[email protected]>
[ Upstream commit b4e5646178e86665f5caef2894578600f597098a ]
We regularly get dmesg error reports of:
[ 18.184066] hdmi-audio-codec hdmi-audio-codec.3.auto: ASoC: error at snd_soc_dai_startup on i2s-hifi: -19 [ 18.184098] MAI: soc_pcm_open() failed (-19)
These are generated for any disconnected hdmi interface when pulseaudio attempts to open the associated ALSA device (numerous times). Each open generates a kernel error message, generating general log spam.
The error messages all come from _soc_pcm_ret in sound/soc/soc-pcm.c#L39 which suggests returning ENOTSUPP, rather that ENODEV will be quiet. And indeed it is.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
@@ -2160,7 +2160,7 @@ static int vc4_hdmi_audio_startup(struct device *dev, void *data) }if (!vc4_hdmi_audio_can_stream (vc4_hdmi)) { - ret = -ENODEV ; + ret = -ENOTSUPP ; goto out_dev_exit; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 654/772 drm/vc4: hvs: Set AXI panic modes for the HVS
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
[ Upstream commit 014eccc9da7bfc76a3107fceea37dd60f1d63630 ]
The HVS can change AXI request mode based on how full the COB FIFOs are.
Until now the vc4 driver has been relying on the firmware to have set these to sensible values.
With HVS channel 2 now being used for live video, change the panic mode for all channels to be explicitly set by the driver, and the same for all channels.
--- drivers/gpu/drm/vc4/vc4_hvs.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/gpu/drm/vc4/vc4_hvs.c +11 -0
@@ -910,6 +910,17 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data) SCALER_DISPCTRL_SCLEIRQ); +/* Set AXI panic mode. +* VC4 panics when < 2 lines in FIFO. +* VC5 panics when less than 1 line in the FIFO. +*/ + dispctrl &= ~(SCALER_DISPCTRL_PANIC0_MASK | +SCALER_DISPCTRL_PANIC1_MASK | +SCALER_DISPCTRL_PANIC2_MASK ); + dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_PANIC0 ); + dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_PANIC1 ); + dispctrl |=VC4_SET_FIELD (2 ,SCALER_DISPCTRL_PANIC2 ); +/* Set AXI panic mode. * VC4 panics when < 2 lines in FIFO. * VC5 panics when less than 1 line in the FIFO.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 655/772 drm: panel-orientation-quirks: Add quirk for AYA NEO 2 model
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joaquín Ignacio Aramendía <[email protected]>
[ Upstream commit 361ebf5ef843b0aa1704c72eb26b91cf76c3c5b7 ]
Add quirk orientation for AYA NEO 2. The name appears without spaces in DMI strings. That made it difficult to reuse the 2021 match. Also the display is larger in resolution.
Tested by the JELOS team that has been patching their own kernel for a while now and confirmed by users in the AYA NEO and ChimeraOS discord servers.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -184,6 +184,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T103HAF"), }, .driver_data = (void *)&lcd800x1280_rightside_up, + }, { /* AYA NEO AYANEO 2 */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYANEO" ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "AYANEO 2"), + }, + .driver_data = (void *)&lcd1200x1920_rightside_up, }, { /* AYA NEO 2021 */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "AYADEVICE"),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 656/772 drm: panel-orientation-quirks: Add quirk for AYA NEO Founder edition
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joaquín Ignacio Aramendía <[email protected]>
[ Upstream commit d7972d735ca80a40a571bf753c138263981a5698 ]
Add quirk orientation for AYA NEO Founder. The name appears with spaces in DMI strings as other devices of the brand. The panel is the same as the NEXT and 2021 models. Those could not be reused as the former has VENDOR name as "AYANEO" without spaces and the latter has "AYADEVICE".
Tested by the JELOS team that has been patching their own kernel for a while now and confirmed by users in the AYA NEO and ChimeraOS discord servers.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -202,6 +202,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_MATCH(DMI_PRODUCT_NAME, "AIR"), }, .driver_data = (void *)&lcd1080x1920_leftside_up, + }, { /* AYA NEO Founder */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYA NEO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "AYA NEO Founder"), + }, + .driver_data = (void *)&lcd800x1280_rightside_up, }, { /* AYA NEO NEXT */ .matches = { DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AYANEO"),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 657/772 drm: panel-orientation-quirks: Add quirk for AYA NEO GEEK
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joaquín Ignacio Aramendía <[email protected]>
[ Upstream commit 428656feb972ca99200fc127b5aecb574efd9d3d ]
Add quirk orientation for AYA NEO GEEK. The name appears without spaces in DMI strings. The board name is completely different to the previous models making it difficult to reuse their quirks despite being the same resolution and using the same orientation.
Tested by the JELOS team that has been patching their own kernel for a while now and confirmed by users in the AYA NEO and ChimeraOS discord servers.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -208,6 +208,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_MATCH(DMI_PRODUCT_NAME, "AYA NEO Founder"), }, .driver_data = (void *)&lcd800x1280_rightside_up, + }, { /* AYA NEO GEEK */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYANEO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "GEEK"), + }, + .driver_data = (void *)&lcd800x1280_rightside_up, }, { /* AYA NEO NEXT */ .matches = { DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AYANEO"),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 658/772 drm/bridge: it6505: Enable module autoloading
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liao Chen <[email protected]>
[ Upstream commit 1e2ab24cd708b1c864ff983ee1504c0a409d2f8e ]
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from of_device_id table.
--- drivers/gpu/drm/bridge/ite-it6505.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/ite-it6505.c +1 -0
@@ -3349,6 +3349,7 @@ static const struct of_device_id it6505_of_match[] = { { .compatible = "ite,it6505" }, { } }; +MODULE_DEVICE_TABLE (of, it6505_of_match);static struct i2c_driver it6505_i2c_driver = { .driver = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 659/772 drm/mcde: Enable module autoloading
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liao Chen <[email protected]>
[ Upstream commit 8a16b5cdae26207ff4c22834559384ad3d7bc970 ]
Add MODULE_DEVICE_TABLE(), so modules could be properly autoloaded based on the alias from of_device_id table.
--- drivers/gpu/drm/mcde/mcde_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mcde/mcde_drv.c +1 -0
@@ -468,6 +468,7 @@ static const struct of_device_id mcde_of_match[] = { }, {}, }; +MODULE_DEVICE_TABLE (of, mcde_of_match);static struct platform_driver mcde_driver = { .driver = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 660/772 drm/radeon/r600_cs: Fix possible int overflow in r600_packet3_check()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Artemiev <[email protected]>
[ Upstream commit a1e2da6a5072f8abe5b0feaa91a5bcd9dc544a04 ]
It is possible, although unlikely, that an integer overflow will occur when the result of radeon_get_ib_value() is shifted to the left.
Avoid it by casting one of the operands to larger data type (u64).
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/gpu/drm/radeon/r600_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/r600_cs.c +1 -1
@@ -2104,7 +2104,7 @@ static int r600_packet3_check(struct radeon_cs_parser *p,return -EINVAL ; } - offset =radeon_get_ib_value (p, idx+1 ) <<8 ; + offset = (u64 )radeon_get_ib_value (p, idx+1 ) <<8 ;if (offset != track->vgt_strmout_bo_offset[idx_value]) {DRM_ERROR ("bad STRMOUT_BASE_UPDATE, bo offset does not match: 0x%llx, 0x%x\n" , offset, track->vgt_strmout_bo_offset[idx_value]);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 661/772 drm/display: Fix building with GCC 15
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brahmajit Das <[email protected]>
[ Upstream commit a500f3751d3c861be7e4463c933cf467240cca5d ]
GCC 15 enables -Werror=unterminated-string-initialization by default. This results in the following build error
drivers/gpu/drm/display/drm_dp_dual_mode_helper.c: In function ‘is_hdmi_adaptor’:drivers/gpu/drm/display/drm_dp_dual_mode_helper.c:164:17: error: initializer-string for array of
‘char’ is too long [-Werror=unterminated-string-initialization]
164 | "DP-HDMI ADAPTOR\x04";
| ^~~~~~~~~~~~~~~~~~~~~After discussion with Ville, the fix was to increase the size of dp_dual_mode_hdmi_id array by one, so that it can accommodate the NULL line character. This should let us build the kernel with GCC 15.
--- drivers/gpu/drm/display/drm_dp_dual_mode_helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/display/drm_dp_dual_mode_helper.c +2 -2
@@ -160,11 +160,11 @@ EXPORT_SYMBOL(drm_dp_dual_mode_write);static bool is_hdmi_adaptor (const char hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN ]) { -static const char dp_dual_mode_hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN ] = +static const char dp_dual_mode_hdmi_id[DP_DUAL_MODE_HDMI_ID_LEN +1 ] ="DP-HDMI ADAPTOR\x04" ;return memcmp (hdmi_id, dp_dual_mode_hdmi_id, -sizeof (dp_dual_mode_hdmi_id)) ==0 ; +DP_DUAL_MODE_HDMI_ID_LEN ) ==0 ; }static bool is_type1_adaptor (uint8_t adaptor_id)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 662/772 r8169: dont apply UDP padding quirk on RTL8126A
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
[ Upstream commit 87e26448dbda4523b73a894d96f0f788506d3795 ]
Vendor drivers r8125/r8126 indicate that this quirk isn't needed any longer for RTL8126A. Mimic this in r8169.
--- drivers/net/ethernet/realtek/r8169_main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +10 -4
@@ -4139,8 +4139,8 @@ static unsigned int rtl8125_quirk_udp_padto(struct rtl8169_private *tp, {unsigned int padto =0 , len = skb->len; -if (rtl_is_8125 (tp) && len <128 +RTL_MIN_PATCH_LEN && -rtl_skb_is_udp (skb) &&skb_transport_header_was_set (skb)) { +if (len <128 +RTL_MIN_PATCH_LEN &&rtl_skb_is_udp (skb) && +skb_transport_header_was_set (skb)) {unsigned int trans_data_len =skb_tail_pointer (skb) -skb_transport_header (skb);
@@ -4164,9 +4164,15 @@ static unsigned int rtl8125_quirk_udp_padto(struct rtl8169_private *tp,static unsigned int rtl_quirk_packet_padto (struct rtl8169_private *tp,struct sk_buff *skb) { -unsigned int padto; +unsigned int padto =0 ; - padto =rtl8125_quirk_udp_padto (tp, skb); +switch (tp->mac_version) { + case RTL_GIGA_MAC_VER_61 ... RTL_GIGA_MAC_VER_63: + padto =rtl8125_quirk_udp_padto (tp, skb); +break ; +default : +break ; + }switch (tp->mac_version) {case RTL_GIGA_MAC_VER_34 :
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 663/772 samples/bpf: Fix a resource leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Jun <[email protected]>
[ Upstream commit f3ef53174b23246fe9bc2bbc2542f3a3856fa1e2 ]
The opened file should be closed in show_sockopts(), otherwise resource leak will occur that this problem was discovered by reading code
--- samples/bpf/test_cgrp2_sock.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
samples/bpf/test_cgrp2_sock.c +3 -1
@@ -178,8 +178,10 @@ static int show_sockopts(int family)return 1 ; } -if (get_bind_to_device (sd, name,sizeof (name)) <0 ) +if (get_bind_to_device (sd, name,sizeof (name)) <0 ) { +close (sd);return 1 ; + } mark =get_somark (sd); prio =get_priority (sd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 664/772 net: fec_mpc52xx_phy: Use %pa to format resource_size_t
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit 020bfdc4ed94be472138c891bde4d14241cf00fd ]
The correct format string for resource_size_t is %pa which acts on the address of the variable to be formatted [1].
[1] https://elixir.bootlin.com/linux/v6.11.3/source/Documentation/core-api/printk-formats.rst#L229
Introduced by commit 9d9326d3bc0e ("phy: Change mii_bus id field to a string")
Flagged by gcc-14 as:
drivers/net/ethernet/freescale/fec_mpc52xx_phy.c: In function 'mpc52xx_fec_mdio_probe':drivers/net/ethernet/freescale/fec_mpc52xx_phy.c:97:46: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Wformat=]
97 | snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
| ~^ ~~~~~~~~~
| | |
| | resource_size_t {aka long long unsigned int}
| unsigned int
| %llxNo functional change intended.
Compile tested only.
--- drivers/net/ethernet/freescale/fec_mpc52xx_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_mpc52xx_phy.c +1 -1
@@ -93,7 +93,7 @@ static int mpc52xx_fec_mdio_probe(struct platform_device *of) goto out_free; } -snprintf (bus->id,MII_BUS_ID_SIZE ,"%x" , res.start); +snprintf (bus->id,MII_BUS_ID_SIZE ,"%pa" , &res.start); bus->priv = priv; bus->parent = dev;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 665/772 net: ethernet: fs_enet: Use %pa to format resource_size_t
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit 45fe45fada261e1e83fce2a07fa22835aec1cf0a ]
The correct format string for resource_size_t is %pa which acts on the address of the variable to be formatted [1].
[1] https://elixir.bootlin.com/linux/v6.11.3/source/Documentation/core-api/printk-formats.rst#L229
Introduced by commit 9d9326d3bc0e ("phy: Change mii_bus id field to a string")
Flagged by gcc-14 as:
drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c: In function 'fs_mii_bitbang_init':drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c:126:46: warning: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Wformat=]
126 | snprintf(bus->id, MII_BUS_ID_SIZE, "%x", res.start);
| ~^ ~~~~~~~~~
| | |
| | resource_size_t {aka long long unsigned int}
| unsigned int
| %llxNo functional change intended.
Compile tested only.
--- drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/fs_enet/mii-bitbang.c +1 -1
@@ -126,7 +126,7 @@ static int fs_mii_bitbang_init(struct mii_bus *bus, struct device_node *np)* we get is an int, and the odds of multiple bitbang mdio buses * is low enough that it's not worth going too crazy. */ -snprintf (bus->id,MII_BUS_ID_SIZE ,"%x" , res.start); +snprintf (bus->id,MII_BUS_ID_SIZE ,"%pa" , &res.start); data =of_get_property (np,"fsl,mdio-pin" , &len);if (!data || len !=4 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 666/772 net/sched: cbs: Fix integer overflow in cbs_set_port_rate()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Elena Salomatkina <[email protected]>
[ Upstream commit 397006ba5d918f9b74e734867e8fddbc36dc2282 ]
The subsequent calculation of port_rate = speed * 1000 * BYTES_PER_KBIT, where the BYTES_PER_KBIT is of type LL, may cause an overflow. At least when speed = SPEED_20000, the expression to the left of port_rate will be greater than INT_MAX.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- net/sched/sch_cbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_cbs.c +1 -1
@@ -310,7 +310,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q) {struct ethtool_link_ksettings ecmd;int speed =SPEED_10 ; -int port_rate; +s64 port_rate;int err; err =__ethtool_get_link_ksettings (dev, &ecmd);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 667/772 af_packet: avoid erroring out after sock_init_data() in packet_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit 46f2a11cb82b657fd15bab1c47821b635e03838b ]
After sock_init_data() the allocated sk object is attached to the provided sock object. On error, packet_create() frees the sk object leaving the dangling pointer in the sock object on return. Some other code may try to use this pointer and cause use-after-free.
--- net/packet/af_packet.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
net/packet/af_packet.c +6 -6
@@ -3418,18 +3418,18 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,if (sock->type ==SOCK_PACKET ) sock->ops = &packet_ops_spkt; + po =pkt_sk (sk); + err =packet_alloc_pending (po); +if (err) + goto out_sk_free; +sock_init_data (sock, sk); - po =pkt_sk (sk);init_completion (&po->skb_completion); sk->sk_family =PF_PACKET ; po->num = proto; po->xmit = dev_queue_xmit; - err =packet_alloc_pending (po); -if (err) - goto out2; -packet_cached_dev_reset (po); sk->sk_destruct = packet_sock_destruct;
@@ -3462,7 +3462,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,sock_prot_inuse_add (net, &packet_proto,1 );return 0 ; -out2: +out_sk_free:sk_free (sk); out:return err;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 668/772 Bluetooth: L2CAP: do not leave dangling sk pointer on error in l2cap_sock_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit 7c4f78cdb8e7501e9f92d291a7d956591bf73be9 ]
bt_sock_alloc() allocates the sk object and attaches it to the provided sock object. On error l2cap_sock_alloc() frees the sk object, but the dangling pointer is still attached to the sock object, which may create use-after-free in other code.
--- net/bluetooth/l2cap_sock.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/l2cap_sock.c +1 -0
@@ -1920,6 +1920,7 @@ static struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, chan =l2cap_chan_create ();if (!chan) {sk_free (sk); + sock->sk =NULL ;return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 669/772 Bluetooth: RFCOMM: avoid leaving dangling sk pointer in rfcomm_sock_alloc()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit 3945c799f12b8d1f49a3b48369ca494d981ac465 ]
bt_sock_alloc() attaches allocated sk object to the provided sock object. If rfcomm_dlc_alloc() fails, we release the sk object, but leave the dangling pointer in the sock object, which may cause use-after-free.
Fix this by swapping calls to bt_sock_alloc() and rfcomm_dlc_alloc().
--- net/bluetooth/rfcomm/sock.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
net/bluetooth/rfcomm/sock.c +5 -5
@@ -274,13 +274,13 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock,struct rfcomm_dlc *d;struct sock *sk; - sk =bt_sock_alloc (net, sock, &rfcomm_proto, proto, prio, kern); -if (!sk) + d =rfcomm_dlc_alloc (prio); +if (!d)return NULL ; - d =rfcomm_dlc_alloc (prio); -if (!d) { -sk_free (sk); + sk =bt_sock_alloc (net, sock, &rfcomm_proto, proto, prio, kern); +if (!sk) { +rfcomm_dlc_free (d);return NULL ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 670/772 net: af_can: do not leave a dangling sk pointer in can_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit 811a7ca7320c062e15d0f5b171fe6ad8592d1434 ]
On error can_create() frees the allocated sk object, but sock_init_data() has already attached it to the provided sock object. This will leave a dangling sk pointer in the sock object and may cause use-after-free later.
--- net/can/af_can.c | 1 + 1 file changed, 1 insertion(+)
net/can/af_can.c +1 -0
@@ -171,6 +171,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,/* release sk on errors */ sock_orphan (sk);sock_put (sk); + sock->sk =NULL ; } errout:
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 671/772 net: ieee802154: do not leave a dangling sk pointer in ieee802154_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit b4fcd63f6ef79c73cafae8cf4a114def5fc3d80d ]
sock_init_data() attaches the allocated sk object to the provided sock object. If ieee802154_create() fails later, the allocated sk object is freed, but the dangling pointer remains in the provided sock object, which may allow use-after-free.
Clear the sk pointer in the sock object on error.
--- net/ieee802154/socket.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/ieee802154/socket.c +7 -5
@@ -1046,19 +1046,21 @@ static int ieee802154_create(struct net *net, struct socket *sock,if (sk->sk_prot->hash) { rc = sk->sk_prot->hash (sk); -if (rc) { -sk_common_release (sk); - goto out; - } +if (rc) + goto out_sk_release; }if (sk->sk_prot->init) { rc = sk->sk_prot->init (sk);if (rc) -sk_common_release (sk); + goto out_sk_release; } out:return rc; +out_sk_release: +sk_common_release (sk); + sock->sk =NULL ; + goto out; }static const struct net_proto_family ieee802154_family_ops = {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 672/772 net: inet: do not leave a dangling sk pointer in inet_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit 9365fa510c6f82e3aa550a09d0c5c6b44dbc78ff ]
sock_init_data() attaches the allocated sk object to the provided sock object. If inet_create() fails later, the sk object is freed, but the sock object retains the dangling pointer, which may create use-after-free later.
Clear the sk pointer in the sock object on error.
--- net/ipv4/af_inet.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
net/ipv4/af_inet.c +10 -12
@@ -371,32 +371,30 @@ static int inet_create(struct net *net, struct socket *sock, int protocol, inet->inet_sport =htons (inet->inet_num);/* Add to protocol hash chains. */ err = sk->sk_prot->hash (sk); -if (err) { -sk_common_release (sk); - goto out; - } +if (err) + goto out_sk_release; }if (sk->sk_prot->init) { err = sk->sk_prot->init (sk); -if (err) { -sk_common_release (sk); - goto out; - } +if (err) + goto out_sk_release; }if (!kern) { err =BPF_CGROUP_RUN_PROG_INET_SOCK (sk); -if (err) { -sk_common_release (sk); - goto out; - } +if (err) + goto out_sk_release; } out:return err; out_rcu_unlock:rcu_read_unlock (); goto out; +out_sk_release: +sk_common_release (sk); + sock->sk =NULL ; + goto out; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 673/772 net: inet6: do not leave a dangling sk pointer in inet6_create()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignat Korchagin <[email protected]>
[ Upstream commit 9df99c395d0f55fb444ef39f4d6f194ca437d884 ]
sock_init_data() attaches the allocated sk pointer to the provided sock object. If inet6_create() fails later, the sk object is released, but the sock object retains the dangling sk pointer, which may cause use-after-free later.
Clear the sock sk pointer on error.
--- net/ipv6/af_inet6.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
net/ipv6/af_inet6.c +10 -12
@@ -260,31 +260,29 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,*/ inet->inet_sport =htons (inet->inet_num); err = sk->sk_prot->hash (sk); -if (err) { -sk_common_release (sk); - goto out; - } +if (err) + goto out_sk_release; }if (sk->sk_prot->init) { err = sk->sk_prot->init (sk); -if (err) { -sk_common_release (sk); - goto out; - } +if (err) + goto out_sk_release; }if (!kern) { err =BPF_CGROUP_RUN_PROG_INET_SOCK (sk); -if (err) { -sk_common_release (sk); - goto out; - } +if (err) + goto out_sk_release; } out:return err; out_rcu_unlock:rcu_read_unlock (); goto out; +out_sk_release: +sk_common_release (sk); + sock->sk =NULL ; + goto out; } static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 674/772 wifi: ath5k: add PCI ID for SX76X
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit da0474012402d4729b98799d71a54c35dc5c5de3 ]
This is in two devices made by Gigaset, SX762 and SX763.
--- drivers/net/wireless/ath/ath5k/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath5k/pci.c +1 -0
@@ -46,6 +46,7 @@ static const struct pci_device_id ath5k_pci_id_table[] = { { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */ { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */ { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */ + { PCI_VDEVICE(ATHEROS, 0xff16) }, /* Gigaset SX76[23] AR241[34]A */ { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */ { 0 } };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 675/772 wifi: ath5k: add PCI ID for Arcadyan devices
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit f3ced9bb90b0a287a1fa6184d16b0f104a78fa90 ]
Arcadyan made routers with this PCI ID containing an AR2417.
--- drivers/net/wireless/ath/ath5k/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/ath/ath5k/pci.c +1 -0
@@ -47,6 +47,7 @@ static const struct pci_device_id ath5k_pci_id_table[] = { { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */ { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */ { PCI_VDEVICE(ATHEROS, 0xff16) }, /* Gigaset SX76[23] AR241[34]A */ + { PCI_VDEVICE(ATHEROS, 0xff1a) }, /* Arcadyan ARV45XX AR2417 */ { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */ { 0 } };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 676/772 drm/panel: simple: Add Microchip AC69T88A LVDS Display panel
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manikandan Muralidharan <[email protected]>
[ Upstream commit 40da1463cd6879f542238b36c1148f517927c595 ]
Add support for Microchip AC69T88A 5 inch TFT LCD 800x480 Display module with LVDS interface.The panel uses the Sitronix ST7262 800x480 Display driver
--- drivers/gpu/drm/panel/panel-simple.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/panel/panel-simple.c +28 -0
@@ -3908,6 +3908,31 @@ static const struct panel_desc yes_optoelectronics_ytc700tlag_05_201c = { .connector_type = DRM_MODE_CONNECTOR_LVDS, }; +static const struct drm_display_mode mchp_ac69t88a_mode = { + .clock =25000 , + .hdisplay =800 , + .hsync_start =800 +88 , + .hsync_end =800 +88 +5 , + .htotal =800 +88 +5 +40 , + .vdisplay =480 , + .vsync_start =480 +23 , + .vsync_end =480 +23 +5 , + .vtotal =480 +23 +5 +1 , +}; + +static const struct panel_desc mchp_ac69t88a = { + .modes = &mchp_ac69t88a_mode, + .num_modes =1 , + .bpc =8 , + .size = { + .width =108 , + .height =65 , + }, + .bus_flags =DRM_BUS_FLAG_DE_HIGH , + .bus_format =MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA , + .connector_type =DRM_MODE_CONNECTOR_LVDS , +}; +static const struct drm_display_mode arm_rtsm_mode[] = { { .clock =65000 ,
@@ -4325,6 +4350,9 @@ static const struct of_device_id platform_of_match[] = { }, { .compatible = "yes-optoelectronics,ytc700tlag-05-201c", .data = &yes_optoelectronics_ytc700tlag_05_201c, + }, { + .compatible = "microchip,ac69t88a", + .data = &mchp_ac69t88a, }, { /* Must be the last entry */ .compatible = "panel-dpi",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 677/772 net: sfp: change quirks for Alcatel Lucent G-010S-P
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengyu Qu <[email protected]>
[ Upstream commit 90cb5f1776ba371478e2b08fbf7018c7bd781a8d ]
Seems Alcatel Lucent G-010S-P also have the same problem that it uses TX_FAULT pin for SOC uart. So apply sfp_fixup_ignore_tx_fault to it.
--- drivers/net/phy/sfp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/phy/sfp.c +2 -1
@@ -386,7 +386,8 @@ static void sfp_quirk_ubnt_uf_instant(const struct sfp_eeprom_id *id,static const struct sfp_quirk sfp_quirks[] = {// Alcatel Lucent G-010S-P can operate at 2500base-X, but incorrectly // report 2500MBd NRZ in their EEPROM -SFP_QUIRK_M ("ALCATELLUCENT" ,"G010SP" , sfp_quirk_2500basex), +SFP_QUIRK ("ALCATELLUCENT" ,"G010SP" , sfp_quirk_2500basex, + sfp_fixup_ignore_tx_fault),// Alcatel Lucent G-010S-A can operate at 2500base-X, but report 3.2GBd // NRZ in their EEPROM
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 678/772 drm/sched: memset() job in drm_sched_job_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philipp Stanner <[email protected]>
[ Upstream commit 2320c9e6a768d135c7b0039995182bb1a4e4fd22 ]
drm_sched_job_init() has no control over how users allocate struct drm_sched_job. Unfortunately, the function can also not set some struct members such as job->sched.
This could theoretically lead to UB by users dereferencing the struct's pointer members too early.
It is easier to debug such issues if these pointers are initialized to NULL, so dereferencing them causes a NULL pointer exception. Accordingly, drm_sched_entity_init() does precisely that and initializes its struct with memset().
Initialize parameter "job" to 0 in drm_sched_job_init().
--- drivers/gpu/drm/scheduler/sched_main.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/scheduler/sched_main.c +8 -0
@@ -595,6 +595,14 @@ int drm_sched_job_init(struct drm_sched_job *job,if (!entity->rq)return -ENOENT ; +/* +* We don't know for sure how the user has allocated. Thus, zero the +* struct so that unallowed (i.e., too early) usage of pointers that +* this function does not set is guaranteed to lead to a NULL pointer +* exception instead of UB. +*/ +memset (job,0 ,sizeof (*job)); + job->entity = entity; job->s_fence =drm_sched_fence_alloc (entity, owner);if (!job->s_fence)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 679/772 drm/amdgpu: clear RB_OVERFLOW bit when enabling interrupts for vega20_ih
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Lu <[email protected]>
[ Upstream commit 8b22f048331dfd45fdfbf0efdfb1d43deff7518d ]
Port this change to vega20_ih.c:
commit afbf7955ff01 ("drm/amdgpu: clear RB_OVERFLOW bit when enabling interrupts")
Original commit message:
"Why:
Setting IH_RB_WPTR register to 0 will not clear the RB_OVERFLOW bit if RB_ENABLE is not set.
How to fix:
Set WPTR_OVERFLOW_CLEAR bit after RB_ENABLE bit is set. The RB_ENABLE bit is required to be set, together with WPTR_OVERFLOW_ENABLE bit so that setting WPTR_OVERFLOW_CLEAR bit would clear the RB_OVERFLOW."
--- drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +27 -0
@@ -109,6 +109,33 @@ static int vega20_ih_toggle_ring_interrupts(struct amdgpu_device *adev, tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,RB_ENABLE , (enable ?1 :0 )); tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,RB_GPU_TS_ENABLE ,1 ); +if (enable) { +/* Unset the CLEAR_OVERFLOW bit to make sure the next step +* is switching the bit from 0 to 1 +*/ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,0 ); +if (amdgpu_sriov_vf (adev) &&amdgpu_sriov_reg_indirect_ih (adev)) { +if (psp_reg_program (&adev->psp, ih_regs->psp_reg_id, tmp)) +return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + +/* Clear RB_OVERFLOW bit */ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,1 ); +if (amdgpu_sriov_vf (adev) &&amdgpu_sriov_reg_indirect_ih (adev)) { +if (psp_reg_program (&adev->psp, ih_regs->psp_reg_id, tmp)) +return -ETIMEDOUT ; + }else { +WREG32_NO_KIQ (ih_regs->ih_rb_cntl, tmp); + } + +/* Unset the CLEAR_OVERFLOW bit immediately so new overflows +* can be detected. +*/ + tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,WPTR_OVERFLOW_CLEAR ,0 ); + } +/* enable_intr field is only valid in ring0 */ if (ih == &adev->irq.ih) tmp =REG_SET_FIELD (tmp,IH_RB_CNTL ,ENABLE_INTR , (enable ?1 :0 ));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 680/772 drm/amdgpu: Dereference the ATCS ACPI buffer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prike Liang <[email protected]>
[ Upstream commit 32e7ee293ff476c67b51be006e986021967bc525 ]
Need to dereference the atcs acpi buffer after the method is executed, otherwise it will result in a memory leak.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +1 -0
@@ -758,6 +758,7 @@ int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev,return -EIO ; } +kfree (info);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 681/772 drm/amdgpu: refine error handling in amdgpu_ttm_tt_pin_userptr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lang Yu <[email protected]>
[ Upstream commit 46186667f98fb7158c98f4ff5da62c427761ffcd ]
Free sg table when dma_map_sgtable() failed to avoid memory leak.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -1
@@ -776,7 +776,7 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,/* Map SG to device */ r =dma_map_sgtable (adev->dev, ttm->sg, direction,0 );if (r) - goto release_sg; + goto release_sg_table;/* convert SG to linear array of pages and dma addresses */ drm_prime_sg_to_dma_addr_array(ttm->sg, gtt->ttm.dma_address,
@@ -784,6 +784,8 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_device *bdev,return 0 ; +release_sg_table: +sg_free_table (ttm->sg); release_sg:kfree (ttm->sg); ttm->sg =NULL ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 682/772 dma-debug: fix a possible deadlock on radix_lock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Levi Yun <[email protected]>
[ Upstream commit 7543c3e3b9b88212fcd0aaf5cab5588797bdc7de ]
radix_lock() shouldn't be held while holding dma_hash_entry[idx].lock otherwise, there's a possible deadlock scenario when
dma debug API is called holding rq_lock():
CPU0 CPU1 CPU2dma_free_attrs()check_unmap() add_dma_entry() __schedule() //out
(A) rq_lock()
get_hash_bucket()
(A) dma_entry_hash
check_sync()
(A) radix_lock() (W) dma_entry_hashdma_entry_free()
(W) radix_lock()
// CPU2's one
(W) rq_lock()CPU1 situation can happen when it extending radix tree and it tries to wake up kswapd via wake_all_kswapd().
CPU2 situation can happen while perf_event_task_sched_out() (i.e. dma sync operation is called while deleting perf_event using
etm and etr tmc which are Arm Coresight hwtracing driver backends).
To remove this possible situation, call dma_entry_free() after put_hash_bucket() in check_unmap().
--- kernel/dma/debug.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/dma/debug.c +6 -2
@@ -1044,9 +1044,13 @@ static void check_unmap(struct dma_debug_entry *ref) }hash_bucket_del (entry); -dma_entry_free (entry); -put_hash_bucket (bucket, flags); + +/* +* Free the entry outside of bucket_lock to avoid ABBA deadlocks +* between that and radix_lock. +*/ +dma_entry_free (entry); } static void check_for_stack(struct device *dev,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 683/772 jfs: array-index-out-of-bounds fix in dtReadFirst
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ghanshyam Agrawal <[email protected]>
[ Upstream commit ca84a2c9be482836b86d780244f0357e5a778c46 ]
The value of stbl can be sometimes out of bounds due to a bad filesystem. Added a check with appopriate return of error code in that case.
--- fs/jfs/jfs_dtree.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/jfs/jfs_dtree.c +7 -0
@@ -3086,6 +3086,13 @@ static int dtReadFirst(struct inode *ip, struct btstack * btstack)/* get the leftmost entry */ stbl =DT_GETSTBL (p); + +if (stbl[0 ] <0 || stbl[0 ] >127 ) { +DT_PUTPAGE (mp); +jfs_error (ip->i_sb,"stbl[0] out of bound\n" ); +return -EIO ; + } + xd = (pxd_t *) & p->slot[stbl[0 ]];/* get the child page block address */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 684/772 jfs: fix shift-out-of-bounds in dbSplit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ghanshyam Agrawal <[email protected]>
[ Upstream commit a5f5e4698f8abbb25fe4959814093fb5bfa1aa9d ]
When dmt_budmin is less than zero, it causes errors
in the later stages. Added a check to return an error beforehand in dbAllocCtl itself.
--- fs/jfs/jfs_dmap.c | 3 +++ 1 file changed, 3 insertions(+)
fs/jfs/jfs_dmap.c +3 -0
@@ -1820,6 +1820,9 @@ dbAllocCtl(struct bmap * bmp, s64 nblocks, int l2nb, s64 blkno, s64 * results)return -EIO ; dp = (struct dmap *) mp->data; +if (dp->tree.budmin <0 ) +return -EIO ; +/* try to allocate the blocks. */ rc =dbAllocDmapLev (bmp, dp, (int ) nblocks, l2nb, results);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 685/772 jfs: fix array-index-out-of-bounds in jfs_readdir
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ghanshyam Agrawal <[email protected]>
[ Upstream commit 839f102efb168f02dfdd46717b7c6dddb26b015e ]
The stbl might contain some invalid values. Added a check to return error code in that case.
--- fs/jfs/jfs_dtree.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/jfs/jfs_dtree.c +8 -0
@@ -2891,6 +2891,14 @@ int jfs_readdir(struct file *file, struct dir_context *ctx) stbl =DT_GETSTBL (p);for (i = index; i < p->header.nextindex; i++) { +if (stbl[i] <0 || stbl[i] >127 ) { +jfs_err ("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld" , + i, stbl[i], (long )ip->i_ino, (long long )bn); +free_page (dirent_buf); +DT_PUTPAGE (mp); +return -EIO ; + } + d = (struct ldtentry *) & p->slot[stbl[i]]; if (((long) jfs_dirent + d->namlen + 1) >
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 686/772 jfs: add a check to prevent array-index-out-of-bounds in dbAdjTree
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nihar Chaithanya <[email protected]>
[ Upstream commit a174706ba4dad895c40b1d2277bade16dfacdcd9 ]
When the value of lp is 0 at the beginning of the for loop, it will become negative in the next assignment and we should bail out.
--- fs/jfs/jfs_dmap.c | 3 +++ 1 file changed, 3 insertions(+)
fs/jfs/jfs_dmap.c +3 -0
@@ -2891,6 +2891,9 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)/* bubble the new value up the tree as required. */ for (k =0 ; k <le32_to_cpu (tp->dmt_height); k++) { +if (lp ==0 ) +break ; +/* get the index of the first leaf of the 4 leaf * group containing the specified leaf (leafno). */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 687/772 drm/amdgpu: skip amdgpu_device_cache_pci_state under sriov
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Zhao <[email protected]>
[ Upstream commit afe260df55ac280cd56306248cb6d8a6b0db095c ]
Under sriov, host driver will save and restore vf pci cfg space during reset. And during device init, under sriov, pci_restore_state happens after fullaccess released, and it can have race condition with mmio protection enable from host side leading to missing interrupts.
So skip amdgpu_device_cache_pci_state for sriov.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
@@ -6013,6 +6013,9 @@ bool amdgpu_device_cache_pci_state(struct pci_dev *pdev)struct amdgpu_device *adev =drm_to_adev (dev);int r; +if (amdgpu_sriov_vf (adev)) +return false; + r =pci_save_state (pdev);if (!r) {kfree (adev->pci_state);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 688/772 ALSA: usb-audio: Make mic volume workarounds globally applicable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d6e6b9218ced5249b9136833ef5ec3f554ec7fde ]
It seems that many webcams have buggy firmware and don't expose the mic capture volume with the proper resolution. We have workarounds in mixer.c, but judging from the numbers, those can be better managed as global quirk flags.
--- sound/usb/mixer.c | 58 ++++++++++++-------------------------------- sound/usb/quirks.c | 31 +++++++++++++++++++---- sound/usb/usbaudio.h | 4 +++ 3 files changed, 45 insertions(+), 48 deletions(-)
sound/usb/mixer.c +15 -43
@@ -1084,6 +1084,21 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval, struct snd_kcontrol *kctl) {struct snd_usb_audio *chip = cval->head.mixer->chip; + +if (chip->quirk_flags &QUIRK_FLAG_MIC_RES_384 ) { +if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { +usb_audio_info (chip, +"set resolution quirk: cval->res = 384\n" ); + cval->res =384 ; + } + }else if (chip->quirk_flags &QUIRK_FLAG_MIC_RES_16 ) { +if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { +usb_audio_info (chip, +"set resolution quirk: cval->res = 16\n" ); + cval->res =16 ; + } + } +switch (chip->usb_id) {case USB_ID (0x0763 ,0x2030 ):/* M-Audio Fast Track C400 */ case USB_ID (0x0763 ,0x2031 ):/* M-Audio Fast Track C600 */
@@ -1168,27 +1183,6 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval, }break ; -case USB_ID (0x046d ,0x0807 ):/* Logitech Webcam C500 */ -case USB_ID (0x046d ,0x0808 ): -case USB_ID (0x046d ,0x0809 ): -case USB_ID (0x046d ,0x0819 ):/* Logitech Webcam C210 */ -case USB_ID (0x046d ,0x081b ):/* HD Webcam c310 */ -case USB_ID (0x046d ,0x081d ):/* HD Webcam c510 */ -case USB_ID (0x046d ,0x0825 ):/* HD Webcam c270 */ -case USB_ID (0x046d ,0x0826 ):/* HD Webcam c525 */ -case USB_ID (0x046d ,0x08ca ):/* Logitech Quickcam Fusion */ -case USB_ID (0x046d ,0x0991 ): -case USB_ID (0x046d ,0x09a2 ):/* QuickCam Communicate Deluxe/S7500 */ -/* Most audio usb devices lie about volume resolution. -* Most Logitech webcams have res = 384. -* Probably there is some logitech magic behind this number --fishor -*/ -if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { -usb_audio_info (chip, -"set resolution quirk: cval->res = 384\n" ); - cval->res =384 ; - } -break ;case USB_ID (0x0495 ,0x3042 ):/* ESS Technology Asus USB DAC */ if ((strstr (kctl->id.name,"Playback Volume" ) !=NULL ) ||strstr (kctl->id.name,"Capture Volume" ) !=NULL ) {
@@ -1197,28 +1191,6 @@ static void volume_control_quirks(struct usb_mixer_elem_info *cval, cval->res =1 ; }break ; -case USB_ID (0x1224 ,0x2a25 ):/* Jieli Technology USB PHY 2.0 */ -if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { -usb_audio_info (chip, -"set resolution quirk: cval->res = 16\n" ); - cval->res =16 ; - } -break ; -case USB_ID (0x1bcf ,0x2283 ):/* NexiGo N930AF FHD Webcam */ -case USB_ID (0x03f0 ,0x654a ):/* HP 320 FHD Webcam */ -if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { -usb_audio_info (chip, -"set resolution quirk: cval->res = 16\n" ); - cval->res =16 ; - } -break ; -case USB_ID (0x1bcf ,0x2281 ):/* HD Webcam */ -if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { -usb_audio_info (chip, -"set resolution quirk: cval->res = 16\n" ); - cval->res =16 ; - } -break ; } }
sound/usb/quirks.c +26 -5
@@ -2030,7 +2030,7 @@ struct usb_audio_quirk_flags_table {static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {/* Device matches */ DEVICE_FLG (0x03f0 ,0x654a ,/* HP 320 FHD Webcam */ -QUIRK_FLAG_GET_SAMPLE_RATE ), +QUIRK_FLAG_GET_SAMPLE_RATE |QUIRK_FLAG_MIC_RES_16 ),DEVICE_FLG (0x041e ,0x3000 ,/* Creative SB Extigy */ QUIRK_FLAG_IGNORE_CTL_ERROR ), DEVICE_FLG(0x041e, 0x4080, /* Creative Live Cam VF0610 */
@@ -2038,10 +2038,31 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {DEVICE_FLG (0x045e ,0x083c ,/* MS USB Link headset */ QUIRK_FLAG_GET_SAMPLE_RATE |QUIRK_FLAG_CTL_MSG_DELAY |QUIRK_FLAG_DISABLE_AUTOSUSPEND ), +DEVICE_FLG (0x046d ,0x0807 ,/* Logitech Webcam C500 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x0808 ,/* Logitech Webcam C600 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x0809 , +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x0819 ,/* Logitech Webcam C210 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x081b ,/* HD Webcam c310 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x081d ,/* HD Webcam c510 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x0825 ,/* HD Webcam c270 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x0826 ,/* HD Webcam c525 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ),DEVICE_FLG (0x046d ,0x084c ,/* Logitech ConferenceCam Connect */ QUIRK_FLAG_GET_SAMPLE_RATE |QUIRK_FLAG_CTL_MSG_DELAY_1M ), +DEVICE_FLG (0x046d ,0x08ca ,/* Logitech Quickcam Fusion */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ),DEVICE_FLG (0x046d ,0x0991 ,/* Logitech QuickCam Pro */ -QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_IGNORE_CTL_ERROR ), +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_IGNORE_CTL_ERROR | +QUIRK_FLAG_MIC_RES_384 ), +DEVICE_FLG (0x046d ,0x09a2 ,/* QuickCam Communicate Deluxe/S7500 */ +QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_MIC_RES_384 ),DEVICE_FLG (0x046d ,0x09a4 ,/* Logitech QuickCam E 3500 */ QUIRK_FLAG_CTL_MSG_DELAY_1M |QUIRK_FLAG_IGNORE_CTL_ERROR ), DEVICE_FLG(0x0499, 0x1509, /* Steinberg UR22 */
@@ -2109,7 +2130,7 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {DEVICE_FLG (0x0fd9 ,0x0008 ,/* Hauppauge HVR-950Q */ QUIRK_FLAG_SHARE_MEDIA_DEVICE |QUIRK_FLAG_ALIGN_TRANSFER ),DEVICE_FLG (0x1224 ,0x2a25 ,/* Jieli Technology USB PHY 2.0 */ -QUIRK_FLAG_GET_SAMPLE_RATE ), +QUIRK_FLAG_GET_SAMPLE_RATE |QUIRK_FLAG_MIC_RES_16 ),DEVICE_FLG (0x1395 ,0x740a ,/* Sennheiser DECT */ QUIRK_FLAG_GET_SAMPLE_RATE ), DEVICE_FLG(0x1397, 0x0507, /* Behringer UMC202HD */
@@ -2147,9 +2168,9 @@ static const struct usb_audio_quirk_flags_table quirk_flags_table[] = {DEVICE_FLG (0x19f7 ,0x0035 ,/* RODE NT-USB+ */ QUIRK_FLAG_GET_SAMPLE_RATE ),DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ -QUIRK_FLAG_GET_SAMPLE_RATE ), +QUIRK_FLAG_GET_SAMPLE_RATE |QUIRK_FLAG_MIC_RES_16 ),DEVICE_FLG (0x1bcf ,0x2283 ,/* NexiGo N930AF FHD Webcam */ -QUIRK_FLAG_GET_SAMPLE_RATE ), +QUIRK_FLAG_GET_SAMPLE_RATE |QUIRK_FLAG_MIC_RES_16 ),DEVICE_FLG (0x2040 ,0x7200 ,/* Hauppauge HVR-950Q */ QUIRK_FLAG_SHARE_MEDIA_DEVICE |QUIRK_FLAG_ALIGN_TRANSFER ), DEVICE_FLG(0x2040, 0x7201, /* Hauppauge HVR-950Q-MXL */
sound/usb/usbaudio.h +4 -0
@@ -178,6 +178,8 @@ extern bool snd_usb_skip_validation;* QUIRK_FLAG_FIXED_RATE * Do not set PCM rate (frequency) when only one rate is available * for the given endpoint. +* QUIRK_FLAG_MIC_RES_16 and QUIRK_FLAG_MIC_RES_384 +* Set the fixed resolution for Mic Capture Volume (mostly for webcams) */ #define QUIRK_FLAG_GET_SAMPLE_RATE (1U << 0)
@@ -202,5 +204,7 @@ extern bool snd_usb_skip_validation;#define QUIRK_FLAG_IFACE_SKIP_CLOSE (1U << 19)#define QUIRK_FLAG_FORCE_IFACE_RESET (1U << 20)#define QUIRK_FLAG_FIXED_RATE (1U << 21) +#define QUIRK_FLAG_MIC_RES_16 (1U << 22) +#define QUIRK_FLAG_MIC_RES_384 (1U << 23)#endif /* __USBAUDIO_H */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 689/772 drm/amdgpu: set the right AMDGPU sg segment limitation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prike Liang <[email protected]>
[ Upstream commit e2e97435783979124ba92d6870415c57ecfef6a5 ]
The driver needs to set the correct max_segment_size; otherwise debug_dma_map_sg() will complain about the over-mapping of the AMDGPU sg length as following:
WARNING: CPU: 6 PID: 1964 at kernel/dma/debug.c:1178 debug_dma_map_sg+0x2dc/0x370 [ 364.049444] Modules linked in: veth amdgpu(OE) amdxcp drm_exec gpu_sched drm_buddy drm_ttm_helper ttm(OE) drm_suballoc_helper drm_display_helper drm_kms_helper i2c_algo_bit rpcsec_gss_krb5 auth_rpcgss nfsv4 nfs lockd grace netfs xt_conntrack xt_MASQUERADE nf_conntrack_netlink xfrm_user xfrm_algo iptable_nat xt_addrtype iptable_filter br_netfilter nvme_fabrics overlay nfnetlink_cttimeout nfnetlink openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c bridge stp llc amd_atl intel_rapl_msr intel_rapl_common sunrpc sch_fq_codel snd_hda_codec_realtek snd_hda_codec_generic snd_hda_scodec_component snd_hda_codec_hdmi snd_hda_intel snd_intel_dspcfg edac_mce_amd binfmt_misc snd_hda_codec snd_pci_acp6x snd_hda_core snd_acp_config snd_hwdep snd_soc_acpi kvm_amd snd_pcm kvm snd_seq_midi snd_seq_midi_event crct10dif_pclmul ghash_clmulni_intel sha512_ssse3 snd_rawmidi sha256_ssse3 sha1_ssse3 aesni_intel snd_seq nls_iso8859_1 crypto_simd snd_seq_device cryptd snd_timer rapl input_leds snd [ 364.049532] ipmi_devintf wmi_bmof ccp serio_raw k10temp sp5100_tco soundcore ipmi_msghandler cm32181 industrialio mac_hid msr parport_pc ppdev lp parport drm efi_pstore ip_tables x_tables pci_stub crc32_pclmul nvme ahci libahci i2c_piix4 r8169 nvme_core i2c_designware_pci realtek i2c_ccgx_ucsi video wmi hid_generic cdc_ether usbnet usbhid hid r8152 mii [ 364.049576] CPU: 6 PID: 1964 Comm: rocminfo Tainted: G OE 6.10.0-custom #492 [ 364.049579] Hardware name: AMD Majolica-RN/Majolica-RN, BIOS RMJ1009A 06/13/2021 [ 364.049582] RIP: 0010:debug_dma_map_sg+0x2dc/0x370 [ 364.049585] Code: 89 4d b8 e8 36 b1 86 00 8b 4d b8 48 8b 55 b0 44 8b 45 a8 4c 8b 4d a0 48 89 c6 48 c7 c7 00 4b 74 bc 4c 89 4d b8 e8 b4 73 f3 ff <0f> 0b 4c 8b 4d b8 8b 15 c8 2c b8 01 85 d2 0f 85 ee fd ff ff 8b 05 [ 364.049588] RSP: 0018:ffff9ca600b57ac0 EFLAGS: 00010286 [ 364.049590] RAX: 0000000000000000 RBX: ffff88b7c132b0c8 RCX: 0000000000000027 [ 364.049592] RDX: ffff88bb0f521688 RSI: 0000000000000001 RDI: ffff88bb0f521680 [ 364.049594] RBP: ffff9ca600b57b20 R08: 000000000000006f R09: ffff9ca600b57930 [ 364.049596] R10: ffff9ca600b57928 R11: ffffffffbcb46328 R12: 0000000000000000 [ 364.049597] R13: 0000000000000001 R14: ffff88b7c19c0700 R15: ffff88b7c9059800 [ 364.049599] FS: 00007fb2d3516e80(0000) GS:ffff88bb0f500000(0000) knlGS:0000000000000000 [ 364.049601] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 364.049603] CR2: 000055610bd03598 CR3: 00000001049f6000 CR4: 0000000000350ef0 [ 364.049605] Call Trace: [ 364.049607] <TASK> [ 364.049609] ? show_regs+0x6d/0x80 [ 364.049614] ? __warn+0x8c/0x140 [ 364.049618] ? debug_dma_map_sg+0x2dc/0x370 [ 364.049621] ? report_bug+0x193/0x1a0 [ 364.049627] ? handle_bug+0x46/0x80 [ 364.049631] ? exc_invalid_op+0x1d/0x80 [ 364.049635] ? asm_exc_invalid_op+0x1f/0x30 [ 364.049642] ? debug_dma_map_sg+0x2dc/0x370 [ 364.049647] __dma_map_sg_attrs+0x90/0xe0 [ 364.049651] dma_map_sgtable+0x25/0x40 [ 364.049654] amdgpu_bo_move+0x59a/0x850 [amdgpu] [ 364.049935] ? srso_return_thunk+0x5/0x5f [ 364.049939] ? amdgpu_ttm_tt_populate+0x5d/0xc0 [amdgpu] [ 364.050095] ttm_bo_handle_move_mem+0xc3/0x180 [ttm] [ 364.050103] ttm_bo_validate+0xc1/0x160 [ttm] [ 364.050108] ? amdgpu_ttm_tt_get_user_pages+0xe5/0x1b0 [amdgpu] [ 364.050263] amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu+0xa12/0xc90 [amdgpu] [ 364.050473] kfd_ioctl_alloc_memory_of_gpu+0x16b/0x3b0 [amdgpu] [ 364.050680] kfd_ioctl+0x3c2/0x530 [amdgpu] [ 364.050866] ? __pfx_kfd_ioctl_alloc_memory_of_gpu+0x10/0x10 [amdgpu] [ 364.051054] ? srso_return_thunk+0x5/0x5f [ 364.051057] ? tomoyo_file_ioctl+0x20/0x30 [ 364.051063] __x64_sys_ioctl+0x9c/0xd0 [ 364.051068] x64_sys_call+0x1219/0x20d0 [ 364.051073] do_syscall_64+0x51/0x120 [ 364.051077] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 364.051081] RIP: 0033:0x7fb2d2f1a94f
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
@@ -1732,6 +1732,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)mutex_init (&adev->mman.gtt_window_lock); +dma_set_max_seg_size (adev->dev,UINT_MAX );/* No others user of address space so set it to 0 */ r = ttm_device_init(&adev->mman.bdev, &amdgpu_bo_driver, adev->dev, adev_to_drm(adev)->anon_inode->i_mapping,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 690/772 wifi: ipw2x00: libipw_rx_any(): fix bad alignment
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiapeng Chong <[email protected]>
[ Upstream commit 4fa4f049dc0d9741b16c96bcbf0108c85368a2b9 ]
This patch fixes incorrect code alignment.
./drivers/net/wireless/intel/ipw2x00/libipw_rx.c:871:2-3: code aligned with following code on line 882. ./drivers/net/wireless/intel/ipw2x00/libipw_rx.c:886:2-3: code aligned with following code on line 900.
--- drivers/net/wireless/intel/ipw2x00/libipw_rx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/intel/ipw2x00/libipw_rx.c +4 -4
@@ -870,8 +870,8 @@ void libipw_rx_any(struct libipw_device *ieee,switch (ieee->iw_mode) {case IW_MODE_ADHOC :/* our BSS and not from/to DS */ -if (ether_addr_equal (hdr->addr3, ieee->bssid)) -if ((fc & (IEEE80211_FCTL_TODS +IEEE80211_FCTL_FROMDS )) ==0 ) { +if (ether_addr_equal (hdr->addr3, ieee->bssid) && + ((fc & (IEEE80211_FCTL_TODS +IEEE80211_FCTL_FROMDS )) ==0 )) {/* promisc: get all */ if (ieee->dev->flags &IFF_PROMISC ) is_packet_for_us =1 ;
@@ -885,8 +885,8 @@ void libipw_rx_any(struct libipw_device *ieee,break ;case IW_MODE_INFRA :/* our BSS (== from our AP) and from DS */ -if (ether_addr_equal (hdr->addr2, ieee->bssid)) -if ((fc & (IEEE80211_FCTL_TODS +IEEE80211_FCTL_FROMDS )) ==IEEE80211_FCTL_FROMDS ) { +if (ether_addr_equal (hdr->addr2, ieee->bssid) && + ((fc & (IEEE80211_FCTL_TODS +IEEE80211_FCTL_FROMDS )) ==IEEE80211_FCTL_FROMDS )) {/* promisc: get all */ if (ieee->dev->flags &IFF_PROMISC ) is_packet_for_us =1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 691/772 wifi: brcmfmac: Fix oops due to NULL pointer dereference in brcmf_sdiod_sglist_rw()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Norbert van Bolhuis <[email protected]>
[ Upstream commit 857282b819cbaa0675aaab1e7542e2c0579f52d7 ]
This patch fixes a NULL pointer dereference bug in brcmfmac that occurs when a high 'sd_sgentry_align' value applies (e.g. 512) and a lot of queued SKBs are sent from the pkt queue.
The problem is the number of entries in the pre-allocated sgtable, it is nents = max(rxglom_size, txglom_size) + max(rxglom_size, txglom_size) >> 4 + 1. Given the default [rt]xglom_size=32 it's actually 35 which is too small. Worst case, the pkt queue can end up with 64 SKBs. This occurs when a new SKB is added for each original SKB if tailroom isn't enough to hold tail_pad. At least one sg entry is needed for each SKB. So, eventually the "skb_queue_walk loop" in brcmf_sdiod_sglist_rw may run out of sg entries. This makes sg_next return NULL and this causes the oops.
The patch sets nents to max(rxglom_size, txglom_size) * 2 to be able handle the worst-case.
Btw. this requires only 64-35=29 * 16 (or 20 if CONFIG_NEED_SG_DMA_LENGTH) = 464 additional bytes of memory.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +1 -1
@@ -770,7 +770,7 @@ void brcmf_sdiod_sgtable_alloc(struct brcmf_sdio_dev *sdiodev) nents =max_t (uint,BRCMF_DEFAULT_RXGLOM_SIZE , sdiodev->settings->bus.sdio.txglomsz); - nents += (nents >>4 ) +1 ; + nents *=2 ;WARN_ON (nents > sdiodev->max_segment_count);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 692/772 dsa: qca8k: Use nested lock to avoid splat
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
[ Upstream commit 078e0d596f7b5952dad8662ace8f20ed2165e2ce ]
qca8k_phy_eth_command() is used to probe the child MDIO bus while the parent MDIO is locked. This causes lockdep splat, reporting a possible deadlock. It is not an actually deadlock, because different locks are used. By making use of mutex_lock_nested() we can avoid this false positive.
--- drivers/net/dsa/qca/qca8k-8xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/dsa/qca/qca8k-8xxx.c +1 -1
@@ -551,7 +551,7 @@ qca8k_phy_eth_command(struct qca8k_priv *priv, bool read, int phy,* We therefore need to lock the MDIO bus onto which the switch is * connected. */ -mutex_lock (&priv->bus->mdio_lock); +mutex_lock_nested (&priv->bus->mdio_lock,MDIO_MUTEX_NESTED );/* Actually start the request: * 1. Send mdio master packet
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 693/772 Bluetooth: btusb: Add RTL8852BE device 0489:e123 to device tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hilda Wu <[email protected]>
[ Upstream commit 69b84ffce260ff13826dc10aeb3c3e5c2288a552 ]
Add the support ID 0489:e123 to usb_device_id table for Realtek RTL8852B chip.
The device info from /sys/kernel/debug/usb/devices as below.
T: Bus=01 Lev=01 Prnt=01 Port=07 Cnt=04 Dev#= 7 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e123 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -549,6 +549,8 @@ static const struct usb_device_id blacklist_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3591), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0489, 0xe123), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0489, 0xe125), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH },
Signature · 1 line
2.43.0