6.19.6-rc1 review
Subsystems (6)
Sasha Levin
maintainerPATCH 556/844 KVM: x86: Return "unsupported" instead of "invalid" on access to unsupported PV MSR
In reply to Sasha LevinFrom: Sean Christopherson <[email protected]>
[ Upstream commit 5bb9ac1865123356337a389af935d3913ee917ed ]
Return KVM_MSR_RET_UNSUPPORTED instead of '1' (which for all intents and purposes means "invalid") when rejecting accesses to KVM PV MSRs to adhere to KVM's ABI of allowing host reads and writes of '0' to MSRs that are advertised to userspace via KVM_GET_MSR_INDEX_LIST, even if the vCPU model doesn't support the MSR.
E.g. running a QEMU VM with
-cpu host,-kvmclock,kvm-pv-enforce-cpuid
yields:
qemu: error: failed to set MSR 0x12 to 0x0
qemu: target/i386/kvm/kvm.c:3301: kvm_buf_set_msrs:
Assertion `ret == cpu->kvm_msr_buf->nmsrs' failed.
--- arch/x86/kvm/x86.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-)
arch/x86/kvm/x86.c +20 -20
@@ -4096,47 +4096,47 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)break ;case MSR_KVM_WALL_CLOCK_NEW :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE2 )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; vcpu->kvm->arch.wall_clock = data;kvm_write_wall_clock (vcpu->kvm, data,0 );break ;case MSR_KVM_WALL_CLOCK :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; vcpu->kvm->arch.wall_clock = data;kvm_write_wall_clock (vcpu->kvm, data,0 );break ;case MSR_KVM_SYSTEM_TIME_NEW :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE2 )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;kvm_write_system_time (vcpu, data, false, msr_info->host_initiated);break ;case MSR_KVM_SYSTEM_TIME :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;kvm_write_system_time (vcpu, data, true, msr_info->host_initiated);break ;case MSR_KVM_ASYNC_PF_EN :if (!guest_pv_has (vcpu,KVM_FEATURE_ASYNC_PF )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;if (kvm_pv_enable_async_pf (vcpu, data))return 1 ;break ;case MSR_KVM_ASYNC_PF_INT :if (!guest_pv_has (vcpu,KVM_FEATURE_ASYNC_PF_INT )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;if (kvm_pv_enable_async_pf_int (vcpu, data))return 1 ;break ;case MSR_KVM_ASYNC_PF_ACK :if (!guest_pv_has (vcpu,KVM_FEATURE_ASYNC_PF_INT )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;if (data &0x1 ) {/* * Pairs with the smp_mb__after_atomic() in
@@ -4149,7 +4149,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)break ;case MSR_KVM_STEAL_TIME :if (!guest_pv_has (vcpu,KVM_FEATURE_STEAL_TIME )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;if (unlikely (!sched_info_on ()))return 1 ;
@@ -4167,7 +4167,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)break ;case MSR_KVM_PV_EOI_EN :if (!guest_pv_has (vcpu,KVM_FEATURE_PV_EOI )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;if (kvm_lapic_set_pv_eoi (vcpu, data,sizeof (u8)))return 1 ;
@@ -4175,7 +4175,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)case MSR_KVM_POLL_CONTROL :if (!guest_pv_has (vcpu,KVM_FEATURE_POLL_CONTROL )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ;/* only enable bit supported */ if (data & (-1ULL <<1 ))
@@ -4476,61 +4476,61 @@ int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)break ;case MSR_KVM_WALL_CLOCK :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->kvm->arch.wall_clock;break ;case MSR_KVM_WALL_CLOCK_NEW :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE2 )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->kvm->arch.wall_clock;break ;case MSR_KVM_SYSTEM_TIME :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.time;break ;case MSR_KVM_SYSTEM_TIME_NEW :if (!guest_pv_has (vcpu,KVM_FEATURE_CLOCKSOURCE2 )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.time;break ;case MSR_KVM_ASYNC_PF_EN :if (!guest_pv_has (vcpu,KVM_FEATURE_ASYNC_PF )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.apf.msr_en_val;break ;case MSR_KVM_ASYNC_PF_INT :if (!guest_pv_has (vcpu,KVM_FEATURE_ASYNC_PF_INT )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.apf.msr_int_val;break ;case MSR_KVM_ASYNC_PF_ACK :if (!guest_pv_has (vcpu,KVM_FEATURE_ASYNC_PF_INT )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data =0 ;break ;case MSR_KVM_STEAL_TIME :if (!guest_pv_has (vcpu,KVM_FEATURE_STEAL_TIME )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.st.msr_val;break ;case MSR_KVM_PV_EOI_EN :if (!guest_pv_has (vcpu,KVM_FEATURE_PV_EOI )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.pv_eoi.msr_val;break ;case MSR_KVM_POLL_CONTROL :if (!guest_pv_has (vcpu,KVM_FEATURE_POLL_CONTROL )) -return 1 ; +return KVM_MSR_RET_UNSUPPORTED ; msr_info->data = vcpu->arch.msr_kvm_poll_control;break ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 557/844 KVM: nSVM: Remove a user-triggerable WARN on nested_svm_load_cr3() succeeding
In reply to Sasha LevinFrom: Sean Christopherson <[email protected]>
[ Upstream commit fc3ba56385d03501eb582e4b86691ba378e556f9 ]
Drop the WARN in svm_set_nested_state() on nested_svm_load_cr3() failing as it is trivially easy to trigger from userspace by modifying CPUID after loading CR3. E.g. modifying the state restoration selftest like so:
--- tools/testing/selftests/kvm/x86/state_test.c +++ tools/testing/selftests/kvm/x86/state_test.c @@ -280,7 +280,16 @@ int main(int argc, char *argv[])
/* Restore state in a new VM. */
vcpu = vm_recreate_with_one_vcpu(vm); - vcpu_load_state(vcpu, state);
+
+ if (stage == 4) {
+ state->sregs.cr3 = BIT(44);
+ vcpu_load_state(vcpu, state);
+
+ vcpu_set_cpuid_property(vcpu, X86_PROPERTY_MAX_PHY_ADDR, 36);
+ __vcpu_nested_state_set(vcpu, &state->nested);
+ } else {
+ vcpu_load_state(vcpu, state);
+ }
/*
* Restore XSAVE state in a dummy vCPU, first without doing
generates:
WARNING: CPU: 30 PID: 938 at arch/x86/kvm/svm/nested.c:1877 svm_set_nested_state+0x34a/0x360 [kvm_amd] Modules linked in: kvm_amd kvm irqbypass [last unloaded: kvm] CPU: 30 UID: 1000 PID: 938 Comm: state_test Tainted: G W 6.18.0-rc7-58e10b63777d-next-vm Tainted: [W]=WARN Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015 RIP: 0010:svm_set_nested_state+0x34a/0x360 [kvm_amd] Call Trace: <TASK> kvm_arch_vcpu_ioctl+0xf33/0x1700 [kvm] kvm_vcpu_ioctl+0x4e6/0x8f0 [kvm] __x64_sys_ioctl+0x8f/0xd0 do_syscall_64+0x61/0xad0 entry_SYSCALL_64_after_hwframe+0x4b/0x53
Simply delete the WARN instead of trying to prevent userspace from shoving "illegal" state into CR3. For better or worse, KVM's ABI allows userspace to set CPUID after SREGS, and vice versa, and KVM is very permissive when it comes to guest CPUID. I.e. attempting to enforce the virtual CPU model when setting CPUID could break userspace. Given that the WARN doesn't provide any meaningful protection for KVM or benefit for userspace, simply drop it even though the odds of breaking userspace are minuscule.
Opportunistically delete a spurious newline.
--- arch/x86/kvm/svm/nested.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/svm/nested.c +1 -2
@@ -1870,10 +1870,9 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,* thus MMU might not be initialized correctly. * Set it again to fix this. */ - ret =nested_svm_load_cr3 (&svm->vcpu, vcpu->arch.cr3,nested_npt_enabled (svm), false); -if (WARN_ON_ONCE (ret)) +if (ret) goto out_free; svm->nested.force_msr_bitmap_recalc = true;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 558/844 arm64: Disable branch profiling for all arm64 code
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit f22c81bebf8bda6e54dc132df0ed54f6bf8756f9 ]
The arm64 kernel doesn't boot with annotated branches (PROFILE_ANNOTATED_BRANCHES) enabled and CONFIG_DEBUG_VIRTUAL together.
Bisecting it, I found that disabling branch profiling in arch/arm64/mm solved the problem. Narrowing down a bit further, I found that physaddr.c is the file that needs to have branch profiling disabled to get the machine to boot.
I suspect that it might invoke some ftrace helper very early in the boot process and ftrace is still not enabled(!?).
Rather than playing whack-a-mole with individual files, disable branch profiling for the entire arch/arm64 tree, similar to what x86 already does in arch/x86/Kbuild.
--- arch/arm64/Kbuild | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/Kbuild +4 -0
@@ -1,4 +1,8 @@ # SPDX-License-Identifier: GPL-2.0-only + +# Branch profiling isn't noinstr-safe +subdir-ccflags-$(CONFIG_TRACE_BRANCH_PROFILING) += -DDISABLE_BRANCH_PROFILING + obj-y += kernel/ mm/ net/ obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_XEN) += xen/
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 559/844 pinctrl: meson: amlogic-a4: mark the GPIO controller as sleeping
In reply to Sasha LevinFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit d6df4abe95a409e812c5d9af9657fe63ac299e3a ]
The GPIO controller is configured as non-sleeping but it uses generic pinctrl helpers which use a mutex for synchronization. This will cause lockdep splats when used together with shared GPIOs going through the GPIO shared proxy driver.
--- drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/meson/pinctrl-amlogic-a4.c +1 -1
@@ -895,7 +895,7 @@ static const struct gpio_chip aml_gpio_template = { .direction_input = aml_gpio_direction_input, .direction_output = aml_gpio_direction_output, .get_direction = aml_gpio_get_direction, - .can_sleep = false, + .can_sleep = true, }; static void init_bank_register_bit(struct aml_pinctrl *info,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 560/844 HID: hid-pl: handle probe errors
In reply to Sasha LevinFrom: Oliver Neukum <[email protected]>
[ Upstream commit 3756a272d2cf356d2203da8474d173257f5f8521 ]
Errors in init must be reported back or we'll follow a NULL pointer the first time FF is used.
--- drivers/hid/hid-pl.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/hid-pl.c +6 -1
@@ -194,9 +194,14 @@ static int pl_probe(struct hid_device *hdev, const struct hid_device_id *id) goto err; } -plff_init (hdev); + ret =plff_init (hdev); +if (ret) + goto stop;return 0 ; + +stop: +hid_hw_stop (hdev); err:return ret; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 561/844 HID: magicmouse: Do not crash on missing msc->input
In reply to Sasha LevinFrom: Günther Noack <[email protected]>
[ Upstream commit 17abd396548035fbd6179ee1a431bd75d49676a7 ]
Fake USB devices can send their own report descriptors for which the input_mapping() hook does not get called. In this case, msc->input stays NULL, leading to a crash at a later time.
Detect this condition in the input_configured() hook and reject the device.
This is not supposed to happen with actual magic mouse devices, but can be provoked by imposing as a magic mouse USB device.
--- drivers/hid/hid-magicmouse.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hid/hid-magicmouse.c +5 -0
@@ -725,6 +725,11 @@ static int magicmouse_input_configured(struct hid_device *hdev,struct magicmouse_sc *msc =hid_get_drvdata (hdev);int ret; +if (!msc->input) { +hid_err (hdev,"magicmouse setup input failed (no input)" ); +return -EINVAL ; + } + ret =magicmouse_setup_input (msc->input, hdev);if (ret) {hid_err (hdev,"magicmouse setup input failed (%d)\n" , ret);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 562/844 HID: prodikeys: Check presence of pm->input_ep82
In reply to Sasha LevinFrom: Günther Noack <[email protected]>
[ Upstream commit cee8337e1bad168136aecfe6416ecd7d3aa7529a ]
Fake USB devices can send their own report descriptors for which the input_mapping() hook does not get called. In this case, pm->input_ep82 stays NULL, which leads to a crash later.
This does not happen with the real device, but can be provoked by imposing as one.
--- drivers/hid/hid-prodikeys.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/hid/hid-prodikeys.c +4 -0
@@ -378,6 +378,10 @@ static int pcmidi_handle_report4(struct pcmidi_snd *pm, u8 *data) bit_mask = (bit_mask <<8 ) | data[2 ]; bit_mask = (bit_mask <<8 ) | data[3 ]; +/* robustness in case input_mapping hook does not get called */ +if (!pm->input_ep82) +return 0 ; +/* break keys */ for (bit_index =0 ; bit_index <24 ; bit_index++) {if (!((0x01 << bit_index) & bit_mask)) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 563/844 HID: logitech-hidpp: Check maxfield in hidpp_get_report_length()
In reply to Sasha LevinFrom: Günther Noack <[email protected]>
[ Upstream commit 1547d41f9f19d691c2c9ce4c29f746297baef9e9 ]
Do not crash when a report has no fields.
Fake USB gadgets can send their own HID report descriptors and can define report structures without valid fields. This can be used to crash the kernel over USB.
--- drivers/hid/hid-logitech-hidpp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-logitech-hidpp.c +1 -1
@@ -4314,7 +4314,7 @@ static int hidpp_get_report_length(struct hid_device *hdev, int id) re = &(hdev->report_enum[HID_OUTPUT_REPORT ]); report = re->report_id_hash[id]; -if (!report) +if (!report || !report->maxfield)return 0 ;return report->field[0 ]->report_count +1 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 564/844 fs: ensure that internal tmpfs mount gets mount id zero
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit a2062463e894039a6fdc2334b96afd91d44b64a8 ]
and the rootfs get mount id one as it always has. Before we actually mount the rootfs we create an internal tmpfs mount which has mount id zero but is never exposed anywhere. Continue that "tradition".
--- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/namespace.c +1 -1
@@ -221,7 +221,7 @@ static int mnt_alloc_id(struct mount *mnt)int res;xa_lock (&mnt_id_xa); - res =__xa_alloc (&mnt_id_xa, &mnt->mnt_id, mnt,XA_LIMIT (1 ,INT_MAX ),GFP_KERNEL ); + res =__xa_alloc (&mnt_id_xa, &mnt->mnt_id, mnt, xa_limit_31b,GFP_KERNEL );if (!res) mnt->mnt_id_unique = ++mnt_id_ctr;xa_unlock (&mnt_id_xa);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 565/844 arm64: dts: apple: t8112-j473: Keep the HDMI port powered on
In reply to Sasha LevinFrom: Janne Grunau <[email protected]>
[ Upstream commit 3e4e729325131fe6f7473a0673f7d8cdde53f5a0 ]
Add the display controller and DPTX phy power-domains to the framebuffer node to keep the framebuffer and display out working after device probing finished.
The OS has more control about the display pipeline used for the HDMI output on M2 based devices. The HDMI output is driven by an integrated DisplayPort to HDMI converter (Parade PS190). The DPTX phy is now controlled by the OS and no longer by firmware running on the display co-processor. This allows using the second display controller on the second USB type-c port or tunneling 2 DisplayPort connections over USB4/Thunderbolt.
The m1n1 bootloader uses the second display controller to drive the HDMI output. Adjust for this difference compared to the notebooks as well.
--- arch/arm64/boot/dts/apple/t8112-j473.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/apple/t8112-j473.dts +19 -0
@@ -21,6 +21,25 @@ aliases { }; }; +/* + * Keep the power-domains used for the HDMI port on. + */ +&framebuffer0 { + power-domains = <&ps_dispext_cpu0>, <&ps_dptx_ext_phy>; +}; + +/* + * The M2 Mac mini uses dispext for the HDMI output so it's not necessary to + * keep disp0 power-domains always-on. + */ +&ps_disp0_sys { + /delete-property/ apple,always-on; +}; + +&ps_disp0_fe { + /delete-property/ apple,always-on; +}; + /* * Force the bus number assignments so that we can declare some of the * on-board devices and properties that are populated by the bootloader
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 566/844 media: amphion: Drop min_queued_buffers assignment
In reply to Sasha LevinFrom: Ming Qian <[email protected]>
[ Upstream commit 5633ec763a2a18cef6c5ac9250e4f4b8786e7999 ]
The min_queued_buffers field controls when start_streaming() is called by the vb2 core (it delays the callback until at least N buffers are queued). Setting it to 1 affects the timing of start_streaming(), which breaks the seek flow in decoder scenarios and causes test failures.
The current driver implementation does not rely on this minimum buffer requirement and handles streaming start correctly with the default value of 0, so remove these assignments.
--- drivers/media/platform/amphion/vpu_v4l2.c | 2 -- 1 file changed, 2 deletions(-)
drivers/media/platform/amphion/vpu_v4l2.c +0 -2
@@ -670,7 +670,6 @@ static int vpu_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_q src_vq->mem_ops = &vb2_vmalloc_memops; src_vq->drv_priv = inst; src_vq->buf_struct_size =sizeof (struct vpu_vb2_buffer ); - src_vq->min_queued_buffers =1 ; src_vq->dev = inst->vpu->dev; src_vq->lock = &inst->lock; ret =vb2_queue_init (src_vq);
@@ -687,7 +686,6 @@ static int vpu_m2m_queue_init(void *priv, struct vb2_queue *src_vq, struct vb2_q dst_vq->mem_ops = &vb2_vmalloc_memops; dst_vq->drv_priv = inst; dst_vq->buf_struct_size =sizeof (struct vpu_vb2_buffer ); - dst_vq->min_queued_buffers =1 ; dst_vq->dev = inst->vpu->dev; dst_vq->lock = &inst->lock; ret =vb2_queue_init (dst_vq);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 567/844 media: rockchip: rga: Fix possible ERR_PTR dereference in rga_buf_init()
In reply to Sasha LevinFrom: Alper Ak <[email protected]>
[ Upstream commit 81f8e0e6a2e115df9274d0289779f8fca694479c ]
rga_get_frame() can return ERR_PTR(-EINVAL) when buffer type is unsupported or invalid. rga_buf_init() does not check the return value and unconditionally dereferences the pointer when accessing f->size.
Add proper ERR_PTR checking and return the error to prevent dereferencing an invalid pointer.
--- drivers/media/platform/rockchip/rga/rga-buf.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/rockchip/rga/rga-buf.c +3 -0
@@ -80,6 +80,9 @@ static int rga_buf_init(struct vb2_buffer *vb)struct rga_frame *f =rga_get_frame (ctx, vb->vb2_queue->type);size_t n_desc =0 ; +if (IS_ERR (f)) +return PTR_ERR (f); + n_desc =DIV_ROUND_UP (f->size,PAGE_SIZE ); rbuf->n_desc = n_desc;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 568/844 media: verisilicon: AV1: Set IDR flag for intra_only frame type
In reply to Sasha LevinFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit 1c1b79f40ee4444fa1ac96079751608b724c6b2b ]
Intra_only frame could be considered as a key frame so Instantaneous Decoding Refresh (IDR) flag must be set of the both case and not only for key frames.
--- drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +1 -1
@@ -2018,7 +2018,7 @@ static void rockchip_vpu981_av1_dec_set_parameters(struct hantro_ctx *ctx) !!(ctrls->frame->quantization.flags & V4L2_AV1_QUANTIZATION_FLAG_DELTA_Q_PRESENT)); -hantro_reg_write (vpu, &av1_idr_pic_e, !ctrls->frame->frame_type); +hantro_reg_write (vpu, &av1_idr_pic_e,IS_INTRA (ctrls->frame->frame_type));hantro_reg_write (vpu, &av1_quant_base_qindex, ctrls->frame->quantization.base_q_idx);hantro_reg_write (vpu, &av1_bit_depth_y_minus8, ctx->bit_depth -8 );hantro_reg_write (vpu, &av1_bit_depth_c_minus8, ctx->bit_depth -8 );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 569/844 media: tegra-video: Fix memory leak in __tegra_channel_try_format()
In reply to Sasha LevinFrom: Zilin Guan <[email protected]>
[ Upstream commit 43e5302d22334f1183dec3e0d5d8007eefe2817c ]
The state object allocated by __v4l2_subdev_state_alloc() must be freed with __v4l2_subdev_state_free() when it is no longer needed.
In __tegra_channel_try_format(), two error paths return directly after v4l2_subdev_call() fails, without freeing the allocated 'sd_state' object. This violates the requirement and causes a memory leak.
Fix this by introducing a cleanup label and using goto statements in the error paths to ensure that __v4l2_subdev_state_free() is always called before the function returns.
--- drivers/staging/media/tegra-video/vi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/staging/media/tegra-video/vi.c +8 -5
@@ -438,7 +438,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, .target = V4L2_SEL_TGT_CROP_BOUNDS, };struct v4l2_rect *try_crop; -int ret; +int ret =0 ; subdev =tegra_channel_get_remote_source_subdev (chan);if (!subdev)
@@ -482,8 +482,10 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, }else { ret =v4l2_subdev_call (subdev, pad, get_selection,NULL , &sdsel); -if (ret) -return -EINVAL ; +if (ret) { + ret = -EINVAL ; + goto out_free; + } try_crop->width = sdsel.r.width; try_crop->height = sdsel.r.height;
@@ -495,14 +497,15 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan, ret =v4l2_subdev_call (subdev, pad, set_fmt, sd_state, &fmt);if (ret <0 ) -return ret; + goto out_free;v4l2_fill_pix_format (pix, &fmt.format); chan->vi->ops->vi_fmt_align (pix, fmtinfo->bpp); +out_free:__v4l2_subdev_state_free (sd_state); -return 0 ; +return ret; } static int tegra_channel_try_format(struct file *file, void *fh,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 570/844 media: radio-keene: fix memory leak in error path
In reply to Sasha LevinFrom: Shaurya Rane <[email protected]>
[ Upstream commit b8bf939d77c0cd01118e953bbf554e0fa15e9006 ]
Fix a memory leak in usb_keene_probe(). The v4l2 control handler is initialized and controls are added, but if v4l2_device_register() or video_register_device() fails afterward, the handler was never freed, leaking memory.
Add v4l2_ctrl_handler_free() call in the err_v4l2 error path to ensure the control handler is properly freed for all error paths after it is initialized.
--- drivers/media/radio/radio-keene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/radio/radio-keene.c +1 -1
@@ -338,7 +338,6 @@ static int usb_keene_probe(struct usb_interface *intf,if (hdl->error) { retval = hdl->error; -v4l2_ctrl_handler_free (hdl); goto err_v4l2; } retval =v4l2_device_register (&intf->dev, &radio->v4l2_dev);
@@ -384,6 +383,7 @@ static int usb_keene_probe(struct usb_interface *intf, err_vdev:v4l2_device_unregister (&radio->v4l2_dev); err_v4l2: +v4l2_ctrl_handler_free (&radio->hdl);kfree (radio->buffer);kfree (radio); err:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 571/844 media: cx88: Add missing unmap in snd_cx88_hw_params()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit dbc527d980f7ba8559de38f8c1e4158c71a78915 ]
In error path, add cx88_alsa_dma_unmap() to release resource acquired by cx88_alsa_dma_map().
--- drivers/media/pci/cx88/cx88-alsa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/pci/cx88/cx88-alsa.c +3 -1
@@ -483,8 +483,10 @@ static int snd_cx88_hw_params(struct snd_pcm_substream *substream, ret =cx88_risc_databuffer (chip->pci, &buf->risc, buf->sglist, chip->period_size, chip->num_periods,1 ); -if (ret <0 ) +if (ret <0 ) { +cx88_alsa_dma_unmap (chip); goto error; + }/* Loop back to start of program */ buf->risc.jmp[0 ] =cpu_to_le32 (RISC_JUMP |RISC_IRQ1 |RISC_CNT_INC );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 572/844 media: cx23885: Add missing unmap in snd_cx23885_hw_params()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit 141c81849fab2ad4d6e3fdaff7cbaa873e8b5eb2 ]
In error path, add cx23885_alsa_dma_unmap() to release the resource acquired by cx23885_alsa_dma_map().
--- drivers/media/pci/cx23885/cx23885-alsa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/pci/cx23885/cx23885-alsa.c +3 -1
@@ -392,8 +392,10 @@ static int snd_cx23885_hw_params(struct snd_pcm_substream *substream, ret =cx23885_risc_databuffer (chip->pci, &buf->risc, buf->sglist, chip->period_size, chip->num_periods,1 ); -if (ret <0 ) +if (ret <0 ) { +cx23885_alsa_dma_unmap (chip); goto error; + }/* Loop back to start of program */ buf->risc.jmp[0 ] =cpu_to_le32 (RISC_JUMP |RISC_IRQ1 |RISC_CNT_INC );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 573/844 media: cx25821: Add missing unmap in snd_cx25821_hw_params()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit 863f50d583445c3c8b28a0fc4bb9c18fd9656f41 ]
In error path, add cx25821_alsa_dma_unmap() to release the resource acquired by cx25821_alsa_dma_map()
--- drivers/media/pci/cx25821/cx25821-alsa.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/cx25821/cx25821-alsa.c +1 -0
@@ -535,6 +535,7 @@ static int snd_cx25821_hw_params(struct snd_pcm_substream *substream, chip->period_size, chip->num_periods, 1);if (ret <0 ) {pr_info ("DEBUG: ERROR after cx25821_risc_databuffer_audio()\n" ); +cx25821_alsa_dma_unmap (chip); goto error; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 574/844 media: i2c/tw9903: Fix potential memory leak in tw9903_probe()
In reply to Sasha LevinFrom: Abdun Nihaal <[email protected]>
[ Upstream commit 9cea16fea47e5553f51d10957677ff735b1eff03 ]
In one of the error paths in tw9903_probe(), the memory allocated in v4l2_ctrl_handler_init() and v4l2_ctrl_new_std() is not freed. Fix that by calling v4l2_ctrl_handler_free() on the handler in that error path.
--- drivers/media/i2c/tw9903.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/tw9903.c +1 -0
@@ -228,6 +228,7 @@ static int tw9903_probe(struct i2c_client *client)if (write_regs (sd, initial_registers) <0 ) {v4l2_err (client,"error initializing TW9903\n" ); +v4l2_ctrl_handler_free (hdl);return -EINVAL ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 575/844 media: i2c/tw9906: Fix potential memory leak in tw9906_probe()
In reply to Sasha LevinFrom: Abdun Nihaal <[email protected]>
[ Upstream commit cad237b6c875fbee5d353a2b289e98d240d17ec8 ]
In one of the error paths in tw9906_probe(), the memory allocated in v4l2_ctrl_handler_init() and v4l2_ctrl_new_std() is not freed. Fix that by calling v4l2_ctrl_handler_free() on the handler in that error path.
--- drivers/media/i2c/tw9906.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/tw9906.c +1 -0
@@ -196,6 +196,7 @@ static int tw9906_probe(struct i2c_client *client)if (write_regs (sd, initial_registers) <0 ) {v4l2_err (client,"error initializing TW9906\n" ); +v4l2_ctrl_handler_free (hdl);return -EINVAL ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 576/844 media: i2c: ov01a10: Fix the horizontal flip control
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit ada20c3db0db4f2834d9515f6105111871f04a4d ]
During sensor calibration I noticed that with the hflip control set to false/disabled the image was mirrored.
So it seems that the horizontal flip control is inverted and needs to be set to 1 to not flip (just like the similar problem recently fixed on the ov08x40 sensor).
Invert the hflip control to fix the sensor mirroring by default.
As the comment above the newly added OV01A10_MEDIA_BUS_FMT define explains the control being inverted also means that the native Bayer-order of the sensor actually is GBRG not BGGR, but so as to not break userspace the Bayer-order is kept at BGGR.
--- drivers/media/i2c/ov01a10.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/media/i2c/ov01a10.c +17 -8
@@ -75,6 +75,15 @@#define OV01A10_REG_X_WIN 0x3811#define OV01A10_REG_Y_WIN 0x3813 +/* +* The native ov01a10 bayer-pattern is GBRG, but there was a driver bug enabling +* hflip/mirroring by default resulting in BGGR. Because of this bug Intel's +* proprietary IPU6 userspace stack expects BGGR. So we report BGGR to not break +* userspace and fix things up by shifting the crop window-x coordinate by 1 +* when hflip is *disabled*. +*/ +#define OV01A10_MEDIA_BUS_FMT MEDIA_BUS_FMT_SBGGR10_1X10 +struct ov01a10_reg {u16 address;u8 val;
@@ -185,14 +194,14 @@ static const struct ov01a10_reg sensor_1280x800_setting[] = { {0x380e, 0x03}, {0x380f, 0x80}, {0x3810, 0x00}, - {0x3811, 0x08}, + {0x3811, 0x09}, {0x3812, 0x00}, {0x3813, 0x08}, {0x3814, 0x01}, {0x3815, 0x01}, {0x3816, 0x01}, {0x3817, 0x01}, - {0x3820, 0xa0}, + {0x3820, 0xa8}, {0x3822, 0x13}, {0x3832, 0x28}, {0x3833, 0x10},
@@ -411,7 +420,7 @@ static int ov01a10_set_hflip(struct ov01a10 *ov01a10, u32 hflip)int ret;u32 val, offset; - offset = hflip ?0x9 :0x8 ; + offset = hflip ?0x8 :0x9 ; ret =ov01a10_write_reg (ov01a10,OV01A10_REG_X_WIN ,1 , offset);if (ret)return ret;
@@ -420,8 +429,8 @@ static int ov01a10_set_hflip(struct ov01a10 *ov01a10, u32 hflip)if (ret)return ret; - val = hflip ? val |FIELD_PREP (OV01A10_HFLIP_MASK ,0x1 ) : - val & ~OV01A10_HFLIP_MASK ; + val = hflip ? val & ~OV01A10_HFLIP_MASK : + val |FIELD_PREP (OV01A10_HFLIP_MASK ,0x1 );return ov01a10_write_reg (ov01a10,OV01A10_REG_FORMAT1 ,1 , val); }
@@ -610,7 +619,7 @@ static void ov01a10_update_pad_format(const struct ov01a10_mode *mode, { fmt->width = mode->width; fmt->height = mode->height; - fmt->code =MEDIA_BUS_FMT_SBGGR10_1X10 ; + fmt->code =OV01A10_MEDIA_BUS_FMT ; fmt->field =V4L2_FIELD_NONE ; fmt->colorspace =V4L2_COLORSPACE_RAW ; }
@@ -751,7 +760,7 @@ static int ov01a10_enum_mbus_code(struct v4l2_subdev *sd,if (code->index >0 )return -EINVAL ; - code->code =MEDIA_BUS_FMT_SBGGR10_1X10 ; + code->code =OV01A10_MEDIA_BUS_FMT ;return 0 ; }
@@ -761,7 +770,7 @@ static int ov01a10_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_frame_size_enum *fse) {if (fse->index >=ARRAY_SIZE (supported_modes) || - fse->code !=MEDIA_BUS_FMT_SBGGR10_1X10 ) + fse->code !=OV01A10_MEDIA_BUS_FMT )return -EINVAL ; fse->min_width = supported_modes[fse->index].width;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 577/844 media: i2c: ov01a10: Fix reported pixel-rate value
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 9c632eebf6af4cb7b0f85503fe1ebc5176ff0db1 ]
CSI lanes are double-clocked so with a single lane at 400MHZ the resulting pixel-rate for 10-bits pixels is 400 MHz * 2 / 10 = 80 MHz, not 40 MHz.
This also matches with the observed frame-rate of 60 fps with the default vblank setting: 80000000 / (1488 * 896) = 60.
--- drivers/media/i2c/ov01a10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov01a10.c +1 -1
@@ -16,7 +16,7 @@#include <media/v4l2-fwnode.h> #define OV01A10_LINK_FREQ_400MHZ 400000000ULL -#define OV01A10_SCLK 40000000LL +#define OV01A10_SCLK 80000000LL#define OV01A10_DATA_LANES 1#define OV01A10_REG_CHIP_ID 0x300a
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 578/844 media: i2c: ov01a10: Fix analogue gain range
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 109e0feacaeca5ec2dd71d7d17c73232ce5cbddc ]
A analogue maximum gain of 0xffff / 65525 seems unlikely and testing indeed shows that the gain control wraps-around at 16383, so set the maximum gain to 0x3fff / 16383.
The minimum gain of 0x100 is correct. Setting bits 8-11 to 0x0 results in the same gain values as setting these bits to 0x1, with bits 0-7 still increasing the gain when going from 0x000 - 0x0ff in the exact same range as when going from 0x100 - 0x1ff.
--- drivers/media/i2c/ov01a10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov01a10.c +1 -1
@@ -48,7 +48,7 @@/* analog gain controls */ #define OV01A10_REG_ANALOG_GAIN 0x3508#define OV01A10_ANAL_GAIN_MIN 0x100 -#define OV01A10_ANAL_GAIN_MAX 0xffff +#define OV01A10_ANAL_GAIN_MAX 0x3fff#define OV01A10_ANAL_GAIN_STEP 1/* digital gain controls */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 579/844 media: i2c: ov01a10: Add missing v4l2_subdev_cleanup() calls
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 0dfec6e30c334364145d0acb38bb8c216b9a7a78 ]
Add missing v4l2_subdev_cleanup() calls to cleanup after v4l2_subdev_init_finalize().
--- drivers/media/i2c/ov01a10.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/ov01a10.c +2 -0
@@ -864,6 +864,7 @@ static void ov01a10_remove(struct i2c_client *client)struct v4l2_subdev *sd =i2c_get_clientdata (client);v4l2_async_unregister_subdev (sd); +v4l2_subdev_cleanup (sd);media_entity_cleanup (&sd->entity);v4l2_ctrl_handler_free (sd->ctrl_handler);
@@ -934,6 +935,7 @@ static int ov01a10_probe(struct i2c_client *client) err_pm_disable:pm_runtime_disable (dev);pm_runtime_set_suspended (&client->dev); +v4l2_subdev_cleanup (&ov01a10->sd); err_media_entity_cleanup:media_entity_cleanup (&ov01a10->sd.entity);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 580/844 media: i2c: ov01a10: Fix passing stream instead of pad to v4l2_subdev_state_get_format()
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit f8563a375e7fba7c776eb591d4498be592c19098 ]
The 2 argument version of v4l2_subdev_state_get_format() takes the pad as second argument, not the stream.
--- drivers/media/i2c/ov01a10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov01a10.c +1 -1
@@ -731,7 +731,7 @@ static int ov01a10_set_format(struct v4l2_subdev *sd, h_blank); } - format =v4l2_subdev_state_get_format (sd_state, fmt->stream); + format =v4l2_subdev_state_get_format (sd_state, fmt->pad); *format = fmt->format;return 0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 581/844 media: i2c: ov01a10: Fix test-pattern disabling
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 409fb57c1b3deada4b8e153eb6344afb3c2dfb9c ]
When the test-pattern control gets set to 0 (Disabled) 0 should be written to the test-pattern register, rather then doing nothing.
--- drivers/media/i2c/ov01a10.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/media/i2c/ov01a10.c +4 -7
@@ -249,9 +249,8 @@ static const struct ov01a10_reg sensor_1280x800_setting[] = {static const char *const ov01a10_test_pattern_menu[] = {"Disabled" ,"Color Bar" , -"Top-Bottom Darker Color Bar" , -"Right-Left Darker Color Bar" , -"Color Bar type 4" , +"Left-Right Darker Color Bar" , +"Bottom-Top Darker Color Bar" , };static const s64 link_freq_menu_items[] = {
@@ -406,10 +405,8 @@ static int ov01a10_update_digital_gain(struct ov01a10 *ov01a10, u32 d_gain)static int ov01a10_test_pattern (struct ov01a10 *ov01a10,u32 pattern) { -if (!pattern) -return 0 ; - - pattern = (pattern -1 ) |OV01A10_TEST_PATTERN_ENABLE ; +if (pattern) + pattern |=OV01A10_TEST_PATTERN_ENABLE ;return ov01a10_write_reg (ov01a10,OV01A10_REG_TEST_PATTERN ,1 , pattern); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 582/844 media: qcom: camss: vfe: Fix out-of-bounds access in vfe_isr_reg_update()
In reply to Sasha LevinFrom: Alper Ak <[email protected]>
[ Upstream commit d965919af524e68cb2ab1a685872050ad2ee933d ]
vfe_isr() iterates using MSM_VFE_IMAGE_MASTERS_NUM(7) as the loop bound and passes the index to vfe_isr_reg_update(). However, vfe->line[] array is defined with VFE_LINE_NUM_MAX(4):
struct vfe_line line[VFE_LINE_NUM_MAX];
When index is 4, 5, 6, the access to vfe->line[line_id] exceeds the array bounds and resulting in out-of-bounds memory access.
Fix this by using separate loops for output lines and write masters.
--- drivers/media/platform/qcom/camss/camss-vfe-480.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-480.c +4 -2
@@ -202,11 +202,13 @@ static irqreturn_t vfe_isr(int irq, void *dev)writel_relaxed (status, vfe->base +VFE_BUS_IRQ_CLEAR (0 ));writel_relaxed (1 , vfe->base +VFE_BUS_IRQ_CLEAR_GLOBAL ); -/* Loop through all WMs IRQs */ -for (i =0 ; i <MSM_VFE_IMAGE_MASTERS_NUM ; i++) { +for (i =0 ; i <MAX_VFE_OUTPUT_LINES ; i++) {if (status &BUS_IRQ_MASK_0_RDI_RUP (vfe, i))vfe_isr_reg_update (vfe, i); + } +/* Loop through all WMs IRQs */ +for (i =0 ; i <MSM_VFE_IMAGE_MASTERS_NUM ; i++) {if (status &BUS_IRQ_MASK_0_COMP_DONE (vfe,RDI_COMP_GROUP (i)))vfe_buf_done (vfe, i); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 583/844 media: ccs: Avoid possible division by zero
In reply to Sasha LevinFrom: Sakari Ailus <[email protected]>
[ Upstream commit 679f0b7b6a409750a25754c8833e268e5fdde742 ]
Calculating maximum M for scaler configuration involves dividing by MIN_X_OUTPUT_SIZE limit register's value. Albeit the value is presumably non-zero, the driver was missing the check it in fact was. Fix this.
--- drivers/media/i2c/ccs/ccs-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ccs/ccs-core.c +1 -1
@@ -2346,7 +2346,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev, *CCS_LIM (sensor,SCALER_N_MIN ) / sel->r.height; max_m = crops[CCS_PAD_SINK ]->width *CCS_LIM (sensor,SCALER_N_MIN ) - /CCS_LIM (sensor,MIN_X_OUTPUT_SIZE ); + / (CCS_LIM (sensor,MIN_X_OUTPUT_SIZE ) ?:1 ); a =clamp (a,CCS_LIM (sensor,SCALER_M_MIN ),CCS_LIM (sensor,SCALER_M_MAX ));
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 584/844 media: i2c: ov5647: Initialize subdev before controls
In reply to Sasha LevinFrom: Jai Luthra <[email protected]>
[ Upstream commit eee13cbccacb6d0a3120c126b8544030905b069d ]
In ov5647_init_controls() we call v4l2_get_subdevdata, but it is initialized by v4l2_i2c_subdev_init() in the probe, which currently happens after init_controls(). This can result in a segfault if the error condition is hit, and we try to access i2c_client, so fix the order.
--- drivers/media/i2c/ov5647.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5647.c +4 -4
@@ -1420,15 +1420,15 @@ static int ov5647_probe(struct i2c_client *client) sensor->mode =OV5647_DEFAULT_MODE ; - ret =ov5647_init_controls (sensor); -if (ret) - goto mutex_destroy; - sd = &sensor->sd;v4l2_i2c_subdev_init (sd, client, &ov5647_subdev_ops); sd->internal_ops = &ov5647_subdev_internal_ops; sd->flags |=V4L2_SUBDEV_FL_HAS_DEVNODE |V4L2_SUBDEV_FL_HAS_EVENTS ; + ret =ov5647_init_controls (sensor); +if (ret) + goto mutex_destroy; + sensor->pad.flags =MEDIA_PAD_FL_SOURCE ; sd->entity.function =MEDIA_ENT_F_CAM_SENSOR ; ret =media_entity_pads_init (&sd->entity,1 , &sensor->pad);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 585/844 media: i2c: ov5647: Correct pixel array offset
In reply to Sasha LevinFrom: David Plowman <[email protected]>
[ Upstream commit a4e62e597f21bb37db0ad13aca486094e9188167 ]
The top offset in the pixel array is actually 6 (see page 3-1 of the OV5647 data sheet).
--- drivers/media/i2c/ov5647.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov5647.c +1 -1
@@ -69,7 +69,7 @@#define OV5647_NATIVE_HEIGHT 1956U#define OV5647_PIXEL_ARRAY_LEFT 16U -#define OV5647_PIXEL_ARRAY_TOP 16U +#define OV5647_PIXEL_ARRAY_TOP 6U#define OV5647_PIXEL_ARRAY_WIDTH 2592U#define OV5647_PIXEL_ARRAY_HEIGHT 1944U
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 586/844 media: i2c: ov5647: Correct minimum VBLANK value
In reply to Sasha LevinFrom: David Plowman <[email protected]>
[ Upstream commit 1438248c5a82c86b4e1f0311c3bb827af747a8cf ]
Trial and error reveals that the minimum vblank value appears to be 24 (the OV5647 data sheet does not give any clues). This fixes streaming lock-ups in full resolution mode.
--- drivers/media/i2c/ov5647.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov5647.c +1 -1
@@ -73,7 +73,7 @@#define OV5647_PIXEL_ARRAY_WIDTH 2592U#define OV5647_PIXEL_ARRAY_HEIGHT 1944U -#define OV5647_VBLANK_MIN 4 +#define OV5647_VBLANK_MIN 24#define OV5647_VTS_MAX 32767#define OV5647_EXPOSURE_MIN 4
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 587/844 media: i2c: ov5647: Sensor should report RAW color space
In reply to Sasha LevinFrom: David Plowman <[email protected]>
[ Upstream commit f007586b1e89dcea40168415d0422cb7a0fc31b1 ]
As this sensor captures RAW bayer frames, the colorspace should be V4L2_COLORSPACE_RAW instead of SRGB.
--- drivers/media/i2c/ov5647.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/i2c/ov5647.c +4 -4
@@ -508,7 +508,7 @@ static const struct ov5647_mode ov5647_modes[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width =2592 , .height = 1944
@@ -529,7 +529,7 @@ static const struct ov5647_mode ov5647_modes[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width =1920 , .height = 1080
@@ -550,7 +550,7 @@ static const struct ov5647_mode ov5647_modes[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width =1296 , .height = 972
@@ -571,7 +571,7 @@ static const struct ov5647_mode ov5647_modes[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width =640 , .height = 480
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 588/844 media: i2c: ov5647: Fix PIXEL_RATE value for VGA mode
In reply to Sasha LevinFrom: Jai Luthra <[email protected]>
[ Upstream commit c063632b494b02e891442d10f17e37b7fcfab9b3 ]
The pixel rate for VGA (640x480) mode is configured in the mode's table to be 58.333 MPix/s instead of 55 MPix/s, so fix it.
--- drivers/media/i2c/ov5647.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov5647.c +1 -1
@@ -582,7 +582,7 @@ static const struct ov5647_mode ov5647_modes[] = { .width = 2560, .height = 1920, }, - .pixel_rate = 55000000, + .pixel_rate = 58333000, .hts = 1852, .vts = 0x1f8, .reg_list = ov5647_640x480_10bpp,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 589/844 media: ccs: Fix setting initial sub-device state
In reply to Sasha LevinFrom: Sakari Ailus <[email protected]>
[ Upstream commit 31e5191aa11931b53e1242acef4f4375f00ca523 ]
Fix setting sub-device state for non-source sub-devices.
--- drivers/media/i2c/ccs/ccs-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/media/i2c/ccs/ccs-core.c +9 -1
@@ -2940,6 +2940,8 @@ static void ccs_cleanup(struct ccs_sensor *sensor)ccs_free_controls (sensor); } +static const struct v4l2_subdev_internal_ops ccs_internal_ops; + static int ccs_init_subdev(struct ccs_sensor *sensor, struct ccs_subdev *ssd, const char *name, unsigned short num_pads, u32 function,
@@ -2952,8 +2954,10 @@ static int ccs_init_subdev(struct ccs_sensor *sensor,if (!ssd)return 0 ; -if (ssd != sensor->src) +if (ssd != sensor->src) {v4l2_subdev_init (&ssd->sd, &ccs_ops); + ssd->sd.internal_ops = &ccs_internal_ops; + } ssd->sd.flags |=V4L2_SUBDEV_FL_HAS_DEVNODE ; ssd->sd.entity.function = function;
@@ -3062,6 +3066,10 @@ static const struct media_entity_operations ccs_entity_ops = { .link_validate = v4l2_subdev_link_validate, }; +static const struct v4l2_subdev_internal_ops ccs_internal_ops = { + .init_state = ccs_init_state, +}; +static const struct v4l2_subdev_internal_ops ccs_internal_src_ops = { .init_state = ccs_init_state, .registered = ccs_registered,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 590/844 media: i2c: ov5647: use our own mutex for the ctrl lock
In reply to Sasha LevinFrom: Xiaolei Wang <[email protected]>
[ Upstream commit 973e42fd5d2b397bff34f0c249014902dbf65912 ]
__v4l2_ctrl_handler_setup() and __v4l2_ctrl_modify_range() contains an assertion to verify that the v4l2_ctrl_handler::lock is held, as it should only be called when the lock has already been acquired. Therefore use our own mutex for the ctrl lock, otherwise a warning will be reported.
--- drivers/media/i2c/ov5647.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/ov5647.c +2 -0
@@ -1291,6 +1291,8 @@ static int ov5647_init_controls(struct ov5647 *sensor)v4l2_ctrl_handler_init (&sensor->ctrls,9 ); + sensor->ctrls.lock = &sensor->lock; +v4l2_ctrl_new_std (&sensor->ctrls, &ov5647_ctrl_ops,V4L2_CID_AUTOGAIN ,0 ,1 ,1 ,0 );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 591/844 media: dw9714: Fix powerup sequence
In reply to Sasha LevinFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 401aec35ac7bd04b4018a519257b945abb88e26c ]
We have experienced seen multiple I2C errors while doing stress test on the module:
dw9714 i2c-PRP0001:01: dw9714_vcm_resume I2C failure: -5 dw9714 i2c-PRP0001:01: I2C write fail
Inspecting the powerup sequence we found that it does not match the documentation at:
https://blog.arducam.com/downloads/DW9714A-DONGWOON(Autofocus_motor_manual).pdf
"""
(2) DW9714A requires waiting time of 12ms after power on. During this waiting time, the offset calibration of internal amplifier is operating for minimization of output offset current .
"""
This patch increases the powerup delay to follow the documentation.
--- drivers/media/i2c/dw9714.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/dw9714.c +1 -1
@@ -149,7 +149,7 @@ static int dw9714_power_up(struct dw9714_device *dw9714_dev)gpiod_set_value_cansleep (dw9714_dev->powerdown_gpio,0 ); -usleep_range (1000 ,2000 ); +usleep_range (12000 ,14000 );return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 592/844 media: ipu6: Fix typo and wrong constant in ipu6-mmu.c
In reply to Sasha LevinFrom: Bingbu Cao <[email protected]>
[ Upstream commit 3e0fcc91277d5af114a58aaa68f34b44e8d8a411 ]
Fix two coding errors in ipu6-mmu.c:
1. Fix syntax error in page_table_dump() where the closing parenthesis and semicolon were swapped in the TBL_PHYS_ADDR macro call.
2. Fix incorrect loop bound in alloc_l2_pt(). When initializing L2 page table entries, the loop was incorrectly using ISP_L1PT_PTES instead of ISP_L2PT_PTES.
--- drivers/media/pci/intel/ipu6/ipu6-mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/pci/intel/ipu6/ipu6-mmu.c +2 -2
@@ -102,7 +102,7 @@ static void page_table_dump(struct ipu6_mmu_info *mmu_info)if (mmu_info->l1_pt[l1_idx] == mmu_info->dummy_l2_pteval)continue ; - l2_phys = TBL_PHYS_ADDR(mmu_info->l1_pt[l1_idx];) + l2_phys =TBL_PHYS_ADDR (mmu_info->l1_pt[l1_idx]);dev_dbg (mmu_info->dev,"l1 entry %u; iovas 0x%8.8x-0x%8.8x, at %pap\n" , l1_idx, iova, iova +ISP_PAGE_SIZE , &l2_phys);
@@ -248,7 +248,7 @@ static u32 *alloc_l2_pt(struct ipu6_mmu_info *mmu_info)dev_dbg (mmu_info->dev,"alloc_l2: get_zeroed_page() = %p\n" , pt); -for (i =0 ; i <ISP_L1PT_PTES ; i++) +for (i =0 ; i <ISP_L2PT_PTES ; i++) pt[i] = mmu_info->dummy_page_pteval;return pt;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 593/844 media: ipu6: Fix RPM reference leak in probe error paths
In reply to Sasha LevinFrom: Bingbu Cao <[email protected]>
[ Upstream commit 6099f78e4c9223f4de4169d2fd1cded01279da1a ]
Several error paths in ipu6_pci_probe() were jumping directly to out_ipu6_bus_del_devices without releasing the runtime PM reference. Add pm_runtime_put_sync() before cleaning up other resources.
--- drivers/media/pci/intel/ipu6/ipu6.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/pci/intel/ipu6/ipu6.c +6 -4
@@ -630,21 +630,21 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (ret) {dev_err_probe (&isp->pdev->dev, ret,"Failed to set MMU hardware\n" ); - goto out_ipu6_bus_del_devices; + goto out_ipu6_rpm_put; } ret =ipu6_buttress_map_fw_image (isp->psys, isp->cpd_fw, &isp->psys->fw_sgt);if (ret) {dev_err_probe (&isp->pdev->dev, ret,"failed to map fw image\n" ); - goto out_ipu6_bus_del_devices; + goto out_ipu6_rpm_put; } ret =ipu6_cpd_create_pkg_dir (isp->psys, isp->cpd_fw->data);if (ret) {dev_err_probe (&isp->pdev->dev, ret,"failed to create pkg dir\n" ); - goto out_ipu6_bus_del_devices; + goto out_ipu6_rpm_put; } ret = devm_request_threaded_irq(dev, pdev->irq, ipu6_buttress_isr,
@@ -652,7 +652,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) IRQF_SHARED, IPU6_NAME, isp);if (ret) {dev_err_probe (dev, ret,"Requesting irq failed\n" ); - goto out_ipu6_bus_del_devices; + goto out_ipu6_rpm_put; } ret =ipu6_buttress_authenticate (isp);
@@ -683,6 +683,8 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) out_free_irq:devm_free_irq (dev, pdev->irq, isp); +out_ipu6_rpm_put: +pm_runtime_put_sync (&isp->psys->auxdev.dev); out_ipu6_bus_del_devices:if (isp->psys) {ipu6_cpd_free_pkg_dir (isp->psys);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 594/844 media: staging/ipu7: Ignore interrupts when device is suspended
In reply to Sasha LevinFrom: Bingbu Cao <[email protected]>
[ Upstream commit 9ad65684b9285c5d66fb417d50e91a25ef8c994d ]
IPU7 devices have shared interrupts with others. In some case when IPU7 device is suspended, driver get unexpected interrupt and invalid irq status 0xffffffff from ISR_STATUS and PB LOCAL_STATUS registers as interrupt is triggered from other device on shared irq line.
In order to avoid this issue use pm_runtime_get_if_active() to check if IPU7 device is resumed, ignore the invalid irq status and use synchronize_irq() in suspend.
--- drivers/staging/media/ipu7/ipu7-buttress.c | 17 ++++++++++++++++- drivers/staging/media/ipu7/ipu7.c | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7-buttress.c +16 -1
@@ -342,14 +342,23 @@ irqreturn_t ipu_buttress_isr(int irq, void *isp_ptr)u32 disable_irqs =0 ;u32 irq_status;unsigned int i; +int active; -pm_runtime_get_noresume (dev); + active =pm_runtime_get_if_active (dev); +if (active <=0 ) +return IRQ_NONE ; pb_irq =readl (isp->pb_base +INTERRUPT_STATUS );writel (pb_irq, isp->pb_base +INTERRUPT_STATUS );/* check btrs ATS, CFI and IMR errors, BIT(0) is unused for IPU */ pb_local_irq =readl (isp->pb_base +BTRS_LOCAL_INTERRUPT_MASK ); +if (pb_local_irq ==0xffffffff ) { +dev_warn_once (dev,"invalid PB irq status\n" ); +pm_runtime_put_noidle (dev); +return IRQ_NONE ; + } +if (pb_local_irq & ~BIT (0 )) {dev_warn (dev,"PB interrupt status 0x%x local 0x%x\n" , pb_irq, pb_local_irq);
@@ -370,6 +379,12 @@ irqreturn_t ipu_buttress_isr(int irq, void *isp_ptr)return IRQ_NONE ; } +if (irq_status ==0xffffffff ) { +dev_warn_once (dev,"invalid irq status 0x%08x\n" , irq_status); +pm_runtime_put_noidle (dev); +return IRQ_NONE ; + } + do { writel(irq_status, isp->base + BUTTRESS_REG_IRQ_CLEAR);
drivers/staging/media/ipu7/ipu7.c +4 -0
@@ -2684,6 +2684,10 @@ static void ipu7_pci_reset_done(struct pci_dev *pdev)*/ static int ipu7_suspend (struct device *dev) { +struct pci_dev *pdev =to_pci_dev (dev); + +synchronize_irq (pdev->irq); +return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 595/844 media: staging/ipu7: Call synchronous RPM suspend in probe failure
In reply to Sasha LevinFrom: Bingbu Cao <[email protected]>
[ Upstream commit 1433e6ccc25e9ea596683ab66e1c51f37fc7d491 ]
If firmware authentication failed during driver probe, driver call an asynchronous API to suspend the psys device but the bus device will be removed soon, thus runtime PM of bus device will be disabled soon, that will cancel the suspend request, so use synchronous suspend to make sure the runtime suspend before disabling its RPM.
IPU7 hardware has constraints that the PSYS device must be powered off before ISYS, otherwise it will cause machine check error.
--- drivers/staging/media/ipu7/ipu7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7.c +1 -1
@@ -2620,7 +2620,7 @@ static int ipu7_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (!IS_ERR_OR_NULL (isp->isys) && !IS_ERR_OR_NULL (isp->isys->mmu))ipu7_mmu_cleanup (isp->isys->mmu);if (!IS_ERR_OR_NULL (isp->psys)) -pm_runtime_put (&isp->psys->auxdev.dev); +pm_runtime_put_sync (&isp->psys->auxdev.dev);ipu7_bus_del_devices (pdev);release_firmware (isp->cpd_fw); buttress_exit:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 596/844 media: staging/ipu7: Update CDPHY register settings
In reply to Sasha LevinFrom: Bingbu Cao <[email protected]>
[ Upstream commit f7923e6bafcad686adb51cc100ba1860f8b43922 ]
Some CPHY settings needs to updated according to the latest guide from SNPS. This patch program 45ohm for tuning resistance to fix CPHY problem and update the ITMINRX and GMODE for CPHY.
--- drivers/staging/media/ipu7/ipu7-isys-csi-phy.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/staging/media/ipu7/ipu7-isys-csi-phy.c +10 -3
@@ -124,6 +124,7 @@ static const struct cdr_fbk_cap_prog_params table7[] = { { 1350, 1589, 4 }, { 1590, 1949, 5 }, { 1950, 2499, 6 }, + { 2500, 3500, 7 }, { } };
@@ -838,9 +839,10 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,dwc_phy_write_mask (isys, id, reg +0x400 * i, reset_thresh,9 ,11 ); +/* Tuning ITMINRX to 2 for CPHY */ reg =CORE_DIG_CLANE_0_RW_LP_0 ;for (i =0 ; i < trios; i++) -dwc_phy_write_mask (isys, id, reg +0x400 * i,1 ,12 ,15 ); +dwc_phy_write_mask (isys, id, reg +0x400 * i,2 ,12 ,15 ); reg =CORE_DIG_CLANE_0_RW_LP_2 ;for (i =0 ; i < trios; i++)
@@ -860,7 +862,11 @@ static void ipu7_isys_cphy_config(struct ipu7_isys *isys, u8 id, u8 lanes,for (i =0 ; i < (lanes +1 ); i++) { reg =CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_9 +0x400 * i;dwc_phy_write_mask (isys, id, reg,4U ,0 ,2 ); -dwc_phy_write_mask (isys, id, reg,0U ,3 ,4 ); +/* Set GMODE to 2 when CPHY >= 1.5Gsps */ +if (mbps >=1500 ) +dwc_phy_write_mask (isys, id, reg,2U ,3 ,4 ); +else +dwc_phy_write_mask (isys, id, reg,0U ,3 ,4 ); reg =CORE_DIG_IOCTRL_RW_AFE_LANE0_CTRL_2_7 +0x400 * i;dwc_phy_write_mask (isys, id, reg, cap_prog,10 ,12 );
@@ -930,8 +936,9 @@ static int ipu7_isys_phy_config(struct ipu7_isys *isys, u8 id, u8 lanes, 7, 12, 14);dwc_phy_write_mask (isys, id,CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_7 ,0 ,8 ,10 ); +/* resistance tuning: 1 for 45ohm, 0 for 50ohm */ dwc_phy_write_mask (isys, id,CORE_DIG_IOCTRL_RW_AFE_CB_CTRL_2_5 , -0 ,8 ,8 ); +1 ,8 ,8 );if (aggregation) phy_mode = isys->csi2[0 ].phy_mode;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 597/844 media: staging/ipu7: Fix the loop bound in l2 table alloc
In reply to Sasha LevinFrom: Bingbu Cao <[email protected]>
[ Upstream commit 98cc19a353abc8b48b7d58fd7a455e09e7c3aba3 ]
This patch fixes the incorrect loop bound in alloc_l2_pt(). When initializing L2 page table entries, the loop was incorrectly using ISP_L1PT_PTES instead of ISP_L2PT_PTES though the ISP_L1PT_PTES is equal to ISP_L2PT_PTES.
--- drivers/staging/media/ipu7/ipu7-mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7-mmu.c +1 -1
@@ -231,7 +231,7 @@ static u32 *alloc_l2_pt(struct ipu7_mmu_info *mmu_info)dev_dbg (mmu_info->dev,"alloc_l2: get_zeroed_page() = %p\n" , pt); -for (i =0 ; i <ISP_L1PT_PTES ; i++) +for (i =0 ; i <ISP_L2PT_PTES ; i++) pt[i] = mmu_info->dummy_page_pteval;return pt;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 598/844 platform/x86: ISST: Add missing write block check
In reply to Sasha LevinFrom: Srinivas Pandruvada <[email protected]>
[ Upstream commit 0e5aef2795008c80c515f6fa04e377c6e5715958 ]
If writes are blocked, then return error during SST-CP enable command. Add missing write block check in this code path.
--- drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +3 -0
@@ -612,6 +612,9 @@ static long isst_if_core_power_state(void __user *argp)return -EINVAL ;if (core_power.get_set) { +if (power_domain_info->write_blocked) +return -EPERM ; +_write_cp_info ("cp_enable" , core_power.enable,SST_CP_CONTROL_OFFSET , SST_CP_ENABLE_START, SST_CP_ENABLE_WIDTH, SST_MUL_FACTOR_NONE) _write_cp_info("cp_prio_type", core_power.priority_type, SST_CP_CONTROL_OFFSET,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 599/844 platform/x86: ISST: Store and restore all domains data
In reply to Sasha LevinFrom: Srinivas Pandruvada <[email protected]>
[ Upstream commit dc7901b5a1563a9c9eb29b3b0b0dac3162065cd8 ]
The suspend/resume callbacks currently only store and restore the configuration for power domain 0. However, other power domains may also have modified configurations that need to be preserved across suspend/ resume cycles.
Extend the store/restore functionality to handle all power domains.
--- .../intel/speed_select_if/isst_tpmi_core.c | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-)
drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +33 -21
@@ -1723,55 +1723,67 @@ EXPORT_SYMBOL_NS_GPL(tpmi_sst_dev_remove, "INTEL_TPMI_SST");void tpmi_sst_dev_suspend (struct auxiliary_device *auxdev) {struct tpmi_sst_struct *tpmi_sst =auxiliary_get_drvdata (auxdev); -struct tpmi_per_power_domain_info *power_domain_info; +struct tpmi_per_power_domain_info *power_domain_info, *pd_info;struct oobmsm_plat_info *plat_info;void __iomem *cp_base; +int num_resources, i; plat_info =tpmi_get_platform_data (auxdev);if (!plat_info)return ; power_domain_info = tpmi_sst->power_domain_info[plat_info->partition]; + num_resources = tpmi_sst->number_of_power_domains[plat_info->partition]; - cp_base = power_domain_info->sst_base + power_domain_info->sst_header.cp_offset; - power_domain_info->saved_sst_cp_control =readq (cp_base +SST_CP_CONTROL_OFFSET ); - -memcpy_fromio (power_domain_info->saved_clos_configs, cp_base +SST_CLOS_CONFIG_0_OFFSET , -sizeof (power_domain_info->saved_clos_configs)); +for (i =0 ; i < num_resources; i++) { + pd_info = &power_domain_info[i]; +if (!pd_info || !pd_info->sst_base) +continue ; -memcpy_fromio (power_domain_info->saved_clos_assocs, cp_base +SST_CLOS_ASSOC_0_OFFSET , -sizeof (power_domain_info->saved_clos_assocs)); + cp_base = pd_info->sst_base + pd_info->sst_header.cp_offset; + pd_info->saved_sst_cp_control =readq (cp_base +SST_CP_CONTROL_OFFSET ); +memcpy_fromio (pd_info->saved_clos_configs, cp_base +SST_CLOS_CONFIG_0_OFFSET , +sizeof (pd_info->saved_clos_configs)); +memcpy_fromio (pd_info->saved_clos_assocs, cp_base +SST_CLOS_ASSOC_0_OFFSET , +sizeof (pd_info->saved_clos_assocs)); - power_domain_info->saved_pp_control =readq (power_domain_info->sst_base + - power_domain_info->sst_header.pp_offset + -SST_PP_CONTROL_OFFSET ); + pd_info->saved_pp_control =readq (pd_info->sst_base + + pd_info->sst_header.pp_offset + +SST_PP_CONTROL_OFFSET ); + } }EXPORT_SYMBOL_NS_GPL (tpmi_sst_dev_suspend,"INTEL_TPMI_SST" );void tpmi_sst_dev_resume (struct auxiliary_device *auxdev) {struct tpmi_sst_struct *tpmi_sst =auxiliary_get_drvdata (auxdev); -struct tpmi_per_power_domain_info *power_domain_info; +struct tpmi_per_power_domain_info *power_domain_info, *pd_info;struct oobmsm_plat_info *plat_info;void __iomem *cp_base; +int num_resources, i; plat_info =tpmi_get_platform_data (auxdev);if (!plat_info)return ; power_domain_info = tpmi_sst->power_domain_info[plat_info->partition]; + num_resources = tpmi_sst->number_of_power_domains[plat_info->partition]; - cp_base = power_domain_info->sst_base + power_domain_info->sst_header.cp_offset; -writeq (power_domain_info->saved_sst_cp_control, cp_base +SST_CP_CONTROL_OFFSET ); - -memcpy_toio (cp_base +SST_CLOS_CONFIG_0_OFFSET , power_domain_info->saved_clos_configs, -sizeof (power_domain_info->saved_clos_configs)); +for (i =0 ; i < num_resources; i++) { + pd_info = &power_domain_info[i]; +if (!pd_info || !pd_info->sst_base) +continue ; -memcpy_toio (cp_base +SST_CLOS_ASSOC_0_OFFSET , power_domain_info->saved_clos_assocs, -sizeof (power_domain_info->saved_clos_assocs)); + cp_base = pd_info->sst_base + pd_info->sst_header.cp_offset; +writeq (pd_info->saved_sst_cp_control, cp_base +SST_CP_CONTROL_OFFSET ); +memcpy_toio (cp_base +SST_CLOS_CONFIG_0_OFFSET , pd_info->saved_clos_configs, +sizeof (pd_info->saved_clos_configs)); +memcpy_toio (cp_base +SST_CLOS_ASSOC_0_OFFSET , pd_info->saved_clos_assocs, +sizeof (pd_info->saved_clos_assocs)); -writeq (power_domain_info->saved_pp_control, power_domain_info->sst_base + - power_domain_info->sst_header.pp_offset +SST_PP_CONTROL_OFFSET ); +writeq (pd_info->saved_pp_control, power_domain_info->sst_base + + pd_info->sst_header.pp_offset +SST_PP_CONTROL_OFFSET ); + } }EXPORT_SYMBOL_NS_GPL (tpmi_sst_dev_resume,"INTEL_TPMI_SST" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 600/844 KVM: x86: Ignore -EBUSY when checking nested events from vcpu_block()
In reply to Sasha LevinFrom: Sean Christopherson <[email protected]>
[ Upstream commit ead63640d4e72e6f6d464f4e31f7fecb79af8869 ]
Ignore -EBUSY when checking nested events after exiting a blocking state while L2 is active, as exiting to userspace will generate a spurious userspace exit, usually with KVM_EXIT_UNKNOWN, and likely lead to the VM's demise. Continuing with the wakeup isn't perfect either, as *something* has gone sideways if a vCPU is awakened in L2 with an injected event (or worse, a nested run pending), but continuing on gives the VM a decent chance of surviving without any major side effects.
As explained in the Fixes commits, it _should_ be impossible for a vCPU to be put into a blocking state with an already-injected event (exception, IRQ, or NMI). Unfortunately, userspace can stuff MP_STATE and/or injected events, and thus put the vCPU into what should be an impossible state.
Don't bother trying to preserve the WARN, e.g. with an anti-syzkaller Kconfig, as WARNs can (hopefully) be added in paths where _KVM_ would be violating x86 architecture, e.g. by WARNing if KVM attempts to inject an exception or interrupt while the vCPU isn't running.
--- arch/x86/kvm/x86.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/x86.c +1 -2
@@ -11609,8 +11609,7 @@ static inline int vcpu_block(struct kvm_vcpu *vcpu)if (is_guest_mode (vcpu)) {int r =kvm_check_nested_events (vcpu); -WARN_ON_ONCE (r == -EBUSY ); -if (r <0 ) +if (r <0 && r != -EBUSY )return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 601/844 dm-integrity: fix a typo in the code for write/discard race
In reply to Sasha LevinFrom: Mikulas Patocka <[email protected]>
[ Upstream commit c698b7f417801fcd79f0dc844250b3361d38e6b8 ]
If we send a write followed by a discard, it may be possible that the discarded data end up being overwritten by the previous write from the journal. The code tries to prevent that, but there was a typo in this logic that made it not being activated as it should be.
Note that if we end up here the second time (when discard_retried is true), it means that the write bio is actually racing with the discard bio, and in this situation it is not specified which of them should win.
--- drivers/md/dm-integrity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-integrity.c +1 -1
@@ -2411,7 +2411,7 @@ static void dm_integrity_map_continue(struct dm_integrity_io *dio, bool from_map new_pos =find_journal_node (ic, dio->range.logical_sector, &next_sector);if (unlikely (new_pos !=NOT_FOUND ) || -unlikely (next_sector < dio->range.logical_sector - dio->range.n_sectors)) { +unlikely (next_sector < dio->range.logical_sector + dio->range.n_sectors)) {remove_range_unlocked (ic, &dio->range);spin_unlock_irq (&ic->endio_wait.lock);queue_work (ic->commit_wq, &ic->commit_work);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 602/844 dm: clear cloned request bio pointer when last clone bio completes
In reply to Sasha LevinFrom: Michael Liang <[email protected]>
[ Upstream commit fb8a6c18fb9a6561f7a15b58b272442b77a242dd ]
Stale rq->bio values have been observed to cause double-initialization of cloned bios in request-based device-mapper targets, leading to use-after-free and double-free scenarios.
One such case occurs when using dm-multipath on top of a PCIe NVMe namespace, where cloned request bios are freed during blk_complete_request(), but rq->bio is left intact. Subsequent clone teardown then attempts to free the same bios again via blk_rq_unprep_clone().
The resulting double-free path looks like:
nvme_pci_complete_batch()
nvme_complete_batch()
blk_mq_end_request_batch()
blk_complete_request() // called on a DM clone request
bio_endio() // first free of all clone bios
...
rq->end_io() // end_clone_request()
dm_complete_request(tio->orig)
dm_softirq_done()
dm_done()
dm_end_request()
blk_rq_unprep_clone() // second free of clone biosFix this by clearing the clone request's bio pointer when the last cloned bio completes, ensuring that later teardown paths do not attempt to free already-released bios.
--- drivers/md/dm-rq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/md/dm-rq.c +10 -3
@@ -109,14 +109,21 @@ static void end_clone_bio(struct bio *clone)*/ tio->completed += nr_bytes; +if (!is_last) +return ; +/* +* At this moment we know this is the last bio of the cloned request, +* and all cloned bios have been released, so reset the clone request's +* bio pointer to avoid double free. +*/ + tio->clone->bio =NULL ; + exit:/* * Update the original request. * Do not use blk_mq_end_request() here, because it may complete * the original request before the clone, and break the ordering. */ -if (is_last) - exit: -blk_update_request (tio->orig,BLK_STS_OK , tio->completed); +blk_update_request (tio->orig,BLK_STS_OK , tio->completed); }static struct dm_rq_target_io *tio_from_request (struct request *rq)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 603/844 drm/tegra: dsi: fix device leak on probe
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit bfef062695570842cf96358f2f46f4c6642c6689 ]
Make sure to drop the reference taken when looking up the companion (ganged) device and its driver data during probe().
Note that holding a reference to a device does not prevent its driver data from going away so there is no point in keeping the reference.
--- drivers/gpu/drm/tegra/dsi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/dsi.c +2 -4
@@ -1542,11 +1542,9 @@ static int tegra_dsi_ganged_probe(struct tegra_dsi *dsi)return -EPROBE_DEFER ; dsi->slave =platform_get_drvdata (gangster); - -if (!dsi->slave) { -put_device (&gangster->dev); +put_device (&gangster->dev); +if (!dsi->slave)return -EPROBE_DEFER ; - } dsi->slave->master = dsi; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 604/844 soc: ti: k3-socinfo: Fix regmap leak on probe failure
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit c933138d45176780fabbbe7da263e04d5b3e525d ]
The mmio regmap allocated during probe is never freed.
Switch to using the device managed allocator so that the regmap is released on probe failures (e.g. probe deferral) and on driver unbind.
--- drivers/soc/ti/k3-socinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/ti/k3-socinfo.c +1 -1
@@ -141,7 +141,7 @@ static int k3_chipinfo_probe(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - regmap =regmap_init_mmio (dev, base, &k3_chipinfo_regmap_cfg); + regmap =devm_regmap_init_mmio (dev, base, &k3_chipinfo_regmap_cfg);if (IS_ERR (regmap))return PTR_ERR (regmap);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 605/844 soc: ti: pruss: Fix double free in pruss_clk_mux_setup()
In reply to Sasha LevinFrom: Wentao Liang <[email protected]>
[ Upstream commit 80db65d4acfb9ff12d00172aed39ea8b98261aad ]
In the pruss_clk_mux_setup(), the devm_add_action_or_reset() indirectly calls pruss_of_free_clk_provider(), which calls of_node_put(clk_mux_np) on the error path. However, after the devm_add_action_or_reset() returns, the of_node_put(clk_mux_np) is called again, causing a double free.
Fix by returning directly, to avoid the duplicate of_node_put().
--- drivers/soc/ti/pruss.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/soc/ti/pruss.c +2 -4
@@ -366,12 +366,10 @@ static int pruss_clk_mux_setup(struct pruss *pruss, struct clk *clk_mux, ret =devm_add_action_or_reset (dev, pruss_of_free_clk_provider, clk_mux_np); -if (ret) { +if (ret)dev_err (dev,"failed to add clkmux free action %d" , ret); - goto put_clk_mux_np; - } -return 0 ; +return ret; put_clk_mux_np:of_node_put (clk_mux_np);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 606/844 arm64: dts: ti: k3-am69-aquila: Change main_spi0/2 CS to GPIO mode
In reply to Sasha LevinFrom: Vitor Soares <[email protected]>
[ Upstream commit 78a123f45a7e9ac2a59f0eff8a37d31773e7a021 ]
Hardware chip select does not work correctly on main_spi0 and main_spi2 controllers. Testing shows main_spi2 loses CS state during runtime PM suspend, while main_spi0 cannot drive CS HIGH when bus is idle.
Use GPIO-based chip select for both controllers.
--- arch/arm64/boot/dts/ti/k3-am69-aquila.dtsi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/ti/k3-am69-aquila.dtsi +4 -2
@@ -479,7 +479,7 @@ J784S4_IOPAD(0x0dc, PIN_OUTPUT, 0) /* (AM36) SPI0_D1 */ /* AQUILA D17 */ /* Aquila SPI_2 CS */ pinctrl_main_spi0_cs0: main-spi0-cs0-default-pins { pinctrl-single,pins = < - J784S4_IOPAD(0x0cc, PIN_OUTPUT, 0) /* (AM37) SPI0_CS0 */ /* AQUILA D16 */ + J784S4_IOPAD(0x0cc, PIN_OUTPUT, 7) /* (AM37) SPI0_CS0.GPIO0_51 */ /* AQUILA D16 */ >; };
@@ -495,7 +495,7 @@ J784S4_IOPAD(0x0ac, PIN_OUTPUT, 10) /* (AE34) MCASP0_AXR15.SPI2_D1 */ /* AQUILA /* Aquila SPI_1 CS */ pinctrl_main_spi2_cs0: main-spi2-cs0-default-pins { pinctrl-single,pins = < - J784S4_IOPAD(0x09c, PIN_OUTPUT, 10) /* (AF35) MCASP0_AXR11.SPI2_CS1 */ /* AQUILA D9 */ + J784S4_IOPAD(0x09c, PIN_OUTPUT, 7) /* (AF35) MCASP0_AXR11.GPIO0_39 */ /* AQUILA D9 */ >; };
@@ -1204,6 +1204,7 @@ &main_sdhci1 { &main_spi0 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_main_spi0>, <&pinctrl_main_spi0_cs0>; + cs-gpios = <&main_gpio0 51 GPIO_ACTIVE_LOW>; status = "disabled"; };
@@ -1211,6 +1212,7 @@ &main_spi0 { &main_spi2 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_main_spi2>, <&pinctrl_main_spi2_cs0>; + cs-gpios = <&main_gpio0 39 GPIO_ACTIVE_LOW>; status = "disabled"; };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 607/844 arm64: dts: ti: k3-am69-aquila-clover: Change main_spi2 CS0 to GPIO mode
In reply to Sasha LevinFrom: Vitor Soares <[email protected]>
[ Upstream commit 319fff9c7d620af83d8ab67050a54f63f16ae4e8 ]
Change CS0 from hardware chip select to GPIO-based chip select to align with the base aquila device tree configuration.
--- arch/arm64/boot/dts/ti/k3-am69-aquila-clover.dts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am69-aquila-clover.dts +2 -1
@@ -208,7 +208,8 @@ &main_spi2 { pinctrl-0 = <&pinctrl_main_spi2>, <&pinctrl_main_spi2_cs0>, <&pinctrl_gpio_05>; - cs-gpios = <0>, <&wkup_gpio0 29 GPIO_ACTIVE_LOW>; + cs-gpios = <&main_gpio0 39 GPIO_ACTIVE_LOW>, + <&wkup_gpio0 29 GPIO_ACTIVE_LOW>; status = "okay"; tpm@1 {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 608/844 KVM: nSVM: Always use vmcb01 in VMLOAD/VMSAVE emulation
In reply to Sasha LevinFrom: Yosry Ahmed <[email protected]>
[ Upstream commit 127ccae2c185f62e6ecb4bf24f9cb307e9b9c619 ]
Commit cc3ed80ae69f ("KVM: nSVM: always use vmcb01 to for vmsave/vmload of guest state") made KVM always use vmcb01 for the fields controlled by VMSAVE/VMLOAD, but it missed updating the VMLOAD/VMSAVE emulation code to always use vmcb01.
As a result, if VMSAVE/VMLOAD is executed by an L2 guest and is not intercepted by L1, KVM will mistakenly use vmcb02. Always use vmcb01 instead of the current VMCB.
--- arch/x86/kvm/svm/svm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/svm.c +3 -2
@@ -2099,12 +2099,13 @@ static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload) ret =kvm_skip_emulated_instruction (vcpu); +/* KVM always performs VMLOAD/VMSAVE on VMCB01 (see __svm_vcpu_run()) */ if (vmload) { -svm_copy_vmloadsave_state (svm->vmcb, vmcb12); +svm_copy_vmloadsave_state (svm->vmcb01.ptr, vmcb12); svm->sysenter_eip_hi =0 ; svm->sysenter_esp_hi =0 ; }else { -svm_copy_vmloadsave_state (vmcb12, svm->vmcb); +svm_copy_vmloadsave_state (vmcb12, svm->vmcb01.ptr); }kvm_vcpu_unmap (vcpu, &map);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 609/844 bus: omap-ocp2scp: fix OF populate on driver rebind
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 5eb63e9bb65d88abde647ced50fe6ad40c11de1a ]
Since commit c6e126de43e7 ("of: Keep track of populated platform devices") child devices will not be created by of_platform_populate() if the devices had previously been deregistered individually so that the OF_POPULATED flag is still set in the corresponding OF nodes.
Switch to using of_platform_depopulate() instead of open coding so that the child devices are created if the driver is rebound.
--- drivers/bus/omap-ocp2scp.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/bus/omap-ocp2scp.c +2 -11
@@ -17,15 +17,6 @@#define OCP2SCP_TIMING 0x18#define SYNC2_MASK 0xf -static int ocp2scp_remove_devices (struct device *dev,void *c) -{ -struct platform_device *pdev =to_platform_device (dev); - -platform_device_unregister (pdev); - -return 0 ; -} -static int omap_ocp2scp_probe (struct platform_device *pdev) {int ret;
@@ -79,7 +70,7 @@ static int omap_ocp2scp_probe(struct platform_device *pdev)pm_runtime_disable (&pdev->dev); err0: -device_for_each_child (&pdev->dev,NULL , ocp2scp_remove_devices); +of_platform_depopulate (&pdev->dev);return ret; }
@@ -87,7 +78,7 @@ static int omap_ocp2scp_probe(struct platform_device *pdev)static void omap_ocp2scp_remove (struct platform_device *pdev) {pm_runtime_disable (&pdev->dev); -device_for_each_child (&pdev->dev,NULL , ocp2scp_remove_devices); +of_platform_depopulate (&pdev->dev); }#ifdef CONFIG_OF
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 610/844 clk: clk-apple-nco: Add "apple,t8103-nco" compatible
In reply to Sasha LevinFrom: Janne Grunau <[email protected]>
[ Upstream commit ef9b3b4dbe767e4ac642a88dc0507927ac545047 ]
After discussion with the devicetree maintainers we agreed to not extend lists with the generic compatible "apple,nco" anymore [1]. Use "apple,t8103-nco" as base compatible as it is the SoC the driver and bindings were written for.
[1]: https://lore.kernel.org/asahi/[email protected]/
--- drivers/clk/clk-apple-nco.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/clk-apple-nco.c +1 -0
@@ -320,6 +320,7 @@ static int applnco_probe(struct platform_device *pdev) }static const struct of_device_id applnco_ids[] = { + { .compatible ="apple,t8103-nco" }, { .compatible ="apple,nco" }, { } };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 611/844 soc: rockchip: grf: Fix wrong RK3576_IOCGRF_MISC_CON definition
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit 3cdc30c42d4a87444f6c7afbefd6a9381c4caa27 ]
RK3576_IOCGRF_MISC_CON is IOC_GRF + 0x40F0, fix it.
--- drivers/soc/rockchip/grf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/rockchip/grf.c +1 -1
@@ -146,7 +146,7 @@ static const struct rockchip_grf_info rk3576_sysgrf __initconst = { .num_values = ARRAY_SIZE(rk3576_defaults_sys_grf), }; -#define RK3576_IOCGRF_MISC_CON 0x04F0 +#define RK3576_IOCGRF_MISC_CON 0x40F0static const struct rockchip_grf_value rk3576_defaults_ioc_grf[]__initconst = { {"jtag switching" ,RK3576_IOCGRF_MISC_CON ,FIELD_PREP_WM16_CONST (BIT (1 ),0 ) },
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 612/844 soc: rockchip: grf: Support multiple grf to be handled
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit 75fb63ae031211e9264ac888fabc2ca9cd3fcccf ]
Currently, only the first matched node will be handled. This leads to jtag switching broken for RK3576, as rk3576-sys-grf is found before rk3576-ioc-grf. Change the code to scan all the possible node to fix the problem.
--- drivers/soc/rockchip/grf.c | 55 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-)
drivers/soc/rockchip/grf.c +27 -28
@@ -217,34 +217,33 @@ static int __init rockchip_grf_init(void)struct regmap *grf;int ret, i; - np =of_find_matching_node_and_match (NULL , rockchip_grf_dt_match, - &match); -if (!np) -return -ENODEV ; -if (!match || !match->data) { -pr_err ("%s: missing grf data\n" , __func__); -of_node_put (np); -return -EINVAL ; - } - - grf_info = match->data; - - grf =syscon_node_to_regmap (np); -of_node_put (np); -if (IS_ERR (grf)) { -pr_err ("%s: could not get grf syscon\n" , __func__); -return PTR_ERR (grf); - } - -for (i =0 ; i < grf_info->num_values; i++) { -const struct rockchip_grf_value *val = &grf_info->values[i]; - -pr_debug ("%s: adjusting %s in %#6x to %#10x\n" , __func__, - val->desc, val->reg, val->val); - ret =regmap_write (grf, val->reg, val->val); -if (ret <0 ) -pr_err ("%s: write to %#6x failed with %d\n" , - __func__, val->reg, ret); +for_each_matching_node_and_match (np, rockchip_grf_dt_match, &match) { +if (!of_device_is_available (np)) +continue ; +if (!match || !match->data) { +pr_err ("%s: missing grf data\n" , __func__); +of_node_put (np); +return -EINVAL ; + } + + grf_info = match->data; + + grf =syscon_node_to_regmap (np); +if (IS_ERR (grf)) { +pr_err ("%s: could not get grf syscon\n" , __func__); +return PTR_ERR (grf); + } + +for (i =0 ; i < grf_info->num_values; i++) { +const struct rockchip_grf_value *val = &grf_info->values[i]; + +pr_debug ("%s: adjusting %s in %#6x to %#10x\n" , __func__, + val->desc, val->reg, val->val); + ret =regmap_write (grf, val->reg, val->val); +if (ret <0 ) +pr_err ("%s: write to %#6x failed with %d\n" , + __func__, val->reg, ret); + } }return 0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 613/844 media: stm32: dcmipp: avoid naming clock if only one is needed
In reply to Sasha LevinFrom: Alain Volmat <[email protected]>
[ Upstream commit 2f130245f2143fa8f4da77071f844911d2c69319 ]
When DCMIPP requires only a single clock (kclk), avoid relying on its name to obtain it. The introduction of MP25 support added the mclk, which necessitated naming the first clock kclk. However, this breaks backward compatibility with existing MP13 device trees that do not specify clock names.
--- drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c +6 -1
@@ -526,7 +526,12 @@ static int dcmipp_probe(struct platform_device *pdev)return ret; } - kclk =devm_clk_get (&pdev->dev,"kclk" ); +/* +* In case of the DCMIPP has only 1 clock (such as on MP13), the +* clock might not be named. +*/ + kclk =devm_clk_get (&pdev->dev, + dcmipp->pipe_cfg->needs_mclk ?"kclk" :NULL );if (IS_ERR (kclk))return dev_err_probe (&pdev->dev,PTR_ERR (kclk),"Unable to get kclk\n" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 614/844 media: stm32: dcmipp: bytecap: clear all interrupts upon stream stop
In reply to Sasha LevinFrom: Alain Volmat <[email protected]>
[ Upstream commit 222f1279edd9008ee35b62de156ddac84e31443c ]
Ensure that there are no pending interrupts after we have stopped the pipeline. Indeed, it could happen that new interrupt has been generated during the stop_streaming processing hence clear them in order to avoid getting a new interrupt right from the start of a next start_streaming.
--- drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c +3 -0
@@ -512,6 +512,9 @@ static void dcmipp_bytecap_stop_streaming(struct vb2_queue *vq)/* Disable pipe */ reg_clear (vcap,DCMIPP_P0FSCR ,DCMIPP_P0FSCR_PIPEN ); +/* Clear any pending interrupts */ +reg_write (vcap,DCMIPP_CMFCR ,DCMIPP_CMIER_P0ALL ); +spin_lock_irq (&vcap->irqlock);/* Return all queued buffers to vb2 in ERROR state */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 615/844 media: stm32: dcmipp: byteproc: disable compose for all bayers
In reply to Sasha LevinFrom: Alain Volmat <[email protected]>
[ Upstream commit 3363aa2640f1738ad7fc56ea56f5e0301ad97196 ]
Avoid possibility to perform compose on all frames which mbus code is within the bayer range or jpeg format.
--- .../media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c +2 -5
@@ -130,11 +130,8 @@ static void dcmipp_byteproc_adjust_compose(struct v4l2_rect *r, r->left =0 ;/* Compose is not possible for JPEG or Bayer formats */ -if (fmt->code ==MEDIA_BUS_FMT_JPEG_1X8 || - fmt->code ==MEDIA_BUS_FMT_SBGGR8_1X8 || - fmt->code ==MEDIA_BUS_FMT_SGBRG8_1X8 || - fmt->code ==MEDIA_BUS_FMT_SGRBG8_1X8 || - fmt->code ==MEDIA_BUS_FMT_SRGGB8_1X8 ) { +if (fmt->code >=MEDIA_BUS_FMT_SBGGR8_1X8 && + fmt->code <=MEDIA_BUS_FMT_JPEG_1X8 ) { r->width = fmt->width; r->height = fmt->height;return ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 616/844 media: i2c: ov01a10: Fix digital gain range
In reply to Sasha LevinFrom: Mehdi Djait <[email protected]>
[ Upstream commit 91848c99ed6a98daf77f4cb7d44cf3f13bc6998f ]
Digital gain wraps-around at the maximum of 16838 / 0x3fff. Fix the maximum digital gain by setting it to 0x3fff.
--- drivers/media/i2c/ov01a10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov01a10.c +1 -1
@@ -57,7 +57,7 @@#define OV01A10_REG_DIGITAL_GAIN_GR 0x3513#define OV01A10_REG_DIGITAL_GAIN_R 0x3516#define OV01A10_DGTL_GAIN_MIN 0 -#define OV01A10_DGTL_GAIN_MAX 0x3ffff +#define OV01A10_DGTL_GAIN_MAX 0x3fff#define OV01A10_DGTL_GAIN_STEP 1#define OV01A10_DGTL_GAIN_DEFAULT 1024
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 617/844 arm64: dts: rockchip: Fix SD card support for RK3576 EVB1
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit 7226664bf952c4cfddccd74b154a7d994608d153 ]
When runtime suspend is enabled, the associated power domain is powered off, which resets the registers, including the power control bit. As a result, the card loses power during runtime suspend. The card should still be able to process I/O with the help of mmc_blk_mq_rw_recovery(), which is suboptimal. To address this issue, we must use vmmc-supply with a GPIO based method to maintain power to the card. Also, add cd-gpios method to make hot-plug work correctly during idle periods.
--- .../boot/dts/rockchip/rk3576-evb1-v10.dts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+)
arch/arm64/boot/dts/rockchip/rk3576-evb1-v10.dts +22 -0
@@ -223,6 +223,18 @@ vcc_3v3_s0: regulator-vcc-3v3-s0 { vin-supply = <&vcc_3v3_s3>; }; + vcc3v3_sd: regulator-vcc-3v3-sd { + compatible = "regulator-fixed"; + enable-active-high; + gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc_pwren>; + regulator-name = "vcc3v3_sd"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc_3v3_s0>; + }; + vcc_ufs_s0: regulator-vcc-ufs-s0 { compatible = "regulator-fixed"; regulator-name = "vcc_ufs_s0";
@@ -810,6 +822,12 @@ pcie0_rst: pcie0-rst { }; }; + sdmmc { + sdmmc_pwren: sdmmc-pwren { + rockchip,pins = <0 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + usb { usb_host_pwren: usb-host-pwren { rockchip,pins = <0 RK_PC7 RK_FUNC_GPIO &pcfg_pull_none>;
@@ -851,11 +869,15 @@ &sdmmc { bus-width = <4>; cap-mmc-highspeed; cap-sd-highspeed; + cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>; disable-wp; max-frequency = <200000000>; no-sdio; no-mmc; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_det &sdmmc0_bus4>; sd-uhs-sdr104; + vmmc-supply = <&vcc3v3_sd>; vqmmc-supply = <&vccio_sd_s0>; status = "okay"; };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 618/844 arm64: dts: rockchip: Fix SD card support for RK3576 Nanopi R76s
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit a9c1acebfe0484343a443d082e039ca77186ed22 ]
When runtime suspend is enabled, the associated power domain is powered off, which resets the registers, including the power control bit. As a result, the card loses power during runtime suspend. The card should still be able to process I/O with the help of mmc_blk_mq_rw_recovery(), which is suboptimal. To address this issue, we must use vmmc-supply with a GPIO based method to maintain power to the card and store valid tuning phases. Also, add cd-gpios method to make hot-plug work correctly during idle periods.
--- .../boot/dts/rockchip/rk3576-nanopi-r76s.dts | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3576-nanopi-r76s.dts +22 -1
@@ -192,6 +192,18 @@ vcc_3v3_s0: regulator-vcc-3v3-s0 { regulator-name = "vcc_3v3_s0"; vin-supply = <&vcc_3v3_s3>; }; + + vcc3v3_sd: regulator-vcc-3v3-sd { + compatible = "regulator-fixed"; + enable-active-high; + gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc_pwren>; + regulator-name = "vcc3v3_sd"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + vin-supply = <&vcc_3v3_s0>; + }; }; &combphy0_ps {
@@ -726,6 +738,12 @@ pcie1_perstn: pcie1-perstn { }; }; + sdmmc { + sdmmc_pwren: sdmmc-pwren { + rockchip,pins = <0 RK_PB6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + usb { usb_otg0_pwren_h: usb-otg0-pwren-h { rockchip,pins = <0 RK_PD1 RK_FUNC_GPIO &pcfg_pull_none>;
@@ -751,11 +769,14 @@ &sdmmc { bus-width = <4>; cap-mmc-highspeed; cap-sd-highspeed; + cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>; disable-wp; no-mmc; no-sdio; + pinctrl-names = "default"; + pinctrl-0 = <&sdmmc0_clk &sdmmc0_cmd &sdmmc0_det &sdmmc0_bus4>; sd-uhs-sdr104; - vmmc-supply = <&vcc_3v3_s3>; + vmmc-supply = <&vcc3v3_sd>; vqmmc-supply = <&vccio_sd_s0>; status = "okay"; };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 619/844 x86/uprobes: Fix XOL allocation failure for 32-bit tasks
In reply to Sasha LevinFrom: Oleg Nesterov <[email protected]>
[ Upstream commit d55c571e4333fac71826e8db3b9753fadfbead6a ]
This script
#!/usr/bin/bash
echo 0 > /proc/sys/kernel/randomize_va_space
echo 'void main(void) {}' > TEST.c
# -fcf-protection to ensure that the 1st endbr32 insn can't be emulated gcc -m32 -fcf-protection=branch TEST.c -o test
bpftrace -e 'uprobe:./test:main {}' -c ./test
"hangs", the probed ./test task enters an endless loop.
The problem is that with randomize_va_space == 0 get_unmapped_area(TASK_SIZE - PAGE_SIZE) called by xol_add_vma() can not just return the "addr == TASK_SIZE - PAGE_SIZE" hint, this addr is used by the stack vma.
arch_get_unmapped_area_topdown() doesn't take TIF_ADDR32 into account and in_32bit_syscall() is false, this leads to info.high_limit > TASK_SIZE. vm_unmapped_area() happily returns the high address > TASK_SIZE and then get_unmapped_area() returns -ENOMEM after the "if (addr > TASK_SIZE - len)" check.
handle_swbp() doesn't report this failure (probably it should) and silently restarts the probed insn. Endless loop.
I think that the right fix should change the x86 get_unmapped_area() paths to rely on TIF_ADDR32 rather than in_32bit_syscall(). Note also that if CONFIG_X86_X32_ABI=y, in_x32_syscall() falsely returns true in this case because ->orig_ax = -1.
But we need a simple fix for -stable, so this patch just sets TS_COMPAT if the probed task is 32-bit to make in_ia32_syscall() true.
--- arch/x86/kernel/uprobes.c | 24 ++++++++++++++++++++++++ include/linux/uprobes.h | 1 + kernel/events/uprobes.c | 10 +++++++--- 3 files changed, 32 insertions(+), 3 deletions(-)
arch/x86/kernel/uprobes.c +24 -0
@@ -1823,3 +1823,27 @@ bool is_uprobe_at_func_entry(struct pt_regs *regs)return false; } + +#ifdef CONFIG_IA32_EMULATION +unsigned long arch_uprobe_get_xol_area (void ) +{ +struct thread_info *ti =current_thread_info (); +unsigned long vaddr; + +/* +* HACK: we are not in a syscall, but x86 get_unmapped_area() paths +* ignore TIF_ADDR32 and rely on in_32bit_syscall() to calculate +* vm_unmapped_area_info.high_limit. +* +* The #ifdef above doesn't cover the CONFIG_X86_X32_ABI=y case, +* but in this case in_32bit_syscall() -> in_x32_syscall() always +* (falsely) returns true because ->orig_ax == -1. +*/ +if (test_thread_flag (TIF_ADDR32 )) + ti->status |=TS_COMPAT ; + vaddr =get_unmapped_area (NULL ,TASK_SIZE -PAGE_SIZE ,PAGE_SIZE ,0 ,0 ); + ti->status &= ~TS_COMPAT ; + +return vaddr; +} +#endif
include/linux/uprobes.h +1 -0
@@ -242,6 +242,7 @@ extern void arch_uprobe_clear_state(struct mm_struct *mm);extern void arch_uprobe_init_state (struct mm_struct *mm);extern void handle_syscall_uprobe (struct pt_regs *regs,unsigned long bp_vaddr);extern void arch_uprobe_optimize (struct arch_uprobe *auprobe,unsigned long vaddr); +extern unsigned long arch_uprobe_get_xol_area (void );#else /* !CONFIG_UPROBES */ struct uprobes_state { };
kernel/events/uprobes.c +7 -3
@@ -1694,6 +1694,12 @@ static const struct vm_special_mapping xol_mapping = { .mremap = xol_mremap, }; +unsigned long __weak arch_uprobe_get_xol_area (void ) +{ +/* Try to map as high as possible, this is only a hint. */ +return get_unmapped_area (NULL ,TASK_SIZE -PAGE_SIZE ,PAGE_SIZE ,0 ,0 ); +} +/* Slot allocation for XOL */ static int xol_add_vma (struct mm_struct *mm,struct xol_area *area) {
@@ -1709,9 +1715,7 @@ static int xol_add_vma(struct mm_struct *mm, struct xol_area *area) }if (!area->vaddr) { -/* Try to map as high as possible, this is only a hint. */ - area->vaddr =get_unmapped_area (NULL ,TASK_SIZE -PAGE_SIZE , -PAGE_SIZE ,0 ,0 ); + area->vaddr =arch_uprobe_get_xol_area ();if (IS_ERR_VALUE (area->vaddr)) { ret = area->vaddr; goto fail;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 620/844 clk: tegra: tegra124-emc: Fix potential memory leak in tegra124_clk_register_emc()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit fce0d0bd9c20fefd180ea9e8362d619182f97a1d ]
If clk_register() fails, call kfree to release "tegra".
--- drivers/clk/tegra/clk-tegra124-emc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/tegra/clk-tegra124-emc.c +3 -1
@@ -538,8 +538,10 @@ struct clk *tegra124_clk_register_emc(void __iomem *base, struct device_node *np tegra->hw.init = &init; clk =clk_register (NULL , &tegra->hw); -if (IS_ERR (clk)) +if (IS_ERR (clk)) { +kfree (tegra);return clk; + } tegra->prev_parent =clk_hw_get_parent_by_index ( &tegra->hw,emc_get_parent (&tegra->hw))->clk;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 621/844 s390/pci: Handle futile config accesses of disabled devices directly
In reply to Sasha LevinFrom: Niklas Schnelle <[email protected]>
[ Upstream commit 84d875e69818bed600edccb09be4a64b84a34a54 ]
On s390 PCI busses and slots with multiple functions may have holes because PCI functions are passed-through by the hypervisor on a per function basis and some functions may be in standby or reserved. This fact is indicated by returning true from the hypervisor_isolated_pci_functions() helper and triggers common code to scan all possible devfn values. Via pci_scan_single_device() this in turn causes config reads for the device and vendor IDs, even for PCI functions which are in standby and thereofore disabled.
So far these futile config reads, as well as potentially writes, which can never succeed were handled by the PCI load/store instructions themselves. This works as the platform just returns an error for a disabled and thus not usable function handle. It does cause spamming of error logs and additional overhead though.
Instead check if the used function handle is enabled in zpci_cfg_load() and zpci_cfg_write() and if not enable directly return -ENODEV. Also refactor zpci_cfg_load() and zpci_cfg_store() slightly to accommodate the new logic while meeting modern kernel style guidelines.
--- arch/s390/pci/pci.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
arch/s390/pci/pci.c +17 -8
@@ -231,24 +231,33 @@ int zpci_fmb_disable_device(struct zpci_dev *zdev)static int zpci_cfg_load (struct zpci_dev *zdev,int offset,u32 *val,u8 len) {u64 req =ZPCI_CREATE_REQ (zdev->fh,ZPCI_PCIAS_CFGSPC , len); +int rc = -ENODEV ;u64 data; -int rc; + +if (!zdev_enabled (zdev)) + goto out_err; rc =__zpci_load (&data, req, offset); -if (!rc) { - data =le64_to_cpu ((__force __le64 ) data); - data >>= (8 - len) *8 ; - *val = (u32 ) data; - }else - *val =0xffffffff ; +if (rc) + goto out_err; + data =le64_to_cpu ((__force __le64 )data); + data >>= (8 - len) *8 ; + *val = (u32 )data; +return 0 ; + +out_err: +PCI_SET_ERROR_RESPONSE (val);return rc; }static int zpci_cfg_store (struct zpci_dev *zdev,int offset,u32 val,u8 len) {u64 req =ZPCI_CREATE_REQ (zdev->fh,ZPCI_PCIAS_CFGSPC , len); +int rc = -ENODEV ;u64 data = val; -int rc; + +if (!zdev_enabled (zdev)) +return rc; data <<= (8 - len) *8 ; data = (__force u64 )cpu_to_le64 (data);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 622/844 mailbox: Prevent out-of-bounds access in fw_mbox_index_xlate()
In reply to Sasha LevinFrom: Joonwon Kang <[email protected]>
[ Upstream commit fcd7f96c783626c07ee3ed75fa3739a8a2052310 ]
Although it is guided that #mbox-cells must be at least 1, there are many instances of #mbox-cells = <0>; in the device tree. If that is the case and the corresponding mailbox controller does not provide fw_xlate and of_xlate function pointers, fw_mbox_index_xlate()` will be used by default and out-of-bounds accesses could occur due to lack of bounds check in that function.
--- drivers/mailbox/mailbox.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mailbox/mailbox.c +2 -4
@@ -489,12 +489,10 @@ EXPORT_SYMBOL_GPL(mbox_free_channel);static struct mbox_chan *fw_mbox_index_xlate (struct mbox_controller *mbox,const struct fwnode_reference_args *sp) { -int ind = sp->args[0 ]; - -if (ind >= mbox->num_chans) +if (sp->nargs <1 || sp->args[0 ] >= mbox->num_chans)return ERR_PTR (-EINVAL ); -return &mbox->chans[ind]; +return &mbox->chans[sp->args[0 ]]; }/**
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 623/844 drm/i915/psr: Don't enable Panel Replay on sink if globally disabled
In reply to Sasha LevinFrom: Jouni Högander <[email protected]>
[ Upstream commit 69f83f167463bad26104af7fbc114ce1f80366b0 ]
With some panels informing support for Panel Replay we are observing problems if having Panel Replay enable bit set on sink when forced to use PSR instead of Panel Replay. Avoid these problems by not setting Panel Replay enable bit in sink when Panel Replay is globally disabled during link training. I.e. disabled by module parameter.
The enable bit is still set when disabling Panel Replay via debugfs interface. Added note comment about this.
--- drivers/gpu/drm/i915/display/intel_psr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_psr.c +6 -1
@@ -857,7 +857,12 @@ static void intel_psr_enable_sink(struct intel_dp *intel_dp,void intel_psr_panel_replay_enable_sink (struct intel_dp *intel_dp) { -if (CAN_PANEL_REPLAY (intel_dp)) +/* +* NOTE: We might want to trigger mode set when +* disabling/enabling Panel Replay via debugfs interface to +* ensure this bit is cleared/set accordingly. +*/ +if (CAN_PANEL_REPLAY (intel_dp) &&panel_replay_global_enabled (intel_dp))drm_dp_dpcd_writeb (&intel_dp->aux,PANEL_REPLAY_CONFIG ,DP_PANEL_REPLAY_ENABLE ); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 624/844 reset: gpio: suppress bind attributes in sysfs
In reply to Sasha LevinFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit 16de4c6a8fe9ff497ca1aba33ef0dbee09f11952 ]
This is a special device that's created dynamically and is supposed to stay in memory forever. We also currently don't have a devlink between it and the actual reset consumer. Suppress sysfs bind attributes so that user-space can't unbind the device because - as of now - it will cause a use-after-free splat from any user that puts the reset control handle.
--- drivers/reset/reset-gpio.c | 1 + 1 file changed, 1 insertion(+)
drivers/reset/reset-gpio.c +1 -0
@@ -111,6 +111,7 @@ static struct auxiliary_driver reset_gpio_driver = { .id_table = reset_gpio_ids, .driver = { .name = "reset-gpio", + .suppress_bind_attrs = true, }, };module_auxiliary_driver (reset_gpio_driver);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 625/844 dm-integrity: fix recalculation in bitmap mode
In reply to Sasha LevinFrom: Mikulas Patocka <[email protected]>
[ Upstream commit 118ba36e446c01e3cd34b3eedabf1d9436525e1d ]
There's a logic quirk in the handling of suspend in the bitmap mode:
This is the sequence of calls if we are reloading a dm-integrity table:
* dm_integrity_ctr reads a superblock with the flag SB_FLAG_DIRTY_BITMAP set.
* dm_integrity_postsuspend initializes a journal and clears the flag SB_FLAG_DIRTY_BITMAP.
* dm_integrity_resume sees the superblock with SB_FLAG_DIRTY_BITMAP set - thus it interprets the journal as if it were a bitmap.
This quirk causes recalculation problem if the user increases the size of the device in the bitmap mode.
Fix this by reading a fresh copy on the superblock in dm_integrity_resume. This commit also fixes another logic quirk - the branch that sets bitmap bits if the device was extended should only be executed if the flag SB_FLAG_DIRTY_BITMAP is set.
--- drivers/md/dm-integrity.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/md/dm-integrity.c +13 -0
@@ -3788,14 +3788,27 @@ static void dm_integrity_resume(struct dm_target *ti)struct dm_integrity_c *ic = ti->private;__u64 old_provided_data_sectors =le64_to_cpu (ic->sb->provided_data_sectors);int r; +__le32 flags;DEBUG_print ("resume\n" ); ic->wrote_to_journal = false; + flags = ic->sb->flags &cpu_to_le32 (SB_FLAG_RECALCULATING ); + r =sync_rw_sb (ic,REQ_OP_READ ); +if (r) +dm_integrity_io_error (ic,"reading superblock" , r); +if ((ic->sb->flags & flags) != flags) { + ic->sb->flags |= flags; + r =sync_rw_sb (ic,REQ_OP_WRITE |REQ_FUA ); +if (unlikely (r)) +dm_integrity_io_error (ic,"writing superblock" , r); + } +if (ic->provided_data_sectors != old_provided_data_sectors) {if (ic->provided_data_sectors > old_provided_data_sectors && ic->mode =='B' && + ic->sb->flags &cpu_to_le32 (SB_FLAG_DIRTY_BITMAP ) && ic->sb->log2_blocks_per_bitmap_bit == ic->log2_blocks_per_bitmap_bit) {rw_journal_sectors (ic,REQ_OP_READ ,0 , ic->n_bitmap_blocks * (BITMAP_BLOCK_SIZE >>SECTOR_SHIFT ),NULL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 626/844 dm-unstripe: fix mapping bug when there are multiple targets in a table
In reply to Sasha LevinFrom: Matt Whitlock <[email protected]>
[ Upstream commit 83c10e8dd43628d0bf86486616556cd749a3c310 ]
The "unstriped" device-mapper target incorrectly calculates the sector offset on the mapped device when the target's origin is not zero.
Take for example this hypothetical concatenation of the members of a two-disk RAID0:
linearized: 0 2097152 unstriped 2 128 0 /dev/md/raid0 0
linearized: 2097152 2097152 unstriped 2 128 1 /dev/md/raid0 0
The intent in this example is to create a single device named /dev/mapper/linearized that comprises all of the chunks of the first disk of the RAID0 set, followed by all of the chunks of the second disk of the RAID0 set.
This fails because dm-unstripe.c's map_to_core function does its computations based on the sector number within the mapper device rather than the sector number within the target. The bug turns invisible when the target's origin is at sector zero of the mapper device, as is the common case. In the example above, however, what happens is that the first half of the mapper device gets mapped correctly to the first disk of the RAID0, but the second half of the mapper device gets mapped past the end of the RAID0 device, and accesses to any of those sectors return errors.
--- drivers/md/dm-unstripe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-unstripe.c +1 -1
@@ -117,7 +117,7 @@ static void unstripe_dtr(struct dm_target *ti)static sector_t map_to_core (struct dm_target *ti,struct bio *bio) {struct unstripe_c *uc = ti->private; -sector_t sector = bio->bi_iter.bi_sector; +sector_t sector =dm_target_offset (ti, bio->bi_iter.bi_sector);sector_t tmp_sector = sector;/* Shift us up to the right "row" on the stripe */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 627/844 rtc: pcf8563: use correct of_node for output clock
In reply to Sasha LevinFrom: John Keeping <[email protected]>
[ Upstream commit a380a02ea3ddc69c1c1ccca3882748dee33ec3d3 ]
When switching to regmap, the i2c_client pointer was removed from struct pcf8563 so this function switched to using the RTC device instead. But the RTC device is a child of the original I2C device and does not have an associated of_node.
Reference the correct device's of_node to ensure that the output clock can be found when referenced by other devices and so that the override clock name is read correctly.
--- drivers/rtc/rtc-pcf8563.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-pcf8563.c +1 -1
@@ -424,7 +424,7 @@ static const struct clk_ops pcf8563_clkout_ops = {static struct clk *pcf8563_clkout_register_clk (struct pcf8563 *pcf8563) { -struct device_node *node = pcf8563->rtc->dev.of_node; +struct device_node *node = pcf8563->rtc->dev.parent->of_node;struct clk_init_data init;struct clk *clk;int ret;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 628/844 drm/tyr: fix register name in error print
In reply to Sasha LevinFrom: Dirk Behme <[email protected]>
[ Upstream commit 793e8f7d52814e096f63373eca643d2672366a5a ]
The ..IRQ.. register is printed here. Not the ..INT.. one. Correct this.
--- drivers/gpu/drm/tyr/driver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/tyr/driver.rs +1 -1
@@ -76,7 +76,7 @@ fn issue_soft_reset(dev: &Device<Bound>, iomem: &Devres<IoMem>) -> Result {dev_err! (dev,"GPU reset failed with errno\n" );dev_err! ( dev, -"GPU_INT_RAWSTAT is {}\n" , +"GPU_IRQ_RAWSTAT is {}\n" , regs::GPU_IRQ_RAWSTAT .read (dev, iomem)? );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 629/844 arm64: dts: rockchip: Do not enable hdmi_sound node on Pinebook Pro
In reply to Sasha LevinFrom: Jun Yan <[email protected]>
[ Upstream commit b18247f9dab735c9c2d63823d28edc9011e7a1ad ]
Remove the redundant enabling of the hdmi_sound node in the Pinebook Pro board dts file, because the HDMI output is unused on this device. [1][2]
This change also eliminates the following kernel log warning, which is caused by the unenabled dependent node of hdmi_sound that ultimately results in the node's probe failure:
platform hdmi-sound: deferred probe pending: asoc-simple-card: parse error
[1] https://files.pine64.org/doc/PinebookPro/pinebookpro_v2.1_mainboard_schematic.pdf
[2] https://files.pine64.org/doc/PinebookPro/pinebookpro_schematic_v21a_20220419.pdf
--- arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts | 4 ---- 1 file changed, 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-pinebook-pro.dts +0 -4
@@ -421,10 +421,6 @@ &gpu { status = "okay"; }; -&hdmi_sound { - status = "okay"; -}; - &i2c0 { clock-frequency = <400000>; i2c-scl-falling-time-ns = <4>;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 630/844 media: venus: vdec: fix error state assignment for zero bytesused
In reply to Sasha LevinFrom: Renjiang Han <[email protected]>
[ Upstream commit 93ecd6ee95c38cb533fa25f48d3c1c8cb69f410f ]
When hfi_session_flush is issued, all queued buffers are returned to the V4L2 driver. Some of these buffers are not processed and have bytesused = 0. Currently, the driver marks such buffers as error even during drain operations, which can incorrectly flag EOS buffers.
Only capture buffers with zero payload (and not EOS) should be marked with VB2_BUF_STATE_ERROR. The check is performed inside the non-EOS branch to ensure correct handling.
--- drivers/media/platform/qcom/venus/vdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/venus/vdec.c +3 -3
@@ -1440,10 +1440,10 @@ static void vdec_buf_done(struct venus_inst *inst, unsigned int buf_type, inst->drain_active = false; inst->codec_state =VENUS_DEC_STATE_STOPPED ; } + }else { +if (!bytesused) + state =VB2_BUF_STATE_ERROR ; } - -if (!bytesused) - state =VB2_BUF_STATE_ERROR ; }else { vbuf->sequence = inst->sequence_out++; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 631/844 media: venus: vdec: restrict EOS addr quirk to IRIS2 only
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 63c072e2937e6c9995df1b6a28523ed2ae68d364 ]
On SM8250 (IRIS2) with firmware older than 1.0.087, the firmware could not handle a dummy device address for EOS buffers, so a NULL device address is sent instead. The existing check used IS_V6() alongside a firmware version gate:
if (IS_V6(core) && is_fw_rev_or_older(core, 1, 0, 87))
fdata.device_addr = 0;
else
fdata.device_addr = 0xdeadb000;However, SC7280 which is also V6, uses a firmware string of the form "1.0.<commit-hash>", which the version parser translates to 1.0.0. This unintentionally satisfies the is_fw_rev_or_older(..., 1, 0, 87) condition on SC7280. Combined with IS_V6() matching there as well, the quirk is incorrectly applied to SC7280, causing VP9 decode failures.
Constrain the check to IRIS2 (SM8250) only, which is the only platform that needed this quirk, by replacing IS_V6() with IS_IRIS2(). This restores correct behavior on SC7280 (no forced NULL EOS buffer address).
--- drivers/media/platform/qcom/venus/vdec.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/venus/vdec.c +7 -1
@@ -565,7 +565,13 @@ vdec_decoder_cmd(struct file *file, void *fh, struct v4l2_decoder_cmd *cmd) fdata.buffer_type =HFI_BUFFER_INPUT ; fdata.flags |=HFI_BUFFERFLAG_EOS ; -if (IS_V6 (inst->core) &&is_fw_rev_or_older (inst->core,1 ,0 ,87 )) + +/* Send NULL EOS addr for only IRIS2 (SM8250),for firmware <= 1.0.87. +* SC7280 also reports "1.0.<hash>" parsed as 1.0.0; restricting to IRIS2 +* avoids misapplying this quirk and breaking VP9 decode on SC7280. +*/ + +if (IS_IRIS2 (inst->core) &&is_fw_rev_or_older (inst->core,1 ,0 ,87 )) fdata.device_addr =0 ;else fdata.device_addr =0xdeadb000 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 632/844 Revert "media: iris: Add sanity check for stop streaming"
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 370e19042fb8ac68109f8bdb0fdd8118baf39318 ]
This reverts commit ad699fa78b59241c9d71a8cafb51525f3dab04d4.
Revert the check that skipped stop_streaming when the instance was in IRIS_INST_ERROR, as it caused multiple regressions:
1. Buffers were not returned to vb2 when the instance was already in error state, triggering warnings in the vb2 core because buffer completion was skipped.
2. If a session failed early (e.g. unsupported configuration), the instance transitioned to IRIS_INST_ERROR. When userspace attempted to stop streaming for cleanup, stop_streaming was skipped due to the added check, preventing proper teardown and leaving the firmware in an inconsistent state.
--- drivers/media/platform/qcom/iris/iris_vb2.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +3 -5
@@ -231,8 +231,6 @@ void iris_vb2_stop_streaming(struct vb2_queue *q)return ;mutex_lock (&inst->lock); -if (inst->state ==IRIS_INST_ERROR ) - goto exit;if (!V4L2_TYPE_IS_OUTPUT (q->type) && !V4L2_TYPE_IS_CAPTURE (q->type))
@@ -243,10 +241,10 @@ void iris_vb2_stop_streaming(struct vb2_queue *q) goto exit; exit: -if (ret) { -iris_helper_buffers_done (inst, q->type,VB2_BUF_STATE_ERROR ); +iris_helper_buffers_done (inst, q->type,VB2_BUF_STATE_ERROR ); +if (ret)iris_inst_change_state (inst,IRIS_INST_ERROR ); - } +mutex_unlock (&inst->lock); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 633/844 media: iris: Fix ffmpeg corrupted frame error
In reply to Sasha LevinFrom: Vishnu Reddy <[email protected]>
[ Upstream commit 89f7cf35901138d9828d981ce64c131a3da6e867 ]
When the ffmpeg decoder is running, the driver receives the V4L2_BUF_FLAG_KEYFRAME flag in the input buffer. The driver then forwards this flag information to the firmware. The firmware, in turn, copies the input buffer flags directly into the output buffer flags. Upon receiving the output buffer from the firmware, the driver observes that the buffer contains the HFI_BUFFERFLAG_DATACORRUPT flag. The root cause is that both V4L2_BUF_FLAG_KEYFRAME and HFI_BUFFERFLAG_DATACORRUPT are the same value. As a result, the driver incorrectly interprets the output frame as corrupted, even though the frame is actually valid. This misinterpretation causes the driver to report an error and skip good frames, leading to missing frames in the final video output and triggering ffmpeg's "corrupt decoded frame" error.
To resolve this issue, the input buffer flags should not be sent to the firmware during decoding, since the firmware does not require this information.
--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +1 -1
@@ -282,7 +282,7 @@ static int iris_hfi_gen1_queue_input_buffer(struct iris_inst *inst, struct iris_ com_ip_pkt.shdr.session_id = inst->session_id; com_ip_pkt.time_stamp_hi =upper_32_bits (buf->timestamp); com_ip_pkt.time_stamp_lo =lower_32_bits (buf->timestamp); - com_ip_pkt.flags = buf->flags; + com_ip_pkt.flags =0 ; com_ip_pkt.mark_target =0 ; com_ip_pkt.mark_data =0 ; com_ip_pkt.offset = buf->data_offset;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 634/844 media: iris: Fix fps calculation
In reply to Sasha LevinFrom: Ricardo Ribalda <[email protected]>
[ Upstream commit 71fe80364a6584f404556ac9a6a4aca4ab80fb5b ]
iris_venc_s_param() uses do_div to divide two 64 bits operators, this is wrong. Luckily for us, both of the operators fit in 32 bits, so we can use a normal division.
Now that we are at it, mark the fps smaller than 1 as invalid, the code does not seem to handle them properly.
The following cocci warning is fixed with this patch:
./platform/qcom/iris/iris_venc.c:378:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead
--- drivers/media/platform/qcom/iris/iris_venc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/media/platform/qcom/iris/iris_venc.c +5 -10
@@ -382,8 +382,7 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm)struct v4l2_fract *timeperframe =NULL ;u32 default_rate =DEFAULT_FPS ;bool is_frame_rate = false; -u64 us_per_frame, fps; -u32 max_rate; +u32 fps, max_rate;int ret =0 ;
@@ -405,23 +404,19 @@ int iris_venc_s_param(struct iris_inst *inst, struct v4l2_streamparm *s_parm) timeperframe->denominator = default_rate; } - us_per_frame = timeperframe->numerator * (u64 )USEC_PER_SEC ; -do_div (us_per_frame, timeperframe->denominator); - -if (!us_per_frame) + fps = timeperframe->denominator / timeperframe->numerator; +if (!fps)return -EINVAL ; - fps = (u64 )USEC_PER_SEC ; -do_div (fps, us_per_frame);if (fps > max_rate) { ret = -ENOMEM ; goto reset_rate; }if (is_frame_rate) - inst->frame_rate = (u32 )fps; + inst->frame_rate = fps;else - inst->operating_rate = (u32 )fps; + inst->operating_rate = fps;if ((s_parm->type ==V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE &&vb2_is_streaming (src_q)) || (s_parm->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE &&vb2_is_streaming (dst_q))) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 635/844 media: iris: use fallback size when S_FMT is called without width/height
In reply to Sasha LevinFrom: Val Packett <[email protected]>
[ Upstream commit 4980721cb97d6c47700ab61a048ac8819cfeec87 ]
According to 4.5.1.5 of the M2M stateful decoder UAPI documentation, providing the width and the height to S_FMT is "required only if it cannot be parsed from the stream", otherwise they can be left as 0 and the S_FMT implementation is expected to return a valid placeholder resolution that would let REQBUFS succeed.
iris was missing the fallback, so clients like rpi-ffmpeg wouldn't work. Fix by adding an explicit fallback to defaults.
--- drivers/media/platform/qcom/iris/iris_vdec.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/platform/qcom/iris/iris_vdec.c +8 -0
@@ -231,6 +231,14 @@ int iris_vdec_s_fmt(struct iris_inst *inst, struct v4l2_format *f)if (vb2_is_busy (q))return -EBUSY ; +/* Width and height are optional, so fall back to a valid placeholder +* resolution until the real one is decoded from the bitstream. +*/ +if (f->fmt.pix_mp.width ==0 && f->fmt.pix_mp.height ==0 ) { + f->fmt.pix_mp.width =DEFAULT_WIDTH ; + f->fmt.pix_mp.height =DEFAULT_HEIGHT ; + } +iris_vdec_try_fmt (inst, f);switch (f->type) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 636/844 media: iris: remove v4l2_m2m_ioctl_{de,en}coder_cmd API usage during STOP handling
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 8fc707d13df517222db12b465af4aa9df05c99e1 ]
Currently v4l2_m2m_ioctl_{de,enc}coder_cmd is being invoked during STOP command handling. However, this is not required as the iris driver has its own drain and stop handling mechanism in place.
Using the m2m command API in this context leads to incorrect behavior, where the LAST flag is prematurely attached to a capture buffer, when there are no buffers in m2m source queue. But, in this scenario even though the source buffers are returned to client, hardware might still need to process the pending capture buffers.
Attaching LAST flag prematurely can result in the capture buffer being removed from the destination queue before the hardware has finished processing it, causing issues when the buffer is eventually returned by the hardware.
To prevent this, remove the m2m API usage in stop handling.
--- drivers/media/platform/qcom/iris/iris_vidc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/platform/qcom/iris/iris_vidc.c +6 -4
@@ -572,9 +572,10 @@ static int iris_dec_cmd(struct file *filp, void *fh,mutex_lock (&inst->lock); - ret =v4l2_m2m_ioctl_decoder_cmd (filp, fh, dec); -if (ret) +if (dec->cmd !=V4L2_DEC_CMD_STOP && dec->cmd !=V4L2_DEC_CMD_START ) { + ret = -EINVAL ; goto unlock; + }if (inst->state ==IRIS_INST_DEINIT ) goto unlock;
@@ -605,9 +606,10 @@ static int iris_enc_cmd(struct file *filp, void *fh,mutex_lock (&inst->lock); - ret =v4l2_m2m_ioctl_encoder_cmd (filp, fh, enc); -if (ret) +if (enc->cmd !=V4L2_ENC_CMD_STOP && enc->cmd !=V4L2_ENC_CMD_START ) { + ret = -EINVAL ; goto unlock; + }if (inst->state ==IRIS_INST_DEINIT ) goto unlock;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 637/844 media: iris: Add missing platform data entries for SM8750
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit bbef55f414100853d5bcea56a41f8b171bac8fcb ]
Two platform-data fields for SM8750 were missed:
- get_vpu_buffer_size = iris_vpu33_buf_size
Without this, the driver fails to allocate the required internal buffers, leading to basic decode/encode failures during session bring-up.
- max_core_mbps = ((7680 * 4320) / 256) * 60
Without this capability exposed, capability checks are incomplete and v4l2-compliance for encoder fails.
--- drivers/media/platform/qcom/iris/iris_platform_gen2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/iris/iris_platform_gen2.c +2 -0
@@ -915,6 +915,7 @@ const struct iris_platform_data sm8750_data = { .get_instance = iris_hfi_gen2_get_instance, .init_hfi_command_ops = iris_hfi_gen2_command_ops_init, .init_hfi_response_ops = iris_hfi_gen2_response_ops_init, + .get_vpu_buffer_size = iris_vpu33_buf_size, .vpu_ops = &iris_vpu35_ops, .set_preset_registers = iris_set_sm8550_preset_registers, .icc_tbl = sm8550_icc_table,
@@ -945,6 +946,7 @@ const struct iris_platform_data sm8750_data = { .num_vpp_pipe = 4, .max_session_count = 16, .max_core_mbpf = NUM_MBS_8K * 2, + .max_core_mbps = ((7680 * 4320) / 256) * 60, .dec_input_config_params_default = sm8550_vdec_input_config_params_default, .dec_input_config_params_default_size =
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 638/844 media: iris: Add buffer to list only after successful allocation
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 2d0bbd982dfdd67da488a772f7a8a1bdca7642bf ]
Move list_add_tail() to after dma_alloc_attrs() succeeds when creating internal buffers. Previously, the buffer was enqueued in buffers->list before the DMA allocation. If the allocation failed, the function returned -ENOMEM while leaving a partially initialized buffer in the list, which could lead to inconsistent state and potential leaks.
By adding the buffer to the list only after dma_alloc_attrs() succeeds, we ensure the list contains only valid, fully initialized buffers.
--- drivers/media/platform/qcom/iris/iris_buffer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/iris/iris_buffer.c +5 -2
@@ -351,12 +351,15 @@ static int iris_create_internal_buffer(struct iris_inst *inst, buffer->index = index; buffer->buffer_size = buffers->size; buffer->dma_attrs =DMA_ATTR_WRITE_COMBINE |DMA_ATTR_NO_KERNEL_MAPPING ; -list_add_tail (&buffer->list, &buffers->list); buffer->kvaddr =dma_alloc_attrs (core->dev, buffer->buffer_size, &buffer->device_addr,GFP_KERNEL , buffer->dma_attrs); -if (!buffer->kvaddr) +if (!buffer->kvaddr) { +kfree (buffer);return -ENOMEM ; + } + +list_add_tail (&buffer->list, &buffers->list);return 0 ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 639/844 media: iris: Skip resolution set on first IPSC
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 811dbc546f47559dc9d2098c612acfd47e32479e ]
The resolution property is not supposed to be set during reconfig. Existing iris_drc_pending(inst) check is insufficient, as it doesn't cover the first port setting change.
Extend the conditional check to also skip resolution setting when the instance is in IRIS_INST_SUB_FIRST_IPSC.
--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +1 -1
@@ -733,7 +733,7 @@ static int iris_hfi_gen1_set_resolution(struct iris_inst *inst, u32 plane)struct hfi_framesize fs;int ret; -if (!iris_drc_pending (inst)) { +if (!iris_drc_pending (inst) && !(inst->sub_state &IRIS_INST_SUB_FIRST_IPSC )) { fs.buffer_type =HFI_BUFFER_INPUT ; fs.width = inst->fmt_src->fmt.pix_mp.width; fs.height = inst->fmt_src->fmt.pix_mp.height;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 640/844 media: iris: gen1: Destroy internal buffers after FW releases
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 1dabf00ee206eceb0f08a1fe5d1ce635f9064338 ]
After the firmware releases internal buffers, the driver was not destroying them. This left stale allocations that were no longer used, especially across resolution changes where new buffers are allocated per the updated requirements. As a result, memory was wasted until session close.
Destroy internal buffers once the release response is received from the firmware.
--- drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/iris/iris_hfi_gen1_command.c +2 -0
@@ -441,6 +441,8 @@ static int iris_hfi_gen1_session_unset_buffers(struct iris_inst *inst, struct ir goto exit; ret =iris_wait_for_session_response (inst, false); +if (!ret) + ret =iris_destroy_internal_buffer (inst, buf); exit:kfree (pkt);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 641/844 media: iris: gen2: Add sanity check for session stop
In reply to Sasha LevinFrom: Dikshita Agarwal <[email protected]>
[ Upstream commit 9aa8d63d09cfc44d879427cc5ba308012ca4ab8e ]
In iris_kill_session, inst->state is set to IRIS_INST_ERROR and session_close is executed, which will kfree(inst_hfi_gen2->packet). If stop_streaming is called afterward, it will cause a crash.
Add a NULL check for inst_hfi_gen2->packet before sendling STOP packet to firmware to fix that.
--- drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/qcom/iris/iris_hfi_gen2_command.c +3 -0
@@ -963,6 +963,9 @@ static int iris_hfi_gen2_session_stop(struct iris_inst *inst, u32 plane)struct iris_inst_hfi_gen2 *inst_hfi_gen2 =to_iris_inst_hfi_gen2 (inst);int ret =0 ; +if (!inst_hfi_gen2->packet) +return -EINVAL ; +reinit_completion (&inst->completion); iris_hfi_gen2_packet_session_command(inst,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 642/844 media: iris: Prevent output buffer queuing before stream-on completes
In reply to Sasha LevinFrom: Vishnu Reddy <[email protected]>
[ Upstream commit 2c73cfd0cfc44ffe331ccb81f6ac45fc399d9ddb ]
During normal playback, stream-on for input is followed by output, and only after input stream-on does actual streaming begin. However, when gst-play performs a seek, both input and output streams are stopped, and on restart, output stream-on occurs first. At this point, firmware has not yet started streaming. Queuing output buffers before the firmware begins streaming causes it to process buffers in an invalid state, leading to an error response. These buffers are returned to the driver as errors, forcing the driver into an error state and stopping playback.
Fix this by deferring output buffer queuing until stream-on completes. Input buffers can still be queued before stream-on as required.
--- drivers/media/platform/qcom/iris/iris_vb2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/media/platform/qcom/iris/iris_vb2.c +7 -3
@@ -193,10 +193,14 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count) buf_type =iris_v4l2_type_to_driver (q->type);if (inst->domain ==DECODER ) { -if (inst->state ==IRIS_INST_STREAMING ) +if (buf_type ==BUF_INPUT ) + ret =iris_queue_deferred_buffers (inst,BUF_INPUT ); + +if (!ret && inst->state ==IRIS_INST_STREAMING ) { ret =iris_queue_internal_deferred_buffers (inst,BUF_DPB ); -if (!ret) - ret =iris_queue_deferred_buffers (inst, buf_type); +if (!ret) + ret =iris_queue_deferred_buffers (inst,BUF_OUTPUT ); + } }else {if (inst->state ==IRIS_INST_STREAMING ) { ret =iris_queue_deferred_buffers (inst,BUF_INPUT );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 643/844 drm: of: drm_of_panel_bridge_remove(): fix device_node leak
In reply to Sasha LevinFrom: Luca Ceresoli <[email protected]>
[ Upstream commit a4b4385d0523e39a7c058cb5a6c8269e513126ca ]
drm_of_panel_bridge_remove() uses of_graph_get_remote_node() to get a device_node but does not put the node reference.
--- include/drm/drm_of.h | 3 +++ 1 file changed, 3 insertions(+)
include/drm/drm_of.h +3 -0
@@ -5,6 +5,7 @@#include <linux/err.h> #include <linux/of_graph.h> #if IS_ENABLED (CONFIG_OF ) &&IS_ENABLED (CONFIG_DRM_PANEL_BRIDGE ) +#include <linux/of.h> #include <drm/drm_bridge.h> #endif
@@ -173,6 +174,8 @@ static inline int drm_of_panel_bridge_remove(const struct device_node *np, bridge =of_drm_find_bridge (remote);drm_panel_bridge_remove (bridge); +of_node_put (remote); +return 0 ;#else return -EINVAL ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 644/844 docs: kdoc: fix logic to handle unissued warnings
In reply to Sasha LevinFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 292eca3163218f2185a8eabe59f4a576bb9e05f8 ]
Changeset 469c1c9eb6c9 ("kernel-doc: Issue warnings that were silently discarded") didn't properly addressed the missing messages behavior, as
it was calling directly python logger low-level function,
instead of using the expected method to emit warnings.
Basically, there are two methods to log messages:
- self.config.log.warning() - This is the raw level to emit a warning. It just writes the a message at stderr, via python logging, as it is initialized as:
self.config.log = logging.getLogger("kernel-doc")
- self.config.warning() - This is where we actually consider a message as a warning, properly incrementing error count.
Due to that, several parsing error messages are internally considered as success, causing -Werror to not work on such messages.
While here, ensure that the last ignored entry will also be handled by adding an extra check at the end of the parse handler.
Message-ID: <95109a6585171da4d6900049deaa2634b41ee743.1768823489.git.mchehab+huawei@kernel.org>
--- tools/lib/python/kdoc/kdoc_parser.py | 35 ++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-)
tools/lib/python/kdoc/kdoc_parser.py +28 -7
@@ -295,7 +295,7 @@ class KernelEntry: # TODO: rename to emit_message after removal of kernel-doc.pl def emit_msg(self, ln, msg, *, warning=True): - """Emit a message""" + """Emit a message.""" log_msg = f"{self.fname}:{ln} {msg}"
@@ -448,18 +448,37 @@ class KernelDoc: self.config.log.debug("Output: %s:%s = %s", dtype, name, pformat(args)) + def emit_unused_warnings(self): + """ + When the parser fails to produce a valid entry, it places some + warnings under `entry.warnings` that will be discarded when resetting + the state. + + Ensure that those warnings are not lost. + + .. note:: + + Because we are calling `config.warning()` here, those + warnings are not filtered by the `-W` parameters: they will all + be produced even when `-Wreturn`, `-Wshort-desc`, and/or + `-Wcontents-before-sections` are used. + + Allowing those warnings to be filtered is complex, because it + would require storing them in a buffer and then filtering them + during the output step of the code, depending on the + selected symbols. + """ + if self.entry and self.entry not in self.entries: + for log_msg in self.entry.warnings: + self.config.warning(log_msg) + def reset_state(self, ln): """ Ancillary routine to create a new entry. It initializes all variables used by the state machine. """ - # - # Flush the warnings out before we proceed further - # - if self.entry and self.entry not in self.entries: - for log_msg in self.entry.warnings: - self.config.log.warning(log_msg) + self.emit_unused_warnings() self.entry = KernelEntry(self.config, self.fname, ln)
@@ -1664,6 +1683,8 @@ class KernelDoc: # Hand this line to the appropriate state handler self.state_actions[self.state](self, ln, line) + self.emit_unused_warnings() + except OSError: self.config.log.error(f"Error: Cannot open file {self.fname}")
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 645/844 docs: kdoc: avoid error_count overflows
In reply to Sasha LevinFrom: Mauro Carvalho Chehab <[email protected]>
[ Upstream commit 802774d8539fa73487190ec45438777a3c38d424 ]
The glibc library limits the return code to 8 bits. We need to stick to this limit when using sys.exit(error_count).
Message-ID: <233d1674db99ed8feb405a2f781de350f0fba0ac.1768823489.git.mchehab+huawei@kernel.org>
--- scripts/kernel-doc.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
scripts/kernel-doc.py +19 -7
@@ -116,6 +116,8 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__)) sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) +WERROR_RETURN_CODE = 3 + DESC = """ Read C language source or header FILEs, extract embedded documentation comments, and print formatted documentation to standard output.
@@ -176,7 +178,21 @@ class MsgFormatter(logging.Formatter): return logging.Formatter.format(self, record) def main(): - """Main program""" + """ + Main program. + + By default, the return value is: + + - 0: success or Python version is not compatible with + kernel-doc. If -Werror is not used, it will also + return 0 if there are issues at kernel-doc markups; + + - 1: an abnormal condition happened; + + - 2: argparse issued an error; + + - 3: -Werror is used, and one or more unfiltered parse warnings happened. + """ parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description=DESC)
@@ -323,16 +339,12 @@ def main(): if args.werror: print("%s warnings as errors" % error_count) # pylint: disable=C0209 - sys.exit(error_count) + sys.exit(WERROR_RETURN_CODE) if args.verbose: print("%s errors" % error_count) # pylint: disable=C0209 - if args.none: - sys.exit(0) - - sys.exit(error_count) - + sys.exit(0) # Call main method if __name__ == "__main__":
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 646/844 mm, page_alloc, thp: prevent reclaim for __GFP_THISNODE THP allocations
In reply to Sasha LevinFrom: Vlastimil Babka <[email protected]>
[ Upstream commit 9c9828d3ead69416d731b1238802af31760c823e ]
Since commit cc638f329ef6 ("mm, thp: tweak reclaim/compaction effort of local-only and all-node allocations"), THP page fault allocations have settled on the following scheme (from the commit log):
1. local node only THP allocation with no reclaim, just compaction.
2. for madvised VMA's or when synchronous compaction is enabled always - THP allocation from any node with effort determined by global defrag setting and VMA madvise
3. fallback to base pages on any node
Recent customer reports however revealed we have a gap in step 1 above. What we have seen is excessive reclaim due to THP page faults on a NUMA node that's close to its high watermark, while other nodes have plenty of free memory.
The problem with step 1 is that it promises no reclaim after the compaction attempt, however reclaim is only avoided for certain compaction outcomes (deferred, or skipped due to insufficient free base pages), and not e.g. when compaction is actually performed but fails (we did see compact_fail vmstat counter increasing).
THP page faults can therefore exhibit a zone_reclaim_mode-like behavior, which is not the intention.
Thus add a check for __GFP_THISNODE that corresponds to this exact situation and prevents continuing with reclaim/compaction once the initial compaction attempt isn't successful in allocating the page.
Note that commit cc638f329ef6 has not introduced this over-reclaim possibility; it appears to exist in some form since commit 2f0799a0ffc0 ("mm, thp: restore node-local hugepage allocations"). Followup commits b39d0ee2632d ("mm, page_alloc: avoid expensive reclaim when compaction may not succeed") and cc638f329ef6 have moved in the right direction, but left the abovementioned gap.
--- mm/page_alloc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
mm/page_alloc.c +14 -0
@@ -4818,6 +4818,20 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, compact_result == COMPACT_DEFERRED) goto nopage; +/* +* THP page faults may attempt local node only first, +* but are then allowed to only compact, not reclaim, +* see alloc_pages_mpol(). +* +* Compaction can fail for other reasons than those +* checked above and we don't want such THP allocations +* to put reclaim pressure on a single node in a +* situation where other nodes might have plenty of +* available memory. +*/ +if (gfp_mask & __GFP_THISNODE) + goto nopage; +/* * Looks like reclaim/compaction is worth trying, but * sync compaction could be very expensive, so keep
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 647/844 selftests/mm/charge_reserved_hugetlb: drop mount size for hugetlbfs
In reply to Sasha LevinFrom: Li Wang <[email protected]>
[ Upstream commit 1aa1dd9cc595917882fb6db67725442956f79607 ]
charge_reserved_hugetlb.sh mounts a hugetlbfs instance at /mnt/huge with a fixed size of 256M. On systems with large base hugepages (e.g. 512MB), this is smaller than a single hugepage, so the hugetlbfs mount ends up with zero capacity (often visible as size=0 in mount output).
As a result, write_to_hugetlbfs fails with ENOMEM and the test can hang waiting for progress.
=== Error log ===
# uname -r 6.12.0-xxx.el10.aarch64+64k
#./charge_reserved_hugetlb.sh -cgroup-v2
# -----------------------------------------
...
# nr hugepages = 10 # writing cgroup limit: 5368709120 # writing reseravation limit: 5368709120 ... # write_to_hugetlbfs: Error mapping the file: Cannot allocate memory # Waiting for hugetlb memory reservation to reach size 2684354560. # 0 # Waiting for hugetlb memory reservation to reach size 2684354560. # 0 ...
# mount |grep /mnt/huge none on /mnt/huge type hugetlbfs (rw,relatime,seclabel,pagesize=512M,size=0)
# grep -i huge /proc/meminfo ... HugePages_Total: 10 HugePages_Free: 10 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 524288 kB Hugetlb: 5242880 kB
Drop the mount args with 'size=256M', so the filesystem capacity is sufficient regardless of HugeTLB page size.
--- tools/testing/selftests/mm/charge_reserved_hugetlb.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/mm/charge_reserved_hugetlb.sh +2 -2
@@ -290,7 +290,7 @@ function run_test() { setup_cgroup "hugetlb_cgroup_test" "$cgroup_limit" "$reservation_limit" mkdir -p /mnt/huge - mount -t hugetlbfs -o pagesize=${MB}M,size=256M none /mnt/huge + mount -t hugetlbfs -o pagesize=${MB}M none /mnt/huge write_hugetlbfs_and_get_usage "hugetlb_cgroup_test" "$size" "$populate" \ "$write" "/mnt/huge/test" "$method" "$private" "$expect_failure" \
@@ -344,7 +344,7 @@ function run_multiple_cgroup_test() { setup_cgroup "hugetlb_cgroup_test2" "$cgroup_limit2" "$reservation_limit2" mkdir -p /mnt/huge - mount -t hugetlbfs -o pagesize=${MB}M,size=256M none /mnt/huge + mount -t hugetlbfs -o pagesize=${MB}M none /mnt/huge write_hugetlbfs_and_get_usage "hugetlb_cgroup_test1" "$size1" \ "$populate1" "$write1" "/mnt/huge/test1" "$method" "$private" \
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 648/844 drm/buddy: Prevent BUG_ON by validating rounded allocation
In reply to Sasha LevinFrom: Sanjay Yadav <[email protected]>
[ Upstream commit 5488a29596cdba93a60a79398dc9b69d5bdadf92 ]
When DRM_BUDDY_CONTIGUOUS_ALLOCATION is set, the requested size is rounded up to the next power-of-two via roundup_pow_of_two(). Similarly, for non-contiguous allocations with large min_block_size, the size is aligned up via round_up(). Both operations can produce a rounded size that exceeds mm->size, which later triggers BUG_ON(order > mm->max_order).
Example scenarios:
- 9G CONTIGUOUS allocation on 10G VRAM memory:
roundup_pow_of_two(9G) = 16G > 10G
- 9G allocation with 8G min_block_size on 10G VRAM memory:
round_up(9G, 8G) = 16G > 10G
Fix this by checking the rounded size against mm->size. For non-contiguous or range allocations where size > mm->size is invalid, return -EINVAL immediately. For contiguous allocations without range restrictions, allow the request to fall through to the existing __alloc_contig_try_harder() fallback.
This ensures invalid user input returns an error or uses the fallback path instead of hitting BUG_ON.
v2: (Matt A)
- Add Fixes, Cc stable, and Closes tags for context
--- drivers/gpu/drm/drm_buddy.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/drm_buddy.c +9 -0
@@ -1156,6 +1156,15 @@ int drm_buddy_alloc_blocks(struct drm_buddy *mm, order =fls (pages) -1 ; min_order =ilog2 (min_block_size) -ilog2 (mm->chunk_size); +if (order > mm->max_order || size > mm->size) { +if ((flags &DRM_BUDDY_CONTIGUOUS_ALLOCATION ) && + !(flags &DRM_BUDDY_RANGE_ALLOCATION )) +return __alloc_contig_try_harder (mm, original_size, + original_min_size, blocks); + +return -EINVAL ; + } + do { order = min(order, (unsigned int)fls(pages) - 1); BUG_ON(order > mm->max_order);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 649/844 drm/bridge: anx7625: Fix invalid EDID size
In reply to Sasha LevinFrom: Loic Poulain <[email protected]>
[ Upstream commit 1d5362145de96b5d00d590605cc94cdfa572b405 ]
DRM checks EDID block count against allocated size in drm_edid_valid function. We have to allocate the right EDID size instead of the max size to prevent the EDID to be reported as invalid.
--- drivers/gpu/drm/bridge/analogix/anx7625.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/analogix/anx7625.c +1 -1
@@ -1801,7 +1801,7 @@ static const struct drm_edid *anx7625_edid_read(struct anx7625_data *ctx)return NULL ; } - ctx->cached_drm_edid =drm_edid_alloc (edid_buf,FOUR_BLOCK_SIZE ); + ctx->cached_drm_edid =drm_edid_alloc (edid_buf, edid_num *ONE_BLOCK_SIZE );kfree (edid_buf); out:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 650/844 phy: fsl-imx8mq-usb: set platform driver data
In reply to Sasha LevinFrom: Xu Yang <[email protected]>
[ Upstream commit debf8326a435ac746f48173e4742a574810f1ff4 ]
Add missing platform_set_drvdata() as the data will be used in remove().
--- drivers/phy/freescale/phy-fsl-imx8mq-usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/freescale/phy-fsl-imx8mq-usb.c +2 -0
@@ -676,6 +676,8 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)if (!imx_phy)return -ENOMEM ; +platform_set_drvdata (pdev, imx_phy); + imx_phy->clk =devm_clk_get (dev,"phy" );if (IS_ERR (imx_phy->clk)) {dev_err (dev,"failed to get imx8mq usb phy clock\n" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 651/844 PCI: dwc: Skip waiting for L2/L3 Ready if dw_pcie_rp::skip_l23_wait is true
In reply to Sasha LevinFrom: Richard Zhu <[email protected]>
[ Upstream commit 58a17b2647ba5aac47e3ffafd0a9b92bf4a9bcbe ]
In NXP i.MX6QP and i.MX7D SoCs, LTSSM registers are not accessible once PME_Turn_Off message is broadcasted to the link. So there is no way to verify whether the link has entered L2/L3 Ready state or not.
Hence, add a new flag 'dw_pcie_rp::skip_l23_ready' and set it to 'true' for the above mentioned SoCs. This flag when set, will allow the DWC core to skip polling for L2/L3 Ready state and just wait for 10ms as recommended in the PCIe spec r6.0, sec 5.3.3.2.1.
--- drivers/pci/controller/dwc/pci-imx6.c | 5 +++++ drivers/pci/controller/dwc/pcie-designware-host.c | 10 ++++++++++ drivers/pci/controller/dwc/pcie-designware.h | 1 + 3 files changed, 16 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +5 -0
@@ -116,6 +116,7 @@ enum imx_pcie_variants {#define IMX_PCIE_FLAG_BROKEN_SUSPEND BIT(9)#define IMX_PCIE_FLAG_HAS_LUT BIT(10)#define IMX_PCIE_FLAG_8GT_ECN_ERR051586 BIT(11) +#define IMX_PCIE_FLAG_SKIP_L23_READY BIT(12)#define imx_check_flag (pci, val) (pci->drvdata->flags & val)
@@ -1798,6 +1799,8 @@ static int imx_pcie_probe(struct platform_device *pdev)*/ imx_pcie_add_lut_by_rid (imx_pcie,0 ); }else { +if (imx_check_flag (imx_pcie,IMX_PCIE_FLAG_SKIP_L23_READY )) + pci->pp.skip_l23_ready = true; pci->pp.use_atu_msg = true; ret =dw_pcie_host_init (&pci->pp);if (ret <0 )
@@ -1859,6 +1862,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .variant = IMX6QP, .flags =IMX_PCIE_FLAG_IMX_PHY |IMX_PCIE_FLAG_SPEED_CHANGE_WORKAROUND | +IMX_PCIE_FLAG_SKIP_L23_READY | IMX_PCIE_FLAG_SUPPORTS_SUSPEND, .dbi_length = 0x200, .gpr = "fsl,imx6q-iomuxc-gpr",
@@ -1875,6 +1879,7 @@ static const struct imx_pcie_drvdata drvdata[] = { .variant = IMX7D, .flags =IMX_PCIE_FLAG_SUPPORTS_SUSPEND |IMX_PCIE_FLAG_HAS_APP_RESET | +IMX_PCIE_FLAG_SKIP_L23_READY | IMX_PCIE_FLAG_HAS_PHY_RESET, .gpr = "fsl,imx7d-iomuxc-gpr", .mode_off[0] = IOMUXC_GPR12,
drivers/pci/controller/dwc/pcie-designware-host.c +10 -0
@@ -1173,6 +1173,16 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci)return ret; } +/* +* Some SoCs do not support reading the LTSSM register after +* PME_Turn_Off broadcast. For those SoCs, skip waiting for L2/L3 Ready +* state and wait 10ms as recommended in PCIe spec r6.0, sec 5.3.3.2.1. +*/ +if (pci->pp.skip_l23_ready) { +mdelay (PCIE_PME_TO_L2_TIMEOUT_US /1000 ); + goto stop_link; + } + ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE || val <= DW_PCIE_LTSSM_DETECT_WAIT,
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -446,6 +446,7 @@ struct dw_pcie_rp {struct pci_config_window *cfg;bool ecam_enabled;bool native_ecam; +bool skip_l23_ready; };struct dw_pcie_ep_ops {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 652/844 xfs: mark data structures corrupt on EIO and ENODATA
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit f39854a3fb2f06dc69b81ada002b641ba5b4696b ]
I learned a few things this year: first, blk_status_to_errno can return ENODATA for critical media errors; and second, the scrub code doesn't mark data structures as corrupt on ENODATA or EIO.
Currently, scrub failing to capture these errors isn't all that impactful -- the checking code will exit to userspace with EIO/ENODATA, and xfs_scrub will log a complaint and exit with nonzero status. Most people treat fsck tools failing as a sign that the fs is corrupt, but online fsck should mark the metadata bad and keep moving.
--- fs/xfs/scrub/btree.c | 2 ++ fs/xfs/scrub/common.c | 4 ++++ fs/xfs/scrub/dabtree.c | 2 ++ 3 files changed, 8 insertions(+)
fs/xfs/scrub/btree.c +2 -0
@@ -42,6 +42,8 @@ __xchk_btree_process_error(break ;case -EFSBADCRC :case -EFSCORRUPTED : +case -EIO : +case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |= errflag; *error =0 ;
fs/xfs/scrub/common.c +4 -0
@@ -103,6 +103,8 @@ __xchk_process_error(break ;case -EFSBADCRC :case -EFSCORRUPTED : +case -EIO : +case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |= errflag; *error =0 ;
@@ -177,6 +179,8 @@ __xchk_fblock_process_error(break ;case -EFSBADCRC :case -EFSCORRUPTED : +case -EIO : +case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |= errflag; *error =0 ;
fs/xfs/scrub/dabtree.c +2 -0
@@ -45,6 +45,8 @@ xchk_da_process_error(break ;case -EFSBADCRC :case -EFSCORRUPTED : +case -EIO : +case -ENODATA :/* Note the badness but don't abort. */ sc->sm->sm_flags |=XFS_SCRUB_OFLAG_CORRUPT ; *error =0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 653/844 xfs: remove xfs_attr_leaf_hasname
In reply to Sasha LevinFrom: Christoph Hellwig <[email protected]>
[ Upstream commit 3a65ea768b8094e4699e72f9ab420eb9e0f3f568 ]
The calling convention of xfs_attr_leaf_hasname() is problematic, because it returns a NULL buffer when xfs_attr3_leaf_read fails, a valid buffer when xfs_attr3_leaf_lookup_int returns -ENOATTR or -EEXIST, and a non-NULL buffer pointer for an already released buffer when xfs_attr3_leaf_lookup_int fails with other error values.
Fix this by simply open coding xfs_attr_leaf_hasname in the callers, so that the buffer release code is done by each caller of xfs_attr3_leaf_read.
--- fs/xfs/libxfs/xfs_attr.c | 75 +++++++++++++--------------------------- 1 file changed, 24 insertions(+), 51 deletions(-)
fs/xfs/libxfs/xfs_attr.c +24 -51
@@ -50,7 +50,6 @@ STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args);*/ STATIC int xfs_attr_leaf_get(xfs_da_args_t *args); STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args); -STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp);/* * Internal routines when attribute list is more than one block.
@@ -979,11 +978,12 @@ xfs_attr_lookup(return error;if (xfs_attr_is_leaf (dp)) { - error =xfs_attr_leaf_hasname (args, &bp); - -if (bp) -xfs_trans_brelse (args->trans, bp); - + error =xfs_attr3_leaf_read (args->trans, args->dp, args->owner, +0 , &bp); +if (error) +return error; + error =xfs_attr3_leaf_lookup_int (bp, args); +xfs_trans_brelse (args->trans, bp);return error; }
@@ -1222,27 +1222,6 @@ xfs_attr_shortform_addname(* External routines when attribute list is one block *========================================================================*/ -/* -* Return EEXIST if attr is found, or ENOATTR if not -*/ -STATIC int -xfs_attr_leaf_hasname ( -struct xfs_da_args *args, -struct xfs_buf **bp) -{ -int error =0 ; - - error =xfs_attr3_leaf_read (args->trans, args->dp, args->owner,0 , bp); -if (error) -return error; - - error =xfs_attr3_leaf_lookup_int (*bp, args); -if (error != -ENOATTR && error != -EEXIST ) -xfs_trans_brelse (args->trans, *bp); - -return error; -} -/* * Remove a name from the leaf attribute list structure *
@@ -1253,25 +1232,22 @@ STATIC intxfs_attr_leaf_removename ( struct xfs_da_args *args) { -struct xfs_inode *dp; -struct xfs_buf *bp; +struct xfs_inode *dp = args->dp;int error, forkoff; +struct xfs_buf *bp;trace_xfs_attr_leaf_removename (args); -/* -* Remove the attribute. -*/ - dp = args->dp; - - error =xfs_attr_leaf_hasname (args, &bp); -if (error == -ENOATTR ) { + error =xfs_attr3_leaf_read (args->trans, args->dp, args->owner,0 , &bp); +if (error) +return error; + error =xfs_attr3_leaf_lookup_int (bp, args); +if (error != -EEXIST ) {xfs_trans_brelse (args->trans, bp); -if (args->op_flags &XFS_DA_OP_RECOVERY ) +if (error == -ENOATTR && (args->op_flags &XFS_DA_OP_RECOVERY ))return 0 ;return error; - }else if (error != -EEXIST ) -return error; + }xfs_attr3_leaf_remove (bp, args);
@@ -1295,23 +1271,20 @@ xfs_attr_leaf_removename(* Returns 0 on successful retrieval, otherwise an error. */ STATIC int -xfs_attr_leaf_get (xfs_da_args_t *args) +xfs_attr_leaf_get ( +struct xfs_da_args *args) { -struct xfs_buf *bp; -int error; +struct xfs_buf *bp; +int error;trace_xfs_attr_leaf_get (args); - error =xfs_attr_leaf_hasname (args, &bp); - -if (error == -ENOATTR ) { -xfs_trans_brelse (args->trans, bp); -return error; - }else if (error != -EEXIST ) + error =xfs_attr3_leaf_read (args->trans, args->dp, args->owner,0 , &bp); +if (error)return error; - - - error =xfs_attr3_leaf_getvalue (bp, args); + error =xfs_attr3_leaf_lookup_int (bp, args); +if (error == -EEXIST ) + error =xfs_attr3_leaf_getvalue (bp, args);xfs_trans_brelse (args->trans, bp);return error; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 654/844 media: verisilicon: AV1: Fix tile info buffer size
In reply to Sasha LevinFrom: Benjamin Gaignard <[email protected]>
[ Upstream commit a505ca2db89ad92a8d8d27fa68ebafb12e04a679 ]
Each tile info is composed of: row_sb, col_sb, start_pos and end_pos (4 bytes each). So the total required memory is AV1_MAX_TILES * 16 bytes.
Use the correct #define to allocate the buffer and avoid writing tile info in non-allocated memory.
--- .../media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c +2 -2
@@ -381,12 +381,12 @@ int rockchip_vpu981_av1_dec_init(struct hantro_ctx *ctx)return -ENOMEM ; av1_dec->global_model.size =GLOBAL_MODEL_SIZE ; - av1_dec->tile_info.cpu =dma_alloc_coherent (vpu->dev,AV1_MAX_TILES , + av1_dec->tile_info.cpu =dma_alloc_coherent (vpu->dev,AV1_TILE_INFO_SIZE , &av1_dec->tile_info.dma,GFP_KERNEL );if (!av1_dec->tile_info.cpu)return -ENOMEM ; - av1_dec->tile_info.size =AV1_MAX_TILES ; + av1_dec->tile_info.size =AV1_TILE_INFO_SIZE ; av1_dec->film_grain.cpu = dma_alloc_coherent(vpu->dev, ALIGN(sizeof(struct rockchip_av1_film_grain), 2048),
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 655/844 dm: fix excessive blk-crypto operations for invalid keys
In reply to Sasha LevinFrom: Eric Biggers <[email protected]>
[ Upstream commit d6d0e6b9d54532264761405a1ba8ea5bd293acb1 ]
dm_exec_wrappedkey_op() passes through the derive_sw_secret, import_key, generate_key, and prepare_key blk-crypto operations to an underlying device.
Currently, it calls the operation on every underlying device until one returns success.
This logic is flawed when the operation is expected to fail, such as an invalid key being passed to derive_sw_secret. That can happen if userspace passes an invalid key to the FS_IOC_ADD_ENCRYPTION_KEY ioctl.
When that happens on a device-mapper device that consists of many dm-linear targets, a lot of unnecessary key unwrapping requests get sent to the underlying key wrapping hardware.
Fix this by considering the first device only. As already documented in the comment, it was already checked that all underlying devices support wrapped keys, so this should be fine.
--- drivers/md/dm-table.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/md/dm-table.c +3 -9
@@ -1237,9 +1237,6 @@ static int dm_wrappedkey_op_callback(struct dm_target *ti, struct dm_dev *dev,bdev_get_queue (bdev)->crypto_profile;int err = -EOPNOTSUPP ; -if (!args->err) -return 0 ; -switch (args->op) {case DERIVE_SW_SECRET : err = blk_crypto_derive_sw_secret(
@@ -1266,9 +1263,7 @@ static int dm_wrappedkey_op_callback(struct dm_target *ti, struct dm_dev *dev,break ; } args->err = err; - -/* Try another device in case this fails. */ -return 0 ; +return 1 ;/* No need to continue the iteration. */ } static int dm_exec_wrappedkey_op(struct blk_crypto_profile *profile,
@@ -1294,14 +1289,13 @@ static int dm_exec_wrappedkey_op(struct blk_crypto_profile *profile,* declared on all underlying devices. Thus, all the underlying devices * should support all wrapped key operations and they should behave * identically, i.e. work with the same keys. So, just executing the -* operation on the first device on which it works suffices for now. +* operation on the first device suffices for now. */ for (i =0 ; i < t->num_targets; i++) { ti =dm_table_get_target (t, i);if (!ti->type->iterate_devices)continue ; - ti->type->iterate_devices (ti, dm_wrappedkey_op_callback, args); -if (!args->err) +if (ti->type->iterate_devices (ti, dm_wrappedkey_op_callback, args) !=0 )break ; } out:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 656/844 media: uvcvideo: Return queued buffers on start_streaming() failure
In reply to Sasha LevinFrom: Michal Pecio <[email protected]>
[ Upstream commit 4cf3b6fd54ebb1ebc977bdc47fb6cfcf9a471a22 ]
Return buffers if streaming fails to start due to uvc_pm_get() error.
This bug may be responsible for a warning I got running
while :; do yavta -c3 /dev/video0; done
on an xHCI controller which failed under this workload. I had no luck reproducing this warning again to confirm.
xhci_hcd 0000:09:00.0: HC died; cleaning up
usb 13-2: USB disconnect, device number 2
WARNING: CPU: 2 PID: 29386 at drivers/media/common/videobuf2/videobuf2-core.c:1803 vb2_start_streaming+0xac/0x120
--- drivers/media/usb/uvc/uvc_queue.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_queue.c +7 -5
@@ -177,18 +177,20 @@ static int uvc_start_streaming_video(struct vb2_queue *vq, unsigned int count) ret =uvc_pm_get (stream->dev);if (ret) -return ret; + goto err_buffers; queue->buf_used =0 ; ret =uvc_video_start_streaming (stream); -if (ret ==0 ) -return 0 ; +if (ret) + goto err_pm; -uvc_pm_put (stream->dev); +return 0 ; +err_pm: +uvc_pm_put (stream->dev); +err_buffers:uvc_queue_return_buffers (queue,UVC_BUF_STATE_QUEUED ); -return ret; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 657/844 iommu/vt-d: Skip dev-iotlb flush for inaccessible PCIe device without scalable mode
In reply to Sasha LevinFrom: Jinhui Guo <[email protected]>
[ Upstream commit 42662d19839f34735b718129ea200e3734b07e50 ]
PCIe endpoints with ATS enabled and passed through to userspace (e.g., QEMU, DPDK) can hard-lock the host when their link drops, either by surprise removal or by a link fault.
Commit 4fc82cd907ac ("iommu/vt-d: Don't issue ATS Invalidation request when device is disconnected") adds pci_dev_is_disconnected() to devtlb_invalidation_with_pasid() so ATS invalidation is skipped only when the device is being safely removed, but it applies only when Intel IOMMU scalable mode is enabled.
With scalable mode disabled or unsupported, a system hard-lock occurs when a PCIe endpoint's link drops because the Intel IOMMU waits indefinitely for an ATS invalidation that cannot complete.
Call Trace: qi_submit_sync qi_flush_dev_iotlb __context_flush_dev_iotlb.part.0 domain_context_clear_one_cb pci_for_each_dma_alias device_block_translation blocking_domain_attach_dev iommu_deinit_device __iommu_group_remove_device iommu_release_device iommu_bus_notifier blocking_notifier_call_chain bus_notify device_del pci_remove_bus_device pci_stop_and_remove_bus_device pciehp_unconfigure_device pciehp_disable_slot pciehp_handle_presence_or_link_change pciehp_ist
Commit 81e921fd3216 ("iommu/vt-d: Fix NULL domain on device release") adds intel_pasid_teardown_sm_context() to intel_iommu_release_device(), which calls qi_flush_dev_iotlb() and can also hard-lock the system when a PCIe endpoint's link drops.
Call Trace: qi_submit_sync qi_flush_dev_iotlb __context_flush_dev_iotlb.part.0 intel_context_flush_no_pasid device_pasid_table_teardown pci_pasid_table_teardown pci_for_each_dma_alias intel_pasid_teardown_sm_context intel_iommu_release_device iommu_deinit_device __iommu_group_remove_device iommu_release_device iommu_bus_notifier blocking_notifier_call_chain bus_notify device_del pci_remove_bus_device pci_stop_and_remove_bus_device pciehp_unconfigure_device pciehp_disable_slot pciehp_handle_presence_or_link_change pciehp_ist
Sometimes the endpoint loses connection without a link-down event (e.g., due to a link fault); killing the process (virsh destroy) then hard-locks the host.
Call Trace: qi_submit_sync qi_flush_dev_iotlb __context_flush_dev_iotlb.part.0 domain_context_clear_one_cb pci_for_each_dma_alias device_block_translation blocking_domain_attach_dev __iommu_attach_device __iommu_device_set_domain __iommu_group_set_domain_internal iommu_detach_group vfio_iommu_type1_detach_group vfio_group_detach_container vfio_group_fops_release __fput
pci_dev_is_disconnected() only covers safe-removal paths; pci_device_is_present() tests accessibility by reading vendor/device IDs and internally calls pci_dev_is_disconnected(). On a ConnectX-5 (8 GT/s, x2) this costs ~70 µs.
Since __context_flush_dev_iotlb() is only called on {attach,release}_dev paths (not hot), add pci_device_is_present() there to skip inaccessible devices and avoid the hard-lock.
--- drivers/iommu/intel/pasid.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/iommu/intel/pasid.c +8 -0
@@ -926,6 +926,14 @@ static void __context_flush_dev_iotlb(struct device_domain_info *info)if (!info->ats_enabled)return ; +/* +* Skip dev-IOTLB flush for inaccessible PCIe devices to prevent the +* Intel IOMMU from waiting indefinitely for an ATS invalidation that +* cannot complete. +*/ +if (!pci_device_is_present (to_pci_dev (info->dev))) +return ; +qi_flush_dev_iotlb (info->iommu,PCI_DEVID (info->bus, info->devfn), info->pfsid, info->ats_qdep,0 ,MAX_AGAW_PFN_WIDTH );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 658/844 iommu/vt-d: Flush dev-IOTLB only when PCIe device is accessible in scalable mode
In reply to Sasha LevinFrom: Jinhui Guo <[email protected]>
[ Upstream commit 10e60d87813989e20eac1f3eda30b3bae461e7f9 ]
Commit 4fc82cd907ac ("iommu/vt-d: Don't issue ATS Invalidation request when device is disconnected") relies on pci_dev_is_disconnected() to skip ATS invalidation for safely-removed devices, but it does not cover link-down caused by faults, which can still hard-lock the system.
For example, if a VM fails to connect to the PCIe device, "virsh destroy" is executed to release resources and isolate the fault, but a hard-lockup occurs while releasing the group fd.
Call Trace: qi_submit_sync qi_flush_dev_iotlb intel_pasid_tear_down_entry device_block_translation blocking_domain_attach_dev __iommu_attach_device __iommu_device_set_domain __iommu_group_set_domain_internal iommu_detach_group vfio_iommu_type1_detach_group vfio_group_detach_container vfio_group_fops_release __fput
Although pci_device_is_present() is slower than pci_dev_is_disconnected(), it still takes only ~70 µs on a ConnectX-5 (8 GT/s, x2) and becomes even faster as PCIe speed and width increase.
Besides, devtlb_invalidation_with_pasid() is called only in the paths below, which are far less frequent than memory map/unmap.
1. mm-struct release
2. {attach,release}_dev
3. set/remove PASID
4. dirty-tracking setup
The gain in system stability far outweighs the negligible cost of using pci_device_is_present() instead of pci_dev_is_disconnected() to decide when to skip ATS invalidation, especially under GDR high-load conditions.
--- drivers/iommu/intel/pasid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/pasid.c +1 -1
@@ -219,7 +219,7 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu,if (!info || !info->ats_enabled)return ; -if (pci_dev_is_disconnected (to_pci_dev (dev))) +if (!pci_device_is_present (to_pci_dev (dev)))return ; sid =PCI_DEVID (info->bus, info->devfn);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 659/844 iommu/vt-d: Flush piotlb for SVM and Nested domain
In reply to Sasha LevinFrom: Yi Liu <[email protected]>
[ Upstream commit 04b1b069f151e793767755f58b51670bff00cbc1 ]
Besides the paging domains that use FS, SVM and Nested domains need to use piotlb invalidation descriptor as well.
--- drivers/iommu/intel/cache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iommu/intel/cache.c +8 -1
@@ -363,6 +363,13 @@ static void qi_batch_add_pasid_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16qi_batch_increment_index (iommu, batch); } +static bool intel_domain_use_piotlb (struct dmar_domain *domain) +{ +return domain->domain.type ==IOMMU_DOMAIN_SVA || + domain->domain.type ==IOMMU_DOMAIN_NESTED || +intel_domain_is_fs_paging (domain); +} +static void cache_tag_flush_iotlb (struct dmar_domain *domain,struct cache_tag *tag,unsigned long addr,unsigned long pages,unsigned long mask,int ih)
@@ -370,7 +377,7 @@ static void cache_tag_flush_iotlb(struct dmar_domain *domain, struct cache_tag *struct intel_iommu *iommu = tag->iommu;u64 type =DMA_TLB_PSI_FLUSH ; -if (intel_domain_is_fs_paging (domain)) { +if (intel_domain_use_piotlb (domain)) {qi_batch_add_piotlb (iommu, tag->domain_id, tag->pasid, addr, pages, ih, domain->qi_batch);return ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 660/844 KVM: arm64: nv: Return correct RES0 bits for FGT registers
In reply to Sasha LevinFrom: "Zenghui Yu (Huawei)" <[email protected]>
[ Upstream commit 2eb80a2eee18762a33aa770d742d64fe47852c7e ]
We had extended the sysreg masking infrastructure to more general registers, instead of restricting it to VNCR-backed registers, since commit a0162020095e ("KVM: arm64: Extend masking facility to arbitrary registers"). Fix kvm_get_sysreg_res0() to reflect this fact.
Note that we're sure that we only deal with FGT registers in kvm_get_sysreg_res0(), the
if (sr < __VNCR_START__)
is actually a never false, which should probably be removed later.
--- arch/arm64/kvm/emulate-nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/emulate-nested.c +1 -1
@@ -2428,7 +2428,7 @@ static u64 kvm_get_sysreg_res0(struct kvm *kvm, enum vcpu_sysreg sr) masks = kvm->arch.sysreg_masks; -return masks->mask[sr - __VNCR_START__].res0; +return masks->mask[sr - __SANITISED_REG_START__].res0; } static bool check_fgt_bit(struct kvm_vcpu *vcpu, enum vcpu_sysreg sr,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 661/844 mfd: core: Add locking around 'mfd_of_node_list'
In reply to Sasha LevinFrom: Douglas Anderson <[email protected]>
[ Upstream commit 20117c92bcf9c11afd64d7481d8f94fdf410726e ]
Manipulating a list in the kernel isn't safe without some sort of mutual exclusion. Add a mutex any time we access / modify 'mfd_of_node_list' to prevent possible crashes.
--- drivers/mfd/mfd-core.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/mfd/mfd-core.c +22 -14
@@ -22,6 +22,7 @@#include <linux/regulator/consumer.h> static LIST_HEAD (mfd_of_node_list); +static DEFINE_MUTEX (mfd_of_node_mutex);struct mfd_of_node_entry {struct list_head list;
@@ -105,9 +106,11 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,u64 of_node_addr;/* Skip if OF node has previously been allocated to a device */ -list_for_each_entry (of_entry, &mfd_of_node_list, list) -if (of_entry->np == np) -return -EAGAIN ; + scoped_guard(mutex, &mfd_of_node_mutex) { +list_for_each_entry (of_entry, &mfd_of_node_list, list) +if (of_entry->np == np) +return -EAGAIN ; + }if (!cell->use_of_reg)/* No of_reg defined - allocate first free compatible match */
@@ -129,7 +132,8 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev, of_entry->dev = &pdev->dev; of_entry->np = np; -list_add_tail (&of_entry->list, &mfd_of_node_list); + scoped_guard(mutex, &mfd_of_node_mutex) +list_add_tail (&of_entry->list, &mfd_of_node_list);of_node_get (np);device_set_node (&pdev->dev,of_fwnode_handle (np));
@@ -286,11 +290,13 @@ static int mfd_add_device(struct device *parent, int id,if (cell->swnode)device_remove_software_node (&pdev->dev); fail_of_entry: -list_for_each_entry_safe (of_entry, tmp, &mfd_of_node_list, list) -if (of_entry->dev == &pdev->dev) { -list_del (&of_entry->list); -kfree (of_entry); - } + scoped_guard(mutex, &mfd_of_node_mutex) { +list_for_each_entry_safe (of_entry, tmp, &mfd_of_node_list, list) +if (of_entry->dev == &pdev->dev) { +list_del (&of_entry->list); +kfree (of_entry); + } + } fail_alias: regulator_bulk_unregister_supply_alias(&pdev->dev, cell->parent_supplies,
@@ -360,11 +366,13 @@ static int mfd_remove_devices_fn(struct device *dev, void *data)if (cell->swnode)device_remove_software_node (&pdev->dev); -list_for_each_entry_safe (of_entry, tmp, &mfd_of_node_list, list) -if (of_entry->dev == &pdev->dev) { -list_del (&of_entry->list); -kfree (of_entry); - } + scoped_guard(mutex, &mfd_of_node_mutex) { +list_for_each_entry_safe (of_entry, tmp, &mfd_of_node_list, list) +if (of_entry->dev == &pdev->dev) { +list_del (&of_entry->list); +kfree (of_entry); + } + }regulator_bulk_unregister_supply_alias (dev, cell->parent_supplies, cell->num_parent_supplies);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 662/844 mfd: tps65219: Implement LOCK register handling for TPS65214
In reply to Sasha LevinFrom: "Kory Maincent (TI.com)" <[email protected]>
[ Upstream commit d3fcf276b501a82d4504fd5b1ed40249546530d1 ]
The TPS65214 PMIC variant has a LOCK_REG register that prevents writes to nearly all registers when locked. Unlock the registers at probe time and leave them unlocked permanently.
This approach is justified because:
- Register locking is very uncommon in typical system operation
- No code path is expected to lock the registers during runtime
- Adding a custom regmap write function would add overhead to every register write, including voltage changes triggered by CPU OPP transitions from the cpufreq governor which could happen quite frequently
--- drivers/mfd/tps65219.c | 9 +++++++++ include/linux/mfd/tps65219.h | 2 ++ 2 files changed, 11 insertions(+)
drivers/mfd/tps65219.c +9 -0
@@ -498,6 +498,15 @@ static int tps65219_probe(struct i2c_client *client)return ret; } +if (chip_id ==TPS65214 ) { + ret =i2c_smbus_write_byte_data (client,TPS65214_REG_LOCK , +TPS65214_LOCK_ACCESS_CMD ); +if (ret) { +dev_err (tps->dev,"Failed to unlock registers %d\n" , ret); +return ret; + } + } + ret =devm_regmap_add_irq_chip (tps->dev, tps->regmap, client->irq,IRQF_ONESHOT ,0 , pmic->irq_chip, &tps->irq_data);
include/linux/mfd/tps65219.h +2 -0
@@ -149,6 +149,8 @@ enum pmic_id {#define TPS65215_ENABLE_LDO2_EN_MASK BIT(5)#define TPS65214_ENABLE_LDO1_EN_MASK BIT(5)#define TPS65219_ENABLE_LDO4_EN_MASK BIT(6) +/* Register Unlock */ +#define TPS65214_LOCK_ACCESS_CMD 0x5a/* power ON-OFF sequence slot */ #define TPS65219_BUCKS_LDOS_SEQUENCE_OFF_SLOT_MASK GENMASK(3, 0)#define TPS65219_BUCKS_LDOS_SEQUENCE_ON_SLOT_MASK GENMASK(7, 4)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 663/844 mfd: macsmc: Initialize mutex
In reply to Sasha LevinFrom: Janne Grunau <[email protected]>
[ Upstream commit 414f65d6736342c77d4ec5e7373039f4a09250dd ]
Initialize struct apple_smc's mutex in apple_smc_probe(). Using the mutex uninitialized surprisingly resulted only in occasional NULL pointer dereferences in apple_smc_read() calls from the probe() functions of sub devices.
--- drivers/mfd/macsmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/macsmc.c +1 -0
@@ -413,6 +413,7 @@ static int apple_smc_probe(struct platform_device *pdev)if (!smc)return -ENOMEM ; +mutex_init (&smc->mutex); smc->dev = &pdev->dev; smc->sram_base =devm_platform_get_and_ioremap_resource (pdev,1 , &smc->sram);if (IS_ERR (smc->sram_base))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 664/844 mfd: qcom-pm8xxx: Fix OF populate on driver rebind
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 27a8acea47a93fea6ad0e2df4c20a9b51490e4d9 ]
Since commit c6e126de43e7 ("of: Keep track of populated platform devices") child devices will not be created by of_platform_populate() if the devices had previously been deregistered individually so that the OF_POPULATED flag is still set in the corresponding OF nodes.
Switch to using of_platform_depopulate() instead of open coding so that the child devices are created if the driver is rebound.
--- drivers/mfd/qcom-pm8xxx.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/mfd/qcom-pm8xxx.c +1 -7
@@ -577,17 +577,11 @@ static int pm8xxx_probe(struct platform_device *pdev)return rc; } -static int pm8xxx_remove_child (struct device *dev,void *unused) -{ -platform_device_unregister (to_platform_device (dev)); -return 0 ; -} -static void pm8xxx_remove (struct platform_device *pdev) {struct pm_irq_chip *chip =platform_get_drvdata (pdev); -device_for_each_child (&pdev->dev,NULL , pm8xxx_remove_child); +of_platform_depopulate (&pdev->dev);irq_domain_remove (chip->irqdomain); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 665/844 mfd: omap-usb-host: Fix OF populate on driver rebind
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 24804ba508a3e240501c521685a1c4eb9f574f8e ]
Since commit c6e126de43e7 ("of: Keep track of populated platform devices") child devices will not be created by of_platform_populate() if the devices had previously been deregistered individually so that the OF_POPULATED flag is still set in the corresponding OF nodes.
Switch to using of_platform_depopulate() instead of open coding so that the child devices are created if the driver is rebound.
--- drivers/mfd/omap-usb-host.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mfd/omap-usb-host.c +4 -2
@@ -819,8 +819,10 @@ static void usbhs_omap_remove(struct platform_device *pdev) {pm_runtime_disable (&pdev->dev); -/* remove children */ -device_for_each_child (&pdev->dev,NULL , usbhs_omap_remove_child); +if (pdev->dev.of_node) +of_platform_depopulate (&pdev->dev); +else +device_for_each_child (&pdev->dev,NULL , usbhs_omap_remove_child); }static const struct dev_pm_ops usbhsomap_dev_pm_ops = {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 666/844 erofs: fix incorrect early exits for invalid metabox-enabled images
In reply to Sasha LevinFrom: Gao Xiang <[email protected]>
[ Upstream commit 643575d5a4f24b23b0c54aa20aa74a4abed8ff5e ]
Crafted EROFS images with metadata compression enabled can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
--- fs/erofs/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/erofs/super.c +3 -2
@@ -330,12 +330,13 @@ static int erofs_read_superblock(struct super_block *sb) } sbi->packed_nid =le64_to_cpu (dsb->packed_nid);if (erofs_sb_has_metabox (sbi)) { + ret = -EFSCORRUPTED ;if (sbi->sb_size <= offsetof(struct erofs_super_block , metabox_nid)) -return -EFSCORRUPTED ; + goto out; sbi->metabox_nid =le64_to_cpu (dsb->metabox_nid);if (sbi->metabox_nid &BIT_ULL (EROFS_DIRENT_NID_METABOX_BIT )) -return -EFSCORRUPTED ;/* self-loop detection */ + goto out;/* self-loop detection */ } sbi->inos =le64_to_cpu (dsb->inos);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 667/844 erofs: fix incorrect early exits in volume label handling
In reply to Sasha LevinFrom: Gao Xiang <[email protected]>
[ Upstream commit 3afa4da38802a4cba1c23848a32284e7e57b831b ]
Crafted EROFS images containing valid volume labels can trigger incorrect early returns, leading to folio reference leaks.
However, this does not cause system crashes or other severe issues.
--- fs/erofs/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/erofs/super.c +4 -2
@@ -347,8 +347,10 @@ static int erofs_read_superblock(struct super_block *sb)if (dsb->volume_name[0 ]) { sbi->volume_name =kstrndup (dsb->volume_name,sizeof (dsb->volume_name),GFP_KERNEL ); -if (!sbi->volume_name) -return -ENOMEM ; +if (!sbi->volume_name) { + ret = -ENOMEM ; + goto out; + } }/* parse on-disk compression configurations */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 668/844 arm64: dts: rockchip: Explicitly request UFS reset pin on RK3576
In reply to Sasha LevinFrom: Alexey Charkov <[email protected]>
[ Upstream commit 79a3286e61829fc43abdd6e3beb31b24930c7af6 ]
Rockchip RK3576 UFS controller uses a dedicated pin to reset the connected UFS device, which can operate either in a hardware controlled mode or as a GPIO pin.
Power-on default is GPIO mode, but the boot ROM reconfigures it to a hardware controlled mode if it uses UFS to load the next boot stage.
Given that existing bindings (and rk3576.dtsi) expect a GPIO-controlled device reset, request the required pin config explicitly.
The pin is requested with pull-down enabled, which is in line with the SoC power-on default and helps ensure that the attached UFS chip stays in reset until the driver takes over the control of the respective GPIO line.
This doesn't appear to affect Linux, but it does affect U-boot:
Before:
=> md.l 0x2604b3982604b398: 00000011 00000000 00000000 00000000 ................
< ... snip ... >
=> ufs init
ufshcd-rockchip ufshc@2a2d0000: [RX, TX]: gear=[3, 3], lane[2, 2], pwr[FASTAUTO_MODE, FASTAUTO_MODE], rate = 2 => md.l 0x2604b3982604b398: 00000011 00000000 00000000 00000000 ................
After:
=> md.l 0x2604b3982604b398: 00000011 00000000 00000000 00000000 ................
< ... snip ...>
=> ufs init
ufshcd-rockchip ufshc@2a2d0000: [RX, TX]: gear=[3, 3], lane[2, 2], pwr[FASTAUTO_MODE, FASTAUTO_MODE], rate = 2 => md.l 0x2604b3982604b398: 00000010 00000000 00000000 00000000 ................
(0x2604b398 is the respective pin mux register, with its BIT0 driving the mode of UFS_RST: unset = GPIO, set = hardware controlled UFS_RST)
This helps ensure that GPIO-driven device reset actually fires when the system requests it, not when whatever black box magic inside the UFSHC decides to reset the flash chip.
--- arch/arm64/boot/dts/rockchip/rk3576-pinctrl.dtsi | 7 +++++++ arch/arm64/boot/dts/rockchip/rk3576.dtsi | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3576-pinctrl.dtsi +7 -0
@@ -5228,6 +5228,13 @@ ufs_rst: ufs-rst { /* ufs_rstn */ <4 RK_PD0 1 &pcfg_pull_none>; }; + + /omit-if-no-ref/ + ufs_rstgpio: ufs-rstgpio { + rockchip,pins = + /* ufs_rstn */ + <4 RK_PD0 RK_FUNC_GPIO &pcfg_pull_down>; + }; }; ufs_testdata0 {
arch/arm64/boot/dts/rockchip/rk3576.dtsi +1 -1
@@ -1826,7 +1826,7 @@ ufshc: ufshc@2a2d0000 { assigned-clock-parents = <&cru CLK_REF_MPHY_26M>; interrupts = <GIC_SPI 361 IRQ_TYPE_LEVEL_HIGH>; power-domains = <&power RK3576_PD_USB>; - pinctrl-0 = <&ufs_refclk>; + pinctrl-0 = <&ufs_refclk &ufs_rstgpio>; pinctrl-names = "default"; resets = <&cru SRST_A_UFS_BIU>, <&cru SRST_A_UFS_SYS>, <&cru SRST_A_UFS>, <&cru SRST_P_UFS_GRF>;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 669/844 arm64: dts: rockchip: Fix rk356x PCIe range mappings
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit f63ea193a404481f080ca2958f73e9f364682db9 ]
The pcie bus address should be mapped 1:1 to the cpu side MMIO address, so that there is no same address allocated from normal system memory. Otherwise it's broken if the same address assigned to the EP for DMA purpose.Fix it to sync with the vendor BSP.
--- arch/arm64/boot/dts/rockchip/rk3568.dtsi | 4 ++-- arch/arm64/boot/dts/rockchip/rk356x-base.dtsi | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/rockchip/rk3568.dtsi +2 -2
@@ -185,7 +185,7 @@ pcie3x1: pcie@fe270000 { <0x0 0xf2000000 0x0 0x00100000>; ranges = <0x01000000 0x0 0xf2100000 0x0 0xf2100000 0x0 0x00100000>, <0x02000000 0x0 0xf2200000 0x0 0xf2200000 0x0 0x01e00000>, - <0x03000000 0x0 0x40000000 0x3 0x40000000 0x0 0x40000000>; + <0x03000000 0x3 0x40000000 0x3 0x40000000 0x0 0x40000000>; reg-names = "dbi", "apb", "config"; resets = <&cru SRST_PCIE30X1_POWERUP>; reset-names = "pipe";
@@ -238,7 +238,7 @@ pcie3x2: pcie@fe280000 { <0x0 0xf0000000 0x0 0x00100000>; ranges = <0x01000000 0x0 0xf0100000 0x0 0xf0100000 0x0 0x00100000>, <0x02000000 0x0 0xf0200000 0x0 0xf0200000 0x0 0x01e00000>, - <0x03000000 0x0 0x40000000 0x3 0x80000000 0x0 0x40000000>; + <0x03000000 0x3 0x80000000 0x3 0x80000000 0x0 0x40000000>; reg-names = "dbi", "apb", "config"; resets = <&cru SRST_PCIE30X2_POWERUP>; reset-names = "pipe";
arch/arm64/boot/dts/rockchip/rk356x-base.dtsi +1 -1
@@ -1022,7 +1022,7 @@ pcie2x1: pcie@fe260000 { power-domains = <&power RK3568_PD_PIPE>; ranges = <0x01000000 0x0 0xf4100000 0x0 0xf4100000 0x0 0x00100000>, <0x02000000 0x0 0xf4200000 0x0 0xf4200000 0x0 0x01e00000>, - <0x03000000 0x0 0x40000000 0x3 0x00000000 0x0 0x40000000>; + <0x03000000 0x3 0x00000000 0x3 0x00000000 0x0 0x40000000>; resets = <&cru SRST_PCIE20_POWERUP>; reset-names = "pipe"; #address-cells = <3>;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 670/844 arm64: dts: rockchip: Fix rk3588 PCIe range mappings
In reply to Sasha LevinFrom: Shawn Lin <[email protected]>
[ Upstream commit 46c56b737161060dfa468f25ae699749047902a2 ]
The pcie bus address should be mapped 1:1 to the cpu side MMIO address, so that there is no same address allocated from normal system memory. Otherwise it's broken if the same address assigned to the EP for DMA purpose.Fix it to sync with the vendor BSP.
--- arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 4 ++-- arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +2 -2
@@ -1955,7 +1955,7 @@ pcie2x1l1: pcie@fe180000 { power-domains = <&power RK3588_PD_PCIE>; ranges = <0x01000000 0x0 0xf3100000 0x0 0xf3100000 0x0 0x00100000>, <0x02000000 0x0 0xf3200000 0x0 0xf3200000 0x0 0x00e00000>, - <0x03000000 0x0 0x40000000 0x9 0xc0000000 0x0 0x40000000>; + <0x03000000 0x9 0xc0000000 0x9 0xc0000000 0x0 0x40000000>; reg = <0xa 0x40c00000 0x0 0x00400000>, <0x0 0xfe180000 0x0 0x00010000>, <0x0 0xf3000000 0x0 0x00100000>;
@@ -2007,7 +2007,7 @@ pcie2x1l2: pcie@fe190000 { power-domains = <&power RK3588_PD_PCIE>; ranges = <0x01000000 0x0 0xf4100000 0x0 0xf4100000 0x0 0x00100000>, <0x02000000 0x0 0xf4200000 0x0 0xf4200000 0x0 0x00e00000>, - <0x03000000 0x0 0x40000000 0xa 0x00000000 0x0 0x40000000>; + <0x03000000 0xa 0x00000000 0xa 0x00000000 0x0 0x40000000>; reg = <0xa 0x41000000 0x0 0x00400000>, <0x0 0xfe190000 0x0 0x00010000>, <0x0 0xf4000000 0x0 0x00100000>;
arch/arm64/boot/dts/rockchip/rk3588-extra.dtsi +3 -3
@@ -375,7 +375,7 @@ pcie3x4: pcie@fe150000 { power-domains = <&power RK3588_PD_PCIE>; ranges = <0x01000000 0x0 0xf0100000 0x0 0xf0100000 0x0 0x00100000>, <0x02000000 0x0 0xf0200000 0x0 0xf0200000 0x0 0x00e00000>, - <0x03000000 0x0 0x40000000 0x9 0x00000000 0x0 0x40000000>; + <0x03000000 0x9 0x00000000 0x9 0x00000000 0x0 0x40000000>; reg = <0xa 0x40000000 0x0 0x00400000>, <0x0 0xfe150000 0x0 0x00010000>, <0x0 0xf0000000 0x0 0x00100000>;
@@ -462,7 +462,7 @@ pcie3x2: pcie@fe160000 { power-domains = <&power RK3588_PD_PCIE>; ranges = <0x01000000 0x0 0xf1100000 0x0 0xf1100000 0x0 0x00100000>, <0x02000000 0x0 0xf1200000 0x0 0xf1200000 0x0 0x00e00000>, - <0x03000000 0x0 0x40000000 0x9 0x40000000 0x0 0x40000000>; + <0x03000000 0x9 0x40000000 0x9 0x40000000 0x0 0x40000000>; reg = <0xa 0x40400000 0x0 0x00400000>, <0x0 0xfe160000 0x0 0x00010000>, <0x0 0xf1000000 0x0 0x00100000>;
@@ -512,7 +512,7 @@ pcie2x1l0: pcie@fe170000 { power-domains = <&power RK3588_PD_PCIE>; ranges = <0x01000000 0x0 0xf2100000 0x0 0xf2100000 0x0 0x00100000>, <0x02000000 0x0 0xf2200000 0x0 0xf2200000 0x0 0x00e00000>, - <0x03000000 0x0 0x40000000 0x9 0x80000000 0x0 0x40000000>; + <0x03000000 0x9 0x80000000 0x9 0x80000000 0x0 0x40000000>; reg = <0xa 0x40800000 0x0 0x00400000>, <0x0 0xfe170000 0x0 0x00010000>, <0x0 0xf2000000 0x0 0x00100000>;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 671/844 PCI/PM: Prevent runtime suspend until devices are fully initialized
In reply to Sasha LevinFrom: Brian Norris <[email protected]>
[ Upstream commit 51c0996dadaea20d73eb0495aeda9cb0422243e8 ]
Previously, it was possible for a PCI device to be runtime-suspended before it was fully initialized. When that happened, the suspend process could save invalid device state, for example, before BAR assignment. Restoring the invalid state during resume may leave the device non-functional.
Prevent runtime suspend for PCI devices until they are fully initialized by deferring pm_runtime_enable().
More details on how exactly this may occur:
1. PCI device is created by pci_scan_slot() or similar
2. As part of pci_scan_slot(), pci_pm_init() puts the device in D0 and prevents runtime suspend prevented via pm_runtime_forbid()
3. pci_device_add() adds the underlying 'struct device' via device_add(), which means user space can allow runtime suspend, e.g.,
echo auto > /sys/bus/pci/devices/.../power/control
4. PCI device receives BAR configuration (pci_assign_unassigned_bus_resources(), etc.)
5. pci_bus_add_device() applies final fixups, saves device state, and tries to attach a driver
The device may potentially be suspended between #3 and #5, so this is racy with user space (udev or similar).
Many PCI devices are enumerated at subsys_initcall time and so will not race with user space, but devices created later by hotplug or modular pwrctrl or host controller drivers are susceptible to this race.
More runtime PM details at the first Link: below.
--- drivers/pci/bus.c | 8 ++++++++ drivers/pci/pci.c | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-)
drivers/pci/bus.c +8 -0
@@ -15,6 +15,7 @@#include <linux/of.h> #include <linux/of_platform.h> #include <linux/platform_device.h> +#include <linux/pm_runtime.h> #include <linux/proc_fs.h> #include <linux/slab.h>
@@ -379,6 +380,13 @@ void pci_bus_add_device(struct pci_dev *dev)put_device (&pdev->dev); } +/* +* Enable runtime PM, which potentially allows the device to +* suspend immediately, only after the PCI state has been +* configured completely. +*/ +pm_runtime_enable (&dev->dev); +if (!dn ||of_device_is_available (dn))pci_dev_allow_binding (dev);
drivers/pci/pci.c +7 -1
@@ -3199,8 +3199,14 @@ void pci_pm_init(struct pci_dev *dev) poweron:pci_pm_power_up_and_verify_state (dev);pm_runtime_forbid (&dev->dev); + +/* +* Runtime PM will be enabled for the device when it has been fully +* configured, but since its parent and suppliers may suspend in +* the meantime, prevent them from doing so by changing the +* device's runtime PM status to "active". +*/ pm_runtime_set_active (&dev->dev); -pm_runtime_enable (&dev->dev); }static unsigned long pci_ea_flags (struct pci_dev *dev,u8 prop)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 672/844 iio: accel: adxl380: Avoid reading more entries than present in FIFO
In reply to Sasha LevinFrom: Francesco Lavra <[email protected]>
[ Upstream commit c1b14015224cfcccd5356333763f2f4f401bd810 ]
The interrupt handler reads FIFO entries in batches of N samples, where N is the number of scan elements that have been enabled. However, the sensor fills the FIFO one sample at a time, even when more than one channel is enabled. Therefore,the number of entries reported by the FIFO status registers may not be a multiple of N; if this number is not a multiple, the number of entries read from the FIFO may exceed the number of entries actually present.
To fix the above issue, round down the number of FIFO entries read from the status registers so that it is always a multiple of N.
--- drivers/iio/accel/adxl380.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/adxl380.c +1 -0
@@ -949,6 +949,7 @@ static irqreturn_t adxl380_irq_handler(int irq, void *p)if (ret)return IRQ_HANDLED ; + fifo_entries =rounddown (fifo_entries, st->fifo_set_size);for (i =0 ; i < fifo_entries; i += st->fifo_set_size) { ret = regmap_noinc_read(st->regmap, ADXL380_FIFO_DATA, &st->fifo_buf[i],
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 673/844 clk: tegra: tegra124-emc: fix device leak on set_rate()
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit da61439c63d34ae6503d080a847f144d587e3a48 ]
Make sure to drop the reference taken when looking up the EMC device and its driver data on first set_rate().
Note that holding a reference to a device does not prevent its driver data from going away so there is no point in keeping the reference.
--- drivers/clk/tegra/clk-tegra124-emc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/tegra/clk-tegra124-emc.c +1 -1
@@ -197,8 +197,8 @@ static struct tegra_emc *emc_ensure_emc_driver(struct tegra_clk_emc *tegra) tegra->emc_node =NULL ; tegra->emc =platform_get_drvdata (pdev); +put_device (&pdev->dev);if (!tegra->emc) { -put_device (&pdev->dev);pr_err ("%s: cannot find EMC driver\n" , __func__);return NULL ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 674/844 iommu/arm-smmu-v3: Add update_safe bits to fix STE update sequence
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 2781f2a930abb5d27f80b8afbabfa19684833b65 ]
C_BAD_STE was observed when updating nested STE from an S1-bypass mode to an S1DSS-bypass mode. As both modes enabled S2, the used bit is slightly different than the normal S1-bypass and S1DSS-bypass modes. As a result, fields like MEV and EATS in S2's used list marked the word1 as a critical word that requested a STE.V=0. This breaks a hitless update.
However, both MEV and EATS aren't critical in terms of STE update. One controls the merge of the events and the other controls the ATS that is managed by the driver at the same time via pci_enable_ats().
Add an arm_smmu_get_ste_update_safe() to allow STE update algorithm to relax those fields, avoiding the STE update breakages.
After this change, entry_set has no caller checking its return value, so change it to void.
Note that this change is required by both MEV and EATS fields, which were introduced in different kernel versions. So add get_update_safe() first. MEV and EATS will be added to arm_smmu_get_ste_update_safe() separately.
--- .../iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c | 31 +++++++++++++++++-- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 28 ++++++++++++----- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 4 +++ 3 files changed, 53 insertions(+), 10 deletions(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c +28 -3
@@ -38,13 +38,16 @@ enum arm_smmu_test_master_feat {static bool arm_smmu_entry_differs_in_used_bits (const __le64 *entry,const __le64 *used_bits,const __le64 *target, +const __le64 *safe,unsigned int length) {bool differs = false;unsigned int i;for (i =0 ; i < length; i++) { -if ((entry[i] & used_bits[i]) != target[i]) +__le64 used = used_bits[i] & ~safe[i]; + +if ((entry[i] & used) != (target[i] & used)) differs = true; }return differs;
@@ -56,12 +59,24 @@ arm_smmu_test_writer_record_syncs(struct arm_smmu_entry_writer *writer)struct arm_smmu_test_writer *test_writer = container_of(writer, struct arm_smmu_test_writer, writer);__le64 *entry_used_bits; +__le64 *safe_target; +__le64 *safe_init; entry_used_bits =kunit_kzalloc ( test_writer->test,sizeof (*entry_used_bits) *NUM_ENTRY_QWORDS ,GFP_KERNEL );KUNIT_ASSERT_NOT_NULL (test_writer->test, entry_used_bits); + safe_target =kunit_kzalloc (test_writer->test, +sizeof (*safe_target) *NUM_ENTRY_QWORDS , +GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test_writer->test, safe_target); + + safe_init =kunit_kzalloc (test_writer->test, +sizeof (*safe_init) *NUM_ENTRY_QWORDS , +GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test_writer->test, safe_init); +pr_debug ("STE value is now set to: " ); print_hex_dump_debug(" ", DUMP_PREFIX_NONE, 16, 8, test_writer->entry,
@@ -79,14 +94,23 @@ arm_smmu_test_writer_record_syncs(struct arm_smmu_entry_writer *writer)* configuration. */ writer->ops->get_used (test_writer->entry, entry_used_bits); +if (writer->ops->get_update_safe) + writer->ops->get_update_safe (test_writer->entry, + test_writer->init_entry, + safe_init); +if (writer->ops->get_update_safe) + writer->ops->get_update_safe (test_writer->entry, + test_writer->target_entry, + safe_target);KUNIT_EXPECT_FALSE ( test_writer->test,arm_smmu_entry_differs_in_used_bits ( test_writer->entry, entry_used_bits, - test_writer->init_entry,NUM_ENTRY_QWORDS ) && + test_writer->init_entry, safe_init, +NUM_ENTRY_QWORDS ) &&arm_smmu_entry_differs_in_used_bits ( test_writer->entry, entry_used_bits, - test_writer->target_entry, + test_writer->target_entry, safe_target,NUM_ENTRY_QWORDS )); } }
@@ -106,6 +130,7 @@ arm_smmu_v3_test_debug_print_used_bits(struct arm_smmu_entry_writer *writer,static const struct arm_smmu_entry_writer_ops test_ste_ops = { .sync = arm_smmu_test_writer_record_syncs, .get_used = arm_smmu_get_ste_used, + .get_update_safe = arm_smmu_get_ste_update_safe, };static const struct arm_smmu_entry_writer_ops test_cd_ops = {
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +21 -7
@@ -1093,6 +1093,13 @@ void arm_smmu_get_ste_used(const __le64 *ent, __le64 *used_bits) }EXPORT_SYMBOL_IF_KUNIT (arm_smmu_get_ste_used); +VISIBLE_IF_KUNIT +void arm_smmu_get_ste_update_safe(const __le64 *cur, const __le64 *target, +__le64 *safe_bits) +{ +} +EXPORT_SYMBOL_IF_KUNIT (arm_smmu_get_ste_update_safe); +/* * Figure out if we can do a hitless update of entry to become target. Returns a * bit mask where 1 indicates that qword needs to be set disruptively.
@@ -1105,13 +1112,22 @@ static u8 arm_smmu_entry_qword_diff(struct arm_smmu_entry_writer *writer, {__le64 target_used[NUM_ENTRY_QWORDS ] = {};__le64 cur_used[NUM_ENTRY_QWORDS ] = {}; +__le64 safe[NUM_ENTRY_QWORDS ] = {};u8 used_qword_diff =0 ;unsigned int i; writer->ops->get_used (entry, cur_used); writer->ops->get_used (target, target_used); +if (writer->ops->get_update_safe) + writer->ops->get_update_safe (entry, target, safe);for (i =0 ; i !=NUM_ENTRY_QWORDS ; i++) { +/* +* Safe is only used for bits that are used by both entries, +* otherwise it is sequenced according to the unused entry. +*/ + safe[i] &= target_used[i] & cur_used[i]; +/* * Check that masks are up to date, the make functions are not * allowed to set a bit to 1 if the used function doesn't say it
@@ -1120,6 +1136,7 @@ static u8 arm_smmu_entry_qword_diff(struct arm_smmu_entry_writer *writer,WARN_ON_ONCE (target[i] & ~target_used[i]);/* Bits can change because they are not currently being used */ + cur_used[i] &= ~safe[i]; unused_update[i] = (entry[i] & cur_used[i]) | (target[i] & ~cur_used[i]);/*
@@ -1132,7 +1149,7 @@ static u8 arm_smmu_entry_qword_diff(struct arm_smmu_entry_writer *writer,return used_qword_diff; } -static bool entry_set (struct arm_smmu_entry_writer *writer,__le64 *entry, +static void entry_set (struct arm_smmu_entry_writer *writer,__le64 *entry,const __le64 *target,unsigned int start,unsigned int len) {
@@ -1148,7 +1165,6 @@ static bool entry_set(struct arm_smmu_entry_writer *writer, __le64 *entry,if (changed) writer->ops->sync (writer); -return changed; }/*
@@ -1218,12 +1234,9 @@ void arm_smmu_write_entry(struct arm_smmu_entry_writer *writer, __le64 *entry,entry_set (writer, entry, target,0 ,1 ); }else {/* -* No inuse bit changed. Sanity check that all unused bits are 0 -* in the entry. The target was already sanity checked by -* compute_qword_diff(). +* No inuse bit changed, though safe bits may have changed. */ -WARN_ON_ONCE ( -entry_set (writer, entry, target,0 ,NUM_ENTRY_QWORDS )); +entry_set (writer, entry, target,0 ,NUM_ENTRY_QWORDS ); } }EXPORT_SYMBOL_IF_KUNIT (arm_smmu_write_entry);
@@ -1554,6 +1567,7 @@ static void arm_smmu_ste_writer_sync_entry(struct arm_smmu_entry_writer *writer)static const struct arm_smmu_entry_writer_ops arm_smmu_ste_writer_ops = { .sync = arm_smmu_ste_writer_sync_entry, .get_used = arm_smmu_get_ste_used, + .get_update_safe = arm_smmu_get_ste_update_safe, }; static void arm_smmu_write_ste(struct arm_smmu_master *master, u32 sid,
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h +4 -0
@@ -900,6 +900,8 @@ struct arm_smmu_entry_writer {struct arm_smmu_entry_writer_ops {void (*get_used)(const __le64 *entry,__le64 *used); +void (*get_update_safe)(const __le64 *cur,const __le64 *target, +__le64 *safe_bits);void (*sync)(struct arm_smmu_entry_writer *writer); };
@@ -911,6 +913,8 @@ void arm_smmu_make_s2_domain_ste(struct arm_smmu_ste *target,#if IS_ENABLED (CONFIG_KUNIT )void arm_smmu_get_ste_used (const __le64 *ent,__le64 *used_bits); +void arm_smmu_get_ste_update_safe (const __le64 *cur,const __le64 *target, +__le64 *safe_bits);void arm_smmu_write_entry (struct arm_smmu_entry_writer *writer,__le64 *cur,const __le64 *target);void arm_smmu_get_cd_used (const __le64 *ent,__le64 *used_bits);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 675/844 iommu/arm-smmu-v3: Mark STE MEV safe when computing the update sequence
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit f3c1d372dbb8e5a86923f20db66deabef42bfc9d ]
Nested CD tables set the MEV bit to try to reduce multi-fault spamming on the hypervisor. Since MEV is in STE word 1 this causes a breaking update sequence that is not required and impacts real workloads.
For the purposes of STE updates the value of MEV doesn't matter, if it is set/cleared early or late it just results in a change to the fault reports that must be supported by the kernel anyhow. The spec says:
Note: Software must expect, and be able to deal with, coalesced fault records even when MEV == 0.
So mark STE MEV safe when computing the update sequence, to avoid creating a breaking update.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +10 -0
@@ -1097,6 +1097,16 @@ VISIBLE_IF_KUNITvoid arm_smmu_get_ste_update_safe (const __le64 *cur,const __le64 *target,__le64 *safe_bits) { +/* +* MEV does not meaningfully impact the operation of the HW, it only +* changes how many fault events are generated, thus we can relax it +* when computing the ordering. The spec notes the device can act like +* MEV=1 anyhow: +* +* Note: Software must expect, and be able to deal with, coalesced +* fault records even when MEV == 0. +*/ + safe_bits[1 ] |=cpu_to_le64 (STRTAB_STE_1_MEV ); }EXPORT_SYMBOL_IF_KUNIT (arm_smmu_get_ste_update_safe);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 676/844 iommu/arm-smmu-v3: Mark EATS_TRANS safe when computing the update sequence
In reply to Sasha LevinFrom: Jason Gunthorpe <[email protected]>
[ Upstream commit 7cad800485956a263318930613f8f4a084af8c70 ]
If VM wants to toggle EATS_TRANS off at the same time as changing the CFG, hypervisor will see EATS change to 0 and insert a V=0 breaking update into the STE even though the VM did not ask for that.
In bare metal, EATS_TRANS is ignored by CFG=ABORT/BYPASS, which is why this does not cause a problem until we have the nested case where CFG is always a variation of S2 trans that does use EATS_TRANS.
Relax the rules for EATS_TRANS sequencing, we don't need it to be exact as the enclosing code will always disable ATS at the PCI device when changing EATS_TRANS. This ensures there are no ATS transactions that can race with an EATS_TRANS change so we don't need to carefully sequence these bits.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +26 -0
@@ -1097,6 +1097,32 @@ VISIBLE_IF_KUNITvoid arm_smmu_get_ste_update_safe (const __le64 *cur,const __le64 *target,__le64 *safe_bits) { +const __le64 eats_s1chk = +FIELD_PREP (STRTAB_STE_1_EATS ,STRTAB_STE_1_EATS_S1CHK ); +const __le64 eats_trans = +FIELD_PREP (STRTAB_STE_1_EATS ,STRTAB_STE_1_EATS_TRANS ); + +/* +* When an STE changes EATS_TRANS, the sequencing code in the attach +* logic already will have the PCI cap for ATS disabled. Thus at this +* moment we can expect that the device will not generate ATS queries +* and so we don't care about the sequencing of EATS. The purpose of +* EATS_TRANS is to protect the system from hostile untrusted devices +* that issue ATS when the PCI config space is disabled. However, if +* EATS_TRANS is being changed, then we must have already trusted the +* device as the EATS_TRANS security block is being disabled. +* +* Note: now the EATS_TRANS update is moved to the first entry_set(). +* Changing S2S and EATS might transiently result in S2S=1 and EATS=1 +* which is a bad STE (see "5.2 Stream Table Entry"). In such a case, +* we can't do a hitless update. Also, it should not be added to the +* safe bits with STRTAB_STE_1_EATS_S1CHK, because EATS=0b11 would be +* effectively an errant 0b00 configuration. +*/ +if (!((cur[1 ] | target[1 ]) &cpu_to_le64 (eats_s1chk)) && + !((cur[2 ] | target[2 ]) &cpu_to_le64 (STRTAB_STE_2_S2S ))) + safe_bits[1 ] |=cpu_to_le64 (eats_trans); +/* * MEV does not meaningfully impact the operation of the HW, it only * changes how many fault events are generated, thus we can relax it
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 677/844 iommu/arm-smmu-v3: Do not set disable_ats unless vSTE is Translate
In reply to Sasha LevinFrom: Nicolin Chen <[email protected]>
[ Upstream commit a45dd34663025c75652b27e384e91c9c05ba1d80 ]
A vSTE may have three configuration types: Abort, Bypass, and Translate.
An Abort vSTE wouldn't enable ATS, but the other two might.
It makes sense for a Transalte vSTE to rely on the guest vSTE.EATS field.
For a Bypass vSTE, it would end up with an S2-only physical STE, similar to an attachment to a regular S2 domain. However, the nested case always disables ATS following the Bypass vSTE, while the regular S2 case always enables ATS so long as arm_smmu_ats_supported(master) == true.
Note that ATS is needed for certain VM centric workloads and historically non-vSMMU cases have relied on this automatic enablement. So, having the nested case behave differently causes problems.
To fix that, add a condition to disable_ats, so that it might enable ATS for a Bypass vSTE, aligning with the regular S2 case.
--- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c +3 -1
@@ -177,7 +177,9 @@ static int arm_smmu_attach_dev_nested(struct iommu_domain *domain,* config bit here base this off the EATS value in the STE. If the EATS * is set then the VM must generate ATC flushes. */ - state.disable_ats = !nested_domain->enable_ats; +if (FIELD_GET (STRTAB_STE_0_CFG ,le64_to_cpu (nested_domain->ste[0 ])) == +STRTAB_STE_0_CFG_S1_TRANS ) + state.disable_ats = !nested_domain->enable_ats; ret =arm_smmu_attach_prepare (&state, domain);if (ret) {mutex_unlock (&arm_smmu_asid_lock);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 678/844 usb: host: tegra: Remove manual wake IRQ disposal
In reply to Sasha LevinFrom: Wayne Chang <[email protected]>
[ Upstream commit ef548189fd3f44786fb813af0018cc8b3bbed2b9 ]
We found that calling irq_dispose_mapping() caused a kernel warning when removing the driver. The IRQs are obtained using platform_get_irq(), which returns a Linux virtual IRQ number directly managed by the device core, not by the OF subsystem. Therefore, the driver should not call irq_dispose_mapping() for these IRQs.
--- drivers/usb/host/xhci-tegra.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
drivers/usb/host/xhci-tegra.c +2 -19
@@ -1570,7 +1570,6 @@ static int tegra_xusb_setup_wakeup(struct platform_device *pdev, struct tegra_xu data =irq_get_irq_data (tegra->wake_irqs[i]);if (!data) {dev_warn (tegra->dev,"get wake event %d irq data fail\n" , i); -irq_dispose_mapping (tegra->wake_irqs[i]);break ; }
@@ -1583,16 +1582,6 @@ static int tegra_xusb_setup_wakeup(struct platform_device *pdev, struct tegra_xureturn 0 ; } -static void tegra_xusb_dispose_wake (struct tegra_xusb *tegra) -{ -unsigned int i; - -for (i =0 ; i < tegra->num_wakes; i++) -irq_dispose_mapping (tegra->wake_irqs[i]); - - tegra->num_wakes =0 ; -} -static int tegra_xusb_probe (struct platform_device *pdev) {struct tegra_xusb *tegra;
@@ -1648,10 +1637,8 @@ static int tegra_xusb_probe(struct platform_device *pdev)return err; tegra->padctl =tegra_xusb_padctl_get (&pdev->dev); -if (IS_ERR (tegra->padctl)) { - err =PTR_ERR (tegra->padctl); - goto dispose_wake; - } +if (IS_ERR (tegra->padctl)) +return PTR_ERR (tegra->padctl); np =of_parse_phandle (pdev->dev.of_node,"nvidia,xusb-padctl" ,0 );if (!np) {
@@ -1975,8 +1962,6 @@ static int tegra_xusb_probe(struct platform_device *pdev) put_padctl:of_node_put (np);tegra_xusb_padctl_put (tegra->padctl); -dispose_wake: -tegra_xusb_dispose_wake (tegra);return err; }
@@ -2009,8 +1994,6 @@ static void tegra_xusb_remove(struct platform_device *pdev)if (tegra->padctl_irq)pm_runtime_disable (&pdev->dev); -tegra_xusb_dispose_wake (tegra); -pm_runtime_put (&pdev->dev);tegra_xusb_disable (tegra);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 679/844 xfs: delete attr leaf freemap entries when empty
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 6f13c1d2a6271c2e73226864a0e83de2770b6f34 ]
Back in commit 2a2b5932db6758 ("xfs: fix attr leaf header freemap.size underflow"), Brian Foster observed that it's possible for a small freemap at the end of the end of the xattr entries array to experience a size underflow when subtracting the space consumed by an expansion of the entries array. There are only three freemap entries, which means that it is not a complete index of all free space in the leaf block.
This code can leave behind a zero-length freemap entry with a nonzero base. Subsequent setxattr operations can increase the base up to the point that it overlaps with another freemap entry. This isn't in and of itself a problem because the code in _leaf_add that finds free space ignores any freemap entry with zero size.
However, there's another bug in the freemap update code in _leaf_add, which is that it fails to update a freemap entry that begins midway through the xattr entry that was just appended to the array. That can result in the freemap containing two entries with the same base but different sizes (0 for the "pushed-up" entry, nonzero for the entry that's actually tracking free space). A subsequent _leaf_add can then allocate xattr namevalue entries on top of the entries array, leading to data loss. But fixing that is for later.
For now, eliminate the possibility of confusion by zeroing out the base of any freemap entry that has zero size. Because the freemap is not intended to be a complete index of free space, a subsequent failure to find any free space for a new xattr will trigger block compaction, which regenerates the freemap.
It looks like this bug has been in the codebase for quite a long time.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/xfs/libxfs/xfs_attr_leaf.c +13 -0
@@ -1580,6 +1580,19 @@ xfs_attr3_leaf_add_work(min_t (uint16_t, ichdr->freemap[i].size,sizeof (xfs_attr_leaf_entry_t)); } + +/* +* Don't leave zero-length freemaps with nonzero base lying +* around, because we don't want the code in _remove that +* matches on base address to get confused and create +* overlapping freemaps. If we end up with no freemap entries +* then the next _add will compact the leaf block and +* regenerate the freemaps. +*/ +if (ichdr->freemap[i].size ==0 && ichdr->freemap[i].base >0 ) { + ichdr->freemap[i].base =0 ; + ichdr->holes =1 ; + } } ichdr->usedbytes +=xfs_attr_leaf_entsize (leaf, args->index); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 680/844 xfs: fix freemap adjustments when adding xattrs to leaf blocks
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 3eefc0c2b78444b64feeb3783c017d6adc3cd3ce ]
xfs/592 and xfs/794 both trip this assertion in the leaf block freemap adjustment code after ~20 minutes of running on my test VMs:
ASSERT(ichdr->firstused >= ichdr->count * sizeof(xfs_attr_leaf_entry_t)
+ xfs_attr3_leaf_hdr_size(leaf));
Upon enabling quite a lot more debugging code, I narrowed this down to fsstress trying to set a local extended attribute with namelen=3 and valuelen=71. This results in an entry size of 80 bytes.
At the start of xfs_attr3_leaf_add_work, the freemap looks like this:
i 0 base 448 size 0 rhs 448 count 46
i 1 base 388 size 132 rhs 448 count 46
i 2 base 2120 size 4 rhs 448 count 46
firstused = 520
where "rhs" is the first byte past the end of the leaf entry array. This is inconsistent -- the entries array ends at byte 448, but freemap[1] says there's free space starting at byte 388!
By the end of the function, the freemap is in worse shape:
i 0 base 456 size 0 rhs 456 count 47
i 1 base 388 size 52 rhs 456 count 47
i 2 base 2120 size 4 rhs 456 count 47
firstused = 440
Important note: 388 is not aligned with the entries array element size of 8 bytes.
Based on the incorrect freemap, the name area starts at byte 440, which is below the end of the entries array! That's why the assertion triggers and the filesystem shuts down.
How did we end up here? First, recall from the previous patch that the freemap array in an xattr leaf block is not intended to be a comprehensive map of all free space in the leaf block. In other words, it's perfectly legal to have a leaf block with:
* 376 bytes in use by the entries array
* freemap[0] has [base = 376, size = 8]
* freemap[1] has [base = 388, size = 1500]
* the space between 376 and 388 is free, but the freemap stopped tracking that some time ago
If we add one xattr, the entries array grows to 384 bytes, and freemap[0] becomes [base = 384, size = 0]. So far, so good. But if we add a second xattr, the entries array grows to 392 bytes, and freemap[0] gets pushed up to [base = 392, size = 0]. This is bad, because freemap[1] hasn't been updated, and now the entries array and the free space claim the same space.
The fix here is to adjust all freemap entries so that none of them collide with the entries array. Note that this fix relies on commit 2a2b5932db6758 ("xfs: fix attr leaf header freemap.size underflow") and the previous patch that resets zero length freemap entries to have base = 0.
--- fs/xfs/libxfs/xfs_attr_leaf.c | 36 +++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-)
fs/xfs/libxfs/xfs_attr_leaf.c +28 -8
@@ -1476,6 +1476,7 @@ xfs_attr3_leaf_add_work(struct xfs_attr_leaf_name_local *name_loc;struct xfs_attr_leaf_name_remote *name_rmt;struct xfs_mount *mp; +int old_end, new_end;int tmp;int i;
@@ -1568,17 +1569,36 @@ xfs_attr3_leaf_add_work(if (be16_to_cpu (entry->nameidx) < ichdr->firstused) ichdr->firstused =be16_to_cpu (entry->nameidx); -ASSERT (ichdr->firstused >= ichdr->count *sizeof (xfs_attr_leaf_entry_t) - +xfs_attr3_leaf_hdr_size (leaf)); - tmp = (ichdr->count -1 ) *sizeof (xfs_attr_leaf_entry_t) - +xfs_attr3_leaf_hdr_size (leaf); + new_end = ichdr->count *sizeof (struct xfs_attr_leaf_entry ) + +xfs_attr3_leaf_hdr_size (leaf); + old_end = new_end -sizeof (struct xfs_attr_leaf_entry ); + +ASSERT (ichdr->firstused >= new_end);for (i =0 ; i <XFS_ATTR_LEAF_MAPSIZE ; i++) { -if (ichdr->freemap[i].base == tmp) { - ichdr->freemap[i].base +=sizeof (xfs_attr_leaf_entry_t); +int diff =0 ; + +if (ichdr->freemap[i].base == old_end) { +/* +* This freemap entry starts at the old end of the +* leaf entry array, so we need to adjust its base +* upward to accomodate the larger array. +*/ + diff =sizeof (struct xfs_attr_leaf_entry ); + }else if (ichdr->freemap[i].size >0 && + ichdr->freemap[i].base < new_end) { +/* +* This freemap entry starts in the space claimed by +* the new leaf entry. Adjust its base upward to +* reflect that. +*/ + diff = new_end - ichdr->freemap[i].base; + } + +if (diff) { + ichdr->freemap[i].base += diff; ichdr->freemap[i].size -= -min_t (uint16_t, ichdr->freemap[i].size, -sizeof (xfs_attr_leaf_entry_t)); +min_t (uint16_t, ichdr->freemap[i].size, diff); }/*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 681/844 xfs: fix the xattr scrub to detect freemap/entries array collisions
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 6fed8270448c246e706921c177e9633013dd3fcf ]
In the previous patches, we observed that it's possible for there to be freemap entries with zero size but a nonzero base. This isn't an inconsistency per se, but older kernels can get confused by this and corrupt the block, leading to corruption.
If we see this, flag the xattr structure for optimization so that it gets rebuilt.
--- fs/xfs/scrub/attr.c | 54 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-)
fs/xfs/scrub/attr.c +27 -27
@@ -287,32 +287,6 @@ xchk_xattr_set_map(return ret; } -/* -* Check the leaf freemap from the usage bitmap. Returns false if the -* attr freemap has problems or points to used space. -*/ -STATIC bool -xchk_xattr_check_freemap ( -struct xfs_scrub *sc, -struct xfs_attr3_icleaf_hdr *leafhdr) -{ -struct xchk_xattr_buf *ab = sc->buf; -unsigned int mapsize = sc->mp->m_attr_geo->blksize; -int i; - -/* Construct bitmap of freemap contents. */ -bitmap_zero (ab->freemap, mapsize); -for (i =0 ; i <XFS_ATTR_LEAF_MAPSIZE ; i++) { -if (!xchk_xattr_set_map (sc, ab->freemap, - leafhdr->freemap[i].base, - leafhdr->freemap[i].size)) -return false; - } - -/* Look for bits that are set in freemap and are marked in use. */ -return !bitmap_intersects (ab->freemap, ab->usedmap, mapsize); -} -/* * Check this leaf entry's relations to everything else. * Returns the number of bytes used for the name/value data.
@@ -403,6 +377,7 @@ xchk_xattr_block( *last_checked = blk->blkno;bitmap_zero (ab->usedmap, mp->m_attr_geo->blksize); +bitmap_zero (ab->freemap, mp->m_attr_geo->blksize);/* Check all the padding. */ if (xfs_has_crc (ds->sc->mp)) {
@@ -449,6 +424,9 @@ xchk_xattr_block(if ((char *)&entries[leafhdr.count] > (char *)leaf + leafhdr.firstused)xchk_da_set_corrupt (ds, level); +if (ds->sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT ) + goto out; + buf_end = (char *)bp->b_addr + mp->m_attr_geo->blksize;for (i =0 , ent = entries; i < leafhdr.count; ent++, i++) {/* Mark the leaf entry itself. */
@@ -467,7 +445,29 @@ xchk_xattr_block( goto out; } -if (!xchk_xattr_check_freemap (ds->sc, &leafhdr)) +/* Construct bitmap of freemap contents. */ +for (i =0 ; i <XFS_ATTR_LEAF_MAPSIZE ; i++) { +if (!xchk_xattr_set_map (ds->sc, ab->freemap, + leafhdr.freemap[i].base, + leafhdr.freemap[i].size)) +xchk_da_set_corrupt (ds, level); + +/* +* freemap entries with zero length and nonzero base can cause +* problems with older kernels, so we mark these for preening +* even though there's no inconsistency. +*/ +if (leafhdr.freemap[i].size ==0 && + leafhdr.freemap[i].base >0 ) +xchk_da_set_preen (ds, level); + +if (ds->sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT ) + goto out; + } + +/* Look for bits that are set in freemap and are marked in use. */ +if (bitmap_intersects (ab->freemap, ab->usedmap, + mp->m_attr_geo->blksize))xchk_da_set_corrupt (ds, level);if (leafhdr.usedbytes != usedbytes)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 682/844 xfs: fix remote xattr valuelblk check
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit bd3138e8912c9db182eac5fed1337645a98b7a4f ]
In debugging other problems with generic/753, it turns out that it's possible for the system go to down in the middle of a remote xattr set operation such that the leaf block entry is marked incomplete and valueblk is set to zero. Make this no longer a failure.
--- fs/xfs/scrub/attr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/xfs/scrub/attr.c +4 -1
@@ -338,7 +338,10 @@ xchk_xattr_entry( rentry =xfs_attr3_leaf_name_remote (leaf, idx); namesize =xfs_attr_leaf_entsize_remote (rentry->namelen); name_end = (char *)rentry + namesize; -if (rentry->namelen ==0 || rentry->valueblk ==0 ) +if (rentry->namelen ==0 ) +xchk_da_set_corrupt (ds, level); +if (rentry->valueblk ==0 && + !(ent->flags &XFS_ATTR_INCOMPLETE ))xchk_da_set_corrupt (ds, level); }if (name_end > buf_end)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 683/844 xfs: get rid of the xchk_xfile_*_descr calls
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 60382993a2e18041f88c7969f567f168cd3b4de3 ]
The xchk_xfile_*_descr macros call kasprintf, which can fail to allocate memory if the formatted string is larger than 16 bytes (or whatever the nofail guarantees are nowadays). Some of them could easily exceed that, and Jiaming Zhang found a few places where that can happen with syzbot.
The descriptions are debugging aids and aren't required to be unique, so let's just pass in static strings and eliminate this path to failure. Note this patch touches a number of commits, most of which were merged between 6.6 and 6.14.
--- fs/xfs/scrub/agheader_repair.c | 13 ++++--------- fs/xfs/scrub/alloc_repair.c | 5 +---- fs/xfs/scrub/attr_repair.c | 20 +++++--------------- fs/xfs/scrub/bmap_repair.c | 6 +----- fs/xfs/scrub/common.h | 25 ------------------------- fs/xfs/scrub/dir.c | 13 ++++--------- fs/xfs/scrub/dir_repair.c | 11 +++-------- fs/xfs/scrub/dirtree.c | 11 +++-------- fs/xfs/scrub/ialloc_repair.c | 5 +---- fs/xfs/scrub/nlinks.c | 6 ++---- fs/xfs/scrub/parent.c | 11 +++-------- fs/xfs/scrub/parent_repair.c | 23 ++++++----------------- fs/xfs/scrub/quotacheck.c | 13 +++---------- fs/xfs/scrub/refcount_repair.c | 13 ++----------- fs/xfs/scrub/rmap_repair.c | 5 +---- fs/xfs/scrub/rtbitmap_repair.c | 6 ++---- fs/xfs/scrub/rtrefcount_repair.c | 15 +++------------ fs/xfs/scrub/rtrmap_repair.c | 5 +---- fs/xfs/scrub/rtsummary.c | 7 ++----- 19 files changed, 47 insertions(+), 166 deletions(-)
fs/xfs/scrub/agheader_repair.c +4 -9
@@ -1708,7 +1708,6 @@ xrep_agi( {struct xrep_agi *ragi;struct xfs_mount *mp = sc->mp; -char *descr;unsigned int i;int error;
@@ -1742,17 +1741,13 @@ xrep_agi(xagino_bitmap_init (&ragi->iunlink_bmp); sc->buf_cleanup = xrep_agi_buf_cleanup; - descr =xchk_xfile_ag_descr (sc,"iunlinked next pointers" ); - error =xfarray_create (descr,0 ,sizeof (xfs_agino_t), - &ragi->iunlink_next); -kfree (descr); + error =xfarray_create ("iunlinked next pointers" ,0 , +sizeof (xfs_agino_t), &ragi->iunlink_next);if (error)return error; - descr =xchk_xfile_ag_descr (sc,"iunlinked prev pointers" ); - error =xfarray_create (descr,0 ,sizeof (xfs_agino_t), - &ragi->iunlink_prev); -kfree (descr); + error =xfarray_create ("iunlinked prev pointers" ,0 , +sizeof (xfs_agino_t), &ragi->iunlink_prev);if (error)return error;
fs/xfs/scrub/alloc_repair.c +1 -4
@@ -850,7 +850,6 @@ xrep_allocbt(struct xrep_abt *ra;struct xfs_mount *mp = sc->mp;unsigned int busy_gen; -char *descr;int error;/* We require the rmapbt to rebuild anything. */
@@ -876,11 +875,9 @@ xrep_allocbt( }/* Set up enough storage to handle maximally fragmented free space. */ - descr =xchk_xfile_ag_descr (sc,"free space records" ); - error =xfarray_create (descr, mp->m_sb.sb_agblocks /2 , + error =xfarray_create ("free space records" , mp->m_sb.sb_agblocks /2 ,sizeof (struct xfs_alloc_rec_incore ), &ra->free_records); -kfree (descr);if (error) goto out_ra;
fs/xfs/scrub/attr_repair.c +5 -15
@@ -1529,7 +1529,6 @@ xrep_xattr_setup_scan( struct xrep_xattr **rxp) {struct xrep_xattr *rx; -char *descr;int max_len;int error;
@@ -1555,35 +1554,26 @@ xrep_xattr_setup_scan( goto out_rx;/* Set up some staging for salvaged attribute keys and values */ - descr =xchk_xfile_ino_descr (sc,"xattr keys" ); - error =xfarray_create (descr,0 ,sizeof (struct xrep_xattr_key ), + error =xfarray_create ("xattr keys" ,0 ,sizeof (struct xrep_xattr_key ), &rx->xattr_records); -kfree (descr);if (error) goto out_rx; - descr =xchk_xfile_ino_descr (sc,"xattr names" ); - error =xfblob_create (descr, &rx->xattr_blobs); -kfree (descr); + error =xfblob_create ("xattr names" , &rx->xattr_blobs);if (error) goto out_keys;if (xfs_has_parent (sc->mp)) {ASSERT (sc->flags &XCHK_FSGATES_DIRENTS ); - descr =xchk_xfile_ino_descr (sc, -"xattr retained parent pointer entries" ); - error =xfarray_create (descr,0 , + error =xfarray_create ("xattr parent pointer entries" ,0 ,sizeof (struct xrep_xattr_pptr ), &rx->pptr_recs); -kfree (descr);if (error) goto out_values; - descr =xchk_xfile_ino_descr (sc, -"xattr retained parent pointer names" ); - error =xfblob_create (descr, &rx->pptr_names); -kfree (descr); + error =xfblob_create ("xattr parent pointer names" , + &rx->pptr_names);if (error) goto out_pprecs;
fs/xfs/scrub/bmap_repair.c +1 -5
@@ -923,7 +923,6 @@ xrep_bmap( bool allow_unwritten) {struct xrep_bmap *rb; -char *descr;xfs_extnum_t max_bmbt_recs;bool large_extcount;int error =0 ;
@@ -945,11 +944,8 @@ xrep_bmap(/* Set up enough storage to handle the max records for this fork. */ large_extcount =xfs_has_large_extent_counts (sc->mp); max_bmbt_recs =xfs_iext_max_nextents (large_extcount, whichfork); - descr =xchk_xfile_ino_descr (sc,"%s fork mapping records" , - whichfork ==XFS_DATA_FORK ?"data" :"attr" ); - error =xfarray_create (descr, max_bmbt_recs, + error =xfarray_create ("fork mapping records" , max_bmbt_recs,sizeof (struct xfs_bmbt_rec ), &rb->bmap_records); -kfree (descr);if (error) goto out_rb;
fs/xfs/scrub/common.h +0 -25
@@ -246,31 +246,6 @@ static inline bool xchk_could_repair(const struct xfs_scrub *sc)int xchk_metadata_inode_forks (struct xfs_scrub *sc); -/* -* Helper macros to allocate and format xfile description strings. -* Callers must kfree the pointer returned. -*/ -#define xchk_xfile_descr (sc, fmt, ...) \ - kasprintf(XCHK_GFP_FLAGS, "XFS (%s): " fmt, \ - (sc)->mp->m_super->s_id, ##__VA_ARGS__) -#define xchk_xfile_ag_descr (sc, fmt, ...) \ - kasprintf(XCHK_GFP_FLAGS, "XFS (%s): AG 0x%x " fmt, \ - (sc)->mp->m_super->s_id, \ - (sc)->sa.pag ? \ - pag_agno((sc)->sa.pag) : (sc)->sm->sm_agno, \ - ##__VA_ARGS__) -#define xchk_xfile_ino_descr (sc, fmt, ...) \ - kasprintf(XCHK_GFP_FLAGS, "XFS (%s): inode 0x%llx " fmt, \ - (sc)->mp->m_super->s_id, \ - (sc)->ip ? (sc)->ip->i_ino : (sc)->sm->sm_ino, \ - ##__VA_ARGS__) -#define xchk_xfile_rtgroup_descr (sc, fmt, ...) \ - kasprintf(XCHK_GFP_FLAGS, "XFS (%s): rtgroup 0x%x " fmt, \ - (sc)->mp->m_super->s_id, \ - (sc)->sa.pag ? \ - rtg_rgno((sc)->sr.rtg) : (sc)->sm->sm_agno, \ - ##__VA_ARGS__) -/* * Setting up a hook to wait for intents to drain is costly -- we have to take * the CPU hotplug lock and force an i-cache flush on all CPUs once to set it
fs/xfs/scrub/dir.c +4 -9
@@ -1102,22 +1102,17 @@ xchk_directory( sd->xname.name = sd->namebuf;if (xfs_has_parent (sc->mp)) { -char *descr; -/* * Set up some staging memory for dirents that we can't check * due to locking contention. */ - descr =xchk_xfile_ino_descr (sc,"slow directory entries" ); - error =xfarray_create (descr,0 ,sizeof (struct xchk_dirent ), - &sd->dir_entries); -kfree (descr); + error =xfarray_create ("slow directory entries" ,0 , +sizeof (struct xchk_dirent ), &sd->dir_entries);if (error) goto out_sd; - descr =xchk_xfile_ino_descr (sc,"slow directory entry names" ); - error =xfblob_create (descr, &sd->dir_names); -kfree (descr); + error =xfblob_create ("slow directory entry names" , + &sd->dir_names);if (error) goto out_entries; }
fs/xfs/scrub/dir_repair.c +3 -8
@@ -1784,20 +1784,15 @@ xrep_dir_setup_scan( struct xrep_dir *rd) {struct xfs_scrub *sc = rd->sc; -char *descr;int error;/* Set up some staging memory for salvaging dirents. */ - descr =xchk_xfile_ino_descr (sc,"directory entries" ); - error =xfarray_create (descr,0 ,sizeof (struct xrep_dirent ), - &rd->dir_entries); -kfree (descr); + error =xfarray_create ("directory entries" ,0 , +sizeof (struct xrep_dirent ), &rd->dir_entries);if (error)return error; - descr =xchk_xfile_ino_descr (sc,"directory entry names" ); - error =xfblob_create (descr, &rd->dir_names); -kfree (descr); + error =xfblob_create ("directory entry names" , &rd->dir_names);if (error) goto out_xfarray;
fs/xfs/scrub/dirtree.c +3 -8
@@ -92,7 +92,6 @@ xchk_setup_dirtree( struct xfs_scrub *sc) {struct xchk_dirtree *dl; -char *descr;int error;xchk_fsgates_enable (sc,XCHK_FSGATES_DIRENTS );
@@ -116,16 +115,12 @@ xchk_setup_dirtree(mutex_init (&dl->lock); - descr =xchk_xfile_ino_descr (sc,"dirtree path steps" ); - error =xfarray_create (descr,0 ,sizeof (struct xchk_dirpath_step ), - &dl->path_steps); -kfree (descr); + error =xfarray_create ("dirtree path steps" ,0 , +sizeof (struct xchk_dirpath_step ), &dl->path_steps);if (error) goto out_dl; - descr =xchk_xfile_ino_descr (sc,"dirtree path names" ); - error =xfblob_create (descr, &dl->path_names); -kfree (descr); + error =xfblob_create ("dirtree path names" , &dl->path_names);if (error) goto out_steps;
fs/xfs/scrub/ialloc_repair.c +1 -4
@@ -797,7 +797,6 @@ xrep_iallocbt( {struct xrep_ibt *ri;struct xfs_mount *mp = sc->mp; -char *descr;xfs_agino_t first_agino, last_agino;int error =0 ;
@@ -816,11 +815,9 @@ xrep_iallocbt(/* Set up enough storage to handle an AG with nothing but inodes. */ xfs_agino_range (mp,pag_agno (sc->sa.pag), &first_agino, &last_agino); last_agino /=XFS_INODES_PER_CHUNK ; - descr =xchk_xfile_ag_descr (sc,"inode index records" ); - error =xfarray_create (descr, last_agino, + error =xfarray_create ("inode index records" , last_agino,sizeof (struct xfs_inobt_rec_incore ), &ri->inode_records); -kfree (descr);if (error) goto out_ri;
fs/xfs/scrub/nlinks.c +2 -4
@@ -990,7 +990,6 @@ xchk_nlinks_setup_scan( struct xchk_nlink_ctrs *xnc) {struct xfs_mount *mp = sc->mp; -char *descr;unsigned long long max_inos;xfs_agnumber_t last_agno = mp->m_sb.sb_agcount -1 ;xfs_agino_t first_agino, last_agino;
@@ -1007,10 +1006,9 @@ xchk_nlinks_setup_scan(*/ xfs_agino_range (mp, last_agno, &first_agino, &last_agino); max_inos =XFS_AGINO_TO_INO (mp, last_agno, last_agino) +1 ; - descr =xchk_xfile_descr (sc,"file link counts" ); - error =xfarray_create (descr,min (XFS_MAXINUMBER +1 , max_inos), + error =xfarray_create ("file link counts" , +min (XFS_MAXINUMBER +1 , max_inos),sizeof (struct xchk_nlink ), &xnc->nlinks); -kfree (descr);if (error) goto out_teardown;
fs/xfs/scrub/parent.c +3 -8
@@ -755,7 +755,6 @@ xchk_parent_pptr( struct xfs_scrub *sc) {struct xchk_pptrs *pp; -char *descr;int error; pp =kvzalloc (sizeof (struct xchk_pptrs ),XCHK_GFP_FLAGS );
@@ -768,16 +767,12 @@ xchk_parent_pptr(* Set up some staging memory for parent pointers that we can't check * due to locking contention. */ - descr =xchk_xfile_ino_descr (sc,"slow parent pointer entries" ); - error =xfarray_create (descr,0 ,sizeof (struct xchk_pptr ), - &pp->pptr_entries); -kfree (descr); + error =xfarray_create ("slow parent pointer entries" ,0 , +sizeof (struct xchk_pptr ), &pp->pptr_entries);if (error) goto out_pp; - descr =xchk_xfile_ino_descr (sc,"slow parent pointer names" ); - error =xfblob_create (descr, &pp->pptr_names); -kfree (descr); + error =xfblob_create ("slow parent pointer names" , &pp->pptr_names);if (error) goto out_entries;
fs/xfs/scrub/parent_repair.c +6 -17
@@ -1497,7 +1497,6 @@ xrep_parent_setup_scan( struct xrep_parent *rp) {struct xfs_scrub *sc = rp->sc; -char *descr;struct xfs_da_geometry *geo = sc->mp->m_attr_geo;int max_len;int error;
@@ -1525,32 +1524,22 @@ xrep_parent_setup_scan( goto out_xattr_name;/* Set up some staging memory for logging parent pointer updates. */ - descr =xchk_xfile_ino_descr (sc,"parent pointer entries" ); - error =xfarray_create (descr,0 ,sizeof (struct xrep_pptr ), - &rp->pptr_recs); -kfree (descr); + error =xfarray_create ("parent pointer entries" ,0 , +sizeof (struct xrep_pptr ), &rp->pptr_recs);if (error) goto out_xattr_value; - descr =xchk_xfile_ino_descr (sc,"parent pointer names" ); - error =xfblob_create (descr, &rp->pptr_names); -kfree (descr); + error =xfblob_create ("parent pointer names" , &rp->pptr_names);if (error) goto out_recs;/* Set up some storage for copying attrs before the mapping exchange */ - descr =xchk_xfile_ino_descr (sc, -"parent pointer retained xattr entries" ); - error =xfarray_create (descr,0 ,sizeof (struct xrep_parent_xattr ), - &rp->xattr_records); -kfree (descr); + error =xfarray_create ("parent pointer xattr entries" ,0 , +sizeof (struct xrep_parent_xattr ), &rp->xattr_records);if (error) goto out_names; - descr =xchk_xfile_ino_descr (sc, -"parent pointer retained xattr values" ); - error =xfblob_create (descr, &rp->xattr_blobs); -kfree (descr); + error =xfblob_create ("parent pointer xattr values" , &rp->xattr_blobs);if (error) goto out_attr_keys;
fs/xfs/scrub/quotacheck.c +3 -10
@@ -741,7 +741,6 @@ xqcheck_setup_scan(struct xfs_scrub *sc, struct xqcheck *xqc) { - char *descr; struct xfs_quotainfo *qi = sc->mp->m_quotainfo;unsigned long long max_dquots =XFS_DQ_ID_MAX +1ULL ;int error;
@@ -756,28 +755,22 @@ xqcheck_setup_scan( error = -ENOMEM ;if (xfs_this_quota_on (sc->mp,XFS_DQTYPE_USER )) { - descr =xchk_xfile_descr (sc,"user dquot records" ); - error =xfarray_create (descr, max_dquots, + error =xfarray_create ("user dquot records" , max_dquots,sizeof (struct xqcheck_dquot ), &xqc->ucounts); -kfree (descr);if (error) goto out_teardown; }if (xfs_this_quota_on (sc->mp,XFS_DQTYPE_GROUP )) { - descr =xchk_xfile_descr (sc,"group dquot records" ); - error =xfarray_create (descr, max_dquots, + error =xfarray_create ("group dquot records" , max_dquots,sizeof (struct xqcheck_dquot ), &xqc->gcounts); -kfree (descr);if (error) goto out_teardown; }if (xfs_this_quota_on (sc->mp,XFS_DQTYPE_PROJ )) { - descr =xchk_xfile_descr (sc,"project dquot records" ); - error =xfarray_create (descr, max_dquots, + error =xfarray_create ("project dquot records" , max_dquots,sizeof (struct xqcheck_dquot ), &xqc->pcounts); -kfree (descr);if (error) goto out_teardown; }
fs/xfs/scrub/refcount_repair.c +2 -11
@@ -123,13 +123,7 @@ intxrep_setup_ag_refcountbt ( struct xfs_scrub *sc) { -char *descr; -int error; - - descr =xchk_xfile_ag_descr (sc,"rmap record bag" ); - error =xrep_setup_xfbtree (sc, descr); -kfree (descr); -return error; +return xrep_setup_xfbtree (sc,"rmap record bag" ); }/* Check for any obvious conflicts with this shared/CoW staging extent. */
@@ -704,7 +698,6 @@ xrep_refcountbt( {struct xrep_refc *rr;struct xfs_mount *mp = sc->mp; -char *descr;int error;/* We require the rmapbt to rebuild anything. */
@@ -717,11 +710,9 @@ xrep_refcountbt( rr->sc = sc;/* Set up enough storage to handle one refcount record per block. */ - descr =xchk_xfile_ag_descr (sc,"reference count records" ); - error =xfarray_create (descr, mp->m_sb.sb_agblocks, + error =xfarray_create ("reference count records" , mp->m_sb.sb_agblocks,sizeof (struct xfs_refcount_irec ), &rr->refcount_records); -kfree (descr);if (error) goto out_rr;
fs/xfs/scrub/rmap_repair.c +1 -4
@@ -164,14 +164,11 @@ xrep_setup_ag_rmapbt( struct xfs_scrub *sc) {struct xrep_rmap *rr; -char *descr;int error;xchk_fsgates_enable (sc,XCHK_FSGATES_RMAP ); - descr =xchk_xfile_ag_descr (sc,"reverse mapping records" ); - error =xrep_setup_xfbtree (sc, descr); -kfree (descr); + error =xrep_setup_xfbtree (sc,"reverse mapping records" );if (error)return error;
fs/xfs/scrub/rtbitmap_repair.c +2 -4
@@ -43,7 +43,6 @@ xrep_setup_rtbitmap( struct xchk_rtbitmap *rtb) {struct xfs_mount *mp = sc->mp; -char *descr;unsigned long long blocks = mp->m_sb.sb_rbmblocks;int error;
@@ -52,9 +51,8 @@ xrep_setup_rtbitmap(return error;/* Create an xfile to hold our reconstructed bitmap. */ - descr =xchk_xfile_rtgroup_descr (sc,"bitmap file" ); - error =xfile_create (descr, blocks * mp->m_sb.sb_blocksize, &sc->xfile); -kfree (descr); + error =xfile_create ("realtime bitmap file" , + blocks * mp->m_sb.sb_blocksize, &sc->xfile);if (error)return error;
fs/xfs/scrub/rtrefcount_repair.c +3 -12
@@ -128,13 +128,7 @@ intxrep_setup_rtrefcountbt ( struct xfs_scrub *sc) { -char *descr; -int error; - - descr =xchk_xfile_ag_descr (sc,"rmap record bag" ); - error =xrep_setup_xfbtree (sc, descr); -kfree (descr); -return error; +return xrep_setup_xfbtree (sc,"realtime rmap record bag" ); }/* Check for any obvious conflicts with this shared/CoW staging extent. */
@@ -704,7 +698,6 @@ xrep_rtrefcountbt( {struct xrep_rtrefc *rr;struct xfs_mount *mp = sc->mp; -char *descr;int error;/* We require the rmapbt to rebuild anything. */
@@ -722,11 +715,9 @@ xrep_rtrefcountbt( rr->sc = sc;/* Set up enough storage to handle one refcount record per rt extent. */ - descr =xchk_xfile_ag_descr (sc,"reference count records" ); - error =xfarray_create (descr, mp->m_sb.sb_rextents, -sizeof (struct xfs_refcount_irec ), + error =xfarray_create ("realtime reference count records" , + mp->m_sb.sb_rextents,sizeof (struct xfs_refcount_irec ), &rr->refcount_records); -kfree (descr);if (error) goto out_rr;
fs/xfs/scrub/rtrmap_repair.c +1 -4
@@ -103,14 +103,11 @@ xrep_setup_rtrmapbt( struct xfs_scrub *sc) {struct xrep_rtrmap *rr; -char *descr;int error;xchk_fsgates_enable (sc,XCHK_FSGATES_RMAP ); - descr =xchk_xfile_rtgroup_descr (sc,"reverse mapping records" ); - error =xrep_setup_xfbtree (sc, descr); -kfree (descr); + error =xrep_setup_xfbtree (sc,"realtime reverse mapping records" );if (error)return error;
fs/xfs/scrub/rtsummary.c +2 -5
@@ -43,7 +43,6 @@ xchk_setup_rtsummary( struct xfs_scrub *sc) {struct xfs_mount *mp = sc->mp; -char *descr;struct xchk_rtsummary *rts;int error;
@@ -70,10 +69,8 @@ xchk_setup_rtsummary(* Create an xfile to construct a new rtsummary file. The xfile allows * us to avoid pinning kernel memory for this purpose. */ - descr =xchk_xfile_descr (sc,"realtime summary file" ); - error =xfile_create (descr,XFS_FSB_TO_B (mp, mp->m_rsumblocks), - &sc->xfile); -kfree (descr); + error =xfile_create ("realtime summary file" , +XFS_FSB_TO_B (mp, mp->m_rsumblocks), &sc->xfile);if (error)return error;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 684/844 spmi: apple: Add "apple,t8103-spmi" compatible
In reply to Sasha LevinFrom: Janne Grunau <[email protected]>
[ Upstream commit 6c54b0a801dd8227237ba0bf0728bb42681cf027 ]
After discussion with the devicetree maintainers we agreed to not extend lists with the generic compatible "apple,spmi" anymore [1]. Use "apple,t8103-spmi" as base compatible as it is the SoC the driver and bindings were written for.
[1]: https://lore.kernel.org/asahi/[email protected]/
--- drivers/spmi/spmi-apple-controller.c | 1 + 1 file changed, 1 insertion(+)
drivers/spmi/spmi-apple-controller.c +1 -0
@@ -149,6 +149,7 @@ static int apple_spmi_probe(struct platform_device *pdev) }static const struct of_device_id apple_spmi_match_table[] = { + { .compatible ="apple,t8103-spmi" , }, { .compatible ="apple,spmi" , }, {} };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 685/844 rust/drm: Fix Registration::{new,new_foreign_owned}() docs
In reply to Sasha LevinFrom: Lyude Paul <[email protected]>
[ Upstream commit 638eeda8abaa3e6afe6bd5758ef8045a7f33b9a0 ]
Looks like we've actually had a malformed rustdoc reference in the rustdocs for Registration::new_foreign_owned() for a while that, when fixed, still couldn't resolve properly because it refers to a private item.
This is probably leftover from when Registration::new() was public, so drop the documentation from that function and fixup the documentation for Registration::new_foreign_owned().
--- rust/kernel/drm/driver.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
rust/kernel/drm/driver.rs +3 -3
@@ -121,7 +121,6 @@ pub trait Driver {pub struct Registration <T :Driver >(ARef <drm::Device <T >>);impl <T :Driver >Registration <T > { -/// Creates a new [`Registration`] and registers it. fn new (drm: &drm::Device <T >, flags:usize ) ->Result <Self > {// SAFETY: `drm.as_raw()` is valid by the invariants of `drm::Device`. to_result (unsafe { bindings::drm_dev_register (drm.as_raw (), flags) })?;
@@ -129,8 +128,9 @@ fn new(drm: &drm::Device<T>, flags: usize) -> Result<Self> {Ok (Self (drm.into ())) } -/// Same as [`Registration::new`}, but transfers ownership of the [`Registration`] to -/// [`devres::register`]. +/// Registers a new [`Device`](drm::Device) with userspace. +/// +/// Ownership of the [`Registration`] object is passed to [`devres::register`]. pub fn new_foreign_owned ( drm: &drm::Device <T >, dev: &device::Device<device::Bound>,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 686/844 KVM: x86: Add SRCU protection for reading PDPTRs in __get_sregs2()
In reply to Sasha LevinFrom: Vasiliy Kovalev <[email protected]>
[ Upstream commit 95d848dc7e639988dbb385a8cba9b484607cf98c ]
Add SRCU read-side protection when reading PDPTR registers in __get_sregs2().
Reading PDPTRs may trigger access to guest memory:kvm_pdptr_read() -> svm_cache_reg() -> load_pdptrs() -> kvm_vcpu_read_guest_page() -> kvm_vcpu_gfn_to_memslot()
kvm_vcpu_gfn_to_memslot() dereferences memslots via __kvm_memslots(), which uses srcu_dereference_check() and requires either kvm->srcu or kvm->slots_lock to be held. Currently only vcpu->mutex is held, triggering lockdep warning:
=============================
WARNING: suspicious RCU usage in kvm_vcpu_gfn_to_memslot 6.12.59+ #3 Not tainted
include/linux/kvm_host.h:1062 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz.5.1717/15100:
#0: ff1100002f4b00b0 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x1d5/0x1590
Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xf0/0x120 lib/dump_stack.c:120 lockdep_rcu_suspicious+0x1e3/0x270 kernel/locking/lockdep.c:6824 __kvm_memslots include/linux/kvm_host.h:1062 [inline] __kvm_memslots include/linux/kvm_host.h:1059 [inline] kvm_vcpu_memslots include/linux/kvm_host.h:1076 [inline] kvm_vcpu_gfn_to_memslot+0x518/0x5e0 virt/kvm/kvm_main.c:2617 kvm_vcpu_read_guest_page+0x27/0x50 virt/kvm/kvm_main.c:3302 load_pdptrs+0xff/0x4b0 arch/x86/kvm/x86.c:1065 svm_cache_reg+0x1c9/0x230 arch/x86/kvm/svm/svm.c:1688 kvm_pdptr_read arch/x86/kvm/kvm_cache_regs.h:141 [inline] __get_sregs2 arch/x86/kvm/x86.c:11784 [inline] kvm_arch_vcpu_ioctl+0x3e20/0x4aa0 arch/x86/kvm/x86.c:6279 kvm_vcpu_ioctl+0x856/0x1590 virt/kvm/kvm_main.c:4663 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl fs/ioctl.c:893 [inline] __x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xbd/0x1d0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/x86.c +2 -0
@@ -12157,9 +12157,11 @@ static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2)return ;if (is_pae_paging (vcpu)) { +kvm_vcpu_srcu_read_lock (vcpu);for (i =0 ; i <4 ; i++) sregs2->pdptrs[i] =kvm_pdptr_read (vcpu, i); sregs2->flags |=KVM_SREGS2_FLAGS_PDPTRS_VALID ; +kvm_vcpu_srcu_read_unlock (vcpu); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 687/844 PCI: endpoint: Fix swapped parameters in pci_{primary/secondary}_epc_epf_unlink() functions
In reply to Sasha LevinFrom: Manikanta Maddireddy <[email protected]>
[ Upstream commit 8754dd7639ab0fd68c3ab9d91c7bdecc3e5740a8 ]
struct configfs_item_operations callbacks are defined like the following:
int (*allow_link)(struct config_item *src, struct config_item *target); void (*drop_link)(struct config_item *src, struct config_item *target);
While pci_primary_epc_epf_link() and pci_secondary_epc_epf_link() specify the parameters in the correct order, pci_primary_epc_epf_unlink() and pci_secondary_epc_epf_unlink() specify the parameters in the wrong order, leading to the below kernel crash when using the unlink command in configfs:
Unable to handle kernel paging request at virtual address 0000000300000857 Mem abort info: ... pc : string+0x54/0x14c lr : vsnprintf+0x280/0x6e8 ... string+0x54/0x14c vsnprintf+0x280/0x6e8 vprintk_default+0x38/0x4c vprintk+0xc4/0xe0 pci_epf_unbind+0xdc/0x108 configfs_unlink+0xe0/0x208+0x44/0x74 vfs_unlink+0x120/0x29c __arm64_sys_unlinkat+0x3c/0x90 invoke_syscall+0x48/0x134 do_el0_svc+0x1c/0x30prop.0+0xd0/0xf0
--- drivers/pci/endpoint/pci-ep-cfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/endpoint/pci-ep-cfs.c +4 -4
@@ -68,8 +68,8 @@ static int pci_secondary_epc_epf_link(struct config_item *epf_item,return 0 ; } -static void pci_secondary_epc_epf_unlink (struct config_item *epc_item, -struct config_item *epf_item) +static void pci_secondary_epc_epf_unlink (struct config_item *epf_item, +struct config_item *epc_item) {struct pci_epf_group *epf_group =to_pci_epf_group (epf_item->ci_parent);struct pci_epc_group *epc_group =to_pci_epc_group (epc_item);
@@ -132,8 +132,8 @@ static int pci_primary_epc_epf_link(struct config_item *epf_item,return 0 ; } -static void pci_primary_epc_epf_unlink (struct config_item *epc_item, -struct config_item *epf_item) +static void pci_primary_epc_epf_unlink (struct config_item *epf_item, +struct config_item *epc_item) {struct pci_epf_group *epf_group =to_pci_epf_group (epf_item->ci_parent);struct pci_epc_group *epc_group =to_pci_epc_group (epc_item);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 688/844 pinctrl: intel: Add code name documentation
In reply to Sasha LevinFrom: Raag Jadav <[email protected]>
[ Upstream commit fc32c5725fbe1164d353400389d3e29d19960a3a ]
Intel pinctrl drivers support large set of platforms and the IPs are often reused by their different variants, but it's currently not possible to figure out the exact driver that supports specific variant. Add user friendly documentation for them.
--- drivers/pinctrl/intel/Kconfig | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/pinctrl/intel/Kconfig +15 -6
@@ -52,7 +52,10 @@ config PINCTRL_ALDERLAKE select PINCTRL_INTEL help This pinctrl driver provides an interface that allows configuring - of Intel Alder Lake PCH pins and using them as GPIOs. + PCH pins of the following platforms and using them as GPIOs: + - Alder Lake HX, N, and S + - Raptor Lake HX, E, and S + - Twin Lake config PINCTRL_BROXTON tristate "Intel Broxton pinctrl and GPIO driver"
@@ -136,15 +139,17 @@ config PINCTRL_METEORLAKE select PINCTRL_INTEL help This pinctrl driver provides an interface that allows configuring - of Intel Meteor Lake pins and using them as GPIOs. + SoC pins of the following platforms and using them as GPIOs: + - Arrow Lake (all variants) + - Meteor Lake (all variants) config PINCTRL_METEORPOINT tristate "Intel Meteor Point pinctrl and GPIO driver" select PINCTRL_INTEL help - Meteor Point is the PCH of Intel Meteor Lake. This pinctrl driver - provides an interface that allows configuring of PCH pins and - using them as GPIOs. + This pinctrl driver provides an interface that allows configuring + PCH pins of the following platforms and using them as GPIOs: + - Arrow Lake HX and S config PINCTRL_SUNRISEPOINT tristate "Intel Sunrisepoint pinctrl and GPIO driver"
@@ -159,7 +164,11 @@ config PINCTRL_TIGERLAKE select PINCTRL_INTEL help This pinctrl driver provides an interface that allows configuring - of Intel Tiger Lake PCH pins and using them as GPIOs. + PCH pins of the following platforms and using them as GPIOs: + - Alder Lake H, P, PS, and U + - Raptor Lake H, P, PS, PX, and U + - Rocket Lake S + - Tiger Lake (all variants) source "drivers/pinctrl/intel/Kconfig.tng" endmenu
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 689/844 xfs: only call xf{array,blob}_destroy if we have a valid pointer
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit ba408d299a3bb3c5309f40c5326e4fb83ead4247 ]
Only call the xfarray and xfblob destructor if we have a valid pointer, and be sure to null out that pointer afterwards. Note that this patch fixes a large number of commits, most of which were merged between 6.9 and 6.10.
--- fs/xfs/scrub/agheader_repair.c | 8 ++++++-- fs/xfs/scrub/attr_repair.c | 6 ++++-- fs/xfs/scrub/dir_repair.c | 8 ++++++-- fs/xfs/scrub/dirtree.c | 8 ++++++-- fs/xfs/scrub/nlinks.c | 3 ++- 5 files changed, 24 insertions(+), 9 deletions(-)
fs/xfs/scrub/agheader_repair.c +6 -2
@@ -837,8 +837,12 @@ xrep_agi_buf_cleanup( {struct xrep_agi *ragi = buf; -xfarray_destroy (ragi->iunlink_prev); -xfarray_destroy (ragi->iunlink_next); +if (ragi->iunlink_prev) +xfarray_destroy (ragi->iunlink_prev); + ragi->iunlink_prev =NULL ; +if (ragi->iunlink_next) +xfarray_destroy (ragi->iunlink_next); + ragi->iunlink_next =NULL ;xagino_bitmap_destroy (&ragi->iunlink_bmp); }
fs/xfs/scrub/attr_repair.c +4 -2
@@ -1516,8 +1516,10 @@ xrep_xattr_teardown(xfblob_destroy (rx->pptr_names);if (rx->pptr_recs)xfarray_destroy (rx->pptr_recs); -xfblob_destroy (rx->xattr_blobs); -xfarray_destroy (rx->xattr_records); +if (rx->xattr_blobs) +xfblob_destroy (rx->xattr_blobs); +if (rx->xattr_records) +xfarray_destroy (rx->xattr_records);mutex_destroy (&rx->lock);kfree (rx); }
fs/xfs/scrub/dir_repair.c +6 -2
@@ -172,8 +172,12 @@ xrep_dir_teardown(struct xrep_dir *rd = sc->buf;xrep_findparent_scan_teardown (&rd->pscan); -xfblob_destroy (rd->dir_names); -xfarray_destroy (rd->dir_entries); +if (rd->dir_names) +xfblob_destroy (rd->dir_names); + rd->dir_names =NULL ; +if (rd->dir_entries) +xfarray_destroy (rd->dir_entries); + rd->dir_names =NULL ; }/* Set up for a directory repair. */
fs/xfs/scrub/dirtree.c +6 -2
@@ -81,8 +81,12 @@ xchk_dirtree_buf_cleanup(kfree (path); } -xfblob_destroy (dl->path_names); -xfarray_destroy (dl->path_steps); +if (dl->path_names) +xfblob_destroy (dl->path_names); + dl->path_names =NULL ; +if (dl->path_steps) +xfarray_destroy (dl->path_steps); + dl->path_steps =NULL ;mutex_destroy (&dl->lock); }
fs/xfs/scrub/nlinks.c +2 -1
@@ -971,7 +971,8 @@ xchk_nlinks_teardown_scan(xfs_dir_hook_del (xnc->sc->mp, &xnc->dhook); -xfarray_destroy (xnc->nlinks); +if (xnc->nlinks) +xfarray_destroy (xnc->nlinks); xnc->nlinks =NULL ;xchk_iscan_teardown (&xnc->collect_iscan);
Signature · 1 line
2.51.0
Re: [PATCH 6.19 689/844] xfs: only call xf{array,blob}_destroy if we have a valid pointer
Quoted 3 lines · Sasha Levin
From: "Darrick J. Wong" <[email protected]>
[ Upstream commit
ba408d299a3bb3c5309f40c5326e4fb83ead4247]
...
Quoted 4 lines
fs/xfs/scrub/dir_repair.c +0
-0@@ -172,8 +172,12 @@ xrep_dir_teardown(struct xrep_dir *rd = sc->buf;
fs/xfs/scrub/dir_repair.c xrep_dir_teardown( · line 180
Quoted 10 lines
fs/xfs/scrub/dir_repair.c +6
-2xrep_findparent_scan_teardown (&rd->pscan); -xfblob_destroy (rd->dir_names); -xfarray_destroy (rd->dir_entries); +if (rd->dir_names) +xfblob_destroy (rd->dir_names); + rd->dir_names =NULL ; +if (rd->dir_entries) +xfarray_destroy (rd->dir_entries); + rd->dir_names =NULL ;
This cut&paste error is fixed by:e764dd439d68 xfs: fix copy-paste error in previous fix
Signature · 2 lines
js suse labs
Re: [PATCH 6.19 689/844] xfs: only call xf{array,blob}_destroy if we have a valid pointer
Quoted 5 lines · Jiri Slaby
Quoted 3 lines · Sasha Levin
From: "Darrick J. Wong" <[email protected]>
[ Upstream commit
ba408d299a3bb3c5309f40c5326e4fb83ead4247]...
Quoted 16 lines
fs/xfs/scrub/dir_repair.c xrep_dir_teardown( · line 179
Quoted 13 lines
fs/xfs/scrub/dir_repair.c +6
-2@@ -172,8 +172,12 @@ xrep_dir_teardown(struct xrep_dir *rd = sc->buf;xrep_findparent_scan_teardown (&rd->pscan); -xfblob_destroy (rd->dir_names); -xfarray_destroy (rd->dir_entries); +if (rd->dir_names) +xfblob_destroy (rd->dir_names); + rd->dir_names =NULL ; +if (rd->dir_entries) +xfarray_destroy (rd->dir_entries); + rd->dir_names =NULL ;This cut&paste error is fixed by:
e764dd439d68xfs: fix copy-paste error in previous fix
Queued up, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 690/844 xfs: check return value of xchk_scrub_create_subord
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit ca27313fb3f23e4ac18532ede4ec1c7cc5814c4a ]
Fix this function to return NULL instead of a mangled ENOMEM, then fix the callers to actually check for a null pointer and return ENOMEM. Most of the corrections here are for code merged between 6.2 and 6.10.
--- fs/xfs/scrub/common.c | 3 +++ fs/xfs/scrub/repair.c | 3 +++ fs/xfs/scrub/scrub.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-)
fs/xfs/scrub/common.c +3 -0
@@ -1399,6 +1399,9 @@ xchk_metadata_inode_subtype(int error; sub =xchk_scrub_create_subord (sc, scrub_type); +if (!sub) +return -ENOMEM ; + error = sub->sc.ops->scrub (&sub->sc);xchk_scrub_free_subord (sub);return error;
fs/xfs/scrub/repair.c +3 -0
@@ -1136,6 +1136,9 @@ xrep_metadata_inode_subtype(* setup/teardown routines. */ sub =xchk_scrub_create_subord (sc, scrub_type); +if (!sub) +return -ENOMEM ; + error = sub->sc.ops->scrub (&sub->sc);if (error) goto out;
fs/xfs/scrub/scrub.c +1 -1
@@ -634,7 +634,7 @@ xchk_scrub_create_subord( sub =kzalloc (sizeof (*sub),XCHK_GFP_FLAGS );if (!sub) -return ERR_PTR (-ENOMEM ); +return NULL ; sub->old_smtype = sc->sm->sm_type; sub->old_smflags = sc->sm->sm_flags;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 691/844 xfs: check for deleted cursors when revalidating two btrees
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 55e03b8cbe2783ec9acfb88e8adb946ed504e117 ]
The free space and inode btree repair functions will rebuild both btrees at the same time, after which it needs to evaluate both btrees to confirm that the corruptions are gone.
However, Jiaming Zhang ran syzbot and produced a crash in the second xchk_allocbt call. His root-cause analysis is as follows (with minor corrections):
In xrep_revalidate_allocbt(), xchk_allocbt() is called twice (first for BNOBT, second for CNTBT). The cause of this issue is that the first call nullified the cursor required by the second call.
Let's first enter xrep_revalidate_allocbt() via following call chain:
xfs_file_ioctl() ->
xfs_ioc_scrubv_metadata() ->
xfs_scrub_metadata() ->
sc->ops->repair_eval(sc) ->
xrep_revalidate_allocbt()
xchk_allocbt() is called twice in this function. In the first call:
/* Note that sc->sm->sm_type is XFS_SCRUB_TYPE_BNOPT now */ xchk_allocbt() ->
xchk_btree() ->
bs->scrub_rec(bs, recp) ->
xchk_allocbt_rec() ->
xchk_allocbt_xref() ->
xchk_allocbt_xref_other()
since sm_type is XFS_SCRUB_TYPE_BNOBT, pur is set to &sc->sa.cnt_cur. Kernel called xfs_alloc_get_rec() and returned -EFSCORRUPTED. Call chain:
xfs_alloc_get_rec() ->
xfs_btree_get_rec() ->
xfs_btree_check_block() ->
(XFS_IS_CORRUPT || XFS_TEST_ERROR), the former is false and the latter is true, return -EFSCORRUPTED. This should be caused by ioctl$XFS_IOC_ERROR_INJECTION I guess.
Back to xchk_allocbt_xref_other(), after receiving -EFSCORRUPTED from xfs_alloc_get_rec(), kernel called xchk_should_check_xref(). In this function, *curpp (points to sc->sa.cnt_cur) is nullified.
Back to xrep_revalidate_allocbt(), since sc->sa.cnt_cur has been nullified, it then triggered null-ptr-deref via xchk_allocbt() (second call) -> xchk_btree().
So. The bnobt revalidation failed on a cross-reference attempt, so we deleted the cntbt cursor, and then crashed when we tried to revalidate the cntbt. Therefore, check for a null cntbt cursor before that revalidation, and mark the repair incomplete. Also we can ignore the second tree entirely if the first tree was rebuilt but is already corrupt.
Apply the same fix to xrep_revalidate_iallocbt because it has the same problem.
--- fs/xfs/scrub/alloc_repair.c | 15 +++++++++++++++ fs/xfs/scrub/ialloc_repair.c | 20 +++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-)
fs/xfs/scrub/alloc_repair.c +15 -0
@@ -923,7 +923,22 @@ xrep_revalidate_allocbt(if (error) goto out; +/* +* If the bnobt is still corrupt, we've failed to repair the filesystem +* and should just bail out. +* +* If the bnobt fails cross-examination with the cntbt, the scan will +* free the cntbt cursor, so we need to mark the repair incomplete +* and avoid walking off the end of the NULL cntbt cursor. +*/ +if (sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT ) + goto out; + sc->sm->sm_type =XFS_SCRUB_TYPE_CNTBT ; +if (!sc->sa.cnt_cur) { +xchk_set_incomplete (sc); + goto out; + } error =xchk_allocbt (sc); out: sc->sm->sm_type = old_type;
fs/xfs/scrub/ialloc_repair.c +17 -3
@@ -863,10 +863,24 @@ xrep_revalidate_iallocbt(if (error) goto out; -if (xfs_has_finobt (sc->mp)) { - sc->sm->sm_type =XFS_SCRUB_TYPE_FINOBT ; - error =xchk_iallocbt (sc); +/* +* If the inobt is still corrupt, we've failed to repair the filesystem +* and should just bail out. +* +* If the inobt fails cross-examination with the finobt, the scan will +* free the finobt cursor, so we need to mark the repair incomplete +* and avoid walking off the end of the NULL finobt cursor. +*/ +if (!xfs_has_finobt (sc->mp) || + (sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT )) + goto out; + + sc->sm->sm_type =XFS_SCRUB_TYPE_FINOBT ; +if (!sc->sa.fino_cur) { +xchk_set_incomplete (sc); + goto out; } + error =xchk_iallocbt (sc); out: sc->sm->sm_type = old_type;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 692/844 md/bitmap: fix GPF in write_page caused by resize race
In reply to Sasha LevinFrom: Jack Wang <[email protected]>
[ Upstream commit 46ef85f854dfa9d5226b3c1c46493d79556c9589 ]
A General Protection Fault occurs in write_page() during array resize:
RIP: 0010:write_page+0x22b/0x3c0 [md_mod]
This is a use-after-free race between bitmap_daemon_work() and __bitmap_resize(). The daemon iterates over bitmap->storage.filemap without locking, while the resize path frees that storage via md_bitmap_file_unmap(). quiesce() does not stop the md thread, allowing concurrent access to freed pages.
Fix by holding mddev->bitmap_info.mutex during the bitmap update.
--- drivers/md/md-bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/md-bitmap.c +2 -1
@@ -2453,6 +2453,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,memcpy (page_address (store.sb_page),page_address (bitmap->storage.sb_page),sizeof (bitmap_super_t)); +mutex_lock (&bitmap->mddev->bitmap_info.mutex);spin_lock_irq (&bitmap->counts.lock);md_bitmap_file_unmap (&bitmap->storage); bitmap->storage = store;
@@ -2560,7 +2561,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,set_page_attr (bitmap, i,BITMAP_PAGE_DIRTY ); }spin_unlock_irq (&bitmap->counts.lock); - +mutex_unlock (&bitmap->mddev->bitmap_info.mutex);if (!init) {__bitmap_unplug (bitmap); bitmap->mddev->pers->quiesce (bitmap->mddev,0 );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 693/844 nfsd: fix nfs4_file refcount leak in nfsd_get_dir_deleg()
In reply to Sasha LevinFrom: Jeff Layton <[email protected]>
[ Upstream commit 789477b849394afdb60507924d65f7ef18f078ce ]
Claude pointed out that there is a nfs4_file refcount leak in nfsd_get_dir_deleg(). Ensure that the reference to "fp" is released before returning.
--- fs/nfsd/nfs4state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +4 -1
@@ -9520,8 +9520,10 @@ nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate,spin_unlock (&clp->cl_lock);spin_unlock (&state_lock); -if (!status) +if (!status) { +put_nfs4_file (fp);return dp; + }/* Something failed. Drop the lease and clean up the stid */ kernel_setlease (fp->fi_deleg_file->nf_file,F_UNLCK ,NULL , (void **)&dp);
@@ -9529,5 +9531,6 @@ nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate,nfs4_put_stid (&dp->dl_stid); out_delegees:put_deleg_file (fp); +put_nfs4_file (fp);return ERR_PTR (status); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 694/844 NFSD: fix setting FMODE_NOCMTIME in nfs4_open_delegation
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit 41b0a87bc60d5ccfa8575481ddb4d4d8758507fa ]
fstests generic/215 and generic/407 were failing because the server wasn't updating mtime properly. When deleg attribute support is not compiled in and thus no attribute delegation was given, the server was skipping updating mtime and ctime because FMODE_NOCMTIME was uncoditionally set for the write delegation.
--- fs/nfsd/nfs4state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +2 -1
@@ -6353,7 +6353,8 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open, dp->dl_ctime = stat.ctime; dp->dl_mtime = stat.mtime;spin_lock (&f->f_lock); - f->f_mode |=FMODE_NOCMTIME ; +if (deleg_ts) + f->f_mode |=FMODE_NOCMTIME ;spin_unlock (&f->f_lock);trace_nfsd_deleg_write (&dp->dl_stid.sc_stateid); }else {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 695/844 nfsd: fix return error code for nfsd_map_name_to_[ug]id
In reply to Sasha LevinFrom: Anthony Iliopoulos <[email protected]>
[ Upstream commit 404d779466646bf1461f2090ff137e99acaecf42 ]
idmap lookups can time out while the cache is waiting for a userspace upcall reply. In that case cache_check() returns -ETIMEDOUT to callers.
The nfsd_map_name_to_[ug]id functions currently proceed with attempting to map the id to a kuid despite a potentially temporary failure to perform the idmap lookup. This results in the code returning the error NFSERR_BADOWNER which can cause client operations to return to userspace with failure.
Fix this by returning the failure status before attempting kuid mapping.
This will return NFSERR_JUKEBOX on idmap lookup timeout so that clients can retry the operation instead of aborting it.
--- fs/nfsd/nfs4idmap.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfsd/nfs4idmap.c +4 -0
@@ -672,6 +672,8 @@ __be32 nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name,return nfserr_inval; status =do_name_to_id (rqstp,IDMAP_TYPE_USER , name, namelen, &id); +if (status) +return status; *uid =make_kuid (nfsd_user_namespace (rqstp), id);if (!uid_valid (*uid)) status = nfserr_badowner;
@@ -707,6 +709,8 @@ __be32 nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name,return nfserr_inval; status =do_name_to_id (rqstp,IDMAP_TYPE_GROUP , name, namelen, &id); +if (status) +return status; *gid =make_kgid (nfsd_user_namespace (rqstp), id);if (!gid_valid (*gid)) status = nfserr_badowner;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 696/844 nvmem: Drop OF node reference on nvmem_add_one_cell() failure
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f397bc0781553d01b4cdba506c09334a31cb0ec5 ]
If nvmem_add_one_cell() failed, the ownership of "child" (or "info.np"), thus its OF reference, is not passed further and function should clean up by putting the reference it got via earlier of_node_get(). Note that this is independent of references obtained via for_each_child_of_node() loop.
--- drivers/nvmem/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/core.c +1 -0
@@ -831,6 +831,7 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nodkfree (info.name);if (ret) {of_node_put (child); +of_node_put (info.np);return ret; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 697/844 PCI: Fix bridge window alignment with optional resources
In reply to Sasha LevinFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 7e90360e6d4599795b6f4e094e20d0bdf3b2615f ]
pbus_size_mem() has two alignments, one for required resources in min_align and another in add_align that takes account optional resources.
The add_align is applied to the bridge window through the realloc_head list. It can happen, however, that add_align is larger than min_align but calculated size1 and size0 are equal due to extra tailroom (e.g., hotplug reservation, tail alignment), and therefore no entry is created to the realloc_head list. Without the bridge appearing in the realloc head, add_align is lost when pbus_size_mem() returns.
The problem is visible in this log for 0000:05:00.0 which lacks add_size ... add_align ... line that would indicate it was added into the realloc_head list:
pci 0000:05:00.0: PCI bridge to [bus 06-16]
...
pci 0000:06:00.0: bridge window [mem 0x00100000-0x001fffff] to [bus 07] requires relaxed alignment rules pci 0000:06:06.0: bridge window [mem 0x00100000-0x001fffff] to [bus 0a] requires relaxed alignment rules pci 0000:06:07.0: bridge window [mem 0x00100000-0x003fffff] to [bus 0b] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x00800000-0x00ffffff 64bit pref] to [bus 0c-14] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x01000000-0x057fffff] to [bus 0c-14] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x01000000-0x057fffff] to [bus 0c-14] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x01000000-0x057fffff] to [bus 0c-14] add_size 100000 add_align 1000000 pci 0000:06:0c.0: bridge window [mem 0x00100000-0x001fffff] to [bus 15] requires relaxed alignment rules pci 0000:06:0d.0: bridge window [mem 0x00100000-0x001fffff] to [bus 16] requires relaxed alignment rules pci 0000:06:0d.0: bridge window [mem 0x00100000-0x001fffff] to [bus 16] requires relaxed alignment rules pci 0000:05:00.0: bridge window [mem 0xd4800000-0xd97fffff]: assigned
pci 0000:05:00.0: bridge window [mem 0x1060000000-0x10607fffff 64bit pref]: assigned
pci 0000:06:08.0: bridge window [mem size 0x04900000]: can't assign; no space
pci 0000:06:08.0: bridge window [mem size 0x04900000]: failed to assign
While this bug itself seems old, it has likely become more visible after the relaxed tail alignment that does not grossly overestimate the size needed for the bridge window.
Make sure add_align > min_align too results in adding an entry into the realloc head list. In addition, add handling to the cases where add_size is zero while only alignment differs.
--- drivers/pci/setup-bus.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pci/setup-bus.c +6 -4
@@ -14,6 +14,7 @@* tighter packing. Prefetchable range support. */ +#include <linux/align.h> #include <linux/bitops.h> #include <linux/bug.h> #include <linux/init.h>
@@ -463,7 +464,7 @@ static void reassign_resources_sorted(struct list_head *realloc_head,"%s %pR: ignoring failure in optional allocation\n" , res_name, res); } - }else if (add_size >0 ) { + }else if (add_size >0 || !IS_ALIGNED (res->start, align)) { res->flags |= add_res->flags & (IORESOURCE_STARTALIGN |IORESOURCE_SIZEALIGN );if (pci_reassign_resource (dev, idx, add_size, align))
@@ -1392,12 +1393,13 @@ static void pbus_size_mem(struct pci_bus *bus, unsigned long type,resource_set_range (b_res, min_align, size0); b_res->flags |=IORESOURCE_STARTALIGN ; -if (bus->self && size1 > size0 && realloc_head) { +if (bus->self && realloc_head && (size1 > size0 || add_align > min_align)) { b_res->flags &= ~IORESOURCE_DISABLED ; -add_to_list (realloc_head, bus->self, b_res, size1-size0, add_align); + add_size = size1 > size0 ? size1 - size0 :0 ; +add_to_list (realloc_head, bus->self, b_res, add_size, add_align);pci_info (bus->self,"bridge window %pR to %pR add_size %llx add_align %llx\n" , b_res, &bus->busn_res, - (unsigned long long ) (size1 - size0), + (unsigned long long ) add_size, (unsigned long long ) add_align); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 698/844 ima: verify the previous kernel's IMA buffer lies in addressable RAM
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 10d1c75ed4382a8e79874379caa2ead8952734f9 ]
Patch series "Address page fault in ima_restore_measurement_list()", v3.
When the second-stage kernel is booted via kexec with a limiting command line such as "mem=<size>" we observe a pafe fault that happens.
BUG: unable to handle page fault for address: ffff97793ff47000
RIP: ima_restore_measurement_list+0xdc/0x45a
#PF: error_code(0x0000) not-present pageThis happens on x86_64 only, as this is already fixed in aarch64 in
commit: cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer against memory bounds")
This patch (of 3):
When the second-stage kernel is booted with a limiting command line (e.g. "mem=<size>"), the IMA measurement buffer handed over from the previous kernel may fall outside the addressable RAM of the new kernel. Accessing such a buffer can fault during early restore.
Introduce a small generic helper, ima_validate_range(), which verifies that a physical [start, end] range for the previous-kernel IMA buffer lies within addressable memory:
- On x86, use pfn_range_is_mapped().
- On OF based architectures, use page_is_ram().
--- include/linux/ima.h | 1 + security/integrity/ima/ima_kexec.c | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/linux/ima.h +1 -0
@@ -69,6 +69,7 @@ static inline int ima_measure_critical_data(const char *event_label,#ifdef CONFIG_HAVE_IMA_KEXEC int __init ima_free_kexec_buffer (void );int __init ima_get_kexec_buffer (void **addr,size_t *size); +int ima_validate_range (phys_addr_t phys,size_t size);#endif #ifdef CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT
security/integrity/ima/ima_kexec.c +35 -0
@@ -12,6 +12,8 @@#include <linux/kexec.h> #include <linux/of.h> #include <linux/ima.h> +#include <linux/mm.h> +#include <linux/overflow.h> #include <linux/reboot.h> #include <asm/page.h> #include "ima.h"
@@ -294,3 +296,36 @@ void __init ima_load_kexec_buffer(void)pr_debug ("Error restoring the measurement list: %d\n" , rc); } } + +/* +* ima_validate_range - verify a physical buffer lies in addressable RAM +* @phys: physical start address of the buffer from previous kernel +* @size: size of the buffer +* +* On success return 0. On failure returns -EINVAL so callers can skip +* restoring. +*/ +int ima_validate_range (phys_addr_t phys,size_t size) +{ +unsigned long start_pfn, end_pfn; +phys_addr_t end_phys; + +if (check_add_overflow (phys, (phys_addr_t )size -1 , &end_phys)) +return -EINVAL ; + + start_pfn =PHYS_PFN (phys); + end_pfn =PHYS_PFN (end_phys); + +#ifdef CONFIG_X86 +if (!pfn_range_is_mapped (start_pfn, end_pfn)) +#else + if (!page_is_ram(start_pfn) || !page_is_ram(end_pfn)) +#endif + { +pr_warn ("IMA: previous kernel measurement buffer %pa (size 0x%zx) lies outside available memory\n" , + &phys, size); +return -EINVAL ; + } + +return 0 ; +}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 699/844 of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 4d02233235ed0450de9c10fcdcf3484e3c9401ce ]
Refactor the OF/DT ima_get_kexec_buffer() to use a generic helper to validate the address range. No functional change intended.
--- drivers/of/kexec.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/of/kexec.c +3 -12
@@ -128,7 +128,6 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size) {int ret, len;unsigned long tmp_addr; -unsigned long start_pfn, end_pfn;size_t tmp_size;const void *prop;
@@ -144,17 +143,9 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size)if (!tmp_size)return -ENOENT ; -/* -* Calculate the PFNs for the buffer and ensure -* they are with in addressable memory. -*/ - start_pfn =PHYS_PFN (tmp_addr); - end_pfn =PHYS_PFN (tmp_addr + tmp_size -1 ); -if (!page_is_ram (start_pfn) || !page_is_ram (end_pfn)) { -pr_warn ("IMA buffer at 0x%lx, size = 0x%zx beyond memory\n" , - tmp_addr, tmp_size); -return -EINVAL ; - } + ret =ima_validate_range (tmp_addr, tmp_size); +if (ret) +return ret; *addr =__va (tmp_addr); *size = tmp_size;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 700/844 x86/kexec: add a sanity check on previous kernel's ima kexec buffer
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit c5489d04337b47e93c0623e8145fcba3f5739efd ]
When the second-stage kernel is booted via kexec with a limiting command line such as "mem=<size>", the physical range that contains the carried over IMA measurement list may fall outside the truncated RAM leading to a kernel panic.
BUG: unable to handle page fault for address: ffff97793ff47000
RIP: ima_restore_measurement_list+0xdc/0x45a
#PF: error_code(0x0000) – not-present pageOther architectures already validate the range with page_is_ram(), as done in commit cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer against memory bounds") do a similar check on x86.
Without carrying the measurement list across kexec, the attestation would fail.
--- arch/x86/kernel/setup.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kernel/setup.c +6 -0
@@ -439,9 +439,15 @@ int __init ima_free_kexec_buffer(void)int __init ima_get_kexec_buffer (void **addr,size_t *size) { +int ret; +if (!ima_kexec_buffer_size)return -ENOENT ; + ret =ima_validate_range (ima_kexec_buffer_phys, ima_kexec_buffer_size); +if (ret) +return ret; + *addr =__va (ima_kexec_buffer_phys); *size = ima_kexec_buffer_size;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 701/844 mm/vmalloc: prevent RCU stalls in kasan_release_vmalloc_node
In reply to Sasha LevinFrom: Deepanshu Kartikey <[email protected]>
[ Upstream commit 5747435e0fd474c24530ef1a6822f47e7d264b27 ]
When CONFIG_PAGE_OWNER is enabled, freeing KASAN shadow pages during vmalloc cleanup triggers expensive stack unwinding that acquires RCU read locks. Processing a large purge_list without rescheduling can cause the task to hold CPU for extended periods (10+ seconds), leading to RCU stalls and potential OOM conditions.
The issue manifests in purge_vmap_node() -> kasan_release_vmalloc_node() where iterating through hundreds or thousands of vmap_area entries and freeing their associated shadow pages causes:
rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: rcu: Tasks blocked on level-0 rcu_node (CPUs 0-1): P6229/1:b..l ... task:kworker/0:17 state:R running task stack:28840 pid:6229 ... kasan_release_vmalloc_node+0x1ba/0xad0 mm/vmalloc.c:2299 purge_vmap_node+0x1ba/0xad0 mm/vmalloc.c:2299
Each call to kasan_release_vmalloc() can free many pages, and with page_owner tracking, each free triggers save_stack() which performs stack unwinding under RCU read lock. Without yielding, this creates an unbounded RCU critical section.
Add periodic cond_resched() calls within the loop to allow:
- RCU grace periods to complete
- Other tasks to run
- Scheduler to preempt when needed
The fix uses need_resched() for immediate response under load, with a batch count of 32 as a guaranteed upper bound to prevent worst-case stalls even under light load.
--- mm/vmalloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/vmalloc.c +8 -0
@@ -2268,11 +2268,14 @@ decay_va_pool_node(struct vmap_node *vn, bool full_decay)reclaim_list_global (&decay_list); } +#define KASAN_RELEASE_BATCH_SIZE 32 +static void kasan_release_vmalloc_node (struct vmap_node *vn) {struct vmap_area *va;unsigned long start, end; +unsigned int batch_count =0 ; start = list_first_entry(&vn->purge_list, struct vmap_area, list)->va_start; end = list_last_entry(&vn->purge_list, struct vmap_area, list)->va_end;
@@ -2282,6 +2285,11 @@ kasan_release_vmalloc_node(struct vmap_node *vn)kasan_release_vmalloc (va->va_start, va->va_end, va->va_start, va->va_end,KASAN_VMALLOC_PAGE_RANGE ); + +if (need_resched () || (++batch_count >=KASAN_RELEASE_BATCH_SIZE )) { +cond_resched (); + batch_count =0 ; + } }kasan_release_vmalloc (start, end, start, end,KASAN_VMALLOC_TLB_FLUSH );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 702/844 usb: gadget: tegra-xudc: Add handling for BLCG_COREPLL_PWRDN
In reply to Sasha LevinFrom: Haotien Hsu <[email protected]>
[ Upstream commit 1132e90840abf3e7db11f1d28199e9fbc0b0e69e ]
The COREPLL_PWRDN bit in the BLCG register must be set when the XUSB device controller is powergated and cleared when it is unpowergated. If this bit is not explicitly controlled, the core PLL may remain in an incorrect power state across suspend/resume or ELPG transitions. Therefore, update the driver to explicitly control this bit during powergate transitions.
--- drivers/usb/gadget/udc/tegra-xudc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +9 -3
@@ -3392,17 +3392,18 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc) {u32 val, imod; + val =xudc_readl (xudc,BLCG );if (xudc->soc->has_ipfs) { - val =xudc_readl (xudc,BLCG ); val |=BLCG_ALL ; val &= ~(BLCG_DFPCI |BLCG_UFPCI |BLCG_FE |BLCG_COREPLL_PWRDN ); val |=BLCG_IOPLL_0_PWRDN ; val |=BLCG_IOPLL_1_PWRDN ; val |=BLCG_IOPLL_2_PWRDN ; - -xudc_writel (xudc, val,BLCG ); + }else { + val &= ~BLCG_COREPLL_PWRDN ; } +xudc_writel (xudc, val,BLCG );if (xudc->soc->port_speed_quirk)tegra_xudc_limit_port_speed (xudc);
@@ -3953,6 +3954,7 @@ static void tegra_xudc_remove(struct platform_device *pdev)static int __maybe_unused tegra_xudc_powergate (struct tegra_xudc *xudc) {unsigned long flags; +u32 val;dev_dbg (xudc->dev,"entering ELPG\n" );
@@ -3965,6 +3967,10 @@ static int __maybe_unused tegra_xudc_powergate(struct tegra_xudc *xudc)spin_unlock_irqrestore (&xudc->lock, flags); + val =xudc_readl (xudc,BLCG ); + val |=BLCG_COREPLL_PWRDN ; +xudc_writel (xudc, val,BLCG ); +clk_bulk_disable_unprepare (xudc->soc->num_clks, xudc->clks);regulator_bulk_disable (xudc->soc->num_supplies, xudc->supplies);
Signature · 1 line
2.51.0