6.12.24-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 128/393 drm/xe/vf: Dont try to trigger a full GT reset if VF
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Wajdeczko <[email protected]>
[ Upstream commit 459777724d306315070d24608fcd89aea85516d6 ]
VFs don't have access to the GDRST(0x941c) register that driver uses to reset a GT. Attempt to trigger a reset using debugfs:
$ cat /sys/kernel/debug/dri/0000:00:02.1/gt0/force_reset
or due to a hang condition detected by the driver leads to:
[ ] xe 0000:00:02.1: [drm] GT0: trying reset from force_reset [xe]
[ ] xe 0000:00:02.1: [drm] GT0: reset queued
[ ] xe 0000:00:02.1: [drm] GT0: reset started
[ ] ------------[ cut here ]------------
[ ] xe 0000:00:02.1: [drm] GT0: VF is trying to write 0x1 to an inaccessible register 0x941c+0x0 [ ] WARNING: CPU: 3 PID: 3069 at drivers/gpu/drm/xe/xe_gt_sriov_vf.c:996 xe_gt_sriov_vf_write32+0xc6/0x580 [xe] [ ] RIP: 0010:xe_gt_sriov_vf_write32+0xc6/0x580 [xe]
[ ] Call Trace:
[ ] <TASK> [ ] ? show_regs+0x6c/0x80 [ ] ? __warn+0x93/0x1c0 [ ] ? xe_gt_sriov_vf_write32+0xc6/0x580 [xe] [ ] ? report_bug+0x182/0x1b0 [ ] ? handle_bug+0x6e/0xb0 [ ] ? exc_invalid_op+0x18/0x80 [ ] ? asm_exc_invalid_op+0x1b/0x20 [ ] ? xe_gt_sriov_vf_write32+0xc6/0x580 [xe] [ ] ? xe_gt_sriov_vf_write32+0xc6/0x580 [xe] [ ] ? xe_gt_tlb_invalidation_reset+0xef/0x110 [xe] [ ] ? __mutex_unlock_slowpath+0x41/0x2e0 [ ] xe_mmio_write32+0x64/0x150 [xe] [ ] do_gt_reset+0x2f/0xa0 [xe] [ ] gt_reset_worker+0x14e/0x1e0 [xe] [ ] process_one_work+0x21c/0x740 [ ] worker_thread+0x1db/0x3c0
Fix that by sending H2G VF_RESET(0x5507) action instead.
--- drivers/gpu/drm/xe/xe_gt.c | 4 ++++ drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 16 ++++++++++++++++ drivers/gpu/drm/xe/xe_gt_sriov_vf.h | 1 + 3 files changed, 21 insertions(+)
drivers/gpu/drm/xe/xe_gt.c +4 -0
@@ -32,6 +32,7 @@#include "xe_gt_pagefault.h" #include "xe_gt_printk.h" #include "xe_gt_sriov_pf.h" +#include "xe_gt_sriov_vf.h" #include "xe_gt_sysfs.h" #include "xe_gt_tlb_invalidation.h" #include "xe_gt_topology.h"
@@ -647,6 +648,9 @@ static int do_gt_reset(struct xe_gt *gt) {int err; +if (IS_SRIOV_VF (gt_to_xe (gt))) +return xe_gt_sriov_vf_reset (gt); +xe_gsc_wa_14015076503 (gt, true);xe_mmio_write32 (gt,GDRST ,GRDOM_FULL );
drivers/gpu/drm/xe/xe_gt_sriov_vf.c +16 -0
@@ -57,6 +57,22 @@ static int vf_reset_guc_state(struct xe_gt *gt)return err; } +/** +* xe_gt_sriov_vf_reset - Reset GuC VF internal state. +* @gt: the &xe_gt +* +* It requires functional `GuC MMIO based communication`_. +* +* Return: 0 on success or a negative error code on failure. +*/ +int xe_gt_sriov_vf_reset (struct xe_gt *gt) +{ +if (!xe_device_uc_enabled (gt_to_xe (gt))) +return -ENODEV ; + +return vf_reset_guc_state (gt); +} +static int guc_action_match_version (struct xe_guc *guc,u32 wanted_branch,u32 wanted_major,u32 wanted_minor,u32 *branch,u32 *major,u32 *minor,u32 *patch)
drivers/gpu/drm/xe/xe_gt_sriov_vf.h +1 -0
@@ -12,6 +12,7 @@ struct drm_printer;struct xe_gt ;struct xe_reg ; +int xe_gt_sriov_vf_reset (struct xe_gt *gt);int xe_gt_sriov_vf_bootstrap (struct xe_gt *gt);int xe_gt_sriov_vf_query_config (struct xe_gt *gt);int xe_gt_sriov_vf_connect (struct xe_gt *gt);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 129/393 drm/amd/display: Update Cursor request mode to the beginning prefetch always
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhikai Zhai <[email protected]>
[ Upstream commit 4a4077b4b63a8404efd6d37fc2926f03fb25bace ]
[Why]
The double buffer cursor registers is updated by the cursor vupdate event. There is a gap between vupdate and cursor data fetch if cursor fetch data reletive to cursor position. Cursor corruption will happen if we update the cursor surface in this gap.
[How]
Modify the cursor request mode to the beginning prefetch always and avoid wraparound calculation issues.
--- .../amd/display/dc/hubp/dcn31/dcn31_hubp.c | 2 +- .../amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 22 ++++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/display/dc/hubp/dcn31/dcn31_hubp.c +1 -1
@@ -44,7 +44,7 @@ void hubp31_set_unbounded_requesting(struct hubp *hubp, bool enable)struct dcn20_hubp *hubp2 =TO_DCN20_HUBP (hubp);REG_UPDATE (DCHUBP_CNTL ,HUBP_UNBOUNDED_REQ_MODE , enable); -REG_UPDATE (CURSOR_CONTROL ,CURSOR_REQ_MODE , enable); +REG_UPDATE (CURSOR_CONTROL ,CURSOR_REQ_MODE ,1 ); }void hubp31_soft_reset (struct hubp *hubp,bool reset)
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c +9 -13
@@ -1992,20 +1992,11 @@ static void delay_cursor_until_vupdate(struct dc *dc, struct pipe_ctx *pipe_ctx) dc->hwss.get_position (&pipe_ctx,1 , &position); vpos = position.vertical_count; -/* Avoid wraparound calculation issues */ - vupdate_start += stream->timing.v_total; - vupdate_end += stream->timing.v_total; - vpos += stream->timing.v_total; -if (vpos <= vupdate_start) {/* VPOS is in VACTIVE or back porch. */ lines_to_vupdate = vupdate_start - vpos; - }else if (vpos > vupdate_end) { -/* VPOS is in the front porch. */ -return ; }else { -/* VPOS is in VUPDATE. */ - lines_to_vupdate =0 ; + lines_to_vupdate = stream->timing.v_total - vpos + vupdate_start; }/* Calculate time until VUPDATE in microseconds. */
@@ -2013,13 +2004,18 @@ static void delay_cursor_until_vupdate(struct dc *dc, struct pipe_ctx *pipe_ctx) stream->timing.h_total *10000u / stream->timing.pix_clk_100hz; us_to_vupdate = lines_to_vupdate * us_per_line; +/* Stall out until the cursor update completes. */ +if (vupdate_end < vupdate_start) + vupdate_end += stream->timing.v_total; + +/* Position is in the range of vupdate start and end*/ +if (lines_to_vupdate > stream->timing.v_total - vupdate_end + vupdate_start) + us_to_vupdate =0 ; +/* 70 us is a conservative estimate of cursor update time*/ if (us_to_vupdate >70 )return ; -/* Stall out until the cursor update completes. */ -if (vupdate_end < vupdate_start) - vupdate_end += stream->timing.v_total; us_vupdate = (vupdate_end - vupdate_start +1 ) * us_per_line;udelay (us_to_vupdate + us_vupdate); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 130/393 drm/amdgpu: Unlocked unmap only clear page table leaves
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philip Yang <[email protected]>
[ Upstream commit 23b645231eeffdaf44021debac881d2f26824150 ]
SVM migration unmap pages from GPU and then update mapping to GPU to recover page fault. Currently unmap clears the PDE entry for range length >= huge page and free PTB bo, update mapping to alloc new PT bo. There is race bug that the freed entry bo maybe still on the pt_free list, reused when updating mapping and then freed, leave invalid PDE entry and cause GPU page fault.
By setting the update to clear only one PDE entry or clear PTB, to avoid unmap to free PTE bo. This fixes the race bug and improve the unmap and map to GPU performance. Update mapping to huge page will still free the PTB bo.
With this change, the vm->pt_freed list and work is not needed. Add WARN_ON(unlocked) in amdgpu_vm_pt_free_dfs to catch if unmap to free the PTB.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 4 --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 43 +++++++---------------- 3 files changed, 13 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -4
@@ -2434,8 +2434,6 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm,spin_lock_init (&vm->status_lock);INIT_LIST_HEAD (&vm->freed);INIT_LIST_HEAD (&vm->done); -INIT_LIST_HEAD (&vm->pt_freed); -INIT_WORK (&vm->pt_free_work, amdgpu_vm_pt_free_work);INIT_KFIFO (vm->faults); r =amdgpu_vm_init_entities (adev, vm);
@@ -2607,8 +2605,6 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)amdgpu_amdkfd_gpuvm_destroy_cb (adev, vm); -flush_work (&vm->pt_free_work); - root =amdgpu_bo_ref (vm->root.bo);amdgpu_bo_reserve (root, true);amdgpu_vm_put_task_info (vm->task_info);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -4
@@ -360,10 +360,6 @@ struct amdgpu_vm {/* BOs which are invalidated, has been updated in the PTs */ struct list_head done; -/* PT BOs scheduled to free and fill with zero if vm_resv is not hold */ -struct list_head pt_freed; -struct work_struct pt_free_work; -/* contains the page directory */ struct amdgpu_vm_bo_base root;struct dma_fence *last_update;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +13 -30
66 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 131/393 drm: panel-orientation-quirks: Add support for AYANEO 2S
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Wyatt <[email protected]>
[ Upstream commit eb8f1e3e8ee10cff591d4a47437dfd34d850d454 ]
AYANEO 2S uses the same panel and orientation as the AYANEO 2.
Update the AYANEO 2 DMI match to also match AYANEO 2S.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_panel_orientation_quirks.c +2 -2
@@ -184,10 +184,10 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T103HAF"), }, .driver_data = (void *)&lcd800x1280_rightside_up, - }, { /* AYA NEO AYANEO 2 */ + }, { /* AYA NEO AYANEO 2/2S */ .matches = {DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYANEO" ), - DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "AYANEO 2"), + DMI_MATCH(DMI_PRODUCT_NAME, "AYANEO 2"), }, .driver_data = (void *)&lcd1200x1920_rightside_up, }, { /* AYA NEO 2021 */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 132/393 drm: panel-orientation-quirks: Add quirks for AYA NEO Flip DS and KB
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Wyatt <[email protected]>
[ Upstream commit 529741c331da1fbf54f86c6ec3a4558b9b0b16dc ]
The AYA NEO Flip DS and KB both use a 1080x1920 portrait LCD panel. The Flip DS additionally uses a 640x960 portrait LCD panel as a second display.
Add DMI matches to correctly rotate these panels.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +18 -0
@@ -93,6 +93,12 @@ static const struct drm_dmi_panel_orientation_data onegx1_pro = { .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, }; +static const struct drm_dmi_panel_orientation_data lcd640x960_leftside_up = { + .width =640 , + .height =960 , + .orientation =DRM_MODE_PANEL_ORIENTATION_LEFT_UP , +}; +static const struct drm_dmi_panel_orientation_data lcd720x1280_rightside_up = { .width =720 , .height =1280 ,
@@ -202,6 +208,18 @@ static const struct dmi_system_id orientation_data[] = { DMI_MATCH(DMI_PRODUCT_NAME, "AIR"), }, .driver_data = (void *)&lcd1080x1920_leftside_up, + }, { /* AYA NEO Flip DS Bottom Screen */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYANEO" ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "FLIP DS"), + }, + .driver_data = (void *)&lcd640x960_leftside_up, + }, { /* AYA NEO Flip KB/DS Top Screen */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYANEO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "FLIP"), + }, + .driver_data = (void *)&lcd1080x1920_leftside_up, }, { /* AYA NEO Founder */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "AYA NEO"),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 133/393 drm: panel-orientation-quirks: Add quirk for AYA NEO Slide
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Wyatt <[email protected]>
[ Upstream commit 132c89ef8872e602cfb909377815111d121fe8d7 ]
The AYANEO Slide uses a 1080x1920 portrait LCD panel. This is the same panel used on the AYANEO Air Plus, but the DMI data is too different to match both with one entry.
Add a DMI match to correctly rotate the panel on the AYANEO Slide.
This also covers the Antec Core HS, which is a rebranded AYANEO Slide with the exact same hardware and DMI strings.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -244,6 +244,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_MATCH(DMI_BOARD_NAME, "KUN"), }, .driver_data = (void *)&lcd1600x2560_rightside_up, + }, { /* AYA NEO SLIDE */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"AYANEO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "SLIDE"), + }, + .driver_data = (void *)&lcd1080x1920_leftside_up, }, { /* AYN Loki Max */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ayn"),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 134/393 drm: panel-orientation-quirks: Add new quirk for GPD Win 2
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Wyatt <[email protected]>
[ Upstream commit a860eb9c6ba6cdbf32e3e01a606556e5a90a2931 ]
Some GPD Win 2 units shipped with the correct DMI strings.
Add a DMI match to correctly rotate the panel on these units.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +6 -0
@@ -339,6 +339,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_BOARD_NAME, "Default string"), }, .driver_data = (void *)&gpd_win2, + }, { /* GPD Win 2 (correct DMI strings) */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"GPD" ), +DMI_EXACT_MATCH (DMI_PRODUCT_NAME ,"WIN2" ) + }, + .driver_data = (void *)&lcd720x1280_rightside_up, }, { /* GPD Win 3 */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "GPD"),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 135/393 drm: panel-orientation-quirks: Add quirk for OneXPlayer Mini (Intel)
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Wyatt <[email protected]>
[ Upstream commit b24dcc183583fc360ae0f0899e286a68f46abbd0 ]
The Intel model of the OneXPlayer Mini uses a 1200x1920 portrait LCD panel. The DMI strings are the same as the OneXPlayer, which already has a DMI quirk, but the panel is different.
Add a DMI match to correctly rotate this panel.
--- drivers/gpu/drm/drm_panel_orientation_quirks.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/drm_panel_orientation_quirks.c +12 -0
@@ -129,6 +129,12 @@ static const struct drm_dmi_panel_orientation_data lcd1080x1920_rightside_up = { .orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP, }; +static const struct drm_dmi_panel_orientation_data lcd1200x1920_leftside_up = { + .width =1200 , + .height =1920 , + .orientation =DRM_MODE_PANEL_ORIENTATION_LEFT_UP , +}; +static const struct drm_dmi_panel_orientation_data lcd1200x1920_rightside_up = { .width =1200 , .height =1920 ,
@@ -473,6 +479,12 @@ static const struct dmi_system_id orientation_data[] = { DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ONE XPLAYER"), }, .driver_data = (void *)&lcd1600x2560_leftside_up, + }, { /* OneXPlayer Mini (Intel) */ + .matches = { +DMI_EXACT_MATCH (DMI_SYS_VENDOR ,"ONE-NETBOOK TECHNOLOGY CO., LTD." ), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ONE XPLAYER"), + }, + .driver_data = (void *)&lcd1200x1920_leftside_up, }, { /* OrangePi Neo */ .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "OrangePi"),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 136/393 drm/debugfs: fix printk format for bridge index
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
[ Upstream commit 72443c730b7a7b5670a921ea928e17b9b99bd934 ]
idx is an unsigned int, use %u for printk-style strings.
--- drivers/gpu/drm/drm_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_debugfs.c +1 -1
@@ -743,7 +743,7 @@ static int bridges_show(struct seq_file *m, void *data)unsigned int idx =0 ;drm_for_each_bridge_in_chain (encoder, bridge) { -drm_printf (&p,"bridge[%d]: %ps\n" , idx++, bridge->funcs); +drm_printf (&p,"bridge[%u]: %ps\n" , idx++, bridge->funcs);drm_printf (&p,"\ttype: [%d] %s\n" , bridge->type,drm_get_connector_type_name (bridge->type));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 137/393 drm/bridge: panel: forbid initializing a panel with unknown connector type
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Ceresoli <[email protected]>
[ Upstream commit b296955b3a740ecc8b3b08e34fd64f1ceabb8fb4 ]
Having an DRM_MODE_CONNECTOR_Unknown connector type is considered bad, and drm_panel_bridge_add_typed() and derivatives are deprecated for this.
drm_panel_init() won't prevent initializing a panel with a DRM_MODE_CONNECTOR_Unknown connector type. Luckily there are no in-tree users doing it, so take this as an opportinuty to document a valid connector type must be passed.
Returning an error if this rule is violated is not possible because drm_panel_init() is a void function. Add at least a warning to make any violations noticeable, especially to non-upstream drivers.
--- drivers/gpu/drm/drm_panel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_panel.c +4 -1
@@ -49,7 +49,7 @@ static LIST_HEAD(panel_list);* @dev: parent device of the panel * @funcs: panel operations * @connector_type: the connector type (DRM_MODE_CONNECTOR_*) corresponding to -* the panel interface +* the panel interface (must NOT be DRM_MODE_CONNECTOR_Unknown) * * Initialize the panel structure for subsequent registration with * drm_panel_add().
@@ -57,6 +57,9 @@ static LIST_HEAD(panel_list);void drm_panel_init (struct drm_panel *panel,struct device *dev,const struct drm_panel_funcs *funcs,int connector_type) { +if (connector_type == DRM_MODE_CONNECTOR_Unknown) +DRM_WARN ("%s: %s: a valid connector type is required!\n" , __func__,dev_name (dev)); +INIT_LIST_HEAD (&panel->list);INIT_LIST_HEAD (&panel->followers);mutex_init (&panel->follower_lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 138/393 drm/amd/display: stop DML2 from removing pipes based on planes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Katsnelson <[email protected]>
[ Upstream commit 8adeff83a3b07fa6d0958ed51e1b38ba7469e448 ]
[Why]
Transitioning from low to high resolutions at high refresh rates caused grey corruption. During the transition state, there is a period where plane size is based on low resultion state and ODM slices are based on high resoultion state, causing the entire plane to be contained in one ODM slice. DML2 would turn off the pipe for the ODM slice with no plane, causing an underflow since the pixel rate for the higher resolution cannot be supported on one pipe. This change stops DML2 from turning off pipes that are mapped to an ODM slice with no plane. This is possible to do without negative consequences because pipes can now take the minimum viewport and draw with zero recout size, removing the need to have the pipe turned off.
[How]
In map_pipes_from_plane(), remove "check" that skips ODM slices that are not covered by the plane. This prevents the pipes for those ODM slices from being freed.
--- .../display/dc/dml2/dml2_dc_resource_mgmt.c | 26 ------------------- 1 file changed, 26 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml2_dc_resource_mgmt.c +0 -26
@@ -532,26 +532,6 @@ static void calculate_odm_slices(const struct dc_stream_state *stream, unsigned odm_slice_end_x[odm_factor -1 ] = stream->src.width -1 ; } -static bool is_plane_in_odm_slice (const struct dc_plane_state *plane,unsigned int slice_index,unsigned int *odm_slice_end_x,unsigned int num_slices) -{ -unsigned int slice_start_x, slice_end_x; - -if (slice_index ==0 ) - slice_start_x =0 ; -else - slice_start_x = odm_slice_end_x[slice_index -1 ] +1 ; - - slice_end_x = odm_slice_end_x[slice_index]; - -if (plane->clip_rect.x + plane->clip_rect.width < slice_start_x) -return false; - -if (plane->clip_rect.x > slice_end_x) -return false; - -return true; -} - static void add_odm_slice_to_odm_tree(struct dml2_context *ctx, struct dc_state *state, struct dc_pipe_mapping_scratch *scratch,
@@ -791,12 +771,6 @@ static void map_pipes_for_plane(struct dml2_context *ctx, struct dc_state *statesort_pipes_for_splitting (&scratch->pipe_pool);for (odm_slice_index =0 ; odm_slice_index < scratch->odm_info.odm_factor; odm_slice_index++) { -// We build the tree for one ODM slice at a time. -// Each ODM slice shares a common OPP -if (!is_plane_in_odm_slice (plane, odm_slice_index, scratch->odm_info.odm_slice_end_x, scratch->odm_info.odm_factor)) { -continue ; - } -// Now we have a list of all pipes to be used for this plane/stream, now setup the tree. scratch->odm_info.next_higher_pipe_for_odm_slice[odm_slice_index] = add_plane_to_blend_tree(ctx, state, plane,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 139/393 drivers: base: devres: Allow to release group on device release
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas De Marchi <[email protected]>
[ Upstream commit 8e1ddfada4530939a8cb64ee9251aef780474274 ]
When releasing a device, if the release action causes a group to be released, a warning is emitted because it can't find the group. This happens because devres_release_all() moves the entire list to a todo list and also move the group markers. Considering r* normal resource nodes and g1 a group resource node:
g1 -----------. v v r1 -> r2 -> g1[0] -> r3-> g[1] -> r4
After devres_release_all(), dev->devres_head becomes empty and the todo list it iterates on becomes:
g1 v r1 -> r2 -> r3-> r4 -> g1[0]
When a call to component_del() is made and takes down the aggregate device, a warning like this happen:
RIP: 0010:devres_release_group+0x362/0x530 ... Call Trace: <TASK> component_unbind+0x156/0x380 component_unbind_all+0x1d0/0x270 mei_component_master_unbind+0x28/0x80 [mei_hdcp] take_down_aggregate_device+0xc1/0x160 component_del+0x1c6/0x3e0 intel_hdcp_component_fini+0xf1/0x170 [xe] xe_display_fini+0x1e/0x40 [xe]
Because the devres group corresponding to the hdcp component cannot be found. Just ignore this corner case: if the dev->devres_head is empty and the caller is trying to remove a group, it's likely in the process of device cleanup so just ignore it instead of warning.
--- drivers/base/devres.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/base/devres.c +7 -0
@@ -687,6 +687,13 @@ int devres_release_group(struct device *dev, void *id)spin_unlock_irqrestore (&dev->devres_lock, flags);release_nodes (dev, &todo); + }else if (list_empty (&dev->devres_head)) { +/* +* dev is probably dying via devres_release_all(): groups +* have already been removed and are on the process of +* being released - don't touch and don't warn. +*/ +spin_unlock_irqrestore (&dev->devres_lock, flags); }else {WARN_ON (1 );spin_unlock_irqrestore (&dev->devres_lock, flags);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 140/393 drm/amdkfd: clamp queue size to minimum
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Yat Sin <[email protected]>
[ Upstream commit e90711946b53590371ecce32e8fcc381a99d6333 ]
If queue size is less than minimum, clamp it to minimum to prevent underflow when writing queue mqd.
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 10 ++++++++++ include/uapi/linux/kfd_ioctl.h | 2 ++ 2 files changed, 12 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +10 -0
@@ -212,6 +212,11 @@ static int set_queue_properties_from_user(struct queue_properties *q_properties,return -EINVAL ; } +if (args->ring_size <KFD_MIN_QUEUE_RING_SIZE ) { + args->ring_size =KFD_MIN_QUEUE_RING_SIZE ; +pr_debug ("Size lower. clamped to KFD_MIN_QUEUE_RING_SIZE" ); + } +if (!access_ok ((const void __user *) args->read_pointer_address,sizeof (uint32_t ))) {pr_err ("Can't access read pointer\n" );
@@ -461,6 +466,11 @@ static int kfd_ioctl_update_queue(struct file *filp, struct kfd_process *p,return -EINVAL ; } +if (args->ring_size <KFD_MIN_QUEUE_RING_SIZE ) { + args->ring_size =KFD_MIN_QUEUE_RING_SIZE ; +pr_debug ("Size lower. clamped to KFD_MIN_QUEUE_RING_SIZE" ); + } + properties.queue_address = args->ring_base_address; properties.queue_size = args->ring_size; properties.queue_percent = args->queue_percentage &0xFF ;
include/uapi/linux/kfd_ioctl.h +2 -0
@@ -62,6 +62,8 @@ struct kfd_ioctl_get_version_args {#define KFD_MAX_QUEUE_PERCENTAGE 100#define KFD_MAX_QUEUE_PRIORITY 15 +#define KFD_MIN_QUEUE_RING_SIZE 1024 +struct kfd_ioctl_create_queue_args {__u64 ring_base_address;/* to KFD */ __u64 write_pointer_address;/* from KFD */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 141/393 drm/amdkfd: Fix mode1 reset crash issue
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philip Yang <[email protected]>
[ Upstream commit f0b4440cdc1807bb6ec3dce0d6de81170803569b ]
If HW scheduler hangs and mode1 reset is used to recover GPU, KFD signal user space to abort the processes. After process abort exit, user queues still use the GPU to access system memory before h/w is reset while KFD cleanup worker free system memory and free VRAM.
There is use-after-free race bug that KFD allocate and reuse the freed system memory, and user queue write to the same system memory to corrupt the data structure and cause driver crash.
To fix this race, KFD cleanup worker terminate user queues, then flush reset_domain wq to wait for any GPU ongoing reset complete, and then free outstanding BOs.
--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +17 -0
@@ -35,6 +35,7 @@#include <linux/pm_runtime.h> #include "amdgpu_amdkfd.h" #include "amdgpu.h" +#include "amdgpu_reset.h" struct mm_struct ;
@@ -1140,6 +1141,17 @@ static void kfd_process_remove_sysfs(struct kfd_process *p) p->kobj =NULL ; } +/* +* If any GPU is ongoing reset, wait for reset complete. +*/ +static void kfd_process_wait_gpu_reset_complete (struct kfd_process *p) +{ +int i; + +for (i =0 ; i < p->n_pdds; i++) +flush_workqueue (p->pdds[i]->dev->adev->reset_domain->wq); +} +/* No process locking is needed in this function, because the process * is not findable any more. We must assume that no other thread is * using it any more, otherwise we couldn't safely free the process
@@ -1154,6 +1166,11 @@ static void kfd_process_wq_release(struct work_struct *work)kfd_process_dequeue_from_all_devices (p);pqm_uninit (&p->pqm); +/* +* If GPU in reset, user queues may still running, wait for reset complete. +*/ +kfd_process_wait_gpu_reset_complete (p); +/* Signal the eviction fence after user mode queues are * destroyed. This allows any BOs to be freed without * triggering pointless evictions or waiting for fences.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 142/393 drm/amdkfd: Fix pqm_destroy_queue race with GPU reset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philip Yang <[email protected]>
[ Upstream commit 7919b4cad5545ed93778f11881ceee72e4dbed66 ]
If GPU in reset, destroy_queue return -EIO, pqm_destroy_queue should delete the queue from process_queue_list and free the resource.
--- drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -1
@@ -546,7 +546,7 @@ int pqm_destroy_queue(struct process_queue_manager *pqm, unsigned int qid)pr_err ("Pasid 0x%x destroy queue %d failed, ret %d\n" , pqm->process->pasid, pqn->q->properties.queue_id, retval); -if (retval != -ETIME ) +if (retval != -ETIME && retval != -EIO ) goto err_destroy_queue; }kfd_procfs_del_queue (pqn->q);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 143/393 drm/amdkfd: debugfs hang_hws skip GPU with MES
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philip Yang <[email protected]>
[ Upstream commit fe9d0061c413f8fb8c529b18b592b04170850ded ]
debugfs hang_hws is used by GPU reset test with HWS, for MES this crash the kernel with NULL pointer access because dqm->packet_mgr is not setup for MES path.
Skip GPU with MES for now, MES hang_hws debugfs interface will be supported later.
--- drivers/gpu/drm/amd/amdkfd/kfd_device.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_device.c +5 -0
@@ -1493,6 +1493,11 @@ int kfd_debugfs_hang_hws(struct kfd_node *dev)return -EINVAL ; } +if (dev->kfd->shared_resources.enable_mes) { +dev_err (dev->adev->dev,"Inducing MES hang is not supported\n" ); +return -EINVAL ; + } +return dqm_debugfs_hang_hws (dev->dqm); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 144/393 drm/xe/xelp: Move Wa_16011163337 from tunings to workarounds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
[ Upstream commit d9b5d83c5a4d720af6ddbefe2825c78f0325a3fd ]
Workaround database specifies 16011163337 as a workaround so lets move it there.
--- drivers/gpu/drm/xe/xe_tuning.c | 8 -------- drivers/gpu/drm/xe/xe_wa.c | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/xe/xe_tuning.c +0 -8
@@ -97,14 +97,6 @@ static const struct xe_rtp_entry_sr engine_tunings[] = { };static const struct xe_rtp_entry_sr lrc_tunings[] = { - {XE_RTP_NAME ("Tuning: ganged timer, also known as 16011163337" ), -XE_RTP_RULES (GRAPHICS_VERSION_RANGE (1200 ,1210 ),ENGINE_CLASS (RENDER )), -/* read verification is ignored due to 1608008084. */ -XE_RTP_ACTIONS (FIELD_SET_NO_READ_MASK (FF_MODE2 , -FF_MODE2_GS_TIMER_MASK , -FF_MODE2_GS_TIMER_224 )) - }, -/* DG2 */ {XE_RTP_NAME ("Tuning: L3 cache" ),
drivers/gpu/drm/xe/xe_wa.c +7 -0
@@ -606,6 +606,13 @@ static const struct xe_rtp_entry_sr engine_was[] = { };static const struct xe_rtp_entry_sr lrc_was[] = { + {XE_RTP_NAME ("16011163337" ), +XE_RTP_RULES (GRAPHICS_VERSION_RANGE (1200 ,1210 ),ENGINE_CLASS (RENDER )), +/* read verification is ignored due to 1608008084. */ +XE_RTP_ACTIONS (FIELD_SET_NO_READ_MASK (FF_MODE2 , +FF_MODE2_GS_TIMER_MASK , +FF_MODE2_GS_TIMER_224 )) + }, {XE_RTP_NAME ("1409342910, 14010698770, 14010443199, 1408979724, 1409178076, 1409207793, 1409217633, 1409252684, 1409347922, 1409142259" ),XE_RTP_RULES (GRAPHICS_VERSION_RANGE (1200 ,1210 )), XE_RTP_ACTIONS(SET(COMMON_SLICE_CHICKEN3,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 145/393 drm/mediatek: mtk_dpi: Move the input_2p_en bit to platform data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit c90876a695dd83e76680b88b40067275a5982811 ]
In preparation for adding support for MT8195's HDMI reserved DPI instance, move the input_2p_en bit for DP_INTF to platform data.
While at it, remove the input_2pixel member from platform data as having this bit implies that the 2pixel feature must be enabled.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/mediatek/mtk_dpi.c +7 -7
@@ -127,14 +127,14 @@ struct mtk_dpi_yc_limit {* @is_ck_de_pol: Support CK/DE polarity. * @swap_input_support: Support input swap function. * @support_direct_pin: IP supports direct connection to dpi panels. -* @input_2pixel: Input pixel of dp_intf is 2 pixel per round, so enable this -* config to enable this feature. * @dimension_mask: Mask used for HWIDTH, HPORCH, VSYNC_WIDTH and VSYNC_PORCH * (no shift). * @hvsize_mask: Mask of HSIZE and VSIZE mask (no shift). * @channel_swap_shift: Shift value of channel swap. * @yuv422_en_bit: Enable bit of yuv422. * @csc_enable_bit: Enable bit of CSC. +* @input_2p_en_bit: Enable bit for input two pixel per round feature. +* If present, implies that the feature must be enabled. * @pixels_per_iter: Quantity of transferred pixels per iteration. * @edge_cfg_in_mmsys: If the edge configuration for DPI's output needs to be set in MMSYS. */
@@ -148,12 +148,12 @@ struct mtk_dpi_conf {bool is_ck_de_pol;bool swap_input_support;bool support_direct_pin; -bool input_2pixel;u32 dimension_mask;u32 hvsize_mask;u32 channel_swap_shift;u32 yuv422_en_bit;u32 csc_enable_bit; +u32 input_2p_en_bit;u32 pixels_per_iter;bool edge_cfg_in_mmsys; };
@@ -610,9 +610,9 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,mtk_dpi_dual_edge (dpi);mtk_dpi_config_disable_edge (dpi); } -if (dpi->conf->input_2pixel) { -mtk_dpi_mask (dpi,DPI_CON ,DPINTF_INPUT_2P_EN , -DPINTF_INPUT_2P_EN ); +if (dpi->conf->input_2p_en_bit) { +mtk_dpi_mask (dpi,DPI_CON , dpi->conf->input_2p_en_bit, + dpi->conf->input_2p_en_bit); }mtk_dpi_sw_reset (dpi, false);
@@ -992,12 +992,12 @@ static const struct mtk_dpi_conf mt8195_dpintf_conf = { .output_fmts = mt8195_output_fmts, .num_output_fmts = ARRAY_SIZE(mt8195_output_fmts), .pixels_per_iter = 4, - .input_2pixel = true, .dimension_mask = DPINTF_HPW_MASK, .hvsize_mask = DPINTF_HSIZE_MASK, .channel_swap_shift = DPINTF_CH_SWAP, .yuv422_en_bit = DPINTF_YUV422_EN, .csc_enable_bit = DPINTF_CSC_ENABLE, + .input_2p_en_bit = DPINTF_INPUT_2P_EN, };static int mtk_dpi_probe (struct platform_device *pdev)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 146/393 drm/mediatek: mtk_dpi: Explicitly manage TVD clock in power on/off
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 473c33f5ce651365468503c76f33158aaa1c7dd2 ]
In preparation for adding support for MT8195's HDMI reserved DPI, add calls to clk_prepare_enable() / clk_disable_unprepare() for the TVD clock: in this particular case, the aforementioned clock is not (and cannot be) parented to neither pixel or engine clocks hence it won't get enabled automatically by the clock framework.
Please note that on all of the currently supported MediaTek platforms, the TVD clock is always a parent of either pixel or engine clocks, and this means that the common clock framework is already enabling this clock before the children. On such platforms, this commit will only increase the refcount of the TVD clock without any functional change.
--- drivers/gpu/drm/mediatek/mtk_dpi.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/mediatek/mtk_dpi.c +9 -0
@@ -471,6 +471,7 @@ static void mtk_dpi_power_off(struct mtk_dpi *dpi)mtk_dpi_disable (dpi);clk_disable_unprepare (dpi->pixel_clk); +clk_disable_unprepare (dpi->tvd_clk);clk_disable_unprepare (dpi->engine_clk); }
@@ -487,6 +488,12 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) goto err_refcount; } + ret =clk_prepare_enable (dpi->tvd_clk); +if (ret) { +dev_err (dpi->dev,"Failed to enable tvd pll: %d\n" , ret); + goto err_engine; + } + ret =clk_prepare_enable (dpi->pixel_clk);if (ret) {dev_err (dpi->dev,"Failed to enable pixel clock: %d\n" , ret);
@@ -496,6 +503,8 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)return 0 ; err_pixel: +clk_disable_unprepare (dpi->tvd_clk); +err_engine:clk_disable_unprepare (dpi->engine_clk); err_refcount: dpi->refcount--;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 147/393 PCI: Add Rockchip Vendor ID
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Lin <[email protected]>
[ Upstream commit 20bbb083bbc9d3f8db390f2e35e168f1b23dae8a ]
Move PCI_VENDOR_ID_ROCKCHIP from pci_endpoint_test.c to pci_ids.h and reuse it in pcie-rockchip-host.c.
--- drivers/misc/pci_endpoint_test.c | 1 - drivers/pci/controller/pcie-rockchip-host.c | 2 +- drivers/pci/controller/pcie-rockchip.h | 1 - include/linux/pci_ids.h | 2 ++ 4 files changed, 3 insertions(+), 3 deletions(-)
drivers/misc/pci_endpoint_test.c +0 -1
@@ -85,7 +85,6 @@#define PCI_DEVICE_ID_RENESAS_R8A774E1 0x0025#define PCI_DEVICE_ID_RENESAS_R8A779F0 0x0031 -#define PCI_VENDOR_ID_ROCKCHIP 0x1d87#define PCI_DEVICE_ID_ROCKCHIP_RK3588 0x3588static DEFINE_IDA (pci_endpoint_test_ida);
drivers/pci/controller/pcie-rockchip-host.c +1 -1
@@ -367,7 +367,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip) } } -rockchip_pcie_write (rockchip,ROCKCHIP_VENDOR_ID , +rockchip_pcie_write (rockchip,PCI_VENDOR_ID_ROCKCHIP ,PCIE_CORE_CONFIG_VENDOR ); rockchip_pcie_write(rockchip, PCI_CLASS_BRIDGE_PCI_NORMAL << 8,
drivers/pci/controller/pcie-rockchip.h +0 -1
@@ -188,7 +188,6 @@#define AXI_WRAPPER_NOR_MSG 0xc#define PCIE_RC_SEND_PME_OFF 0x11960 -#define ROCKCHIP_VENDOR_ID 0x1d87#define PCIE_LINK_IS_L2 (x) \ (((x) & PCIE_CLIENT_DEBUG_LTSSM_MASK) == PCIE_CLIENT_DEBUG_LTSSM_L2)#define PCIE_LINK_UP (x) \
include/linux/pci_ids.h +2 -0
@@ -2605,6 +2605,8 @@#define PCI_VENDOR_ID_ZHAOXIN 0x1d17 +#define PCI_VENDOR_ID_ROCKCHIP 0x1d87 +#define PCI_VENDOR_ID_HYGON 0x1d94#define PCI_VENDOR_ID_META 0x1d9b
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 148/393 drm/amdgpu: handle amdgpu_cgs_create_device() errors in amd_powerplay_create()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 1435e895d4fc967d64e9f5bf81e992ac32f5ac76 ]
Add error handling to propagate amdgpu_cgs_create_device() failures to the caller. When amdgpu_cgs_create_device() fails, release hwmgr and return -ENOMEM to prevent null pointer dereference.
[v1]->[v2]: Change error code from -EINVAL to -ENOMEM. Free hwmgr.
--- drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +5 -0
@@ -51,6 +51,11 @@ static int amd_powerplay_create(struct amdgpu_device *adev) hwmgr->adev = adev; hwmgr->not_vf = !amdgpu_sriov_vf (adev); hwmgr->device =amdgpu_cgs_create_device (adev); +if (!hwmgr->device) { +kfree (hwmgr); +return -ENOMEM ; + } +mutex_init (&hwmgr->msg_lock); hwmgr->chip_family = adev->family; hwmgr->chip_id = adev->asic_type;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 149/393 PCI: Enable Configuration RRS SV early
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
[ Upstream commit 3f8c4959fc18e477801386a625e726c59f52a2c4 ]
Following a reset, a Function may respond to Config Requests with Request Retry Status (RRS) Completion Status to indicate that it is temporarily unable to process the Request, but will be able to process the Request in the future (PCIe r6.0, sec 2.3.1).
If the Configuration RRS Software Visibility feature is enabled and a Root Complex receives RRS for a config read of the Vendor ID, the Root Complex completes the Request to the host by returning PCI_VENDOR_ID_PCI_SIG, 0x0001 (sec 2.3.2).
The Config RRS SV feature applies only to Root Ports and is not directly related to pci_scan_bridge_extend(). Move the RRS SV enable to set_pcie_port_type() where we handle other PCIe-specific configuration.
--- drivers/pci/probe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/pci/probe.c +5 -3
@@ -1327,8 +1327,6 @@ static int pci_scan_bridge_extend(struct pci_bus *bus, struct pci_dev *dev,pci_write_config_word (dev,PCI_BRIDGE_CONTROL , bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT ); -pci_enable_rrs_sv (dev); -if ((secondary || subordinate) && !pcibios_assign_all_busses () && !is_cardbus && !broken) {unsigned int cmax, buses;
@@ -1569,6 +1567,11 @@ void set_pcie_port_type(struct pci_dev *pdev) pdev->pcie_cap = pos;pci_read_config_word (pdev, pos +PCI_EXP_FLAGS , ®16); pdev->pcie_flags_reg = reg16; + + type =pci_pcie_type (pdev); +if (type ==PCI_EXP_TYPE_ROOT_PORT ) +pci_enable_rrs_sv (pdev); +pci_read_config_dword (pdev, pos +PCI_EXP_DEVCAP , &pdev->devcap); pdev->pcie_mpss =FIELD_GET (PCI_EXP_DEVCAP_PAYLOAD , pdev->devcap);
@@ -1585,7 +1588,6 @@ void set_pcie_port_type(struct pci_dev *pdev)* correctly so detect impossible configurations here and correct * the port type accordingly. */ - type =pci_pcie_type (pdev);if (type ==PCI_EXP_TYPE_DOWNSTREAM ) {/* * If pdev claims to be downstream port but the parent
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 150/393 drm/amdgpu: Fix the race condition for draining retry fault
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emily Deng <[email protected]>
[ Upstream commit f844732e3ad9c4b78df7436232949b8d2096d1a6 ]
Issue:
In the scenario where svm_range_restore_pages is called, but svm->checkpoint_ts has not been set and the retry fault has not been drained, svm_range_unmap_from_cpu is triggered and calls svm_range_free. Meanwhile, svm_range_restore_pages continues execution and reaches svm_range_from_addr. This results in a "failed to find prange..." error,
causing the page recovery to fail.
How to fix:
Move the timestamp check code under the protection of svm->lock.
v2:
Make sure all right locks are released before go out.
v3:
Directly goto out_unlock_svms, and return -EAGAIN.
v4:
Refine code.
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +17 -14
@@ -2992,19 +2992,6 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid, goto out; } -/* check if this page fault time stamp is before svms->checkpoint_ts */ -if (svms->checkpoint_ts[gpuidx] !=0 ) { -if (amdgpu_ih_ts_after (ts, svms->checkpoint_ts[gpuidx])) { -pr_debug ("draining retry fault, drop fault 0x%llx\n" , addr); - r =0 ; - goto out; - }else -/* ts is after svms->checkpoint_ts now, reset svms->checkpoint_ts -* to zero to avoid following ts wrap around give wrong comparing -*/ - svms->checkpoint_ts[gpuidx] =0 ; - } -if (!p->xnack_enabled) {pr_debug ("XNACK not enabled for pasid 0x%x\n" , pasid); r = -EFAULT ;
@@ -3024,6 +3011,21 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid,mmap_read_lock (mm); retry_write_locked:mutex_lock (&svms->lock); + +/* check if this page fault time stamp is before svms->checkpoint_ts */ +if (svms->checkpoint_ts[gpuidx] !=0 ) { +if (amdgpu_ih_ts_after (ts, svms->checkpoint_ts[gpuidx])) { +pr_debug ("draining retry fault, drop fault 0x%llx\n" , addr); + r = -EAGAIN ; + goto out_unlock_svms; + }else { +/* ts is after svms->checkpoint_ts now, reset svms->checkpoint_ts +* to zero to avoid following ts wrap around give wrong comparing +*/ + svms->checkpoint_ts[gpuidx] =0 ; + } + } + prange =svm_range_from_addr (svms, addr,NULL );if (!prange) { pr_debug("failed to find prange svms 0x%p address [0x%llx]\n",
@@ -3148,7 +3150,8 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid,mutex_unlock (&svms->lock);mmap_read_unlock (mm); -svm_range_count_fault (node, p, gpuidx); +if (r != -EAGAIN ) +svm_range_count_fault (node, p, gpuidx);mmput (mm); out:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 151/393 PCI: Check BAR index for validity
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philipp Stanner <[email protected]>
[ Upstream commit b1a7f99967fc0c052db8e65b449c7b32b1e9177f ]
Many functions in PCI use accessor macros such as pci_resource_len(), which take a BAR index. That index, however, is never checked for validity, potentially resulting in undefined behavior by overflowing the array pci_dev.resource in the macro pci_resource_n().
Since many users of those macros directly assign the accessed value to an unsigned integer, the macros cannot be changed easily anymore to return -EINVAL for invalid indexes. Consequently, the problem has to be mitigated in higher layers.
Add pci_bar_index_valid(). Use it where appropriate.
[kwilczynski: correct if-statement condition the pci_bar_index_is_valid() helper function uses, tidy up code comments]
--- drivers/pci/devres.c | 16 ++++++++++++++-- drivers/pci/iomap.c | 29 +++++++++++++++++++++-------- drivers/pci/pci.c | 6 ++++++ drivers/pci/pci.h | 16 ++++++++++++++++ 4 files changed, 57 insertions(+), 10 deletions(-)
drivers/pci/devres.c +14 -2
@@ -577,7 +577,7 @@ static int pcim_add_mapping_to_legacy_table(struct pci_dev *pdev, {void __iomem **legacy_iomap_table; -if (bar >=PCI_STD_NUM_BARS ) +if (!pci_bar_index_is_valid (bar))return -EINVAL ; legacy_iomap_table = (void __iomem **)pcim_iomap_table (pdev);
@@ -622,7 +622,7 @@ static void pcim_remove_bar_from_legacy_table(struct pci_dev *pdev, int bar) {void __iomem **legacy_iomap_table; -if (bar >=PCI_STD_NUM_BARS ) +if (!pci_bar_index_is_valid (bar))return ; legacy_iomap_table = (void __iomem **)pcim_iomap_table (pdev);
@@ -655,6 +655,9 @@ void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen)void __iomem *mapping;struct pcim_addr_devres *res; +if (!pci_bar_index_is_valid (bar)) +return NULL ; + res =pcim_addr_devres_alloc (pdev);if (!res)return NULL ;
@@ -722,6 +725,9 @@ void __iomem *pcim_iomap_region(struct pci_dev *pdev, int bar,int ret;struct pcim_addr_devres *res; +if (!pci_bar_index_is_valid (bar)) +return IOMEM_ERR_PTR (-EINVAL ); + res =pcim_addr_devres_alloc (pdev);if (!res)return IOMEM_ERR_PTR (-ENOMEM );
@@ -822,6 +828,9 @@ static int _pcim_request_region(struct pci_dev *pdev, int bar, const char *name,int ret;struct pcim_addr_devres *res; +if (!pci_bar_index_is_valid (bar)) +return -EINVAL ; + res =pcim_addr_devres_alloc (pdev);if (!res)return -ENOMEM ;
@@ -1043,6 +1052,9 @@ void __iomem *pcim_iomap_range(struct pci_dev *pdev, int bar,void __iomem *mapping;struct pcim_addr_devres *res; +if (!pci_bar_index_is_valid (bar)) +return IOMEM_ERR_PTR (-EINVAL ); + res =pcim_addr_devres_alloc (pdev);if (!res)return IOMEM_ERR_PTR (-ENOMEM );
drivers/pci/iomap.c +21 -8
@@ -9,6 +9,8 @@#include <linux/export.h> +#include "pci.h" /* for pci_bar_index_is_valid() */ +/** * pci_iomap_range - create a virtual mapping cookie for a PCI BAR * @dev: PCI device that owns the BAR
@@ -33,12 +35,19 @@ void __iomem *pci_iomap_range(struct pci_dev *dev, unsigned long offset, unsigned long maxlen) { -resource_size_t start =pci_resource_start (dev, bar); -resource_size_t len =pci_resource_len (dev, bar); -unsigned long flags =pci_resource_flags (dev, bar); +resource_size_t start, len; +unsigned long flags; + +if (!pci_bar_index_is_valid (bar)) +return NULL ; + + start =pci_resource_start (dev, bar); + len =pci_resource_len (dev, bar); + flags =pci_resource_flags (dev, bar);if (len <= offset || !start)return NULL ; + len -= offset; start += offset;if (maxlen && len > maxlen)
@@ -77,16 +86,20 @@ void __iomem *pci_iomap_wc_range(struct pci_dev *dev, unsigned long offset, unsigned long maxlen) { -resource_size_t start =pci_resource_start (dev, bar); -resource_size_t len =pci_resource_len (dev, bar); -unsigned long flags =pci_resource_flags (dev, bar); +resource_size_t start, len; +unsigned long flags; - -if (flags &IORESOURCE_IO ) +if (!pci_bar_index_is_valid (bar))return NULL ; + start =pci_resource_start (dev, bar); + len =pci_resource_len (dev, bar); + flags =pci_resource_flags (dev, bar); +if (len <= offset || !start)return NULL ; +if (flags &IORESOURCE_IO ) +return NULL ; len -= offset; start += offset;
drivers/pci/pci.c +6 -0
@@ -3922,6 +3922,9 @@ EXPORT_SYMBOL(pci_enable_atomic_ops_to_root);*/ void pci_release_region (struct pci_dev *pdev,int bar) { +if (!pci_bar_index_is_valid (bar)) +return ; +/* * This is done for backwards compatibility, because the old PCI devres * API had a mode in which the function became managed if it had been
@@ -3967,6 +3970,9 @@ EXPORT_SYMBOL(pci_release_region);static int __pci_request_region (struct pci_dev *pdev,int bar,const char *res_name,int exclusive) { +if (!pci_bar_index_is_valid (bar)) +return -EINVAL ; +if (pci_is_managed (pdev)) {if (exclusive ==IORESOURCE_EXCLUSIVE )return pcim_request_region_exclusive (pdev, bar, res_name);
drivers/pci/pci.h +16 -0
@@ -165,6 +165,22 @@ static inline void pci_wakeup_event(struct pci_dev *dev)pm_wakeup_event (&dev->dev,100 ); } +/** +* pci_bar_index_is_valid - Check whether a BAR index is within valid range +* @bar: BAR index +* +* Protects against overflowing &struct pci_dev.resource array. +* +* Return: true for valid index, false otherwise. +*/ +static inline bool pci_bar_index_is_valid (int bar) +{ +if (bar >=0 && bar <PCI_NUM_RESOURCES ) +return true; + +return false; +} +static inline bool pci_has_subordinate (struct pci_dev *pci_dev) {return !!(pci_dev->subordinate);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 152/393 PCI: vmd: Make vmd_dev::cfg_lock a raw_spinlock_t type
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryo Takakura <[email protected]>
[ Upstream commit 18056a48669a040bef491e63b25896561ee14d90 ]
The access to the PCI config space via pci_ops::read and pci_ops::write is a low-level hardware access. The functions can be accessed with disabled interrupts even on PREEMPT_RT. The pci_lock is a raw_spinlock_t for this purpose.
A spinlock_t becomes a sleeping lock on PREEMPT_RT, so it cannot be acquired with disabled interrupts. The vmd_dev::cfg_lock is accessed in the same context as the pci_lock.
Make vmd_dev::cfg_lock a raw_spinlock_t type so it can be used with interrupts disabled.
This was reported as:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 Call Trace: rt_spin_lock+0x4e/0x130 vmd_pci_read+0x8d/0x100 [vmd] pci_user_read_config_byte+0x6f/0xe0 pci_read_config+0xfe/0x290 sysfs_kf_bin_read+0x68/0x90
[bhelgaas: add back report info from
https://lore.kernel.org/lkml/[email protected]/]
--- drivers/pci/controller/vmd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/pci/controller/vmd.c +6 -6
@@ -125,7 +125,7 @@ struct vmd_irq_list {struct vmd_dev {struct pci_dev *dev; -spinlock_t cfg_lock; +raw_spinlock_t cfg_lock;void __iomem *cfgbar;int msix_count;
@@ -391,7 +391,7 @@ static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg,if (!addr)return -EFAULT ; -spin_lock_irqsave (&vmd->cfg_lock, flags); +raw_spin_lock_irqsave (&vmd->cfg_lock, flags);switch (len) {case 1 : *value =readb (addr);
@@ -406,7 +406,7 @@ static int vmd_pci_read(struct pci_bus *bus, unsigned int devfn, int reg, ret = -EINVAL ;break ; } -spin_unlock_irqrestore (&vmd->cfg_lock, flags); +raw_spin_unlock_irqrestore (&vmd->cfg_lock, flags);return ret; }
@@ -426,7 +426,7 @@ static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg,if (!addr)return -EFAULT ; -spin_lock_irqsave (&vmd->cfg_lock, flags); +raw_spin_lock_irqsave (&vmd->cfg_lock, flags);switch (len) {case 1 :writeb (value, addr);
@@ -444,7 +444,7 @@ static int vmd_pci_write(struct pci_bus *bus, unsigned int devfn, int reg, ret = -EINVAL ;break ; } -spin_unlock_irqrestore (&vmd->cfg_lock, flags); +raw_spin_unlock_irqrestore (&vmd->cfg_lock, flags);return ret; }
@@ -1009,7 +1009,7 @@ static int vmd_probe(struct pci_dev *dev, const struct pci_device_id *id)if (features &VMD_FEAT_OFFSET_FIRST_VECTOR ) vmd->first_vec =1 ; -spin_lock_init (&vmd->cfg_lock); +raw_spin_lock_init (&vmd->cfg_lock);pci_set_drvdata (dev, vmd); err =vmd_enable_domain (vmd, features);if (err)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 153/393 drm/amdgpu: grab an additional reference on the gang fence v2
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
[ Upstream commit 0d9a95099dcb05b5f4719c830d15bf4fdcad0dc2 ]
We keep the gang submission fence around in adev, make sure that it stays alive.
v2: fix memory leak on retry
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -1
@@ -6575,18 +6575,26 @@ struct dma_fence *amdgpu_device_switch_gang(struct amdgpu_device *adev, {struct dma_fence *old =NULL ; +dma_fence_get (gang);do {dma_fence_put (old); old =amdgpu_device_get_gang (adev);if (old == gang)break ; -if (!dma_fence_is_signaled (old)) +if (!dma_fence_is_signaled (old)) { +dma_fence_put (gang);return old; + } }while (cmpxchg ((struct dma_fence __force **)&adev->gang_submit, old, gang) != old); +/* +* Drop it once for the exchanged reference in adev and once for the +* thread local reference acquired in amdgpu_device_get_gang(). +*/ +dma_fence_put (old);dma_fence_put (old);return NULL ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 154/393 fbdev: omapfb: Add plane value check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leonid Arapov <[email protected]>
[ Upstream commit 3e411827f31db7f938a30a3c7a7599839401ec30 ]
Function dispc_ovl_setup is not intended to work with the value OMAP_DSS_WB of the enum parameter plane.
The value of this parameter is initialized in dss_init_overlays and in the current state of the code it cannot take this value so it's not a real problem.
For the purposes of defensive coding it wouldn't be superfluous to check the parameter value, because some functions down the call stack process this value correctly and some not.
For example, in dispc_ovl_setup_global_alpha it may lead to buffer overflow.
Add check for this value.
Found by Linux Verification Center (linuxtesting.org) with SVACE static analysis tool.
--- drivers/video/fbdev/omap2/omapfb/dss/dispc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/video/fbdev/omap2/omapfb/dss/dispc.c +5 -1
@@ -2749,9 +2749,13 @@ int dispc_ovl_setup(enum omap_plane plane, const struct omap_overlay_info *oi, bool mem_to_mem) {int r; -enum omap_overlay_caps caps =dss_feat_get_overlay_caps (plane); +enum omap_overlay_caps caps;enum omap_channel channel; +if (plane ==OMAP_DSS_WB ) +return -EINVAL ; + + caps =dss_feat_get_overlay_caps (plane); channel =dispc_ovl_get_channel_out (plane); DSSDBG("dispc_ovl_setup %d, pa %pad, pa_uv %pad, sw %d, %d,%d, %dx%d ->"
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 155/393 tracing: probe-events: Add comments about entry data storing code
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
[ Upstream commit bb9c6020f4c3a07a90dc36826cb5fbe83f09efd5 ]
Add comments about entry data storing code to __store_entry_arg() and traceprobe_get_entry_data_size(). These are a bit complicated because of building the entry data storing code and scanning it.
This just add comments, no behavior change.
--- kernel/trace/trace_probe.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
kernel/trace/trace_probe.c +28 -0
@@ -770,6 +770,10 @@ static int check_prepare_btf_string_fetch(char *typename,#ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API +/* +* Add the entry code to store the 'argnum'th parameter and return the offset +* in the entry data buffer where the data will be stored. +*/ static int __store_entry_arg (struct trace_probe *tp,int argnum) {struct probe_entry_arg *earg = tp->entry_arg;
@@ -793,6 +797,20 @@ static int __store_entry_arg(struct trace_probe *tp, int argnum) tp->entry_arg = earg; } +/* +* The entry code array is repeating the pair of +* [FETCH_OP_ARG(argnum)][FETCH_OP_ST_EDATA(offset of entry data buffer)] +* and the rest of entries are filled with [FETCH_OP_END]. +* +* To reduce the redundant function parameter fetching, we scan the entry +* code array to find the FETCH_OP_ARG which already fetches the 'argnum' +* parameter. If it doesn't match, update 'offset' to find the last +* offset. +* If we find the FETCH_OP_END without matching FETCH_OP_ARG entry, we +* will save the entry with FETCH_OP_ARG and FETCH_OP_ST_EDATA, and +* return data offset so that caller can find the data offset in the entry +* data buffer. +*/ offset =0 ;for (i =0 ; i < earg->size -1 ; i++) {switch (earg->code[i].op) {
@@ -826,6 +844,16 @@ int traceprobe_get_entry_data_size(struct trace_probe *tp)if (!earg)return 0 ; +/* +* earg->code[] array has an operation sequence which is run in +* the entry handler. +* The sequence stopped by FETCH_OP_END and each data stored in +* the entry data buffer by FETCH_OP_ST_EDATA. The FETCH_OP_ST_EDATA +* stores the data at the data buffer + its offset, and all data are +* "unsigned long" size. The offset must be increased when a data is +* stored. Thus we need to find the last FETCH_OP_ST_EDATA in the +* code array. +*/ for (i =0 ; i < earg->size; i++) {switch (earg->code[i].op) {case FETCH_OP_END :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 156/393 ktest: Fix Test Failures Due to Missing LOG_FILE Directories
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ayush Jain <[email protected]>
[ Upstream commit 5a1bed232781d356f842576daacc260f0d0c8d2e ]
Handle missing parent directories for LOG_FILE path to prevent test failures. If the parent directories don't exist, create them to ensure the tests proceed successfully.
--- tools/testing/ktest/ktest.pl | 8 ++++++++ 1 file changed, 8 insertions(+)
tools/testing/ktest/ktest.pl +8 -0
@@ -4303,6 +4303,14 @@ if (defined($opt{"LOG_FILE"})) { if ($opt{"CLEAR_LOG"}) { unlink $opt{"LOG_FILE"}; } + + if (! -e $opt{"LOG_FILE"} && $opt{"LOG_FILE"} =~ m,^(.*/),) { + my $dir = $1; + if (! -d $dir) { + mkpath($dir) or die "Failed to create directories '$dir': $!"; + print "\nThe log directory $dir did not exist, so it was created.\n"; + } + } open(LOG, ">> $opt{LOG_FILE}") or die "Can't write to $opt{LOG_FILE}"; LOG->autoflush(1); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 157/393 tpm, tpm_tis: Workaround failed command reception on Infineon devices
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan McDowell <[email protected]>
[ Upstream commit de9e33df7762abbfc2a1568291f2c3a3154c6a9d ]
Some Infineon devices have a issue where the status register will get stuck with a quick REQUEST_USE / COMMAND_READY sequence. This is not simply a matter of requiring a longer timeout; the work around is to retry the command submission. Add appropriate logic to do this in the send path.
This is fixed in later firmware revisions, but those are not always available, and cannot generally be easily updated from outside a firmware environment.
Testing has been performed with a simple repeated loop of doing a TPM2_CC_GET_CAPABILITY for TPM_CAP_PROP_MANUFACTURER using the Go code at:
https://the.earth.li/~noodles/tpm-stuff/timeout-reproducer-simple.go
It can take several hours to reproduce, and several million operations.
--- drivers/char/tpm/tpm_tis_core.c | 17 ++++++++++++++--- drivers/char/tpm/tpm_tis_core.h | 1 + include/linux/tpm.h | 1 + 3 files changed, 16 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm_tis_core.c +14 -3
@@ -464,7 +464,10 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)if (wait_for_tpm_stat (chip,TPM_STS_VALID , chip->timeout_c, &priv->int_queue, false) <0 ) { - rc = -ETIME ; +if (test_bit (TPM_TIS_STATUS_VALID_RETRY , &priv->flags)) + rc = -EAGAIN ; +else + rc = -ETIME ; goto out_err; } status =tpm_tis_status (chip);
@@ -481,7 +484,10 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len)if (wait_for_tpm_stat (chip,TPM_STS_VALID , chip->timeout_c, &priv->int_queue, false) <0 ) { - rc = -ETIME ; +if (test_bit (TPM_TIS_STATUS_VALID_RETRY , &priv->flags)) + rc = -EAGAIN ; +else + rc = -ETIME ; goto out_err; } status =tpm_tis_status (chip);
@@ -546,9 +552,11 @@ static int tpm_tis_send_main(struct tpm_chip *chip, const u8 *buf, size_t len)if (rc >=0 )/* Data transfer done successfully */ break ; -else if (rc != -EIO ) +else if (rc != -EAGAIN && rc != -EIO )/* Data transfer failed, not recoverable */ return rc; + +usleep_range (priv->timeout_min, priv->timeout_max); }/* go and do it */
@@ -1144,6 +1152,9 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, priv->timeout_max =TIS_TIMEOUT_MAX_ATML ; } +if (priv->manufacturer_id ==TPM_VID_IFX ) +set_bit (TPM_TIS_STATUS_VALID_RETRY , &priv->flags); +if (is_bsw ()) { priv->ilb_base_addr =ioremap (INTEL_LEGACY_BLK_BASE_ADDR ,ILB_REMAP_SIZE );
drivers/char/tpm/tpm_tis_core.h +1 -0
@@ -89,6 +89,7 @@ enum tpm_tis_flags {TPM_TIS_INVALID_STATUS =1 ,TPM_TIS_DEFAULT_CANCELLATION =2 ,TPM_TIS_IRQ_TESTED =3 , + TPM_TIS_STATUS_VALID_RETRY = 4, }; struct tpm_tis_data {
include/linux/tpm.h +1 -0
@@ -335,6 +335,7 @@ enum tpm2_cc_attrs {#define TPM_VID_WINBOND 0x1050#define TPM_VID_STM 0x104A#define TPM_VID_ATML 0x1114 +#define TPM_VID_IFX 0x15D1enum tpm_chip_flags {TPM_CHIP_FLAG_BOOTSTRAPPED =BIT (0 ),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 158/393 tpm: End any active auth session before shutdown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan McDowell <[email protected]>
[ Upstream commit 1dbf74e00a5f882b04b398399b6def65cd51ef21 ]
Lazy flushing of TPM auth sessions can interact badly with IMA + kexec, resulting in loaded session handles being leaked across the kexec and not cleaned up. Fix by ensuring any active auth session is ended before the TPM is told about the shutdown, matching what is done when suspending.
Before:
root@debian-qemu-efi:~# tpm2_getcap handles-loaded-session root@debian-qemu-efi:~# tpm2_getcap handles-saved-session root@debian-qemu-efi:~# kexec --load --kexec-file-syscall … root@debian-qemu-efi:~# systemctl kexec … root@debian-qemu-efi:~# tpm2_getcap handles-loaded-session - 0x2000000 root@debian-qemu-efi:~# tpm2_getcap handles-saved-session root@debian-qemu-efi:~# (repeat kexec steps) root@debian-qemu-efi:~# tpm2_getcap handles-loaded-session - 0x2000000 - 0x2000001 root@debian-qemu-efi:~# tpm2_getcap handles-saved-session root@debian-qemu-efi:~#
After:
root@debian-qemu-efi:~# tpm2_getcap handles-loaded-session root@debian-qemu-efi:~# tpm2_getcap handles-saved-session root@debian-qemu-efi:~# kexec --load --kexec-file-syscall … root@debian-qemu-efi:~# systemctl kexec … root@debian-qemu-efi:~# tpm2_getcap handles-loaded-session root@debian-qemu-efi:~# tpm2_getcap handles-saved-session root@debian-qemu-efi:~#
--- drivers/char/tpm/tpm-chip.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/tpm/tpm-chip.c +1 -0
@@ -300,6 +300,7 @@ int tpm_class_shutdown(struct device *dev)down_write (&chip->ops_sem);if (chip->flags &TPM_CHIP_FLAG_TPM2 ) {if (!tpm_chip_start (chip)) { +tpm2_end_auth_session (chip);tpm2_shutdown (chip,TPM2_SU_CLEAR );tpm_chip_stop (chip); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 159/393 pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
[ Upstream commit 7ca59947b5fcf94e7ea4029d1bd0f7c41500a161 ]
With CONFIG_COMPILE_TEST && !CONFIG_HAVE_CLK, pwm_mediatek_config() has a divide-by-zero in the following line:
do_div(resolution, clk_get_rate(pc->clk_pwms[pwm->hwpwm]));
due to the fact that the !CONFIG_HAVE_CLK version of clk_get_rate() returns zero.
This is presumably just a theoretical problem: COMPILE_TEST overrides the dependency on RALINK which would select COMMON_CLK. Regardless it's a good idea to check for the error explicitly to avoid divide-by-zero.
Fixes the following warning:
drivers/pwm/pwm-mediatek.o: warning: objtool: .text: unexpected end of section
--- drivers/pwm/pwm-mediatek.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pwm/pwm-mediatek.c +6 -2
@@ -121,21 +121,25 @@ static int pwm_mediatek_config(struct pwm_chip *chip, struct pwm_device *pwm,struct pwm_mediatek_chip *pc =to_pwm_mediatek_chip (chip);u32 clkdiv =0 , cnt_period, cnt_duty, reg_width =PWMDWIDTH , reg_thres =PWMTHRES ; +unsigned long clk_rate;u64 resolution;int ret; ret =pwm_mediatek_clk_enable (chip, pwm); -if (ret <0 )return ret; + clk_rate =clk_get_rate (pc->clk_pwms[pwm->hwpwm]); +if (!clk_rate) +return -EINVAL ; +/* Make sure we use the bus clock and not the 26MHz clock */ if (pc->soc->has_ck_26m_sel)writel (0 , pc->regs +PWM_CK_26M_SEL );/* Using resolution in picosecond gets accuracy higher */ resolution = (u64 )NSEC_PER_SEC *1000 ; -do_div (resolution,clk_get_rate (pc->clk_pwms[pwm->hwpwm])); +do_div (resolution, clk_rate); cnt_period =DIV_ROUND_CLOSEST_ULL ((u64 )period_ns *1000 , resolution);while (cnt_period >8191 ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 160/393 pwm: rcar: Improve register calculation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit e7327c193014a4d8666e9c1cda09cf2c060518e8 ]
There were several issues in the function rcar_pwm_set_counter():
- The u64 values period_ns and duty_ns were cast to int on function call which might loose bits on 32 bit architectures.
Fix: Make parameters to rcar_pwm_set_counter() u64
- The algorithm divided by the result of a division which looses precision.
Fix: Make use of mul_u64_u64_div_u64()
- The calculated values were just masked to fit the respective register fields which again might loose bits.
Fix: Explicitly check for overlow
Implement the respective fixes.
A side effect of fixing the 2nd issue is that there is no division by 0 if clk_get_rate() returns 0.
[ukleinek: Added an explicit #include <linux/bitfield.h> to please the 0day build bot]
--- drivers/pwm/pwm-rcar.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/pwm/pwm-rcar.c +13 -11
@@ -8,6 +8,7 @@* - The hardware cannot generate a 0% duty cycle. */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/io.h>
@@ -102,23 +103,24 @@ static void rcar_pwm_set_clock_control(struct rcar_pwm_chip *rp,rcar_pwm_write (rp, value,RCAR_PWMCR ); } -static int rcar_pwm_set_counter (struct rcar_pwm_chip *rp,int div,int duty_ns, -int period_ns) +static int rcar_pwm_set_counter (struct rcar_pwm_chip *rp,int div,u64 duty_ns, +u64 period_ns) { -unsigned long long one_cycle, tmp;/* 0.01 nanoseconds */ +unsigned long long tmp;unsigned long clk_rate =clk_get_rate (rp->clk);u32 cyc, ph; - one_cycle =NSEC_PER_SEC *100ULL << div; -do_div (one_cycle, clk_rate); +/* div <= 24 == RCAR_PWM_MAX_DIVISION, so the shift doesn't overflow. */ + tmp =mul_u64_u64_div_u64 (period_ns, clk_rate, (u64 )NSEC_PER_SEC << div); +if (tmp >FIELD_MAX (RCAR_PWMCNT_CYC0_MASK )) + tmp =FIELD_MAX (RCAR_PWMCNT_CYC0_MASK ); - tmp = period_ns *100ULL ; -do_div (tmp, one_cycle); - cyc = (tmp <<RCAR_PWMCNT_CYC0_SHIFT ) &RCAR_PWMCNT_CYC0_MASK ; + cyc =FIELD_PREP (RCAR_PWMCNT_CYC0_MASK , tmp); - tmp = duty_ns *100ULL ; -do_div (tmp, one_cycle); - ph = tmp &RCAR_PWMCNT_PH0_MASK ; + tmp =mul_u64_u64_div_u64 (duty_ns, clk_rate, (u64 )NSEC_PER_SEC << div); +if (tmp >FIELD_MAX (RCAR_PWMCNT_PH0_MASK )) + tmp =FIELD_MAX (RCAR_PWMCNT_PH0_MASK ); + ph =FIELD_PREP (RCAR_PWMCNT_PH0_MASK , tmp);/* Avoid prohibited setting */ if (cyc ==0 || ph ==0 )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 161/393 pwm: fsl-ftm: Handle clk_get_rate() returning 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 928446a5302eee30ebb32075c0db5dda5a138fb7 ]
Considering that the driver doesn't enable the used clocks (and also that clk_get_rate() returns 0 if CONFIG_HAVE_CLK is unset) better check the return value of clk_get_rate() for being non-zero before dividing by it.
--- drivers/pwm/pwm-fsl-ftm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/pwm/pwm-fsl-ftm.c +6 -0
@@ -118,6 +118,9 @@ static unsigned int fsl_pwm_ticks_to_ns(struct fsl_pwm_chip *fpc,unsigned long long exval; rate =clk_get_rate (fpc->clk[fpc->period.clk_select]); +if (rate >> fpc->period.clk_ps ==0 ) +return 0 ; + exval = ticks; exval *=1000000000UL ;do_div (exval, rate >> fpc->period.clk_ps);
@@ -190,6 +193,9 @@ static unsigned int fsl_pwm_calculate_duty(struct fsl_pwm_chip *fpc,unsigned int period = fpc->period.mod_period +1 ;unsigned int period_ns =fsl_pwm_ticks_to_ns (fpc, period); +if (!period_ns) +return 0 ; + duty = (unsigned long long )duty_ns * period;do_div (duty, period_ns);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 162/393 erofs: set error to bio if file-backed IO fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sheng Yong <[email protected]>
[ Upstream commit 1595f15391b81815e4ef91c339991913d556c1b6 ]
If a file-backed IO fails before submitting the bio to the lower filesystem, an error is returned, but the bio->bi_status is not marked as an error. However, the error information should be passed to the end_io handler. Otherwise, the IO request will be treated as successful.
--- fs/erofs/fileio.c | 2 ++ 1 file changed, 2 insertions(+)
fs/erofs/fileio.c +2 -0
@@ -32,6 +32,8 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret) ret =0 ; }if (rq->bio.bi_end_io) { +if (ret <0 && !rq->bio.bi_status) + rq->bio.bi_status =errno_to_blk_status (ret); rq->bio.bi_end_io (&rq->bio); }else {bio_for_each_folio_all (fi, &rq->bio) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 163/393 bpf: support SKF_NET_OFF and SKF_LL_OFF on skb frags
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit d4bac0288a2b444e468e6df9cb4ed69479ddf14a ]
Classic BPF socket filters with SKB_NET_OFF and SKB_LL_OFF fail to read when these offsets extend into frags.
This has been observed with iwlwifi and reproduced with tun with IFF_NAPI_FRAGS. The below straightforward socket filter on UDP port, applied to a RAW socket, will silently miss matching packets.
const int offset_proto = offsetof(struct ip6_hdr, ip6_nxt);
const int offset_dport = sizeof(struct ip6_hdr) + offsetof(struct udphdr, dest);
struct sock_filter filter_code[] = {
BPF_STMT(BPF_LD + BPF_B + BPF_ABS, SKF_AD_OFF + SKF_AD_PKTTYPE),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, PACKET_HOST, 0, 4),
BPF_STMT(BPF_LD + BPF_B + BPF_ABS, SKF_NET_OFF + offset_proto),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_UDP, 0, 2),
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, SKF_NET_OFF + offset_dport),This is unexpected behavior. Socket filter programs should be consistent regardless of environment. Silent misses are particularly concerning as hard to detect.
Use skb_copy_bits for offsets outside linear, same as done for non-SKF_(LL|NET) offsets.
Offset is always positive after subtracting the reference threshold SKB_(LL|NET)_OFF, so is always >= skb_(mac|network)_offset. The sum of the two is an offset against skb->data, and may be negative, but it cannot point before skb->head, as skb_(mac|network)_offset would too.
This appears to go back to when frag support was introduced to sk_run_filter in linux-2.4.4, before the introduction of git.
The amount of code change and 8/16/32 bit duplication are unfortunate. But any attempt I made to be smarter saved very few LoC while complicating the code.
--- net/core/filter.c | 80 ++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 36 deletions(-)
net/core/filter.c +44 -36
@@ -218,24 +218,36 @@ BPF_CALL_3(bpf_skb_get_nlattr_nest, struct sk_buff *, skb, u32, a, u32, x)return 0 ; } +static int bpf_skb_load_helper_convert_offset (const struct sk_buff *skb,int offset) +{ +if (likely (offset >=0 )) +return offset; + +if (offset >=SKF_NET_OFF ) +return offset -SKF_NET_OFF +skb_network_offset (skb); + +if (offset >=SKF_LL_OFF &&skb_mac_header_was_set (skb)) +return offset -SKF_LL_OFF +skb_mac_offset (skb); + +return INT_MIN ; +} + BPF_CALL_4(bpf_skb_load_helper_8, const struct sk_buff *, skb, const void *, data, int, headlen, int, offset) { -u8 tmp, *ptr; +u8 tmp;const int len =sizeof (tmp); -if (offset >=0 ) { -if (headlen - offset >= len) -return *(u8 *)(data + offset); -if (!skb_copy_bits (skb, offset, &tmp,sizeof (tmp))) -return tmp; - }else { - ptr =bpf_internal_load_pointer_neg_helper (skb, offset, len); -if (likely (ptr)) -return *(u8 *)ptr; - } + offset =bpf_skb_load_helper_convert_offset (skb, offset); +if (offset ==INT_MIN ) +return -EFAULT ; -return -EFAULT ; +if (headlen - offset >= len) +return *(u8 *)(data + offset); +if (!skb_copy_bits (skb, offset, &tmp,sizeof (tmp))) +return tmp; +else +return -EFAULT ; } BPF_CALL_2(bpf_skb_load_helper_8_no_cache, const struct sk_buff *, skb,
@@ -248,21 +260,19 @@ BPF_CALL_2(bpf_skb_load_helper_8_no_cache, const struct sk_buff *, skb, BPF_CALL_4(bpf_skb_load_helper_16, const struct sk_buff *, skb, const void *, data, int, headlen, int, offset) { -__be16 tmp, *ptr; +__be16 tmp;const int len =sizeof (tmp); -if (offset >=0 ) { -if (headlen - offset >= len) -return get_unaligned_be16 (data + offset); -if (!skb_copy_bits (skb, offset, &tmp,sizeof (tmp))) -return be16_to_cpu (tmp); - }else { - ptr =bpf_internal_load_pointer_neg_helper (skb, offset, len); -if (likely (ptr)) -return get_unaligned_be16 (ptr); - } + offset =bpf_skb_load_helper_convert_offset (skb, offset); +if (offset ==INT_MIN ) +return -EFAULT ; -return -EFAULT ; +if (headlen - offset >= len) +return get_unaligned_be16 (data + offset); +if (!skb_copy_bits (skb, offset, &tmp,sizeof (tmp))) +return be16_to_cpu (tmp); +else +return -EFAULT ; } BPF_CALL_2(bpf_skb_load_helper_16_no_cache, const struct sk_buff *, skb,
@@ -275,21 +285,19 @@ BPF_CALL_2(bpf_skb_load_helper_16_no_cache, const struct sk_buff *, skb, BPF_CALL_4(bpf_skb_load_helper_32, const struct sk_buff *, skb, const void *, data, int, headlen, int, offset) { -__be32 tmp, *ptr; +__be32 tmp;const int len =sizeof (tmp); -if (likely (offset >=0 )) { -if (headlen - offset >= len) -return get_unaligned_be32 (data + offset); -if (!skb_copy_bits (skb, offset, &tmp,sizeof (tmp))) -return be32_to_cpu (tmp); - }else { - ptr =bpf_internal_load_pointer_neg_helper (skb, offset, len); -if (likely (ptr)) -return get_unaligned_be32 (ptr); - } + offset =bpf_skb_load_helper_convert_offset (skb, offset); +if (offset ==INT_MIN ) +return -EFAULT ; -return -EFAULT ; +if (headlen - offset >= len) +return get_unaligned_be32 (data + offset); +if (!skb_copy_bits (skb, offset, &tmp,sizeof (tmp))) +return be32_to_cpu (tmp); +else +return -EFAULT ; } BPF_CALL_2(bpf_skb_load_helper_32_no_cache, const struct sk_buff *, skb,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 164/393 ext4: dont treat fhandle lookup of ea_inode as FS corruption
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
[ Upstream commit 642335f3ea2b3fd6dba03e57e01fa9587843a497 ]
A file handle that userspace provides to open_by_handle_at() can legitimately contain an outdated inode number that has since been reused for another purpose - that's why the file handle also contains a generation number.
But if the inode number has been reused for an ea_inode, check_igot_inode() will notice, __ext4_iget() will go through ext4_error_inode(), and if the inode was newly created, it will also be marked as bad by iget_failed(). This all happens before the point where the inode generation is checked.
ext4_error_inode() is supposed to only be used on filesystem corruption; it should not be used when userspace just got unlucky with a stale file handle. So when this happens, let __ext4_iget() just return an error.
--- fs/ext4/inode.c | 68 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 20 deletions(-)
fs/ext4/inode.c +48 -20
@@ -4681,22 +4681,43 @@ static inline void ext4_inode_set_iversion_queried(struct inode *inode, u64 val)inode_set_iversion_queried (inode, val); } -static const char *check_igot_inode (struct inode *inode,ext4_iget_flags flags) - +static int check_igot_inode (struct inode *inode,ext4_iget_flags flags, +const char *function,unsigned int line) { +const char *err_str; +if (flags &EXT4_IGET_EA_INODE ) { -if (!(EXT4_I (inode)->i_flags &EXT4_EA_INODE_FL )) -return "missing EA_INODE flag" ; +if (!(EXT4_I (inode)->i_flags &EXT4_EA_INODE_FL )) { + err_str ="missing EA_INODE flag" ; + goto error; + }if (ext4_test_inode_state (inode,EXT4_STATE_XATTR ) || -EXT4_I (inode)->i_file_acl) -return "ea_inode with extended attributes" ; +EXT4_I (inode)->i_file_acl) { + err_str ="ea_inode with extended attributes" ; + goto error; + } }else { -if ((EXT4_I (inode)->i_flags &EXT4_EA_INODE_FL )) -return "unexpected EA_INODE flag" ; +if ((EXT4_I (inode)->i_flags &EXT4_EA_INODE_FL )) { +/* +* open_by_handle_at() could provide an old inode number +* that has since been reused for an ea_inode; this does +* not indicate filesystem corruption +*/ +if (flags &EXT4_IGET_HANDLE ) +return -ESTALE ; + err_str ="unexpected EA_INODE flag" ; + goto error; + } + } +if (is_bad_inode (inode) && !(flags &EXT4_IGET_BAD )) { + err_str ="unexpected bad inode w/o EXT4_IGET_BAD" ; + goto error; } -if (is_bad_inode (inode) && !(flags &EXT4_IGET_BAD )) -return "unexpected bad inode w/o EXT4_IGET_BAD" ; -return NULL ; +return 0 ; + +error: +ext4_error_inode (inode, function, line,0 , err_str); +return -EFSCORRUPTED ; } struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
@@ -4708,7 +4729,6 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,struct ext4_inode_info *ei;struct ext4_super_block *es =EXT4_SB (sb)->s_es;struct inode *inode; -const char *err_str;journal_t *journal =EXT4_SB (sb)->s_journal;long ret;loff_t size;
@@ -4737,10 +4757,10 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,if (!inode)return ERR_PTR (-ENOMEM );if (!(inode->i_state &I_NEW )) { -if ((err_str =check_igot_inode (inode, flags)) !=NULL ) { -ext4_error_inode (inode, function, line,0 , err_str); + ret =check_igot_inode (inode, flags, function, line); +if (ret) {iput (inode); -return ERR_PTR (-EFSCORRUPTED ); +return ERR_PTR (ret); }return inode; }
@@ -5012,13 +5032,21 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, ret = -EFSCORRUPTED ; goto bad_inode; } -if ((err_str =check_igot_inode (inode, flags)) !=NULL ) { -ext4_error_inode (inode, function, line,0 , err_str); - ret = -EFSCORRUPTED ; - goto bad_inode; + ret =check_igot_inode (inode, flags, function, line); +/* +* -ESTALE here means there is nothing inherently wrong with the inode, +* it's just not an inode we can return for an fhandle lookup. +*/ +if (ret == -ESTALE ) { +brelse (iloc.bh); +unlock_new_inode (inode); +iput (inode); +return ERR_PTR (-ESTALE ); } - +if (ret) + goto bad_inode;brelse (iloc.bh); +unlock_new_inode (inode);return inode;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 165/393 s390/pci: Fix s390_mmio_read/write syscall page fault handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Schnelle <[email protected]>
[ Upstream commit 41a0926e82f4963046876ed9a1b5f681be8087a8 ]
The s390 MMIO syscalls when using the classic PCI instructions do not cause a page fault when follow_pfnmap_start() fails due to the page not being present. Besides being a general deficiency this breaks vfio-pci's mmap() handling once VFIO_PCI_MMAP gets enabled as this lazily maps on first access. Fix this by following a failed follow_pfnmap_start() with fixup_user_page() and retrying the follow_pfnmap_start(). Also fix a VM_READ vs VM_WRITE mixup in the read syscall.
--- arch/s390/pci/pci_mmio.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
arch/s390/pci/pci_mmio.c +13 -5
@@ -171,8 +171,12 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr, args.address = mmio_addr; args.vma = vma; ret =follow_pfnmap_start (&args); -if (ret) - goto out_unlock_mmap; +if (ret) { +fixup_user_fault (current->mm, mmio_addr,FAULT_FLAG_WRITE ,NULL ); + ret =follow_pfnmap_start (&args); +if (ret) + goto out_unlock_mmap; + } io_addr = (void __iomem *)((args.pfn <<PAGE_SHIFT ) | (mmio_addr & ~PAGE_MASK ));
@@ -305,14 +309,18 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,if (!(vma->vm_flags & (VM_IO |VM_PFNMAP ))) goto out_unlock_mmap; ret = -EACCES ; -if (!(vma->vm_flags &VM_WRITE )) +if (!(vma->vm_flags &VM_READ )) goto out_unlock_mmap; args.vma = vma; args.address = mmio_addr; ret =follow_pfnmap_start (&args); -if (ret) - goto out_unlock_mmap; +if (ret) { +fixup_user_fault (current->mm, mmio_addr,0 ,NULL ); + ret =follow_pfnmap_start (&args); +if (ret) + goto out_unlock_mmap; + } io_addr = (void __iomem *)((args.pfn <<PAGE_SHIFT ) | (mmio_addr & ~PAGE_MASK ));
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 166/393 HID: pidff: Clamp PERIODIC effect period to devices logical range
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit f538183e997a9fb6087e94e71e372de967b9e56a ]
This ensures the effect can actually be played on the connected force feedback device. Adds clamping functions used instead of rescaling, as we don't want to change the characteristics of the periodic effects.
Fixes edge cases found on Moza Racing and some other hardware where the effects would not play if the period is outside the defined logical range.
Changes in v6:
- Use in-kernel clamp macro instead of a custom solution
--- drivers/hid/usbhid/hid-pidff.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-pidff.c +16 -3
@@ -15,10 +15,9 @@#include <linux/input.h> #include <linux/slab.h> #include <linux/usb.h> -#include <linux/hid.h> +#include <linux/minmax.h> -#include "usbhid.h" #define PID_EFFECTS_MAX 64#define PID_INFINITE 0xffff
@@ -192,6 +191,16 @@ struct pidff_device {u32 quirks; }; +/* +* Clamp value for a given field +*/ +static s32 pidff_clamp (s32 i,struct hid_field *field) +{ +s32 clamped =clamp (i, field->logical_minimum, field->logical_maximum); +pr_debug ("clamped from %d to %d" , i, clamped); +return clamped; +} +/* * Scale an unsigned value with range 0..max for the given field */
@@ -372,7 +381,11 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,pidff_set_signed (&pidff->set_periodic[PID_OFFSET ], effect->u.periodic.offset);pidff_set (&pidff->set_periodic[PID_PHASE ], effect->u.periodic.phase); - pidff->set_periodic[PID_PERIOD ].value[0 ] = effect->u.periodic.period; + +/* Clamp period to ensure the device can play the effect */ + pidff->set_periodic[PID_PERIOD ].value[0 ] = +pidff_clamp (effect->u.periodic.period, + pidff->set_periodic[PID_PERIOD ].field);hid_hw_request (pidff->hid, pidff->reports[PID_SET_PERIODIC ],HID_REQ_SET_REPORT );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 167/393 HID: pidff: Stop all effects before enabling actuators
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit ce52c0c939fcb568d1abe454821d5623de38b424 ]
Some PID compliant devices automatically play effects after boot (i.e. autocenter spring) that prevent the rendering of other effects since it is done outside the kernel driver.
This makes sure all the effects currently played are stopped after resetting the device.
It brings compatibility to the Brunner CLS-P joystick and others
--- drivers/hid/usbhid/hid-pidff.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/hid/usbhid/hid-pidff.c +7 -2
@@ -109,8 +109,9 @@ static const u8 pidff_pool[] = { 0x80, 0x83, 0xa9 };/* Special field key tables used to put special field keys into arrays */ #define PID_ENABLE_ACTUATORS 0 -#define PID_RESET 1 -static const u8 pidff_device_control[] = {0x97 ,0x9a }; +#define PID_STOP_ALL_EFFECTS 1 +#define PID_RESET 2 +static const u8 pidff_device_control[] = {0x97 ,0x99 ,0x9a };#define PID_CONSTANT 0#define PID_RAMP 1
@@ -1235,6 +1236,10 @@ static void pidff_reset(struct pidff_device *pidff)hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT );hid_hw_wait (hid); + pidff->device_control->value[0 ] = pidff->control_id[PID_STOP_ALL_EFFECTS ]; +hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT ); +hid_hw_wait (hid); + pidff->device_control->value[0 ] = pidff->control_id[PID_ENABLE_ACTUATORS ];hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 168/393 HID: pidff: Completely rework and fix pidff_reset function
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit cb3fd788e3fa5358602a49809c4eb4911539c9d0 ]
Previously, it was assumed that DEVICE_CONTROL usage is always an array but a lot of devices implements it as a bitmask variable. This led to the pidff_reset function not working and causing errors in such cases.
Selectors can come in three types. One selection of a set, N selections and Any selection in form of bitmask as from USB Hid Usage Tables v1.5, subsection 3.4.2.1
Added pidff_send_device_control which handles usage flag check which decides whether DEVICE_CONTROL should be handled as "One selection of a set" or "Any selection of a set".
Reset was triggered once, on device initialization. Now, it's triggered every time when uploading an effect to an empty device (no currently stored effects), tracked by pidff->effect_count variable.
--- drivers/hid/usbhid/hid-pidff.c | 138 +++++++++++++++++++++------------ 1 file changed, 89 insertions(+), 49 deletions(-)
drivers/hid/usbhid/hid-pidff.c +89 -49
@@ -109,9 +109,10 @@ static const u8 pidff_pool[] = { 0x80, 0x83, 0xa9 };/* Special field key tables used to put special field keys into arrays */ #define PID_ENABLE_ACTUATORS 0 -#define PID_STOP_ALL_EFFECTS 1 -#define PID_RESET 2 -static const u8 pidff_device_control[] = {0x97 ,0x99 ,0x9a }; +#define PID_DISABLE_ACTUATORS 1 +#define PID_STOP_ALL_EFFECTS 2 +#define PID_RESET 3 +static const u8 pidff_device_control[] = {0x97 ,0x98 ,0x99 ,0x9a };#define PID_CONSTANT 0#define PID_RAMP 1
@@ -190,6 +191,7 @@ struct pidff_device {int pid_id[PID_EFFECTS_MAX ];u32 quirks; +u8 effect_count; };/*
@@ -490,9 +492,83 @@ static int pidff_needs_set_ramp(struct ff_effect *effect, struct ff_effect *old) effect->u.ramp.end_level != old->u.ramp.end_level; } +/* +* Clear device control report +*/ +static void pidff_send_device_control (struct pidff_device *pidff,int field) +{ +int i, tmp; +int field_index = pidff->control_id[field]; + +/* Detect if the field is a bitmask variable or an array */ +if (pidff->device_control->flags &HID_MAIN_ITEM_VARIABLE ) { +hid_dbg (pidff->hid,"DEVICE_CONTROL is a bitmask\n" ); +/* Clear current bitmask */ +for (i =0 ; i <sizeof (pidff_device_control); i++) { + tmp = pidff->control_id[i]; + pidff->device_control->value[tmp] =0 ; + } + pidff->device_control->value[field_index -1 ] =1 ; + }else { +hid_dbg (pidff->hid,"DEVICE_CONTROL is an array\n" ); + pidff->device_control->value[0 ] = field_index; + } + +hid_hw_request (pidff->hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT ); +hid_hw_wait (pidff->hid); +} + +/* +* Modify actuators state +*/ +static void pidff_modify_actuators_state (struct pidff_device *pidff,bool enable) +{ +hid_dbg (pidff->hid,"%s actuators\n" , enable ?"Enable" :"Disable" ); +pidff_send_device_control (pidff, + enable ?PID_ENABLE_ACTUATORS :PID_DISABLE_ACTUATORS ); +} + +/* +* Reset the device, stop all effects, enable actuators +* Refetch pool report +*/ +static void pidff_reset (struct pidff_device *pidff) +{ +int i =0 ; + +/* We reset twice as sometimes hid_wait_io isn't waiting long enough */ +pidff_send_device_control (pidff,PID_RESET ); +pidff_send_device_control (pidff,PID_RESET ); + pidff->effect_count =0 ; + +pidff_send_device_control (pidff,PID_STOP_ALL_EFFECTS ); +pidff_modify_actuators_state (pidff,1 ); + +/* pool report is sometimes messed up, refetch it */ +hid_hw_request (pidff->hid, pidff->reports[PID_POOL ],HID_REQ_GET_REPORT ); +hid_hw_wait (pidff->hid); + +if (pidff->pool[PID_SIMULTANEOUS_MAX ].value) { +while (pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ] <2 ) { +if (i++ >20 ) { +hid_warn (pidff->hid, +"device reports %d simultaneous effects\n" , + pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ]); +break ; + } +hid_dbg (pidff->hid,"pid_pool requested again\n" ); +hid_hw_request (pidff->hid, pidff->reports[PID_POOL ], +HID_REQ_GET_REPORT ); +hid_hw_wait (pidff->hid); + } + } +} +/* * Send a request for effect upload to the device * +* Reset and enable actuators if no effects were present on the device +* * Returns 0 if device reported success, -ENOSPC if the device reported memory * is full. Upon unknown response the function will retry for 60 times, if * still unsuccessful -EIO is returned.
@@ -501,6 +577,9 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum) {int j; +if (!pidff->effect_count) +pidff_reset (pidff); + pidff->create_new_effect_type->value[0 ] = efnum;hid_hw_request (pidff->hid, pidff->reports[PID_CREATE_NEW_EFFECT ],HID_REQ_SET_REPORT );
@@ -520,6 +599,8 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum)hid_dbg (pidff->hid,"device reported free memory: %d bytes\n" , pidff->block_load[PID_RAM_POOL_AVAILABLE ].value ? pidff->block_load[PID_RAM_POOL_AVAILABLE ].value[0 ] :-1 ); + + pidff->effect_count++;return 0 ; } if (pidff->block_load_status->value[0] ==
@@ -568,12 +649,16 @@ static int pidff_playback(struct input_dev *dev, int effect_id, int value)/* * Erase effect with PID id +* Decrease the device effect counter */ static void pidff_erase_pid (struct pidff_device *pidff,int pid_id) { pidff->block_free[PID_EFFECT_BLOCK_INDEX ].value[0 ] = pid_id;hid_hw_request (pidff->hid, pidff->reports[PID_BLOCK_FREE ],HID_REQ_SET_REPORT ); + +if (pidff->effect_count >0 ) + pidff->effect_count--; }/*
@@ -1221,50 +1306,6 @@ static int pidff_init_fields(struct pidff_device *pidff, struct input_dev *dev)return 0 ; } -/* -* Reset the device -*/ -static void pidff_reset (struct pidff_device *pidff) -{ -struct hid_device *hid = pidff->hid; -int i =0 ; - - pidff->device_control->value[0 ] = pidff->control_id[PID_RESET ]; -/* We reset twice as sometimes hid_wait_io isn't waiting long enough */ -hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT ); -hid_hw_wait (hid); -hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT ); -hid_hw_wait (hid); - - pidff->device_control->value[0 ] = pidff->control_id[PID_STOP_ALL_EFFECTS ]; -hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT ); -hid_hw_wait (hid); - - pidff->device_control->value[0 ] = - pidff->control_id[PID_ENABLE_ACTUATORS ]; -hid_hw_request (hid, pidff->reports[PID_DEVICE_CONTROL ],HID_REQ_SET_REPORT ); -hid_hw_wait (hid); - -/* pool report is sometimes messed up, refetch it */ -hid_hw_request (hid, pidff->reports[PID_POOL ],HID_REQ_GET_REPORT ); -hid_hw_wait (hid); - -if (pidff->pool[PID_SIMULTANEOUS_MAX ].value) { -while (pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ] <2 ) { -if (i++ >20 ) { -hid_warn (pidff->hid, -"device reports %d simultaneous effects\n" , - pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ]); -break ; - } -hid_dbg (pidff->hid,"pid_pool requested again\n" ); -hid_hw_request (hid, pidff->reports[PID_POOL ], -HID_REQ_GET_REPORT ); -hid_hw_wait (hid); - } - } -} -/* * Test if autocenter modification is using the supported method */
@@ -1330,6 +1371,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks) pidff->hid = hid; pidff->quirks = initial_quirks; + pidff->effect_count =0 ;hid_device_io_start (hid);
@@ -1346,8 +1388,6 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks)if (error) goto fail; -pidff_reset (pidff); -if (test_bit (FF_GAIN , dev->ffbit)) {pidff_set (&pidff->device_gain[PID_DEVICE_GAIN_FIELD ],0xffff ); hid_hw_request(hid, pidff->reports[PID_DEVICE_GAIN],
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 169/393 HID: pidff: Simplify pidff_upload_effect function
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit e4bdc80ef14272ef56c38d8ca2f365fdf59cd0ba ]
Merge a bit of code that reqeusts conditional effects upload. Makes it clear, that effect handling should be identical for SPRING, DAMPER, INERTIA and FRICTION.
--- drivers/hid/usbhid/hid-pidff.c | 54 ++++++++++------------------------ 1 file changed, 16 insertions(+), 38 deletions(-)
drivers/hid/usbhid/hid-pidff.c +16 -38
@@ -770,48 +770,26 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,break ;case FF_SPRING : -if (!old) { - error =pidff_request_effect_upload (pidff, - pidff->type_id[PID_SPRING ]); -if (error) -return error; - } -if (!old ||pidff_needs_set_effect (effect, old)) -pidff_set_effect_report (pidff, effect); -if (!old ||pidff_needs_set_condition (effect, old)) -pidff_set_condition_report (pidff, effect); -break ; - -case FF_FRICTION : -if (!old) { - error =pidff_request_effect_upload (pidff, - pidff->type_id[PID_FRICTION ]); -if (error) -return error; - } -if (!old ||pidff_needs_set_effect (effect, old)) -pidff_set_effect_report (pidff, effect); -if (!old ||pidff_needs_set_condition (effect, old)) -pidff_set_condition_report (pidff, effect); -break ; -case FF_DAMPER : -if (!old) { - error =pidff_request_effect_upload (pidff, - pidff->type_id[PID_DAMPER ]); -if (error) -return error; - } -if (!old ||pidff_needs_set_effect (effect, old)) -pidff_set_effect_report (pidff, effect); -if (!old ||pidff_needs_set_condition (effect, old)) -pidff_set_condition_report (pidff, effect); -break ; -case FF_INERTIA : +case FF_FRICTION :if (!old) { +switch (effect->type) { +case FF_SPRING : + type_id =PID_SPRING ; +break ; +case FF_DAMPER : + type_id =PID_DAMPER ; +break ; +case FF_INERTIA : + type_id =PID_INERTIA ; +break ; +case FF_FRICTION : + type_id =PID_FRICTION ; +break ; + } error =pidff_request_effect_upload (pidff, - pidff->type_id[PID_INERTIA ]); + pidff->type_id[type_id]);if (error)return error; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 170/393 HID: pidff: Define values used in pidff_find_special_fields
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 1c12f136891cf4d2d4e6aa202d671a9d2171a716 ]
Makes it clear where did these values came from
--- drivers/hid/usbhid/hid-pidff.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/hid/usbhid/hid-pidff.c +15 -6
@@ -48,6 +48,14 @@ static const u8 pidff_reports[] = {/* device_control is really 0x95, but 0x96 specified as it is the usage of the only field in that report */ +/* PID special fields */ + +#define PID_EFFECT_TYPE 0x25 +#define PID_DIRECTION 0x57 +#define PID_EFFECT_OPERATION_ARRAY 0x78 +#define PID_BLOCK_LOAD_STATUS 0x8b +#define PID_DEVICE_CONTROL_ARRAY 0x96 +/* Value usage tables used to put fields and values into arrays */ #define PID_EFFECT_BLOCK_INDEX 0
@@ -1056,23 +1064,24 @@ static int pidff_find_special_fields(struct pidff_device *pidff) pidff->create_new_effect_type =pidff_find_special_field (pidff->reports[PID_CREATE_NEW_EFFECT ], -0x25 ,1 ); +PID_EFFECT_TYPE ,1 ); pidff->set_effect_type =pidff_find_special_field (pidff->reports[PID_SET_EFFECT ], -0x25 ,1 ); +PID_EFFECT_TYPE ,1 ); pidff->effect_direction =pidff_find_special_field (pidff->reports[PID_SET_EFFECT ], -0x57 ,0 ); +PID_DIRECTION ,0 ); pidff->device_control =pidff_find_special_field (pidff->reports[PID_DEVICE_CONTROL ], -0x96 , !(pidff->quirks &HID_PIDFF_QUIRK_PERMISSIVE_CONTROL )); +PID_DEVICE_CONTROL_ARRAY , + !(pidff->quirks &HID_PIDFF_QUIRK_PERMISSIVE_CONTROL )); pidff->block_load_status =pidff_find_special_field (pidff->reports[PID_BLOCK_LOAD ], -0x8b ,1 ); +PID_BLOCK_LOAD_STATUS ,1 ); pidff->effect_operation_status =pidff_find_special_field (pidff->reports[PID_EFFECT_OPERATION ], -0x78 ,1 ); +PID_EFFECT_OPERATION_ARRAY ,1 );hid_dbg (pidff->hid,"search done\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 171/393 HID: pidff: Rescale time values to match field units
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 8713107221a8ce4021ec5fa12bb50ecc8165cf08 ]
PID devices can use different exponents for time fields, while Linux Force Feedback API only supports miliseconds.
Read the exponent of a given time field and scale its value accordingly.
Changes in v7:
- Rescale all time fields, not only period
changes in v9:
- Properly assign fade_lenght, not attack_length to PID_FADE_TIME
--- drivers/hid/usbhid/hid-pidff.c | 69 ++++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 15 deletions(-)
drivers/hid/usbhid/hid-pidff.c +54 -15
@@ -22,6 +22,9 @@#define PID_EFFECTS_MAX 64#define PID_INFINITE 0xffff +/* Linux Force Feedback API uses miliseconds as time unit */ +#define FF_TIME_EXPONENT -3 +/* Report usage table used to put reports into an array */ #define PID_SET_EFFECT 0
@@ -231,6 +234,24 @@ static int pidff_rescale_signed(int i, struct hid_field *field) field->logical_minimum /-0x8000 ; } +/* +* Scale time value from Linux default (ms) to field units +*/ +static u32 pidff_rescale_time (u16 time,struct hid_field *field) +{ +u32 scaled_time = time; +int exponent = field->unit_exponent; +pr_debug ("time field exponent: %d\n" , exponent); + +for (;exponent <FF_TIME_EXPONENT ; exponent++) + scaled_time *=10 ; +for (;exponent >FF_TIME_EXPONENT ; exponent--) + scaled_time /=10 ; + +pr_debug ("time calculated from %d to %d\n" , time, scaled_time); +return scaled_time; +} +static void pidff_set (struct pidff_usage *usage,u16 value) { usage->value[0 ] =pidff_rescale (value,0xffff , usage->field);
@@ -252,6 +273,27 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value)pr_debug ("calculated from %d to %d\n" , value, usage->value[0 ]); } +static void pidff_set_time (struct pidff_usage *usage,u16 time) +{ +u32 modified_time =pidff_rescale_time (time, usage->field); + usage->value[0 ] =pidff_clamp (modified_time, usage->field); +} + +static void pidff_set_duration (struct pidff_usage *usage,u16 duration) +{ +/* Convert infinite length from Linux API (0) +to PID standard (NULL) if needed */ +if (duration ==0 ) + duration =PID_INFINITE ; + +if (duration ==PID_INFINITE ) { + usage->value[0 ] =PID_INFINITE ; +return ; + } + +pidff_set_time (usage, duration); +} +/* * Send envelope report to the device */
@@ -270,8 +312,10 @@ static void pidff_set_envelope_report(struct pidff_device *pidff,0x7fff ?0x7fff : envelope->fade_level,0x7fff , pidff->set_envelope[PID_FADE_LEVEL].field); - pidff->set_envelope[PID_ATTACK_TIME ].value[0 ] = envelope->attack_length; - pidff->set_envelope[PID_FADE_TIME ].value[0 ] = envelope->fade_length; +pidff_set_time (&pidff->set_envelope[PID_ATTACK_TIME ], + envelope->attack_length); +pidff_set_time (&pidff->set_envelope[PID_FADE_TIME ], + envelope->fade_length); hid_dbg(pidff->hid, "attack %u => %d\n", envelope->attack_level,
@@ -340,14 +384,12 @@ static void pidff_set_effect_report(struct pidff_device *pidff, pidff->set_effect_type->value[0 ] = pidff->create_new_effect_type->value[0 ]; -/* Convert infinite length from Linux API (0) -to PID standard (NULL) if needed */ - pidff->set_effect[PID_DURATION ].value[0 ] = - effect->replay.length ==0 ?PID_INFINITE : effect->replay.length; +pidff_set_duration (&pidff->set_effect[PID_DURATION ], + effect->replay.length); pidff->set_effect[PID_TRIGGER_BUTTON ].value[0 ] = effect->trigger.button; - pidff->set_effect[PID_TRIGGER_REPEAT_INT ].value[0 ] = - effect->trigger.interval; +pidff_set_time (&pidff->set_effect[PID_TRIGGER_REPEAT_INT ], + effect->trigger.interval); pidff->set_effect[PID_GAIN ].value[0 ] = pidff->set_effect[PID_GAIN ].field->logical_maximum; pidff->set_effect[PID_DIRECTION_ENABLE ].value[0 ] =1 ;
@@ -360,7 +402,8 @@ static void pidff_set_effect_report(struct pidff_device *pidff,/* Omit setting delay field if it's missing */ if (!(pidff->quirks &HID_PIDFF_QUIRK_MISSING_DELAY )) - pidff->set_effect[PID_START_DELAY ].value[0 ] = effect->replay.delay; +pidff_set_time (&pidff->set_effect[PID_START_DELAY ], + effect->replay.delay);hid_hw_request (pidff->hid, pidff->reports[PID_SET_EFFECT ],HID_REQ_SET_REPORT );
@@ -392,15 +435,11 @@ static void pidff_set_periodic_report(struct pidff_device *pidff,pidff_set_signed (&pidff->set_periodic[PID_OFFSET ], effect->u.periodic.offset);pidff_set (&pidff->set_periodic[PID_PHASE ], effect->u.periodic.phase); - -/* Clamp period to ensure the device can play the effect */ - pidff->set_periodic[PID_PERIOD ].value[0 ] = -pidff_clamp (effect->u.periodic.period, - pidff->set_periodic[PID_PERIOD ].field); +pidff_set_time (&pidff->set_periodic[PID_PERIOD ], + effect->u.periodic.period);hid_hw_request (pidff->hid, pidff->reports[PID_SET_PERIODIC ],HID_REQ_SET_REPORT ); - }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 172/393 HID: pidff: Factor out code for setting gain
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit f7ebf0b11b9e04bf59c438ad14f0115b12aa2f44 ]
Makes it possible to easily set gain from inside hid-pidff.c
Changes in v7:
- Check if device gain field exists before setting device gain
--- drivers/hid/usbhid/hid-pidff.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
drivers/hid/usbhid/hid-pidff.c +15 -11
@@ -539,6 +539,19 @@ static int pidff_needs_set_ramp(struct ff_effect *effect, struct ff_effect *old) effect->u.ramp.end_level != old->u.ramp.end_level; } +/* +* Set device gain +*/ +static void pidff_set_gain_report (struct pidff_device *pidff,u16 gain) +{ +if (!pidff->device_gain[PID_DEVICE_GAIN_FIELD ].field) +return ; + +pidff_set (&pidff->device_gain[PID_DEVICE_GAIN_FIELD ], gain); +hid_hw_request (pidff->hid, pidff->reports[PID_DEVICE_GAIN ], +HID_REQ_SET_REPORT ); +} +/* * Clear device control report */
@@ -865,11 +878,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,*/ static void pidff_set_gain (struct input_dev *dev,u16 gain) { -struct pidff_device *pidff = dev->ff->private; - -pidff_set (&pidff->device_gain[PID_DEVICE_GAIN_FIELD ], gain); -hid_hw_request (pidff->hid, pidff->reports[PID_DEVICE_GAIN ], -HID_REQ_SET_REPORT ); +pidff_set_gain_report (dev->ff->private, gain); }static void pidff_autocenter (struct pidff_device *pidff,u16 magnitude)
@@ -1414,12 +1423,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks)if (error) goto fail; -if (test_bit (FF_GAIN , dev->ffbit)) { -pidff_set (&pidff->device_gain[PID_DEVICE_GAIN_FIELD ],0xffff ); -hid_hw_request (hid, pidff->reports[PID_DEVICE_GAIN ], -HID_REQ_SET_REPORT ); - } - +pidff_set_gain_report (pidff,0xffff ); error =pidff_check_autocenter (pidff, dev);if (error) goto fail;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 173/393 HID: pidff: Move all hid-pidff definitions to a dedicated header
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 0d24d4b1da96df9fc5ff36966f40f980ef864d46 ]
Do not clutter hid includes with stuff not needed outside of the kernel.
--- drivers/hid/hid-universal-pidff.c | 3 ++- drivers/hid/usbhid/hid-core.c | 1 + drivers/hid/usbhid/hid-pidff.c | 3 ++- drivers/hid/usbhid/hid-pidff.h | 33 +++++++++++++++++++++++++++++++ include/linux/hid.h | 15 -------------- 5 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 drivers/hid/usbhid/hid-pidff.h
drivers/hid/hid-universal-pidff.c +2 -1
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/input-event-codes.h> #include "hid-ids.h" +#include "usbhid/hid-pidff.h" #define JOY_RANGE (BTN_DEAD - BTN_JOYSTICK + 1)
@@ -89,7 +90,7 @@ static int universal_pidff_probe(struct hid_device *hdev, }/* Check if HID_PID support is enabled */ -int (*init_function)(struct hid_device *,__u32 ); +int (*init_function)(struct hid_device *,u32 ); init_function = hid_pidff_init_with_quirks;if (!init_function) {
drivers/hid/usbhid/hid-core.c +1 -0
@@ -35,6 +35,7 @@#include <linux/hid-debug.h> #include <linux/hidraw.h> #include "usbhid.h" +#include "hid-pidff.h" /* * Version Information
drivers/hid/usbhid/hid-pidff.c +2 -1
@@ -12,6 +12,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include "hid-pidff.h" #include <linux/input.h> #include <linux/slab.h> #include <linux/usb.h>
@@ -1383,7 +1384,7 @@ static int pidff_check_autocenter(struct pidff_device *pidff,* Check if the device is PID and initialize it * Set initial quirks */ -int hid_pidff_init_with_quirks (struct hid_device *hid,__u32 initial_quirks) +int hid_pidff_init_with_quirks (struct hid_device *hid,u32 initial_quirks) {struct pidff_device *pidff; struct hid_input *hidinput = list_entry(hid->inputs.next,
drivers/hid/usbhid/hid-pidff.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __HID_PIDFF_H +#define __HID_PIDFF_H + +#include <linux/hid.h> + +/* HID PIDFF quirks */ + +/* Delay field (0xA7) missing. Skip it during set effect report upload */ +#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) + +/* Missing Paramter block offset (0x23). Skip it during SET_CONDITION +report upload */ +#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1) + +/* Initialise device control field even if logical_minimum != 1 */ +#define HID_PIDFF_QUIRK_PERMISSIVE_CONTROL BIT(2) + +/* Use fixed 0x4000 direction during SET_EFFECT report upload */ +#define HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(3) + +/* Force all periodic effects to be uploaded as SINE */ +#define HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY BIT(4) + +#ifdef CONFIG_HID_PID +int hid_pidff_init (struct hid_device *hid); +int hid_pidff_init_with_quirks (struct hid_device *hid,u32 initial_quirks); +#else +#define hid_pidff_init NULL +#define hid_pidff_init_with_quirks NULL +#endif + +#endif
include/linux/hid.h +0 -15
@@ -1221,21 +1221,6 @@ unsigned long hid_lookup_quirk(const struct hid_device *hdev);int hid_quirks_init (char **quirks_param,__u16 bus,int count);void hid_quirks_exit (__u16 bus); -#ifdef CONFIG_HID_PID -int hid_pidff_init (struct hid_device *hid); -int hid_pidff_init_with_quirks (struct hid_device *hid,__u32 initial_quirks); -#else -#define hid_pidff_init NULL -#define hid_pidff_init_with_quirks NULL -#endif - -/* HID PIDFF quirks */ -#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) -#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1) -#define HID_PIDFF_QUIRK_PERMISSIVE_CONTROL BIT(2) -#define HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(3) -#define HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY BIT(4) -#define dbg_hid (fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)#define hid_err (hid, fmt, ...) \
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 174/393 HID: pidff: Simplify pidff_rescale_signed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 4eb9c2ee538b62dc5dcae192297c3a4044b7ade5 ]
This function overrelies on ternary operators and makes it hard to parse it mentally. New version makes it very easy to understand.
--- drivers/hid/usbhid/hid-pidff.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hid/usbhid/hid-pidff.c +3 -3
@@ -230,9 +230,9 @@ static int pidff_rescale(int i, int max, struct hid_field *field)*/ static int pidff_rescale_signed (int i,struct hid_field *field) { -return i ==0 ?0 : i > -0 ? i * field->logical_maximum /0x7fff : i * - field->logical_minimum /-0x8000 ; +if (i >0 )return i * field->logical_maximum /0x7fff ; +if (i <0 )return i * field->logical_minimum /-0x8000 ; +return 0 ; }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 175/393 HID: pidff: Use macros instead of hardcoded min/max values for shorts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 21755162456902998f8d9897086b8c980c540df5 ]
Makes it obvious these magic values ARE in fact derived from min and max values for s16 and u16
--- drivers/hid/usbhid/hid-pidff.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/hid/usbhid/hid-pidff.c +12 -12
@@ -21,7 +21,7 @@#define PID_EFFECTS_MAX 64 -#define PID_INFINITE 0xffff +#define PID_INFINITE U16_MAX/* Linux Force Feedback API uses miliseconds as time unit */ #define FF_TIME_EXPONENT -3
@@ -226,12 +226,12 @@ static int pidff_rescale(int i, int max, struct hid_field *field) }/* -* Scale a signed value in range -0x8000..0x7fff for the given field +* Scale a signed value in range S16_MIN..S16_MAX for the given field */ static int pidff_rescale_signed (int i,struct hid_field *field) { -if (i >0 )return i * field->logical_maximum /0x7fff ; -if (i <0 )return i * field->logical_minimum /-0x8000 ; +if (i >0 )return i * field->logical_maximum /S16_MAX ; +if (i <0 )return i * field->logical_minimum /S16_MIN ;return 0 ; }
@@ -255,7 +255,7 @@ static u32 pidff_rescale_time(u16 time, struct hid_field *field)static void pidff_set (struct pidff_usage *usage,u16 value) { - usage->value[0 ] =pidff_rescale (value,0xffff , usage->field); + usage->value[0 ] =pidff_rescale (value,U16_MAX , usage->field);pr_debug ("calculated from %d to %d\n" , value, usage->value[0 ]); }
@@ -266,10 +266,10 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value)else {if (value <0 ) usage->value[0 ] = -pidff_rescale (-value,0x8000 , usage->field); +pidff_rescale (-value, -S16_MIN , usage->field);else usage->value[0 ] = -pidff_rescale (value,0x7fff , usage->field); +pidff_rescale (value,S16_MAX , usage->field); }pr_debug ("calculated from %d to %d\n" , value, usage->value[0 ]); }
@@ -306,11 +306,11 @@ static void pidff_set_envelope_report(struct pidff_device *pidff, pidff->set_envelope[PID_ATTACK_LEVEL ].value[0 ] =pidff_rescale (envelope->attack_level > -0x7fff ?0x7fff : envelope->attack_level,0x7fff , +S16_MAX ?S16_MAX : envelope->attack_level,S16_MAX , pidff->set_envelope[PID_ATTACK_LEVEL ].field); pidff->set_envelope[PID_FADE_LEVEL ].value[0 ] =pidff_rescale (envelope->fade_level > -0x7fff ?0x7fff : envelope->fade_level,0x7fff , +S16_MAX ?S16_MAX : envelope->fade_level,S16_MAX , pidff->set_envelope[PID_FADE_LEVEL ].field); pidff_set_time(&pidff->set_envelope[PID_ATTACK_TIME],
@@ -399,7 +399,7 @@ static void pidff_set_effect_report(struct pidff_device *pidff, pidff->effect_direction->value[0 ] =pidff_rescale ( pidff->quirks &HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION ?PIDFF_FIXED_WHEEL_DIRECTION : effect->direction, -0xffff , pidff->effect_direction); +U16_MAX , pidff->effect_direction);/* Omit setting delay field if it's missing */ if (!(pidff->quirks &HID_PIDFF_QUIRK_MISSING_DELAY ))
@@ -1366,7 +1366,7 @@ static int pidff_check_autocenter(struct pidff_device *pidff,if (pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value[0 ] == pidff->block_load[PID_EFFECT_BLOCK_INDEX ].field->logical_minimum +1 ) { -pidff_autocenter (pidff,0xffff ); +pidff_autocenter (pidff,U16_MAX );set_bit (FF_AUTOCENTER , dev->ffbit); }else { hid_notice(pidff->hid,
@@ -1424,7 +1424,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, u32 initial_quirks)if (error) goto fail; -pidff_set_gain_report (pidff,0xffff ); +pidff_set_gain_report (pidff,U16_MAX ); error =pidff_check_autocenter (pidff, dev);if (error) goto fail;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 176/393 HID: pidff: Factor out pool report fetch and remove excess declaration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 5d98079b2d0186e1f586301a9c00144a669416a8 ]
We only want to refetch the pool report during device init. Reset function is now called when uploading effects to an empty device so extract pool fetch to separate function and call it from init before autocenter check (autocenter check triggered reset during init).
Remove a superfluous pointer declaration and assigment as well.
--- drivers/hid/usbhid/hid-pidff.c | 45 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/hid/usbhid/hid-pidff.c +24 -21
@@ -591,12 +591,9 @@ static void pidff_modify_actuators_state(struct pidff_device *pidff, bool enable/* * Reset the device, stop all effects, enable actuators -* Refetch pool report */ static void pidff_reset (struct pidff_device *pidff) { -int i =0 ; -/* We reset twice as sometimes hid_wait_io isn't waiting long enough */ pidff_send_device_control (pidff,PID_RESET );pidff_send_device_control (pidff,PID_RESET );
@@ -604,23 +601,29 @@ static void pidff_reset(struct pidff_device *pidff)pidff_send_device_control (pidff,PID_STOP_ALL_EFFECTS );pidff_modify_actuators_state (pidff,1 ); +} -/* pool report is sometimes messed up, refetch it */ -hid_hw_request (pidff->hid, pidff->reports[PID_POOL ],HID_REQ_GET_REPORT ); -hid_hw_wait (pidff->hid); +/* +* Refetch pool report +*/ +static void pidff_fetch_pool (struct pidff_device *pidff) +{ +if (!pidff->pool[PID_SIMULTANEOUS_MAX ].value) +return ; -if (pidff->pool[PID_SIMULTANEOUS_MAX ].value) { -while (pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ] <2 ) { -if (i++ >20 ) { -hid_warn (pidff->hid, -"device reports %d simultaneous effects\n" , - pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ]); -break ; - } -hid_dbg (pidff->hid,"pid_pool requested again\n" ); -hid_hw_request (pidff->hid, pidff->reports[PID_POOL ], -HID_REQ_GET_REPORT ); -hid_hw_wait (pidff->hid); +int i =0 ; +while (pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ] <2 ) { +hid_dbg (pidff->hid,"pid_pool requested again\n" ); +hid_hw_request (pidff->hid, pidff->reports[PID_POOL ], +HID_REQ_GET_REPORT ); +hid_hw_wait (pidff->hid); + +/* break after 20 tries with SIMULTANEOUS_MAX < 2 */ +if (i++ >20 ) { +hid_warn (pidff->hid, +"device reports %d simultaneous effects\n" , + pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ]); +break ; } } }
@@ -916,9 +919,7 @@ static void pidff_autocenter(struct pidff_device *pidff, u16 magnitude)*/ static void pidff_set_autocenter (struct input_dev *dev,u16 magnitude) { -struct pidff_device *pidff = dev->ff->private; - -pidff_autocenter (pidff, magnitude); +pidff_autocenter (dev->ff->private, magnitude); }/*
@@ -1424,6 +1425,8 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, u32 initial_quirks)if (error) goto fail; +/* pool report is sometimes messed up, refetch it */ +pidff_fetch_pool (pidff);pidff_set_gain_report (pidff,U16_MAX ); error =pidff_check_autocenter (pidff, dev);if (error)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 177/393 HID: pidff: Make sure to fetch pool before checking SIMULTANEOUS_MAX
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 1f650dcec32d22deb1d6db12300a2b98483099a9 ]
As noted by Anssi some 20 years ago, pool report is sometimes messed up. This worked fine on many devices but casued oops on VRS DirectForce PRO.
Here, we're making sure pool report is refetched before trying to access any of it's fields. While loop was replaced with a for loop + exit conditions were moved aroud to decrease the possibility of creating an infinite loop scenario.
--- drivers/hid/usbhid/hid-pidff.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-)
drivers/hid/usbhid/hid-pidff.c +13 -16
@@ -604,28 +604,25 @@ static void pidff_reset(struct pidff_device *pidff) }/* -* Refetch pool report +* Fetch pool report */ static void pidff_fetch_pool (struct pidff_device *pidff) { -if (!pidff->pool[PID_SIMULTANEOUS_MAX ].value) -return ; +int i; +struct hid_device *hid = pidff->hid; -int i =0 ; -while (pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ] <2 ) { -hid_dbg (pidff->hid,"pid_pool requested again\n" ); -hid_hw_request (pidff->hid, pidff->reports[PID_POOL ], -HID_REQ_GET_REPORT ); -hid_hw_wait (pidff->hid); +/* Repeat if PID_SIMULTANEOUS_MAX < 2 to make sure it's correct */ +for (i =0 ; i <20 ; i++) { +hid_hw_request (hid, pidff->reports[PID_POOL ],HID_REQ_GET_REPORT ); +hid_hw_wait (hid); -/* break after 20 tries with SIMULTANEOUS_MAX < 2 */ -if (i++ >20 ) { -hid_warn (pidff->hid, -"device reports %d simultaneous effects\n" , - pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ]); -break ; - } +if (!pidff->pool[PID_SIMULTANEOUS_MAX ].value) +return ; +if (pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ] >=2 ) +return ; } +hid_warn (hid,"device reports %d simultaneous effects\n" , + pidff->pool[PID_SIMULTANEOUS_MAX ].value[0 ]); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 178/393 HID: hid-universal-pidff: Add Asetek wheelbases support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit c385f61108d403633e8cfbdae15b35ccf7cee686 ]
Adds Asetek vendor id and product ids for:
- Invicta
- Forte
- La Prima
- Tony Kanaan
v2:
- Misc spelling fix in driver loaded info
v3:
- Chanage Oleg's name order
--- drivers/hid/hid-ids.h | 6 ++++++ drivers/hid/hid-universal-pidff.c | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/hid/hid-ids.h +6 -0
@@ -190,6 +190,12 @@#define USB_DEVICE_ID_APPLE_TOUCHBAR_BACKLIGHT 0x8102#define USB_DEVICE_ID_APPLE_TOUCHBAR_DISPLAY 0x8302 +#define USB_VENDOR_ID_ASETEK 0x2433 +#define USB_DEVICE_ID_ASETEK_INVICTA 0xf300 +#define USB_DEVICE_ID_ASETEK_FORTE 0xf301 +#define USB_DEVICE_ID_ASETEK_LA_PRIMA 0xf303 +#define USB_DEVICE_ID_ASETEK_TONY_KANAAN 0xf306 +#define USB_VENDOR_ID_ASUS 0x0486#define USB_DEVICE_ID_ASUS_T91MT 0x0185#define USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO 0x0186
drivers/hid/hid-universal-pidff.c +7 -3
@@ -4,7 +4,7 @@* hid-pidff wrapper for PID-enabled devices * Handles device reports, quirks and extends usable button range * -* Copyright (c) 2024, 2025 Makarenko Oleg +* Copyright (c) 2024, 2025 Oleg Makarenko * Copyright (c) 2024, 2025 Tomasz Pakuła */
@@ -104,7 +104,7 @@ static int universal_pidff_probe(struct hid_device *hdev, goto err; } -hid_info (hdev,"Universal pidff driver loaded sucesfully!" ); +hid_info (hdev,"Universal pidff driver loaded sucessfully!" );return 0 ; err:
@@ -179,6 +179,10 @@ static const struct hid_device_id universal_pidff_devices[] = { .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_LITE_STAR_GT987_FF), .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_INVICTA) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_FORTE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_LA_PRIMA) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_TONY_KANAAN) }, { } };MODULE_DEVICE_TABLE (hid, universal_pidff_devices);
@@ -194,5 +198,5 @@ module_hid_driver(universal_pidff);MODULE_DESCRIPTION ("Universal driver for USB PID Force Feedback devices" );MODULE_LICENSE ("GPL" ); -MODULE_AUTHOR ("Makarenko Oleg <[email protected]>" ); +MODULE_AUTHOR ("Oleg Makarenko <[email protected]>" );MODULE_AUTHOR ("Tomasz Pakuła <[email protected]>" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 179/393 HID: pidff: Comment and code style update
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit e19675c2477491401b236ed939ad5a43ddc339af ]
Update comments to fully conform to the Linux comment styling. Define Linux infinite effect duration (0) as FF_INFINITE
Chanage Oleg's name order
--- drivers/hid/usbhid/hid-pidff.c | 57 +++++++++++++++------------------- 1 file changed, 25 insertions(+), 32 deletions(-)
drivers/hid/usbhid/hid-pidff.c +25 -32
@@ -3,13 +3,9 @@* Force feedback driver for USB HID PID compliant devices * * Copyright (c) 2005, 2006 Anssi Hannula <[email protected]> +* Upgraded 2025 by Oleg Makarenko and Tomasz Pakuła */ -/* -*/ - -/* #define DEBUG */ -#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include "hid-pidff.h"
@@ -25,9 +21,9 @@/* Linux Force Feedback API uses miliseconds as time unit */ #define FF_TIME_EXPONENT -3 +#define FF_INFINITE 0/* Report usage table used to put reports into an array */ -#define PID_SET_EFFECT 0#define PID_EFFECT_OPERATION 1#define PID_DEVICE_GAIN 2
@@ -48,12 +44,12 @@ static const u8 pidff_reports[] = {0x21 ,0x77 ,0x7d ,0x7f ,0x89 ,0x90 ,0x96 ,0xab ,0x5a ,0x5f ,0x6e ,0x73 ,0x74 }; - -/* device_control is really 0x95, but 0x96 specified as it is the usage of -the only field in that report */ +/* +* device_control is really 0x95, but 0x96 specified +* as it is the usage of the only field in that report. +*/ /* PID special fields */ -#define PID_EFFECT_TYPE 0x25#define PID_DIRECTION 0x57#define PID_EFFECT_OPERATION_ARRAY 0x78
@@ -61,7 +57,6 @@ the only field in that report */#define PID_DEVICE_CONTROL_ARRAY 0x96/* Value usage tables used to put fields and values into arrays */ -#define PID_EFFECT_BLOCK_INDEX 0#define PID_DURATION 1
@@ -119,7 +114,6 @@ static const u8 pidff_device_gain[] = { 0x7e };static const u8 pidff_pool[] = {0x80 ,0x83 ,0xa9 };/* Special field key tables used to put special field keys into arrays */ -#define PID_ENABLE_ACTUATORS 0#define PID_DISABLE_ACTUATORS 1#define PID_STOP_ALL_EFFECTS 2
@@ -176,8 +170,10 @@ struct pidff_device {struct pidff_usage effect_operation[sizeof (pidff_effect_operation)];struct pidff_usage block_free[sizeof (pidff_block_free)]; -/* Special field is a field that is not composed of -usage<->value pairs that pidff_usage values are */ +/* +* Special field is a field that is not composed of +* usage<->value pairs that pidff_usage values are +*/ /* Special field in create_new_effect */ struct hid_field *create_new_effect_type;
@@ -222,7 +218,7 @@ static s32 pidff_clamp(s32 i, struct hid_field *field)static int pidff_rescale (int i,int max,struct hid_field *field) {return i * (field->logical_maximum - field->logical_minimum) / max + - field->logical_minimum; + field->logical_minimum; }/*
@@ -282,9 +278,8 @@ static void pidff_set_time(struct pidff_usage *usage, u16 time)static void pidff_set_duration (struct pidff_usage *usage,u16 duration) { -/* Convert infinite length from Linux API (0) -to PID standard (NULL) if needed */ -if (duration ==0 ) +/* Infinite value conversion from Linux API -> PID */ +if (duration ==FF_INFINITE ) duration =PID_INFINITE ;if (duration ==PID_INFINITE ) {
@@ -302,16 +297,16 @@ static void pidff_set_envelope_report(struct pidff_device *pidff, struct ff_envelope *envelope) { pidff->set_envelope[PID_EFFECT_BLOCK_INDEX ].value[0 ] = - pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value[0 ]; + pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value[0 ]; pidff->set_envelope[PID_ATTACK_LEVEL ].value[0 ] = -pidff_rescale (envelope->attack_level > -S16_MAX ?S16_MAX : envelope->attack_level,S16_MAX , - pidff->set_envelope[PID_ATTACK_LEVEL ].field); +pidff_rescale (envelope->attack_level > +S16_MAX ?S16_MAX : envelope->attack_level,S16_MAX , + pidff->set_envelope[PID_ATTACK_LEVEL ].field); pidff->set_envelope[PID_FADE_LEVEL ].value[0 ] = -pidff_rescale (envelope->fade_level > -S16_MAX ?S16_MAX : envelope->fade_level,S16_MAX , - pidff->set_envelope[PID_FADE_LEVEL ].field); +pidff_rescale (envelope->fade_level > +S16_MAX ?S16_MAX : envelope->fade_level,S16_MAX , + pidff->set_envelope[PID_FADE_LEVEL ].field);pidff_set_time (&pidff->set_envelope[PID_ATTACK_TIME ], envelope->attack_length);
@@ -702,9 +697,7 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)static int pidff_playback (struct input_dev *dev,int effect_id,int value) {struct pidff_device *pidff = dev->ff->private; -pidff_playback_pid (pidff, pidff->pid_id[effect_id], value); -return 0 ; }
@@ -732,8 +725,11 @@ static int pidff_erase_effect(struct input_dev *dev, int effect_id)hid_dbg (pidff->hid,"starting to erase %d/%d\n" , effect_id, pidff->pid_id[effect_id]); -/* Wait for the queue to clear. We do not want a full fifo to -prevent the effect removal. */ + +/* +* Wait for the queue to clear. We do not want +* a full fifo to prevent the effect removal. +*/ hid_hw_wait (pidff->hid);pidff_playback_pid (pidff, pid_id,0 );pidff_erase_pid (pidff, pid_id);
@@ -1239,7 +1235,6 @@ static int pidff_find_effects(struct pidff_device *pidff,set_bit (FF_FRICTION , dev->ffbit);return 0 ; - }#define PIDFF_FIND_FIELDS (name, report, strict) \
@@ -1370,12 +1365,10 @@ static int pidff_check_autocenter(struct pidff_device *pidff,hid_notice (pidff->hid,"device has unknown autocenter control method\n" ); } -pidff_erase_pid (pidff, pidff->block_load[PID_EFFECT_BLOCK_INDEX ].value[0 ]);return 0 ; - }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 180/393 HID: pidff: Support device error response from PID_BLOCK_LOAD
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 9d4174dc4a234408d91fd83725e1899766cd1731 ]
If an error happens on the device, the driver will no longer fall into the trap of reading this status 60 times before it decides that this reply won't change to success/memory full.
Greatly reduces communication overhead during device error situation.
--- drivers/hid/usbhid/hid-pidff.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/hid/usbhid/hid-pidff.c +7 -1
@@ -138,7 +138,8 @@ static const u8 pidff_effect_types[] = {#define PID_BLOCK_LOAD_SUCCESS 0#define PID_BLOCK_LOAD_FULL 1 -static const u8 pidff_block_load_status[] = {0x8c ,0x8d }; +#define PID_BLOCK_LOAD_ERROR 2 +static const u8 pidff_block_load_status[] = {0x8c ,0x8d ,0x8e };#define PID_EFFECT_START 0#define PID_EFFECT_STOP 1
@@ -666,6 +667,11 @@ static int pidff_request_effect_upload(struct pidff_device *pidff, int efnum) pidff->block_load[PID_RAM_POOL_AVAILABLE].value[0] : -1);return -ENOSPC ; } +if (pidff->block_load_status->value[0 ] == + pidff->status_id[PID_BLOCK_LOAD_ERROR ]) { +hid_dbg (pidff->hid,"device error during effect creation\n" ); +return -EREMOTEIO ; + } }hid_err (pidff->hid,"pid_block_load failed 60 times\n" );return -EIO ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 181/393 HID: pidff: Remove redundant call to pidff_find_special_keys
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 1bd55e79cbc0ea2d6a65f51e06c891806359c2f2 ]
Probably left out as a mistake after Anssi created the helper macro
--- drivers/hid/usbhid/hid-pidff.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/hid/usbhid/hid-pidff.c +0 -4
@@ -1159,10 +1159,6 @@ static int pidff_find_special_fields(struct pidff_device *pidff)return -1 ; } -pidff_find_special_keys (pidff->control_id, pidff->device_control, - pidff_device_control, -sizeof (pidff_device_control)); -PIDFF_FIND_SPECIAL_KEYS (control_id, device_control, device_control); if (!PIDFF_FIND_SPECIAL_KEYS(type_id, create_new_effect_type,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 182/393 HID: pidff: Rename two functions to align them with naming convention
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit bbeface1051142bcb0473fdcc89102ea5b31607d ]
Driver uses "set" everywhere to indicate setting report values and requesting HID_REQ_SET_REPORT
--- drivers/hid/usbhid/hid-pidff.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/hid/usbhid/hid-pidff.c +7 -7
@@ -552,7 +552,7 @@ static void pidff_set_gain_report(struct pidff_device *pidff, u16 gain)/* * Clear device control report */ -static void pidff_send_device_control (struct pidff_device *pidff,int field) +static void pidff_set_device_control (struct pidff_device *pidff,int field) {int i, tmp;int field_index = pidff->control_id[field];
@@ -578,10 +578,10 @@ static void pidff_send_device_control(struct pidff_device *pidff, int field)/* * Modify actuators state */ -static void pidff_modify_actuators_state (struct pidff_device *pidff,bool enable) +static void pidff_set_actuators (struct pidff_device *pidff,bool enable) {hid_dbg (pidff->hid,"%s actuators\n" , enable ?"Enable" :"Disable" ); -pidff_send_device_control (pidff, +pidff_set_device_control (pidff, enable ?PID_ENABLE_ACTUATORS :PID_DISABLE_ACTUATORS ); }
@@ -591,12 +591,12 @@ static void pidff_modify_actuators_state(struct pidff_device *pidff, bool enablestatic void pidff_reset (struct pidff_device *pidff) {/* We reset twice as sometimes hid_wait_io isn't waiting long enough */ -pidff_send_device_control (pidff,PID_RESET ); -pidff_send_device_control (pidff,PID_RESET ); +pidff_set_device_control (pidff,PID_RESET ); +pidff_set_device_control (pidff,PID_RESET ); pidff->effect_count =0 ; -pidff_send_device_control (pidff,PID_STOP_ALL_EFFECTS ); -pidff_modify_actuators_state (pidff,1 ); +pidff_set_device_control (pidff,PID_STOP_ALL_EFFECTS ); +pidff_set_actuators (pidff,1 ); }/*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 183/393 HID: pidff: Clamp effect playback LOOP_COUNT value
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 0c6673e3d17b258b8c5c7331d28bf6c49f25ed30 ]
Ensures the loop count will never exceed the logical_maximum.
Fixes implementation errors happening when applications use the max value of int32/DWORD as the effect iterations. This could be observed when running software both native and in wine.
--- drivers/hid/usbhid/hid-pidff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/usbhid/hid-pidff.c +2 -1
@@ -690,7 +690,8 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n) }else { pidff->effect_operation_status->value[0 ] = pidff->operation_id[PID_EFFECT_START ]; - pidff->effect_operation[PID_LOOP_COUNT ].value[0 ] = n; + pidff->effect_operation[PID_LOOP_COUNT ].value[0 ] = +pidff_clamp (n, pidff->effect_operation[PID_LOOP_COUNT ].field); } hid_hw_request(pidff->hid, pidff->reports[PID_EFFECT_OPERATION],
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 184/393 HID: pidff: Compute INFINITE value instead of using hardcoded 0xffff
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit 1a575044d516972a1d036d54c0180b9085e21dc6 ]
As per USB PID standard:
INFINITE - Referrers to the maximum value of a range. i.e. if in an 8 bit unsigned field the value of 255 would indicate INFINITE.
Detecting 0xffff (U16_MAX) is still important as we MIGHT get this value as infinite from some native software as 0 was never actually defined in Linux' FF api as the infinite value. I'm working on it though.
--- drivers/hid/usbhid/hid-pidff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/usbhid/hid-pidff.c +2 -1
@@ -283,8 +283,9 @@ static void pidff_set_duration(struct pidff_usage *usage, u16 duration)if (duration ==FF_INFINITE ) duration =PID_INFINITE ; +/* PID defines INFINITE as the max possible value for duration field */ if (duration ==PID_INFINITE ) { - usage->value[0 ] =PID_INFINITE ; + usage->value[0 ] = (1U << usage->field->report_size) -1 ;return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 185/393 HID: pidff: Fix 90 degrees direction name North -> East
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit f98ecedbeca34a8df1460c3a03cce32639c99a9d ]
--- drivers/hid/usbhid/hid-pidff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/usbhid/hid-pidff.c +1 -1
@@ -145,7 +145,7 @@ static const u8 pidff_block_load_status[] = { 0x8c, 0x8d, 0x8e};#define PID_EFFECT_STOP 1static const u8 pidff_effect_operation_status[] = {0x79 ,0x7b }; -/* Polar direction 90 degrees (North) */ +/* Polar direction 90 degrees (East) */ #define PIDFF_FIXED_WHEEL_DIRECTION 0x4000struct pidff_usage {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 186/393 HID: pidff: Fix set_device_control()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tomasz Pakuła <[email protected]>
[ Upstream commit e2fa0bdf08a70623f24ed52f2037a330999d9800 ]
As the search for Device Control report is permissive, make sure the desired field was actually found, before trying to set it.
Fix bitmask clearing as it was erronously using index instead of index - 1 (HID arrays index is 1-based).
Add last two missing Device Control usages to the defined array. PID_PAUSE and PID_CONTINUE.
--- drivers/hid/usbhid/hid-pidff.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/hid/usbhid/hid-pidff.c +15 -5
@@ -118,7 +118,9 @@ static const u8 pidff_pool[] = { 0x80, 0x83, 0xa9 };#define PID_DISABLE_ACTUATORS 1#define PID_STOP_ALL_EFFECTS 2#define PID_RESET 3 -static const u8 pidff_device_control[] = {0x97 ,0x98 ,0x99 ,0x9a }; +#define PID_PAUSE 4 +#define PID_CONTINUE 5 +static const u8 pidff_device_control[] = {0x97 ,0x98 ,0x99 ,0x9a ,0x9b ,0x9c };#define PID_CONSTANT 0#define PID_RAMP 1
@@ -551,21 +553,29 @@ static void pidff_set_gain_report(struct pidff_device *pidff, u16 gain) }/* -* Clear device control report +* Send device control report to the device */ static void pidff_set_device_control (struct pidff_device *pidff,int field) { -int i, tmp; +int i, index;int field_index = pidff->control_id[field]; +if (field_index <1 ) +return ; +/* Detect if the field is a bitmask variable or an array */ if (pidff->device_control->flags &HID_MAIN_ITEM_VARIABLE ) {hid_dbg (pidff->hid,"DEVICE_CONTROL is a bitmask\n" ); +/* Clear current bitmask */ for (i =0 ; i <sizeof (pidff_device_control); i++) { - tmp = pidff->control_id[i]; - pidff->device_control->value[tmp] =0 ; + index = pidff->control_id[i]; +if (index <1 ) +continue ; + + pidff->device_control->value[index -1 ] =0 ; } + pidff->device_control->value[field_index -1 ] =1 ; }else {hid_dbg (pidff->hid,"DEVICE_CONTROL is an array\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 187/393 auxdisplay: hd44780: Fix an API misuse in hd44780.c
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 9b98a7d2e5f4e2beeff88f6571da0cdc5883c7fb upstream.
Variable allocated by charlcd_alloc() should be released by charlcd_free(). The following patch changed kfree() to charlcd_free() to fix an API misuse.
--- drivers/auxdisplay/hd44780.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/auxdisplay/hd44780.c +2 -2
@@ -313,7 +313,7 @@ static int hd44780_probe(struct platform fail3:kfree (hd); fail2: -kfree (lcd); +charlcd_free (lcd); fail1:kfree (hdc);return ret;
@@ -328,7 +328,7 @@ static void hd44780_remove(struct platfokfree (hdc->hd44780);kfree (lcd->drvdata); -kfree (lcd); +charlcd_free (lcd); }static const struct of_device_id hd44780_of_match[] = {
Greg Kroah-Hartman
maintainerPATCH 188/393 dt-bindings: media: st,stmipid02: correct lane-polarities maxItems
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
commit 3a544a39e0a4c492e3026dfbed018321d2bd6caa upstream.
The MIPID02 can use up to 2 data lanes which leads to having a maximum item number of 3 for the lane-polarities since this also contains the clock lane.
--- Documentation/devicetree/bindings/media/i2c/st,st-mipid02.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/media/i2c/st,st-mipid02.yaml +1 -1
@@ -71,7 +71,7 @@ properties: description: Any lane can be inverted or not. minItems: 1 - maxItems: 2 + maxItems: 3 required: - data-lanes
Greg Kroah-Hartman
maintainerPATCH 189/393 media: mediatek: vcodec: Fix a resource leak related to the scp device in FW initialization
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
commit 4936cd5817af35d23e4d283f48fa59a18ef481e4 upstream.
On Mediatek devices with a system companion processor (SCP) the mtk_scp structure has to be removed explicitly to avoid a resource leak. Free the structure in case the allocation of the firmware structure fails during the firmware initialization.
--- drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/common/mtk_vcodec_fw_scp.c +4 -1
@@ -79,8 +79,11 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_scp_ } fw =devm_kzalloc (&plat_dev->dev,sizeof (*fw),GFP_KERNEL ); -if (!fw) +if (!fw) { +scp_put (scp);return ERR_PTR (-ENOMEM ); + } + fw->type =SCP ; fw->ops = &mtk_vcodec_rproc_msg; fw->scp = scp;
Greg Kroah-Hartman
maintainerPATCH 190/393 media: mtk-vcodec: venc: avoid -Wenum-compare-conditional warning
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 07df4f23ef3ffe6fee697cd2e03623ad27108843 upstream.
This is one of three clang warnings about incompatible enum types in a conditional expression:
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c:597:29: error: conditional expression between different enumeration types ('enum scp_ipi_id' and 'enum ipi_id') [-Werror,-Wenum-compare-conditional]
597 | inst->vpu_inst.id = is_ext ? SCP_IPI_VENC_H264 : IPI_VENC_H264;
| ^ ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~The code is correct, so just rework it to avoid the warning.
--- drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/vcodec/encoder/venc/venc_h264_if.c +5 -1
@@ -594,7 +594,11 @@ static int h264_enc_init(struct mtk_vcod inst->ctx = ctx; inst->vpu_inst.ctx = ctx; - inst->vpu_inst.id = is_ext ?SCP_IPI_VENC_H264 :IPI_VENC_H264 ; +if (is_ext) + inst->vpu_inst.id =SCP_IPI_VENC_H264 ; +else + inst->vpu_inst.id =IPI_VENC_H264 ; + inst->hw_base =mtk_vcodec_get_reg_addr (inst->ctx->dev->reg_base,VENC_SYS ); ret =vpu_enc_init (&inst->vpu_inst);
Greg Kroah-Hartman
maintainerPATCH 191/393 media: uapi: rkisp1-config: Fix typo in extensible params example
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Söderlund <[email protected]>
commit 7b0ee2de7c76e5518e2235a927fd211bc785d320 upstream.
The define used for the version in the example diagram does not match what is defined in enum rksip1_ext_param_buffer_version, nor the description above it. Correct the typo to make it clear which define to use.
--- include/uapi/linux/rkisp1-config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/rkisp1-config.h +1 -1
@@ -1528,7 +1528,7 @@ enum rksip1_ext_param_buffer_version {* The expected memory layout of the parameters buffer is:: * * +-------------------- struct rkisp1_ext_params_cfg -------------------+ -* | version = RKISP_EXT_PARAMS_BUFFER_V1; | +* | version = RKISP1_EXT_PARAM_BUFFER_V1; | * | data_size = sizeof(struct rkisp1_ext_params_bls_config) | * | + sizeof(struct rkisp1_ext_params_dpcc_config); | * | +------------------------- data ---------------------------------+ |
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 192/393 media: mgb4: Fix CMT registers update logic
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Tůma <[email protected]>
commit dd05443189f9ae175dd806594b67bf55ddb6539e upstream.
The CMT "magic values" registers must be updated while the CMT reset registers are active.
--- drivers/media/pci/mgb4/mgb4_cmt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/media/pci/mgb4/mgb4_cmt.c +4 -2
@@ -206,10 +206,11 @@ u32 mgb4_cmt_set_vout_freq(struct mgb4_vmgb4_write_reg (video, regs->config,0x1 | (config & ~0x3 )); +mgb4_mask_reg (video, regs->config,0x100 ,0x100 ); +for (i =0 ; i <ARRAY_SIZE (cmt_addrs_out[0 ]); i++)mgb4_write_reg (&voutdev->mgbdev->cmt, addr[i], reg_set[i]); -mgb4_mask_reg (video, regs->config,0x100 ,0x100 );mgb4_mask_reg (video, regs->config,0x100 ,0x0 );mgb4_write_reg (video, regs->config, config & ~0x1 );
@@ -236,10 +237,11 @@ void mgb4_cmt_set_vin_freq_range(structmgb4_write_reg (video, regs->config,0x1 | (config & ~0x3 )); +mgb4_mask_reg (video, regs->config,0x1000 ,0x1000 ); +for (i =0 ; i <ARRAY_SIZE (cmt_addrs_in[0 ]); i++)mgb4_write_reg (&vindev->mgbdev->cmt, addr[i], reg_set[i]); -mgb4_mask_reg (video, regs->config,0x1000 ,0x1000 );mgb4_mask_reg (video, regs->config,0x1000 ,0x0 );mgb4_write_reg (video, regs->config, config & ~0x1 );
Greg Kroah-Hartman
maintainerPATCH 193/393 media: i2c: adv748x: Fix test pattern selection mask
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Söderlund <[email protected]>
commit 9e38acacb9d809b97a0bdc5c76e725355a47158a upstream.
The mask to select the test-pattern in register ADV748X_SDP_FRP is incorrect, it's the lower 3 bits which controls the pattern. The GENMASK() macro is used incorrectly and the generated mask is 0x0e instead of 0x07.
The result is that not all test patterns are selectable, and that in some cases the wrong test pattern is activated. Fix this by correcting the GENMASK().
--- drivers/media/i2c/adv748x/adv748x.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/adv748x/adv748x.h +1 -1
@@ -320,7 +320,7 @@ struct adv748x_state {/* Free run pattern select */ #define ADV748X_SDP_FRP 0x14 -#define ADV748X_SDP_FRP_MASK GENMASK(3, 1) +#define ADV748X_SDP_FRP_MASK GENMASK(2, 0)/* Saturation */ #define ADV748X_SDP_SD_SAT_U 0xe3/* user_map_rw_reg_e3 */
Greg Kroah-Hartman
maintainerPATCH 194/393 media: mgb4: Fix switched CMT frequency range "magic values" sets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Tůma <[email protected]>
commit 450acf0840232eaf6eb7a80da11cf492e57498e8 upstream.
The reason why this passed unnoticed is that most infotainment systems use frequencies near enough the middle (50MHz) where both sets work.
--- drivers/media/pci/mgb4/mgb4_cmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/mgb4/mgb4_cmt.c +1 -1
@@ -135,8 +135,8 @@ static const u16 cmt_vals_out[][15] = { };static const u16 cmt_vals_in[][13 ] = { - {0x1082 ,0x0000 ,0x5104 ,0x0000 ,0x11C7 ,0x0000 ,0x1041 ,0x02BC ,0x7C01 ,0xFFE9 ,0x9900 ,0x9908 ,0x8100 }, {0x1104 ,0x0000 ,0x9208 ,0x0000 ,0x138E ,0x0000 ,0x1041 ,0x015E ,0x7C01 ,0xFFE9 ,0x0100 ,0x0908 ,0x1000 }, + {0x1082 ,0x0000 ,0x5104 ,0x0000 ,0x11C7 ,0x0000 ,0x1041 ,0x02BC ,0x7C01 ,0xFFE9 ,0x9900 ,0x9908 ,0x8100 }, };static const u32 cmt_addrs_out[][15 ] = {
Greg Kroah-Hartman
maintainerPATCH 195/393 media: intel/ipu6: set the dev_parent of video device to pdev
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bingbu Cao <[email protected]>
commit 6f0ab5d3671f7cbb326c8cab6fb69cb7ab9901cc upstream.
The bus_info in v4l2_capability of IPU6 isys v4l2_dev is missing. The driver didn't set the dev_parent of v4l2_dev, its parent is set to its parent auxdev which is neither platform nor PCI device, thus media_set_bus_info() will not set the bus_info of v4l2_capability, then v4l2-ctl --all cannot show the bus_info.
This patch fixes it by setting the dev_parent of video_device and v4l2 framework can detect the device type and set the bus_info instead.
--- drivers/media/pci/intel/ipu6/ipu6-isys-video.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/intel/ipu6/ipu6-isys-video.c +1 -0
@@ -1296,6 +1296,7 @@ int ipu6_isys_video_init(struct ipu6_isy av->vdev.release = video_device_release_empty; av->vdev.fops = &isys_fops; av->vdev.v4l2_dev = &av->isys->v4l2_dev; + av->vdev.dev_parent = &av->isys->adev->isp->pdev->dev;if (!av->vdev.ioctl_ops) av->vdev.ioctl_ops = &ipu6_v4l2_ioctl_ops; av->vdev.queue = &av->aq.vbq;
Greg Kroah-Hartman
maintainerPATCH 196/393 media: venus: hfi: add a check to handle OOB in sfr region
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit f4b211714bcc70effa60c34d9fa613d182e3ef1e upstream.
sfr->buf_size is in shared memory and can be modified by malicious user. OOB write is possible when the size is made higher than actual sfr data buffer. Cap the size to allocated size for such cases.
--- drivers/media/platform/qcom/venus/hfi_venus.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/hfi_venus.c +10 -2
@@ -1035,18 +1035,26 @@ static void venus_sfr_print(struct venus {struct device *dev = hdev->core->dev;struct hfi_sfr *sfr = hdev->sfr.kva; +u32 size;void *p;if (!sfr)return ; - p =memchr (sfr->data,'\0' , sfr->buf_size); + size = sfr->buf_size; +if (!size) +return ; + +if (size >ALIGNED_SFR_SIZE ) + size =ALIGNED_SFR_SIZE ; + + p =memchr (sfr->data,'\0' , size);/* * SFR isn't guaranteed to be NULL terminated since SYS_ERROR indicates * that Venus is in the process of crashing. */ if (!p) - sfr->data[sfr->buf_size -1 ] ='\0' ; + sfr->data[size -1 ] ='\0' ;dev_err_ratelimited (dev,"SFR message from FW: %s\n" , sfr->data); }
Greg Kroah-Hartman
maintainerPATCH 197/393 media: venus: hfi: add check to handle incorrect queue size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 69baf245b23e20efda0079238b27fc63ecf13de1 upstream.
qsize represents size of shared queued between driver and video firmware. Firmware can modify this value to an invalid large value. In such situation, empty_space will be bigger than the space actually available. Since new_wr_idx is not checked, so the following code will result in an OOB write.
...
qsize = qhdr->q_size
if (wr_idx >= rd_idx)
empty_space = qsize - (wr_idx - rd_idx)
....
if (new_wr_idx < qsize) {
memcpy(wr_ptr, packet, dwords << 2) --> OOB write
Add check to ensure qsize is within the allocated size while reading and writing packets into the queue.
--- drivers/media/platform/qcom/venus/hfi_venus.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/platform/qcom/venus/hfi_venus.c +6 -0
@@ -187,6 +187,9 @@ static int venus_write_queue(struct venu/* ensure rd/wr indices's are read from memory */ rmb (); +if (qsize >IFACEQ_QUEUE_SIZE /4 ) +return -EINVAL ; +if (wr_idx >= rd_idx) empty_space = qsize - (wr_idx - rd_idx);else
@@ -255,6 +258,9 @@ static int venus_read_queue(struct venus wr_idx = qhdr->write_idx; qsize = qhdr->q_size; +if (qsize >IFACEQ_QUEUE_SIZE /4 ) +return -EINVAL ; +/* make sure data is valid before using it */ rmb ();
Greg Kroah-Hartman
maintainerPATCH 198/393 media: vim2m: print device name after registering device
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Majewski <[email protected]>
commit 143d75583f2427f3a97dba62413c4f0604867ebf upstream.
Move the v4l2_info() call displaying the video device name after the device is actually registered.
This fixes a bug where the driver was always displaying "/dev/video0" since it was reading from the vfd before it was registered.
--- drivers/media/test-drivers/vim2m.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/test-drivers/vim2m.c +3 -3
@@ -1316,9 +1316,6 @@ static int vim2m_probe(struct platform_d vfd->v4l2_dev = &dev->v4l2_dev;video_set_drvdata (vfd, dev); -v4l2_info (&dev->v4l2_dev, -"Device registered as /dev/video%d\n" , vfd->num); -platform_set_drvdata (pdev, dev); dev->m2m_dev =v4l2_m2m_init (&m2m_ops);
@@ -1345,6 +1342,9 @@ static int vim2m_probe(struct platform_d goto error_m2m; } +v4l2_info (&dev->v4l2_dev, +"Device registered as /dev/video%d\n" , vfd->num); +#ifdef CONFIG_MEDIA_CONTROLLER ret =v4l2_m2m_register_media_controller (dev->m2m_dev, vfd,MEDIA_ENT_F_PROC_VIDEO_SCALER );
Greg Kroah-Hartman
maintainerPATCH 199/393 media: siano: Fix error handling in smsdvb_module_init()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Can <[email protected]>
commit 734ac57e47b3bdd140a1119e2c4e8e6f8ef8b33d upstream.
The smsdvb_module_init() returns without checking the retval from smscore_register_hotplug().
If the smscore_register_hotplug() failed, the module failed to install, leaving the smsdvb_debugfs not unregistered.
--- drivers/media/common/siano/smsdvb-main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/common/siano/smsdvb-main.c +2 -0
@@ -1243,6 +1243,8 @@ static int __init smsdvb_module_init(voismsdvb_debugfs_register (); rc =smscore_register_hotplug (smsdvb_hotplug); +if (rc) +smsdvb_debugfs_unregister ();pr_debug ("\n" );
Greg Kroah-Hartman
maintainerPATCH 200/393 media: rockchip: rga: fix rga offset lookup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Keeping <[email protected]>
commit 11de3582675cc0b7136e12f3971f1da3e5a05382 upstream.
The arguments to rga_lookup_draw_pos() are passed in the wrong order, rotate mode should be before mirror mode.
--- drivers/media/platform/rockchip/rga/rga-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/rockchip/rga/rga-hw.c +1 -1
@@ -376,7 +376,7 @@ static void rga_cmd_set_dst_info(struct* Configure the dest framebuffer base address with pixel offset. */ offsets =rga_get_addr_offset (&ctx->out, offset, dst_x, dst_y, dst_w, dst_h); - dst_offset =rga_lookup_draw_pos (&offsets, mir_mode, rot_mode); + dst_offset =rga_lookup_draw_pos (&offsets, rot_mode, mir_mode); dest[(RGA_DST_Y_RGB_BASE_ADDR -RGA_MODE_BASE_REG ) >>2 ] = dst_offset->y_off;
Greg Kroah-Hartman
maintainerPATCH 201/393 xenfs/xensyms: respect hypervisors "next" indication
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
commit 5c4e79e29a9fe4ea132118ac40c2bc97cfe23077 upstream.
The interface specifies the symnum field as an input and output; the hypervisor sets it to the next sequential symbol's index. xensyms_next() incrementing the position explicitly (and xensyms_next_sym() decrementing it to "rewind") is only correct as long as the sequence of symbol indexes is non-sparse. Use the hypervisor-supplied value instead to update the position in xensyms_next(), and use the saved incoming index in xensyms_next_sym().
Message-ID: <[email protected]>
--- drivers/xen/xenfs/xensyms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/xen/xenfs/xensyms.c +2 -2
@@ -48,7 +48,7 @@ static int xensyms_next_sym(struct xensyreturn -ENOMEM ;set_xen_guest_handle (symdata->name, xs->name); - symdata->symnum--;/* Rewind */ + symdata->symnum = symnum;/* Rewind */ ret =HYPERVISOR_platform_op (&xs->op);if (ret <0 )
@@ -78,7 +78,7 @@ static void *xensyms_next(struct seq_fil {struct xensyms *xs = m->private; - xs->op.u.symdata.symnum = ++(*pos); + *pos = xs->op.u.symdata.symnum;if (xensyms_next_sym (xs))return NULL ;
Greg Kroah-Hartman
maintainerPATCH 202/393 arm64: cputype: Add MIDR_CORTEX_A76AE
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit a9b5bd81b294d30a747edd125e9f6aef2def7c79 upstream.
Quoted 1 line
From the TRM,
MIDR_CORTEX_A76AEhas a partnum of 0xDOE and an
implementor of 0x41 (ARM). Add the values.
--- arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -75,6 +75,7 @@#define ARM_CPU_PART_CORTEX_A76 0xD0B#define ARM_CPU_PART_NEOVERSE_N1 0xD0C#define ARM_CPU_PART_CORTEX_A77 0xD0D +#define ARM_CPU_PART_CORTEX_A76AE 0xD0E#define ARM_CPU_PART_NEOVERSE_V1 0xD40#define ARM_CPU_PART_CORTEX_A78 0xD41#define ARM_CPU_PART_CORTEX_A78AE 0xD42
@@ -159,6 +160,7 @@#define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76)#define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1)#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77) +#define MIDR_CORTEX_A76AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76AE)#define MIDR_NEOVERSE_V1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_V1)#define MIDR_CORTEX_A78 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78)#define MIDR_CORTEX_A78AE MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A78AE)
Greg Kroah-Hartman
maintainerPATCH 203/393 arm64: errata: Add QCOM_KRYO_4XX_GOLD to the spectre_bhb_k24_list
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit ed1ce841245d8febe3badf51c57e81c3619d0a1d upstream.
Qualcomm Kryo 400-series Gold cores have a derivative of an ARM Cortex A76 in them. Since A76 needs Spectre mitigation via looping then the Kyro 400-series Gold cores also need Spectre mitigation via looping.
Qualcomm has confirmed that the proper "k" value for Kryo 400-series Gold cores is 24.
--- arch/arm64/kernel/proton-pack.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/kernel/proton-pack.c +1 -0
@@ -866,6 +866,7 @@ u8 spectre_bhb_loop_affected(int scope)MIDR_ALL_VERSIONS (MIDR_CORTEX_A76 ),MIDR_ALL_VERSIONS (MIDR_CORTEX_A77 ),MIDR_ALL_VERSIONS (MIDR_NEOVERSE_N1 ), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_GOLD), {}, };static const struct midr_range spectre_bhb_k11_list[] = {
Greg Kroah-Hartman
maintainerPATCH 204/393 arm64: errata: Assume that unknown CPUs _are_ vulnerable to Spectre BHB
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit e403e8538359d8580cbee1976ff71813e947101e upstream.
The code for detecting CPUs that are vulnerable to Spectre BHB was based on a hardcoded list of CPU IDs that were known to be affected. Unfortunately, the list mostly only contained the IDs of standard ARM cores. The IDs for many cores that are minor variants of the standard ARM cores (like many Qualcomm Kyro CPUs) weren't listed. This led the code to assume that those variants were not affected.
Flip the code on its head and instead assume that a core is vulnerable if it doesn't have CSV2_3 but is unrecognized as being safe. This involves creating a "Spectre BHB safe" list.
As of right now, the only CPU IDs added to the "Spectre BHB safe" list are ARM Cortex A35, A53, A55, A510, and A520. This list was created by looking for cores that weren't listed in ARM's list [1] as per review feedback on v2 of this patch [2]. Additionally Brahma A53 is added as per mailing list feedback [3].
NOTE: this patch will not actually _mitigate_ anyone, it will simply cause them to report themselves as vulnerable. If any cores in the system are reported as vulnerable but not mitigated then the whole system will be reported as vulnerable though the system will attempt to mitigate with the information it has about the known cores.
[1] https://developer.arm.com/Arm%20Security%20Center/Spectre-BHB
[2] https://lore.kernel.org/r/20241219175128.GA25477@willie-the-truck
[3] https://lore.kernel.org/r/[email protected]
--- arch/arm64/include/asm/spectre.h | 1 arch/arm64/kernel/proton-pack.c | 201 +++++++++++++++++++-------------------- 2 files changed, 101 insertions(+), 101 deletions(-)
arch/arm64/include/asm/spectre.h +0 -1
@@ -97,7 +97,6 @@ enum mitigation_state arm64_get_meltdownenum mitigation_state arm64_get_spectre_bhb_state (void );bool is_spectre_bhb_affected (const struct arm64_cpu_capabilities *entry,int scope); -u8 spectre_bhb_loop_affected (int scope);void spectre_bhb_enable_mitigation (const struct arm64_cpu_capabilities *__unused);bool try_emulate_el1_ssbs (struct pt_regs *regs,u32 instr);
arch/arm64/kernel/proton-pack.c +101 -100
265 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 205/393 arm64: errata: Add KRYO 2XX/3XX/4XX silver cores to Spectre BHB safe list
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
commit 0c9fc6e652cd5aed48c5f700c32b7642bea7f453 upstream.
Qualcomm has confirmed that, much like Cortex A53 and A55, KRYO 2XX/3XX/4XX silver cores are unaffected by Spectre BHB. Add them to the safe list.
--- arch/arm64/kernel/proton-pack.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kernel/proton-pack.c +3 -0
@@ -854,6 +854,9 @@ static bool is_spectre_bhb_safe(int scopMIDR_ALL_VERSIONS (MIDR_CORTEX_A510 ),MIDR_ALL_VERSIONS (MIDR_CORTEX_A520 ),MIDR_ALL_VERSIONS (MIDR_BRAHMA_B53 ), +MIDR_ALL_VERSIONS (MIDR_QCOM_KRYO_2XX_SILVER ), +MIDR_ALL_VERSIONS (MIDR_QCOM_KRYO_3XX_SILVER ), + MIDR_ALL_VERSIONS(MIDR_QCOM_KRYO_4XX_SILVER), {}, };static bool all_safe = true;
Greg Kroah-Hartman
maintainerPATCH 206/393 KVM: arm64: Tear down vGIC on failed vCPU creation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 250f25367b58d8c65a1b060a2dda037eea09a672 upstream.
If kvm_arch_vcpu_create() fails to share the vCPU page with the hypervisor, we propagate the error back to the ioctl but leave the vGIC vCPU data initialised. Note only does this leak the corresponding memory when the vCPU is destroyed but it can also lead to use-after-free if the redistributor device handling tries to walk into the vCPU.
Add the missing cleanup to kvm_arch_vcpu_create(), ensuring that the vGIC vCPU structures are destroyed on error.
--- arch/arm64/kvm/arm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm64/kvm/arm.c +5 -1
@@ -493,7 +493,11 @@ int kvm_arch_vcpu_create(struct kvm_vcpuif (err)return err; -return kvm_share_hyp (vcpu, vcpu +1 ); + err =kvm_share_hyp (vcpu, vcpu +1 ); +if (err) +kvm_vgic_vcpu_destroy (vcpu); + +return err; }void kvm_arch_vcpu_postcreate (struct kvm_vcpu *vcpu)
Greg Kroah-Hartman
maintainerPATCH 207/393 spi: cadence-qspi: Fix probe on AM62A LP SK
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
commit b8665a1b49f5498edb7b21d730030c06b7348a3c upstream.
In 2020, there's been an unnoticed change which rightfully attempted to report probe deferrals upon DMA absence by checking the return value of dma_request_chan_by_mask(). By doing so, it also reported errors which were simply ignored otherwise, likely on purpose.
This change actually turned a void return into an error code. Hence, not only the -EPROBE_DEFER error codes but all error codes got reported to the callers, now failing to probe in the absence of Rx DMA channel, despite the fact that DMA seems to not be supported natively by many implementations.
Looking at the history, this change probably led to:ad2775dc3fc5 ("spi: cadence-quadspi: Disable the DAC for Intel LGM SoC") f724c296f2f2 ("spi: cadence-quadspi: fix Direct Access Mode disable for SoCFPGA")
In my case, the AM62A LP SK core octo-SPI node from TI does not advertise any DMA channel, hinting that there is likely no support for it, but yet when the support for the am654 compatible was added, DMA seemed to be used, so just discarding its use with the CQSPI_DISABLE_DAC_MODE quirk for this compatible does not seem the correct approach.
Let's get change the return condition back to:
- return a probe deferral error if we get one
- ignore the return value otherwise
The "error" log level was however likely too high for something that is expected to fail, so let's lower it arbitrarily to the info level.
--- drivers/spi/spi-cadence-quadspi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-cadence-quadspi.c +6 -0
@@ -1634,6 +1634,12 @@ static int cqspi_request_mmap_dma(structint ret =PTR_ERR (cqspi->rx_chan); cqspi->rx_chan =NULL ; +if (ret == -ENODEV ) { +/* DMA support is not mandatory */ +dev_info (&cqspi->pdev->dev,"No Rx DMA available\n" ); +return 0 ; + } +return dev_err_probe (&cqspi->pdev->dev, ret,"No Rx DMA available\n" ); }init_completion (&cqspi->rx_dma_complete);
Greg Kroah-Hartman
maintainerPATCH 208/393 mtd: rawnand: brcmnand: fix PM resume warning
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamal Dasu <[email protected]>
commit ddc210cf8b8a8be68051ad958bf3e2cef6b681c2 upstream.
Fixed warning on PM resume as shown below caused due to uninitialized struct nand_operation that checks chip select field :
WARN_ON(op->cs >= nanddev_ntargets(&chip->base)
[ 14.588522] ------------[ cut here ]------------ [ 14.588529] WARNING: CPU: 0 PID: 1392 at drivers/mtd/nand/raw/internals.h:139 nand_reset_op+0x1e0/0x1f8 [ 14.588553] Modules linked in: bdc udc_core [ 14.588579] CPU: 0 UID: 0 PID: 1392 Comm: rtcwake Tainted: G W 6.14.0-rc4-g5394eea10651 #16 [ 14.588590] Tainted: [W]=WARN [ 14.588593] Hardware name: Broadcom STB (Flattened Device Tree) [ 14.588598] Call trace: [ 14.588604] dump_backtrace from show_stack+0x18/0x1c [ 14.588622] r7:00000009 r6:0000008b r5:60000153 r4:c0fa558c [ 14.588625] show_stack from dump_stack_lvl+0x70/0x7c [ 14.588639] dump_stack_lvl from dump_stack+0x18/0x1c [ 14.588653] r5:c08d40b0 r4:c1003cb0 [ 14.588656] dump_stack from __warn+0x84/0xe4 [ 14.588668] __warn from warn_slowpath_fmt+0x18c/0x194 [ 14.588678] r7:c08d40b0 r6:c1003cb0 r5:00000000 r4:00000000 [ 14.588681] warn_slowpath_fmt from nand_reset_op+0x1e0/0x1f8 [ 14.588695] r8:70c40dff r7:89705f41 r6:36b4a597 r5:c26c9444 r4:c26b0048 [ 14.588697] nand_reset_op from brcmnand_resume+0x13c/0x150 [ 14.588714] r9:00000000 r8:00000000 r7:c24f8010 r6:c228a3f8 r5:c26c94bc r4:c26b0040 [ 14.588717] brcmnand_resume from platform_pm_resume+0x34/0x54 [ 14.588735] r5:00000010 r4:c0840a50 [ 14.588738] platform_pm_resume from dpm_run_callback+0x5c/0x14c [ 14.588757] dpm_run_callback from device_resume+0xc0/0x324 [ 14.588776] r9:c24f8054 r8:c24f80a0 r7:00000000 r6:00000000 r5:00000010 r4:c24f8010 [ 14.588779] device_resume from dpm_resume+0x130/0x160 [ 14.588799] r9:c22539e4 r8:00000010 r7:c22bebb0 r6:c24f8010 r5:c22539dc r4:c22539b0 [ 14.588802] dpm_resume from dpm_resume_end+0x14/0x20 [ 14.588822] r10:c2204e40 r9:00000000 r8:c228a3fc r7:00000000 r6:00000003 r5:c228a414 [ 14.588826] r4:00000010 [ 14.588828] dpm_resume_end from suspend_devices_and_enter+0x274/0x6f8 [ 14.588848] r5:c228a414 r4:00000000 [ 14.588851] suspend_devices_and_enter from pm_suspend+0x228/0x2bc [ 14.588868] r10:c3502910 r9:c3501f40 r8:00000004 r7:c228a438 r6:c0f95e18 r5:00000000 [ 14.588871] r4:00000003 [ 14.588874] pm_suspend from state_store+0x74/0xd0 [ 14.588889] r7:c228a438 r6:c0f934c8 r5:00000003 r4:00000003 [ 14.588892] state_store from kobj_attr_store+0x1c/0x28 [ 14.588913] r9:00000000 r8:00000000 r7:f09f9f08 r6:00000004 r5:c3502900 r4:c0283250 [ 14.588916] kobj_attr_store from sysfs_kf_write+0x40/0x4c [ 14.588936] r5:c3502900 r4:c0d92a48 [ 14.588939] sysfs_kf_write from kernfs_fop_write_iter+0x104/0x1f0 [ 14.588956] r5:c3502900 r4:c3501f40 [ 14.588960] kernfs_fop_write_iter from vfs_write+0x250/0x420 [ 14.588980] r10:c0e14b48 r9:00000000 r8:c25f5780 r7:00443398 r6:f09f9f68 r5:c34f7f00 [ 14.588983] r4:c042a88c [ 14.588987] vfs_write from ksys_write+0x74/0xe4 [ 14.589005] r10:00000004 r9:c25f5780 r8:c02002fA0 r7:00000000 r6:00000000 r5:c34f7f00 [ 14.589008] r4:c34f7f00 [ 14.589011] ksys_write from sys_write+0x10/0x14 [ 14.589029] r7:00000004 r6:004421c0 r5:00443398 r4:00000004 [ 14.589032] sys_write from ret_fast_syscall+0x0/0x5c [ 14.589044] Exception stack(0xf09f9fa8 to 0xf09f9ff0) [ 14.589050] 9fa0: 00000004 00443398 00000004 00443398 00000004 00000001 [ 14.589056] 9fc0: 00000004 00443398 004421c0 00000004 b6ecbd58 00000008 bebfbc38 0043eb78 [ 14.589062] 9fe0: 00440eb0 bebfbaf8 b6de18a0 b6e579e8 [ 14.589065] ---[ end trace 0000000000000000 ]---
The fix uses the higher level nand_reset(chip, chipnr); where chipnr = 0, when doing PM resume operation in compliance with the controller support for single die nand chip. Switching from nand_reset_op() to nand_reset() implies more than just setting the cs field op->cs, it also reconfigures the data interface (ie. the timings). Tested and confirmed the NAND chip is in sync timing wise with host after the fix.
--- drivers/mtd/nand/raw/brcmnand/brcmnand.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -1
@@ -3008,7 +3008,7 @@ static int brcmnand_resume(struct devicebrcmnand_save_restore_cs_config (host,1 );/* Reset the chip, required by some chips after power-up */ -nand_reset_op (chip); +nand_reset (chip,0 ); }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 209/393 tpm, tpm_tis: Fix timeout handling when waiting for TPM status
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jonathan McDowell <[email protected]>
commit 7146dffa875cd00e7a7f918e1fce79c7593ac1fa upstream.
The change to only use interrupts to handle supported status changes introduced an issue when it is necessary to poll for the status. Rather than checking for the status after sleeping the code now sleeps after the check. This means a correct, but slower, status change on the part of the TPM can be missed, resulting in a spurious timeout error, especially on a more loaded system. Switch back to sleeping *then* checking. An up front check of the status has been done at the start of the function, so this does not cause an additional delay when the status is already what we're looking for.
--- drivers/char/tpm/tpm_tis_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -2
@@ -114,11 +114,10 @@ again:return 0 ;/* process status changes without irq support */ do { +usleep_range (priv->timeout_min, priv->timeout_max); status = chip->ops->status (chip);if ((status & mask) == mask)return 0 ; -usleep_range (priv->timeout_min, - priv->timeout_max); }while (time_before (jiffies, stop));return -ETIME ; }
Greg Kroah-Hartman
maintainerPATCH 210/393 accel/ivpu: Fix PM related deadlocks in MS IOCTLs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacek Lawrynowicz <[email protected]>
commit d893da85e06edf54737bb80648bb58ba8fd56d9f upstream.
Prevent runtime resume/suspend while MS IOCTLs are in progress. Failed suspend will call ivpu_ms_cleanup() that would try to acquire file_priv->ms_lock, which is already held by the IOCTLs.
--- drivers/accel/ivpu/ivpu_debugfs.c | 4 ++-- drivers/accel/ivpu/ivpu_ms.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-)
drivers/accel/ivpu/ivpu_debugfs.c +2 -2
@@ -331,7 +331,7 @@ ivpu_force_recovery_fn(struct file *filereturn -EINVAL ; ret =ivpu_rpm_get (vdev); -if (ret) +if (ret <0 )return ret;ivpu_pm_trigger_recovery (vdev,"debugfs" );
@@ -408,7 +408,7 @@ static int dct_active_set(void *data, u6return -EINVAL ; ret =ivpu_rpm_get (vdev); -if (ret) +if (ret <0 )return ret;if (active_percent)
drivers/accel/ivpu/ivpu_ms.c +18 -0
@@ -44,6 +44,10 @@ int ivpu_ms_start_ioctl(struct drm_devic args->sampling_period_ns < MS_MIN_SAMPLE_PERIOD_NS)return -EINVAL ; + ret =ivpu_rpm_get (vdev); +if (ret <0 ) +return ret; +mutex_lock (&file_priv->ms_lock);if (get_instance_by_mask (file_priv, args->metric_group_mask)) {
@@ -96,6 +100,8 @@ err_free_ms:kfree (ms); unlock:mutex_unlock (&file_priv->ms_lock); + +ivpu_rpm_put (vdev);return ret; }
@@ -160,6 +166,10 @@ int ivpu_ms_get_data_ioctl(struct drm_deif (!args->metric_group_mask)return -EINVAL ; + ret =ivpu_rpm_get (vdev); +if (ret <0 ) +return ret; +mutex_lock (&file_priv->ms_lock); ms =get_instance_by_mask (file_priv, args->metric_group_mask);
@@ -187,6 +197,7 @@ int ivpu_ms_get_data_ioctl(struct drm_de unlock:mutex_unlock (&file_priv->ms_lock); +ivpu_rpm_put (vdev);return ret; }
@@ -204,11 +215,17 @@ int ivpu_ms_stop_ioctl(struct drm_device {struct ivpu_file_priv *file_priv = file->driver_priv;struct drm_ivpu_metric_streamer_stop *args = data; +struct ivpu_device *vdev = file_priv->vdev;struct ivpu_ms_instance *ms; +int ret;if (!args->metric_group_mask)return -EINVAL ; + ret =ivpu_rpm_get (vdev); +if (ret <0 ) +return ret; +mutex_lock (&file_priv->ms_lock); ms =get_instance_by_mask (file_priv, args->metric_group_mask);
@@ -217,6 +234,7 @@ int ivpu_ms_stop_ioctl(struct drm_devicemutex_unlock (&file_priv->ms_lock); +ivpu_rpm_put (vdev);return ms ?0 : -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 211/393 media: streamzap: prevent processing IR data on URB failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Murad Masimov <[email protected]>
commit 549f6d348167fb2f7800ed7c8d4bce9630c74498 upstream.
If streamzap_callback() receives an urb with any non-critical error status, i.e. any error code other than -ECONNRESET, -ENOENT or -ESHUTDOWN, it will try to process IR data, ignoring a possible transfer failure.
Make streamzap_callback() process IR data only when urb->status is 0. Move processing logic to a separate function to make code cleaner and more similar to the URB completion handlers in other RC drivers.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- drivers/media/rc/streamzap.c | 68 ++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 30 deletions(-)
drivers/media/rc/streamzap.c +38 -30
@@ -138,39 +138,10 @@ static void sz_push_half_space(struct stsz_push_full_space (sz, value &SZ_SPACE_MASK ); } -/* -* streamzap_callback - usb IRQ handler callback -* -* This procedure is invoked on reception of data from -* the usb remote. -*/ -static void streamzap_callback (struct urb *urb) +static void sz_process_ir_data (struct streamzap_ir *sz,int len) { -struct streamzap_ir *sz;unsigned int i; -int len; - -if (!urb) -return ; - - sz = urb->context; - len = urb->actual_length; - -switch (urb->status) { -case -ECONNRESET : -case -ENOENT : -case -ESHUTDOWN : -/* -* this urb is terminated, clean up. -* sz might already be invalid at this point -*/ -dev_err (sz->dev,"urb terminated, status: %d\n" , urb->status); -return ; -default : -break ; - } -dev_dbg (sz->dev,"%s: received urb, len %d\n" , __func__, len);for (i =0 ; i < len; i++) {dev_dbg (sz->dev,"sz->buf_in[%d]: %x\n" , i, (unsigned char )sz->buf_in[i]);
@@ -219,6 +190,43 @@ static void streamzap_callback(struct ur }ir_raw_event_handle (sz->rdev); +} + +/* +* streamzap_callback - usb IRQ handler callback +* +* This procedure is invoked on reception of data from +* the usb remote. +*/ +static void streamzap_callback (struct urb *urb) +{ +struct streamzap_ir *sz; +int len; + +if (!urb) +return ; + + sz = urb->context; + len = urb->actual_length; + +switch (urb->status) { +case 0 : +dev_dbg (sz->dev,"%s: received urb, len %d\n" , __func__, len); +sz_process_ir_data (sz, len); +break ; +case -ECONNRESET : +case -ENOENT : +case -ESHUTDOWN : +/* +* this urb is terminated, clean up. +* sz might already be invalid at this point +*/ +dev_err (sz->dev,"urb terminated, status: %d\n" , urb->status); +return ; +default : +break ; + } +usb_submit_urb (urb,GFP_ATOMIC ); }
Greg Kroah-Hartman
maintainerPATCH 212/393 media: hi556: Fix memory leak (on error) in hi556_check_hwcfg()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit ed554da65abd0c561e40d35272d1a61d030fe977 upstream.
Commit 7d968b5badfc ("media: hi556: Return -EPROBE_DEFER if no endpoint is found") moved the v4l2_fwnode_endpoint_alloc_parse() call in hi556_check_hwcfg() up, but it did not make the error-exit paths between the old and new call-site use "goto check_hwcfg_error;" to free the bus_cfg on errors.
Add the missing "goto check_hwcfg_error;" statements to fix a memleak on early error-exits from hi556_check_hwcfg().
--- drivers/media/i2c/hi556.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/hi556.c +3 -2
@@ -1230,12 +1230,13 @@ static int hi556_check_hwcfg(struct devi ret =fwnode_property_read_u32 (fwnode,"clock-frequency" , &mclk);if (ret) {dev_err (dev,"can't get clock frequency" ); -return ret; + goto check_hwcfg_error; }if (mclk !=HI556_MCLK ) {dev_err (dev,"external clock %d is not supported" , mclk); -return -EINVAL ; + ret = -EINVAL ; + goto check_hwcfg_error; }if (bus_cfg.bus.mipi_csi2.num_data_lanes !=2 ) {
Greg Kroah-Hartman
maintainerPATCH 213/393 media: visl: Fix ERANGE error when setting enum controls
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dufresne <[email protected]>
commit d98e9213a768a3cc3a99f5e1abe09ad3baff2104 upstream.
The visl driver supports both frame and slice mode, with and without a start-code. But, the range and default for these enum controls was not set, which currently limits the decoder to enums with a value of 0. Fix this by setting the decoder mode and start code controls for both the H.264 and HEVC codecs.
--- drivers/media/test-drivers/visl/visl-core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/test-drivers/visl/visl-core.c +12 -0
@@ -161,9 +161,15 @@ static const struct visl_ctrl_desc visl_ }, { .cfg.id = V4L2_CID_STATELESS_H264_DECODE_MODE, + .cfg.min = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, + .cfg.max = V4L2_STATELESS_H264_DECODE_MODE_FRAME_BASED, + .cfg.def = V4L2_STATELESS_H264_DECODE_MODE_SLICE_BASED, }, { .cfg.id = V4L2_CID_STATELESS_H264_START_CODE, + .cfg.min = V4L2_STATELESS_H264_START_CODE_NONE, + .cfg.max = V4L2_STATELESS_H264_START_CODE_ANNEX_B, + .cfg.def = V4L2_STATELESS_H264_START_CODE_NONE, }, { .cfg.id = V4L2_CID_STATELESS_H264_SLICE_PARAMS,
@@ -198,9 +204,15 @@ static const struct visl_ctrl_desc visl_ }, { .cfg.id = V4L2_CID_STATELESS_HEVC_DECODE_MODE, + .cfg.min = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, + .cfg.max = V4L2_STATELESS_HEVC_DECODE_MODE_FRAME_BASED, + .cfg.def = V4L2_STATELESS_HEVC_DECODE_MODE_SLICE_BASED, }, { .cfg.id = V4L2_CID_STATELESS_HEVC_START_CODE, + .cfg.min = V4L2_STATELESS_HEVC_START_CODE_NONE, + .cfg.max = V4L2_STATELESS_HEVC_START_CODE_ANNEX_B, + .cfg.def = V4L2_STATELESS_HEVC_START_CODE_NONE, }, { .cfg.id = V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS,
Greg Kroah-Hartman
maintainerPATCH 214/393 media: platform: stm32: Add check for clk_enable()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
commit f883f34b6a46b1a09d44d7f94c3cd72fe0e8f93b upstream.
Add check for the return value of clk_enable() to gurantee the success.
--- drivers/media/platform/st/stm32/dma2d/dma2d.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/st/stm32/dma2d/dma2d.c +2 -1
@@ -492,7 +492,8 @@ static void device_run(void *prv) dst->sequence = frm_cap->sequence++;v4l2_m2m_buf_copy_metadata (src, dst, true); -clk_enable (dev->gate); +if (clk_enable (dev->gate)) + goto end;dma2d_config_fg (dev, frm_out,vb2_dma_contig_plane_dma_addr (&src->vb2_buf,0 ));
Greg Kroah-Hartman
maintainerPATCH 215/393 media: imx219: Adjust PLL settings based on the number of MIPI lanes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Stevenson <[email protected]>
commit 591a07588c03437dbcc3addfff07675de95a461e upstream.
Commit ceddfd4493b3 ("media: i2c: imx219: Support four-lane operation") added support for device tree to allow configuration of the sensor to use 4 lanes with a link frequency of 363MHz, and amended the advertised pixel rate to 280.8MPix/s.
However it didn't change any of the PLL settings, so actually it would have been running overclocked in the MIPI block, and with the frame rate and exposure calculations being wrong as the pixel rate was unchanged.
The pixel rate and link frequency advertised were taken from the "Clock Setting Example" section of the datasheet. However those are based on an external clock of 12MHz, and are unachievable with a clock of 24MHz - it seems PREPLLCLK_VT_DIV and PREPLLCK_OP_DIV can ONLY be set via the automatic configuration documented in "9-1-2 EXCK_FREQ setting depend on INCK frequency", not by writing the registers.
The closest we can get with a 24MHz clock is 281.6MPix/s and 364MHz.
Dropping all support for the 363MHz link frequency would cause problems for existing users, so allow it, but log a warning that the requested value is being changed to the supported one.
--- drivers/media/i2c/imx219.c | 93 +++++++++++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 24 deletions(-)
drivers/media/i2c/imx219.c +69 -24
@@ -134,10 +134,11 @@/* Pixel rate is fixed for all the modes */ #define IMX219_PIXEL_RATE 182400000 -#define IMX219_PIXEL_RATE_4LANE 280800000 +#define IMX219_PIXEL_RATE_4LANE 281600000#define IMX219_DEFAULT_LINK_FREQ 456000000 -#define IMX219_DEFAULT_LINK_FREQ_4LANE 363000000 +#define IMX219_DEFAULT_LINK_FREQ_4LANE_UNSUPPORTED 363000000 +#define IMX219_DEFAULT_LINK_FREQ_4LANE 364000000/* IMX219 native and active pixel array size. */ #define IMX219_NATIVE_WIDTH 3296U
@@ -169,15 +170,6 @@ static const struct cci_reg_sequence imx { CCI_REG8(0x30eb), 0x05 }, { CCI_REG8(0x30eb), 0x09 }, -/* PLL Clock Table */ - { IMX219_REG_VTPXCK_DIV, 5 }, - { IMX219_REG_VTSYCK_DIV, 1 }, - { IMX219_REG_PREPLLCK_VT_DIV, 3 }, /* 0x03 = AUTO set */ - { IMX219_REG_PREPLLCK_OP_DIV, 3 }, /* 0x03 = AUTO set */ - { IMX219_REG_PLL_VT_MPY, 57 }, - { IMX219_REG_OPSYCK_DIV, 1 }, - { IMX219_REG_PLL_OP_MPY, 114 }, -/* Undocumented registers */ { CCI_REG8(0x455e), 0x00 }, { CCI_REG8(0x471e), 0x4b },
@@ -202,12 +194,45 @@ static const struct cci_reg_sequence imx { IMX219_REG_EXCK_FREQ, IMX219_EXCK_FREQ(IMX219_XCLK_FREQ / 1000000) }, }; +static const struct cci_reg_sequence imx219_2lane_regs[] = { +/* PLL Clock Table */ + {IMX219_REG_VTPXCK_DIV ,5 }, + {IMX219_REG_VTSYCK_DIV ,1 }, + {IMX219_REG_PREPLLCK_VT_DIV ,3 },/* 0x03 = AUTO set */ + {IMX219_REG_PREPLLCK_OP_DIV ,3 },/* 0x03 = AUTO set */ + {IMX219_REG_PLL_VT_MPY ,57 }, + {IMX219_REG_OPSYCK_DIV ,1 }, + {IMX219_REG_PLL_OP_MPY ,114 }, + +/* 2-Lane CSI Mode */ + {IMX219_REG_CSI_LANE_MODE ,IMX219_CSI_2_LANE_MODE }, +}; + +static const struct cci_reg_sequence imx219_4lane_regs[] = { +/* PLL Clock Table */ + {IMX219_REG_VTPXCK_DIV ,5 }, + {IMX219_REG_VTSYCK_DIV ,1 }, + {IMX219_REG_PREPLLCK_VT_DIV ,3 },/* 0x03 = AUTO set */ + {IMX219_REG_PREPLLCK_OP_DIV ,3 },/* 0x03 = AUTO set */ + {IMX219_REG_PLL_VT_MPY ,88 }, + {IMX219_REG_OPSYCK_DIV ,1 }, + {IMX219_REG_PLL_OP_MPY ,91 }, + +/* 4-Lane CSI Mode */ + {IMX219_REG_CSI_LANE_MODE ,IMX219_CSI_4_LANE_MODE }, +}; +static const s64 imx219_link_freq_menu[] = {IMX219_DEFAULT_LINK_FREQ , };static const s64 imx219_link_freq_4lane_menu[] = {IMX219_DEFAULT_LINK_FREQ_4LANE , +/* +* This will never be advertised to userspace, but will be used for +* v4l2_link_freq_to_bitmap +*/ +IMX219_DEFAULT_LINK_FREQ_4LANE_UNSUPPORTED , }; static const char * const imx219_test_pattern_menu[] = {
@@ -663,9 +688,11 @@ static int imx219_set_framefmt(struct imstatic int imx219_configure_lanes (struct imx219 *imx219) { -return cci_write (imx219->regmap,IMX219_REG_CSI_LANE_MODE , - imx219->lanes ==2 ?IMX219_CSI_2_LANE_MODE : -IMX219_CSI_4_LANE_MODE ,NULL ); +/* Write the appropriate PLL settings for the number of MIPI lanes */ +return cci_multi_reg_write (imx219->regmap, + imx219->lanes ==2 ? imx219_2lane_regs : imx219_4lane_regs, + imx219->lanes ==2 ?ARRAY_SIZE (imx219_2lane_regs) : +ARRAY_SIZE (imx219_4lane_regs),NULL ); }; static int imx219_start_streaming(struct imx219 *imx219,
@@ -1042,6 +1069,7 @@ static int imx219_check_hwcfg(struct devstruct v4l2_fwnode_endpoint ep_cfg = { .bus_type =V4L2_MBUS_CSI2_DPHY }; +unsigned long link_freq_bitmap;int ret = -EINVAL ; endpoint =fwnode_graph_get_next_endpoint (dev_fwnode (dev),NULL );
@@ -1063,23 +1091,40 @@ static int imx219_check_hwcfg(struct dev imx219->lanes = ep_cfg.bus.mipi_csi2.num_data_lanes;/* Check the link frequency set in device tree */ -if (!ep_cfg.nr_of_link_frequencies) { -dev_err_probe (dev, -EINVAL , -"link-frequency property not found in DT\n" ); - goto error_out; +switch (imx219->lanes) { +case 2 : + ret =v4l2_link_freq_to_bitmap (dev, + ep_cfg.link_frequencies, + ep_cfg.nr_of_link_frequencies, + imx219_link_freq_menu, +ARRAY_SIZE (imx219_link_freq_menu), + &link_freq_bitmap); +break ; +case 4 : + ret =v4l2_link_freq_to_bitmap (dev, + ep_cfg.link_frequencies, + ep_cfg.nr_of_link_frequencies, + imx219_link_freq_4lane_menu, +ARRAY_SIZE (imx219_link_freq_4lane_menu), + &link_freq_bitmap); + +if (!ret && (link_freq_bitmap &BIT (1 ))) { +dev_warn (dev,"Link frequency of %d not supported, but has been incorrectly advertised previously\n" , +IMX219_DEFAULT_LINK_FREQ_4LANE_UNSUPPORTED ); +dev_warn (dev,"Using link frequency of %d\n" , +IMX219_DEFAULT_LINK_FREQ_4LANE ); + link_freq_bitmap |=BIT (0 ); + } +break ; } -if (ep_cfg.nr_of_link_frequencies !=1 || - (ep_cfg.link_frequencies[0 ] != ((imx219->lanes ==2 ) ? -IMX219_DEFAULT_LINK_FREQ :IMX219_DEFAULT_LINK_FREQ_4LANE ))) { +if (ret || !(link_freq_bitmap &BIT (0 ))) { + ret = -EINVAL ;dev_err_probe (dev, -EINVAL ,"Link frequency not supported: %lld\n" , ep_cfg.link_frequencies[0 ]); - goto error_out; } - ret =0 ; - error_out:v4l2_fwnode_endpoint_free (&ep_cfg);fwnode_handle_put (endpoint);
Greg Kroah-Hartman
maintainerPATCH 216/393 media: v4l2-dv-timings: prevent possible overflow in v4l2_detect_gtf()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karina Yankevich <[email protected]>
commit 3edd1fc48d2c045e8259561797c89fe78f01717e upstream.
In v4l2_detect_gtf(), it seems safer to cast the 32-bit image_width variable to the 64-bit type u64 before multiplying to avoid a possible overflow. The resulting object code even seems to look better, at least on x86_64.
Found by Linux Verification Center (linuxtesting.org) with Svace.
[Sergey: rewrote the patch subject/descripition]
--- drivers/media/v4l2-core/v4l2-dv-timings.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/v4l2-core/v4l2-dv-timings.c +2 -2
@@ -764,7 +764,7 @@ bool v4l2_detect_gtf(unsigned int frame_u64 num;u32 den; - num = ((image_width *GTF_D_C_PRIME * (u64 )hfreq) - + num = (((u64 )image_width *GTF_D_C_PRIME * hfreq) - ((u64 )image_width *GTF_D_M_PRIME *1000 )); den = (hfreq * (100 -GTF_D_C_PRIME ) +GTF_D_M_PRIME *1000 ) * (2 *GTF_CELL_GRAN );
@@ -774,7 +774,7 @@ bool v4l2_detect_gtf(unsigned int frame_u64 num;u32 den; - num = ((image_width *GTF_S_C_PRIME * (u64 )hfreq) - + num = (((u64 )image_width *GTF_S_C_PRIME * hfreq) - ((u64 )image_width *GTF_S_M_PRIME *1000 )); den = (hfreq * (100 -GTF_S_C_PRIME ) +GTF_S_M_PRIME *1000 ) * (2 *GTF_CELL_GRAN );
Greg Kroah-Hartman
maintainerPATCH 217/393 Revert "media: imx214: Fix the error handling in imx214_probe()"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit abd88757252c2a2cea7909f3922de1f0e9e04002 upstream.
This reverts commit 9bc92332cc3f06fda3c6e2423995ca2da0a7ec9a.
Revert this "fix" as it's not really helpful but makes backporting a proper fix harder.
--- drivers/media/i2c/imx214.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/i2c/imx214.c +0 -1
@@ -1114,7 +1114,6 @@ free_ctrl:v4l2_ctrl_handler_free (&imx214->ctrls); error_power_off:pm_runtime_disable (imx214->dev); -regulator_bulk_disable (IMX214_NUM_SUPPLIES , imx214->supplies);return ret; }
Greg Kroah-Hartman
maintainerPATCH 218/393 media: i2c: ccs: Set the devices runtime PM status correctly in remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit e04604583095faf455b3490b004254a225fd60d4 upstream.
Set the device's runtime PM status to suspended in device removal only if it wasn't suspended already.
--- drivers/media/i2c/ccs/ccs-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/i2c/ccs/ccs-core.c +3 -2
@@ -3591,9 +3591,10 @@ static void ccs_remove(struct i2c_clientv4l2_async_unregister_subdev (subdev);pm_runtime_disable (&client->dev); -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev)) {ccs_power_off (&client->dev); -pm_runtime_set_suspended (&client->dev); +pm_runtime_set_suspended (&client->dev); + }for (i =0 ; i < sensor->ssds_used; i++)v4l2_device_unregister_subdev (&sensor->ssds[i].sd);
Greg Kroah-Hartman
maintainerPATCH 219/393 media: i2c: ccs: Set the devices runtime PM status correctly in probe
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 80704d14f1bd3628f578510e0a88b66824990ef6 upstream.
Set the device's runtime PM status to suspended in probe error paths where it was previously set to active.
--- drivers/media/i2c/ccs/ccs-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/i2c/ccs/ccs-core.c +1 -0
@@ -3562,6 +3562,7 @@ static int ccs_probe(struct i2c_client * out_disable_runtime_pm:pm_runtime_put_noidle (&client->dev);pm_runtime_disable (&client->dev); +pm_runtime_set_suspended (&client->dev); out_cleanup:ccs_cleanup (sensor);
Greg Kroah-Hartman
maintainerPATCH 220/393 media: i2c: ov7251: Set enable GPIO low in probe
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit a1963698d59cec83df640ded343af08b76c8e9c5 upstream.
Set the enable GPIO low when acquiring it.
--- drivers/media/i2c/ov7251.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ov7251.c +1 -1
@@ -1696,7 +1696,7 @@ static int ov7251_probe(struct i2c_clienreturn PTR_ERR (ov7251->analog_regulator); } - ov7251->enable_gpio =devm_gpiod_get (dev,"enable" ,GPIOD_OUT_HIGH ); + ov7251->enable_gpio =devm_gpiod_get (dev,"enable" ,GPIOD_OUT_LOW );if (IS_ERR (ov7251->enable_gpio)) {dev_err (dev,"cannot get enable gpio\n" );return PTR_ERR (ov7251->enable_gpio);
Greg Kroah-Hartman
maintainerPATCH 221/393 media: i2c: ov7251: Introduce 1 ms delay between regulators and en GPIO
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 3d391292cdd53984ec1b9a1f6182a62a62751e03 upstream.
Lift the xshutdown (enable) GPIO 1 ms after enabling the regulators, as required by the sensor's power-up sequence.
--- drivers/media/i2c/ov7251.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/ov7251.c +2 -0
@@ -922,6 +922,8 @@ static int ov7251_set_power_on(struct dereturn ret; } +usleep_range (1000 ,1100 ); +gpiod_set_value_cansleep (ov7251->enable_gpio,1 );/* wait at least 65536 external clock cycles */
Greg Kroah-Hartman
maintainerPATCH 222/393 media: nuvoton: Fix reference handling of ece_node
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit 8ba4ef40ad6ca62368292a69855324213181abfb upstream.
Make sure all the code paths call of_node_put().
Instead of manually calling of_node_put, use the __free macros/helpers.
--- drivers/media/platform/nuvoton/npcm-video.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/nuvoton/npcm-video.c +1 -2
@@ -1650,8 +1650,8 @@ rel_ctrl_handler:static int npcm_video_ece_init (struct npcm_video *video) { + struct device_node *ece_node __free(device_node) = NULL;struct device *dev = video->dev; -struct device_node *ece_node;struct platform_device *ece_pdev;void __iomem *regs;
@@ -1671,7 +1671,6 @@ static int npcm_video_ece_init(struct npdev_err (dev,"Failed to find ECE device\n" );return -ENODEV ; } -of_node_put (ece_node); regs =devm_platform_ioremap_resource (ece_pdev,0 );if (IS_ERR (regs)) {
Greg Kroah-Hartman
maintainerPATCH 223/393 media: nuvoton: Fix reference handling of ece_pdev
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit 453d5cadab1bde8e6fdd5bd05f4200338cb21e72 upstream.
When we obtain a reference to of a platform_device, we need to release it via put_device.
Found by cocci:
./platform/nuvoton/npcm-video.c:1677:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function. ./platform/nuvoton/npcm-video.c:1684:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function. ./platform/nuvoton/npcm-video.c:1690:3-9: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function. ./platform/nuvoton/npcm-video.c:1694:1-7: ERROR: missing put_device; call of_find_device_by_node on line 1667, but without a corresponding object release within this function.
Instead of manually calling put_device, use the __free macros.
--- drivers/media/platform/nuvoton/npcm-video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/nuvoton/npcm-video.c +2 -1
@@ -1671,6 +1671,7 @@ static int npcm_video_ece_init(struct npdev_err (dev,"Failed to find ECE device\n" );return -ENODEV ; } + struct device *ece_dev __free(put_device) = &ece_pdev->dev; regs =devm_platform_ioremap_resource (ece_pdev,0 );if (IS_ERR (regs)) {
@@ -1685,7 +1686,7 @@ static int npcm_video_ece_init(struct npreturn PTR_ERR (video->ece.regmap); } - video->ece.reset =devm_reset_control_get (&ece_pdev->dev,NULL ); + video->ece.reset =devm_reset_control_get (ece_dev,NULL );if (IS_ERR (video->ece.reset)) {dev_err (dev,"Failed to get ECE reset control in DTS\n" );return PTR_ERR (video->ece.reset);
Greg Kroah-Hartman
maintainerPATCH 224/393 media: venus: hfi_parser: add check to avoid out of bound access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 172bf5a9ef70a399bb227809db78442dc01d9e48 upstream.
There is a possibility that init_codecs is invoked multiple times during manipulated payload from video firmware. In such case, if codecs_count can get incremented to value more than MAX_CODEC_NUM, there can be OOB access. Reset the count so that it always starts from beginning.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/venus/hfi_parser.c +2 -0
@@ -19,6 +19,8 @@ static void init_codecs(struct venus_corstruct hfi_plat_caps *caps = core->caps, *cap;unsigned long bit; + core->codecs_count =0 ; +if (hweight_long (core->dec_codecs) +hweight_long (core->enc_codecs) >MAX_CODEC_NUM )return ;
Greg Kroah-Hartman
maintainerPATCH 225/393 media: venus: hfi_parser: refactor hfi packet parsing logic
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 9edaaa8e3e15aab1ca413ab50556de1975bcb329 upstream.
words_count denotes the number of words in total payload, while data points to payload of various property within it. When words_count reaches last word, data can access memory beyond the total payload. This can lead to OOB access. With this patch, the utility api for handling individual properties now returns the size of data consumed. Accordingly remaining bytes are calculated before parsing the payload, thereby eliminates the OOB access possibilities.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 98 ++++++++++++++++++------- 1 file changed, 72 insertions(+), 26 deletions(-)
drivers/media/platform/qcom/venus/hfi_parser.c +72 -26
@@ -64,7 +64,7 @@ fill_buf_mode(struct hfi_plat_caps *cap, cap->cap_bufs_mode_dynamic = true; } -static void +static int parse_alloc_mode (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_buffer_alloc_mode_supported *mode = data;
@@ -72,7 +72,7 @@ parse_alloc_mode(struct venus_core *coreu32 *type;if (num_entries >MAX_ALLOC_MODE_ENTRIES ) -return ; +return -EINVAL ; type = mode->data;
@@ -84,6 +84,8 @@ parse_alloc_mode(struct venus_core *core type++; } + +return sizeof (*mode); } static void fill_profile_level(struct hfi_plat_caps *cap, const void *data,
@@ -98,7 +100,7 @@ static void fill_profile_level(struct hf cap->num_pl += num; } -static void +static int parse_profile_level (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_profile_level_supported *pl = data;
@@ -106,12 +108,14 @@ parse_profile_level(struct venus_core *cstruct hfi_profile_level pl_arr[HFI_MAX_PROFILE_COUNT ] = {};if (pl->profile_count >HFI_MAX_PROFILE_COUNT ) -return ; +return -EINVAL ;memcpy (pl_arr, proflevel, pl->profile_count *sizeof (*proflevel));for_each_codec (core->caps,ARRAY_SIZE (core->caps), codecs, domain, fill_profile_level, pl_arr, pl->profile_count); + +return pl->profile_count *sizeof (*proflevel) +sizeof (u32); } static void
@@ -126,7 +130,7 @@ fill_caps(struct hfi_plat_caps *cap, con cap->num_caps += num; } -static void +static int parse_caps (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_capabilities *caps = data;
@@ -135,12 +139,14 @@ parse_caps(struct venus_core *core, u32struct hfi_capability caps_arr[MAX_CAP_ENTRIES ] = {};if (num_caps >MAX_CAP_ENTRIES ) -return ; +return -EINVAL ;memcpy (caps_arr, cap, num_caps *sizeof (*cap));for_each_codec (core->caps,ARRAY_SIZE (core->caps), codecs, domain, fill_caps, caps_arr, num_caps); + +return sizeof (*caps); } static void fill_raw_fmts(struct hfi_plat_caps *cap, const void *fmts,
@@ -155,7 +161,7 @@ static void fill_raw_fmts(struct hfi_pla cap->num_fmts += num_fmts; } -static void +static int parse_raw_formats (struct venus_core *core,u32 codecs,u32 domain,void *data) {struct hfi_uncompressed_format_supported *fmt = data;
@@ -164,7 +170,8 @@ parse_raw_formats(struct venus_core *corstruct raw_formats rawfmts[MAX_FMT_ENTRIES ] = {};u32 entries = fmt->format_entries;unsigned int i =0 ; -u32 num_planes; +u32 num_planes =0 ; +u32 size;while (entries) { num_planes = pinfo->num_planes;
@@ -174,7 +181,7 @@ parse_raw_formats(struct venus_core *cor i++;if (i >=MAX_FMT_ENTRIES ) -return ; +return -EINVAL ;if (pinfo->num_planes >MAX_PLANES )break ;
@@ -186,9 +193,13 @@ parse_raw_formats(struct venus_core *corfor_each_codec (core->caps,ARRAY_SIZE (core->caps), codecs, domain, fill_raw_fmts, rawfmts, i); + size = fmt->format_entries * (sizeof (*constr) * num_planes +2 *sizeof (u32)) + +2 *sizeof (u32); + +return size; } -static void parse_codecs (struct venus_core *core,void *data) +static int parse_codecs (struct venus_core *core,void *data) {struct hfi_codec_supported *codecs = data;
@@ -200,21 +211,27 @@ static void parse_codecs(struct venus_co core->dec_codecs &= ~HFI_VIDEO_CODEC_SPARK ; core->enc_codecs &= ~HFI_VIDEO_CODEC_HEVC ; } + +return sizeof (*codecs); } -static void parse_max_sessions (struct venus_core *core,const void *data) +static int parse_max_sessions (struct venus_core *core,const void *data) {const struct hfi_max_sessions_supported *sessions = data; core->max_sessions_supported = sessions->max_sessions; + +return sizeof (*sessions); } -static void parse_codecs_mask (u32 *codecs,u32 *domain,void *data) +static int parse_codecs_mask (u32 *codecs,u32 *domain,void *data) {struct hfi_codec_mask_supported *mask = data; *codecs = mask->codecs; *domain = mask->video_domains; + +return sizeof (*mask); }static void parser_init (struct venus_inst *inst,u32 *codecs,u32 *domain)
@@ -283,8 +300,9 @@ static int hfi_platform_parser(struct veu32 hfi_parser (struct venus_core *core,struct venus_inst *inst,void *buf,u32 size) { -unsigned int words_count = size >>2 ; -u32 *word = buf, *data, codecs =0 , domain =0 ; +u32 *words = buf, *payload, codecs =0 , domain =0 ; +u32 *frame_size = buf + size; +u32 rem_bytes = size;int ret; ret =hfi_platform_parser (core, inst);
@@ -301,38 +319,66 @@ u32 hfi_parser(struct venus_core *core,memset (core->caps,0 ,sizeof (core->caps)); } -while (words_count) { - data = word +1 ; +while (words < frame_size) { + payload = words +1 ; -switch (*word) { +switch (*words) {case HFI_PROPERTY_PARAM_CODEC_SUPPORTED : -parse_codecs (core, data); +if (rem_bytes <=sizeof (struct hfi_codec_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_codecs (core, payload); +if (ret <0 ) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; +init_codecs (core);break ;case HFI_PROPERTY_PARAM_MAX_SESSIONS_SUPPORTED : -parse_max_sessions (core, data); +if (rem_bytes <=sizeof (struct hfi_max_sessions_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_max_sessions (core, payload);break ;case HFI_PROPERTY_PARAM_CODEC_MASK_SUPPORTED : -parse_codecs_mask (&codecs, &domain, data); +if (rem_bytes <=sizeof (struct hfi_codec_mask_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_codecs_mask (&codecs, &domain, payload);break ;case HFI_PROPERTY_PARAM_UNCOMPRESSED_FORMAT_SUPPORTED : -parse_raw_formats (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_uncompressed_format_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_raw_formats (core, codecs, domain, payload);break ;case HFI_PROPERTY_PARAM_CAPABILITY_SUPPORTED : -parse_caps (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_capabilities )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_caps (core, codecs, domain, payload);break ;case HFI_PROPERTY_PARAM_PROFILE_LEVEL_SUPPORTED : -parse_profile_level (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_profile_level_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_profile_level (core, codecs, domain, payload);break ;case HFI_PROPERTY_PARAM_BUFFER_ALLOC_MODE_SUPPORTED : -parse_alloc_mode (core, codecs, domain, data); +if (rem_bytes <=sizeof (struct hfi_buffer_alloc_mode_supported )) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + ret =parse_alloc_mode (core, codecs, domain, payload);break ;default : + ret =sizeof (u32);break ; } - word++; - words_count--; +if (ret <0 ) +return HFI_ERR_SYS_INSUFFICIENT_RESOURCES ; + + words += ret /sizeof (u32); + rem_bytes -= ret; }if (!core->max_sessions_supported)
Greg Kroah-Hartman
maintainerPATCH 226/393 media: i2c: imx319: Rectify runtime PM handling probe and remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 5f5ffd3bc62b2e6c478061918b10473d8b90ac2d upstream.
Idle the device only after the async sub-device has been successfully registered. In error handling, set the device's runtime PM status to suspended only if it has been set to active previously in probe.
Also set the device's runtime PM status to suspended in remove only if it wasn't so already.
--- drivers/media/i2c/imx319.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/i2c/imx319.c +6 -3
@@ -2442,17 +2442,19 @@ static int imx319_probe(struct i2c_clienif (full_power)pm_runtime_set_active (&client->dev);pm_runtime_enable (&client->dev); -pm_runtime_idle (&client->dev); ret =v4l2_async_register_subdev_sensor (&imx319->sd);if (ret <0 ) goto error_media_entity_pm; +pm_runtime_idle (&client->dev); +return 0 ; error_media_entity_pm:pm_runtime_disable (&client->dev); -pm_runtime_set_suspended (&client->dev); +if (full_power) +pm_runtime_set_suspended (&client->dev);media_entity_cleanup (&imx319->sd.entity); error_handler_free:
@@ -2474,7 +2476,8 @@ static void imx319_remove(struct i2c_cliv4l2_ctrl_handler_free (sd->ctrl_handler);pm_runtime_disable (&client->dev); -pm_runtime_set_suspended (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) +pm_runtime_set_suspended (&client->dev);mutex_destroy (&imx319->mutex); }
Greg Kroah-Hartman
maintainerPATCH 227/393 media: i2c: imx219: Rectify runtime PM handling in probe and remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 42eceae9793566d0df53d509be3e416465c347f5 upstream.
Set the device's runtime PM status and enable runtime PM before registering the async sub-device. This is needed to avoid the case where the device is runtime PM resumed while runtime PM has not been enabled yet.
Also set the device's runtime PM status to suspended in remove only if it wasn't so already.
--- drivers/media/i2c/imx219.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/media/i2c/imx219.c +8 -5
@@ -1231,6 +1231,9 @@ static int imx219_probe(struct i2c_clien goto error_media_entity; } +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + ret =v4l2_async_register_subdev_sensor (&imx219->sd);if (ret <0 ) { dev_err_probe(dev, ret,
@@ -1238,15 +1241,14 @@ static int imx219_probe(struct i2c_clien goto error_subdev_cleanup; } -/* Enable runtime PM and turn off the device */ -pm_runtime_set_active (dev); -pm_runtime_enable (dev);pm_runtime_idle (dev);return 0 ; error_subdev_cleanup:v4l2_subdev_cleanup (&imx219->sd); +pm_runtime_disable (dev); +pm_runtime_set_suspended (dev); error_media_entity:media_entity_cleanup (&imx219->sd.entity);
@@ -1271,9 +1273,10 @@ static void imx219_remove(struct i2c_cliimx219_free_controls (imx219);pm_runtime_disable (&client->dev); -if (!pm_runtime_status_suspended (&client->dev)) +if (!pm_runtime_status_suspended (&client->dev)) {imx219_power_off (&client->dev); -pm_runtime_set_suspended (&client->dev); +pm_runtime_set_suspended (&client->dev); + } }static const struct of_device_id imx219_dt_ids[] = {
Greg Kroah-Hartman
maintainerPATCH 228/393 media: i2c: imx214: Rectify probe error handling related to runtime PM
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit ccc888d1698b6f42d52ddf5cecfe50fe925c95e5 upstream.
There were multiple issues in the driver's probe function related to error handling:
- Device's PM runtime status wasn't reverted to suspended on some errors in probe.
- Runtime PM was left enabled for the device on some probe errors.
- Device was left powered on if a probe failure happened or when it was removed when it was powered on.
- An extra pm_runtime_set_suspended() was issued in driver's remove function when the device was suspended.
Fix these bugs.
--- drivers/media/i2c/imx214.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/media/i2c/imx214.c +15 -9
@@ -1075,10 +1075,6 @@ static int imx214_probe(struct i2c_clien*/ imx214_power_on (imx214->dev); -pm_runtime_set_active (imx214->dev); -pm_runtime_enable (imx214->dev); -pm_runtime_idle (imx214->dev); - ret =imx214_ctrls_init (imx214);if (ret <0 ) goto error_power_off;
@@ -1099,21 +1095,30 @@ static int imx214_probe(struct i2c_clienimx214_entity_init_state (&imx214->sd,NULL ); +pm_runtime_set_active (imx214->dev); +pm_runtime_enable (imx214->dev); + ret =v4l2_async_register_subdev_sensor (&imx214->sd);if (ret <0 ) {dev_err (dev,"could not register v4l2 device\n" ); goto free_entity; } +pm_runtime_idle (imx214->dev); +return 0 ; free_entity: +pm_runtime_disable (imx214->dev); +pm_runtime_set_suspended (&client->dev);media_entity_cleanup (&imx214->sd.entity); + free_ctrl:mutex_destroy (&imx214->mutex);v4l2_ctrl_handler_free (&imx214->ctrls); + error_power_off: -pm_runtime_disable (imx214->dev); +imx214_power_off (imx214->dev);return ret; }
@@ -1126,11 +1131,12 @@ static void imx214_remove(struct i2c_cliv4l2_async_unregister_subdev (&imx214->sd);media_entity_cleanup (&imx214->sd.entity);v4l2_ctrl_handler_free (&imx214->ctrls); - -pm_runtime_disable (&client->dev); -pm_runtime_set_suspended (&client->dev); -mutex_destroy (&imx214->mutex); +pm_runtime_disable (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) { +imx214_power_off (imx214->dev); +pm_runtime_set_suspended (&client->dev); + } }static const struct of_device_id imx214_of_match[] = {
Greg Kroah-Hartman
maintainerPATCH 229/393 media: chips-media: wave5: Fix gray color on screen
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackson.lee <[email protected]>
commit 6bae4d5053da634eecb611118e7cd91a677a4bbf upstream.
When a decoder instance is created, the W5_CMD_ERR_CONCEAL register should be initialized to 0. Otherwise, gray color is occasionally displayed on the screen while decoding.
--- drivers/media/platform/chips-media/wave5/wave5-hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-hw.c +1 -1
@@ -576,7 +576,7 @@ int wave5_vpu_build_up_dec_param(structvpu_write_reg (inst->dev,W5_CMD_NUM_CQ_DEPTH_M1 ,WAVE521_COMMAND_QUEUE_DEPTH -1 ); } - +vpu_write_reg (inst->dev,W5_CMD_ERR_CONCEAL ,0 ); ret =send_firmware_command (inst,W5_CREATE_INSTANCE , true,NULL ,NULL );if (ret) {wave5_vdi_free_dma_memory (vpu_dev, &p_dec_info->vb_work);
Greg Kroah-Hartman
maintainerPATCH 230/393 media: chips-media: wave5: Avoid race condition in the interrupt handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackson.lee <[email protected]>
commit ac35f768986610480a1c01323d9cf9f5eaf3ee9b upstream.
In case of multiple active instances, new interrupts can occur as soon as the current interrupt is cleared. If the driver reads the instance_info after clearing the interrupt, then there is no guarantee, that the instance_info is still valid for the current interrupt.
Read the instance_info register for each interrupt before clearing the interrupt.
--- drivers/media/platform/chips-media/wave5/wave5-vpu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +2 -2
@@ -54,12 +54,12 @@ static void wave5_vpu_handle_irq(void *dstruct vpu_device *dev = dev_id; irq_reason =wave5_vdi_read_register (dev,W5_VPU_VINT_REASON ); + seq_done =wave5_vdi_read_register (dev,W5_RET_SEQ_DONE_INSTANCE_INFO ); + cmd_done =wave5_vdi_read_register (dev,W5_RET_QUEUE_CMD_DONE_INST );wave5_vdi_write_register (dev,W5_VPU_VINT_REASON_CLR , irq_reason);wave5_vdi_write_register (dev,W5_VPU_VINT_CLEAR ,0x1 );list_for_each_entry (inst, &dev->instances, list) { - seq_done =wave5_vdi_read_register (dev,W5_RET_SEQ_DONE_INSTANCE_INFO ); - cmd_done =wave5_vdi_read_register (dev,W5_RET_QUEUE_CMD_DONE_INST );if (irq_reason &BIT (INT_WAVE5_INIT_SEQ ) || irq_reason &BIT (INT_WAVE5_ENC_SET_PARAM )) {
Greg Kroah-Hartman
maintainerPATCH 231/393 media: chips-media: wave5: Fix a hang after seeking
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackson.lee <[email protected]>
commit a2c75e964e51b096e9fe6adfa3eaed53594a668b upstream.
While seeking, the driver calls the flush command. Before the flush command is sent to the VPU, the driver should handle the display buffer flags and should get all decoded information from the VPU if the VCORE is running.
--- drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 17 ++++++++++++++- drivers/media/platform/chips-media/wave5/wave5-vpuapi.c | 10 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +16 -1
@@ -1446,6 +1446,16 @@ static int streamoff_output(struct vb2_qstruct vb2_v4l2_buffer *buf;int ret;dma_addr_t new_rd_ptr; +struct dec_output_info dec_info; +unsigned int i; + +for (i =0 ; i <v4l2_m2m_num_dst_bufs_ready (m2m_ctx); i++) { + ret =wave5_vpu_dec_set_disp_flag (inst, i); +if (ret) +dev_dbg (inst->dev->dev, +"%s: Setting display flag of buf index: %u, fail: %d\n" , + __func__, i, ret); + }while ((buf =v4l2_m2m_src_buf_remove (m2m_ctx))) { dev_dbg(inst->dev->dev, "%s: (Multiplanar) buf type %4u | index %4u\n",
@@ -1453,6 +1463,11 @@ static int streamoff_output(struct vb2_qv4l2_m2m_buf_done (buf,VB2_BUF_STATE_ERROR ); } +while (wave5_vpu_dec_get_output_info (inst, &dec_info) ==0 ) { +if (dec_info.index_frame_display >=0 ) +wave5_vpu_dec_set_disp_flag (inst, dec_info.index_frame_display); + } + ret =wave5_vpu_flush_instance (inst);if (ret)return ret;
@@ -1535,7 +1550,7 @@ static void wave5_vpu_dec_stop_streamingbreak ;if (wave5_vpu_dec_get_output_info (inst, &dec_output_info)) -dev_dbg (inst->dev->dev,"Getting decoding results from fw, fail\n" ); +dev_dbg (inst->dev->dev,"there is no output info\n" ); }v4l2_m2m_update_stop_streaming_state (m2m_ctx, q);
drivers/media/platform/chips-media/wave5/wave5-vpuapi.c +10 -0
@@ -73,6 +73,16 @@ int wave5_vpu_flush_instance(struct vpu_ inst->type == VPU_INST_TYPE_DEC ? "DECODER" : "ENCODER", inst->id);mutex_unlock (&inst->dev->hw_lock);return -ETIMEDOUT ; + }else if (ret == -EBUSY ) { +struct dec_output_info dec_info; + +mutex_unlock (&inst->dev->hw_lock); +wave5_vpu_dec_get_output_info (inst, &dec_info); + ret =mutex_lock_interruptible (&inst->dev->hw_lock); +if (ret) +return ret; +if (dec_info.index_frame_display >0 ) +wave5_vpu_dec_set_disp_flag (inst, dec_info.index_frame_display); } }while (ret !=0 );mutex_unlock (&inst->dev->hw_lock);
Greg Kroah-Hartman
maintainerPATCH 232/393 media: chips-media: wave5: Fix timeout while testing 10bit hevc fluster
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jackson.lee <[email protected]>
commit 035371c9e5098018b8512efc6a8812912469480c upstream.
The Wave5 521C variant does not support 10 bit decoding. When 10 bit decoding support was added for the 515 variant, a section of the code was removed which returned an error. This removal causes a timeout for the 521 variant, which was discovered during HEVC 10-bit decoding tests.
--- drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu-dec.c +14 -0
@@ -1424,10 +1424,24 @@ static int wave5_vpu_dec_start_streamingif (ret) goto free_bitstream_vbuf; }else if (q->type ==V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE ) { +struct dec_initial_info *initial_info = + &inst->codec_info->dec_info.initial_info; +if (inst->state ==VPU_INST_STATE_STOP ) ret =switch_state (inst,VPU_INST_STATE_INIT_SEQ );if (ret) goto return_buffers; + +if (inst->state ==VPU_INST_STATE_INIT_SEQ && + inst->dev->product_code ==WAVE521C_CODE ) { +if (initial_info->luma_bitdepth !=8 ) { +dev_info (inst->dev->dev,"%s: no support for %d bit depth" , + __func__, initial_info->luma_bitdepth); + ret = -EINVAL ; + goto return_buffers; + } + } + }return ret;
Greg Kroah-Hartman
maintainerPATCH 233/393 mptcp: sockopt: fix getting IPV6_V6ONLY
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 8c39633759885b6ff85f6d96cf445560e74df5e8 upstream.
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
IPV6_V6ONLY support for the setsockopt part has been added a while ago, but it looks like the get part got forgotten. It should have been present as a way to verify a setting has been set as expected, and not to act differently from TCP or any other socket types.
Not supporting this getsockopt(IPV6_V6ONLY) blocks some apps which want to check the default value, before doing extra actions. On Linux, the default value is 0, but this can be changed with the net.ipv6.bindv6only sysctl knob. On Windows, it is set to 1 by default. So supporting the get part, like for all other socket options, is important.
Everything was in place to expose it, just the last step was missing. Only new code is added to cover this specific getsockopt(), that seems safe.
--- net/mptcp/sockopt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/mptcp/sockopt.c +16 -0
@@ -1430,6 +1430,20 @@ static int mptcp_getsockopt_v4(struct mpreturn -EOPNOTSUPP ; } +static int mptcp_getsockopt_v6 (struct mptcp_sock *msk,int optname, +char __user *optval,int __user *optlen) +{ +struct sock *sk = (void *)msk; + +switch (optname) { +case IPV6_V6ONLY : +return mptcp_put_int_option (msk, optval, optlen, + sk->sk_ipv6only); + } + +return -EOPNOTSUPP ; +} +static int mptcp_getsockopt_sol_mptcp (struct mptcp_sock *msk,int optname,char __user *optval,int __user *optlen) {
@@ -1469,6 +1483,8 @@ int mptcp_getsockopt(struct sock *sk, inif (level ==SOL_IP )return mptcp_getsockopt_v4 (msk, optname, optval, option); +if (level ==SOL_IPV6 ) +return mptcp_getsockopt_v6 (msk, optname, optval, option);if (level ==SOL_TCP )return mptcp_getsockopt_sol_tcp (msk, optname, optval, option);if (level ==SOL_MPTCP )
Greg Kroah-Hartman
maintainerPATCH 234/393 mptcp: sockopt: fix getting freebind & transparent
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit e2f4ac7bab2205d3c4dd9464e6ffd82502177c51 upstream.
When adding a socket option support in MPTCP, both the get and set parts are supposed to be implemented.
IP(V6)_FREEBIND and IP(V6)_TRANSPARENT support for the setsockopt part has been added a while ago, but it looks like the get part got forgotten. It should have been present as a way to verify a setting has been set as expected, and not to act differently from TCP or any other socket types.
Everything was in place to expose it, just the last step was missing. Only new code is added to cover these specific getsockopt(), that seems safe.
--- net/mptcp/sockopt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/mptcp/sockopt.c +12 -0
@@ -1419,6 +1419,12 @@ static int mptcp_getsockopt_v4(struct mpswitch (optname) {case IP_TOS :return mptcp_put_int_option (msk, optval, optlen,READ_ONCE (inet_sk (sk)->tos)); +case IP_FREEBIND : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (FREEBIND , sk)); +case IP_TRANSPARENT : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (TRANSPARENT , sk));case IP_BIND_ADDRESS_NO_PORT :return mptcp_put_int_option (msk, optval, optlen,inet_test_bit (BIND_ADDRESS_NO_PORT , sk));
@@ -1439,6 +1445,12 @@ static int mptcp_getsockopt_v6(struct mpcase IPV6_V6ONLY :return mptcp_put_int_option (msk, optval, optlen, sk->sk_ipv6only); +case IPV6_TRANSPARENT : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (TRANSPARENT , sk)); +case IPV6_FREEBIND : +return mptcp_put_int_option (msk, optval, optlen, +inet_test_bit (FREEBIND , sk)); }return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 235/393 mtd: Add check for devm_kcalloc()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
commit 2aee30bb10d7bad0a60255059c9ce1b84cf0130e upstream.
Add a check for devm_kcalloc() to ensure successful allocation.
--- drivers/mtd/mtdpstore.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/mtdpstore.c +3 -0
@@ -423,6 +423,9 @@ static void mtdpstore_notify_add(struct longcnt =BITS_TO_LONGS (div_u64 (mtd->size, mtd->erasesize)); cxt->badmap =kcalloc (longcnt,sizeof (long ),GFP_KERNEL ); +if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap) +return ; +/* just support dmesg right now */ cxt->dev.flags =PSTORE_FLAGS_DMESG ; cxt->dev.zone.read = mtdpstore_read;
Greg Kroah-Hartman
maintainerPATCH 236/393 net: dsa: mv88e6xxx: workaround RGMII transmit delay erratum for 6320 family
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Behún <[email protected]>
commit 1ebc8e1ef906db9c08e9abe9776d85ddec837725 upstream.
Implement the workaround for erratum
3.3 RGMII timing may be out of spec when transmit delay is enabled
for the 6320 family, which says:
When transmit delay is enabled via Port register 1 bit 14 = 1, duty cycle may be out of spec. Under very rare conditions this may cause the attached device receive CRC errors.
--- drivers/net/dsa/mv88e6xxx/chip.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/dsa/mv88e6xxx/chip.c +17 -0
@@ -3691,6 +3691,21 @@ static int mv88e6xxx_stats_setup(structreturn mv88e6xxx_g1_stats_clear (chip); } +static int mv88e6320_setup_errata (struct mv88e6xxx_chip *chip) +{ +u16 dummy; +int err; + +/* Workaround for erratum +* 3.3 RGMII timing may be out of spec when transmit delay is enabled +*/ + err =mv88e6xxx_port_hidden_write (chip,0 ,0xf ,0x7 ,0xe000 ); +if (err) +return err; + +return mv88e6xxx_port_hidden_read (chip,0 ,0xf ,0x7 , &dummy); +} +/* Check if the errata has already been applied. */ static bool mv88e6390_setup_errata_applied (struct mv88e6xxx_chip *chip) {
@@ -5144,6 +5159,7 @@ static const struct mv88e6xxx_ops mv88e6static const struct mv88e6xxx_ops mv88e6320_ops = {/* MV88E6XXX_FAMILY_6320 */ + .setup_errata = mv88e6320_setup_errata, .ieee_pri_map = mv88e6085_g1_ieee_pri_map, .ip_pri_map = mv88e6085_g1_ip_pri_map, .irl_init_all = mv88e6352_g2_irl_init_all,
@@ -5193,6 +5209,7 @@ static const struct mv88e6xxx_ops mv88e6static const struct mv88e6xxx_ops mv88e6321_ops = {/* MV88E6XXX_FAMILY_6320 */ + .setup_errata = mv88e6320_setup_errata, .ieee_pri_map = mv88e6085_g1_ieee_pri_map, .ip_pri_map = mv88e6085_g1_ip_pri_map, .irl_init_all = mv88e6352_g2_irl_init_all,
Greg Kroah-Hartman
maintainerPATCH 237/393 net: dsa: mv88e6xxx: fix internal PHYs for 6320 family
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Behún <[email protected]>
commit 52fdc41c3278c981066a461d03d5477ebfcf270c upstream.
Fix internal PHYs definition for the 6320 family, which has only 2 internal PHYs (on ports 3 and 4).
--- drivers/net/dsa/mv88e6xxx/chip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/dsa/mv88e6xxx/chip.c +4 -2
@@ -6171,7 +6171,8 @@ static const struct mv88e6xxx_info mv88e .num_databases = 4096, .num_macs = 8192, .num_ports = 7, - .num_internal_phys = 5, + .num_internal_phys = 2, + .internal_phys_offset = 3, .num_gpio = 15, .max_vid = 4095, .max_sid = 63,
@@ -6365,7 +6366,8 @@ static const struct mv88e6xxx_info mv88e .num_databases = 4096, .num_macs = 8192, .num_ports = 7, - .num_internal_phys = 5, + .num_internal_phys = 2, + .internal_phys_offset = 3, .num_gpio = 15, .max_vid = 4095, .max_sid = 63,
Greg Kroah-Hartman
maintainerPATCH 238/393 mtd: Replace kcalloc() with devm_kcalloc()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiasheng Jiang <[email protected]>
commit 1b61a59876f0eafc19b23007c522ee407f55dbec upstream.
Replace kcalloc() with devm_kcalloc() to prevent memory leaks in case of errors.
--- drivers/mtd/mtdpstore.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mtd/mtdpstore.c +3 -6
@@ -417,11 +417,11 @@ static void mtdpstore_notify_add(struct } longcnt =BITS_TO_LONGS (div_u64 (mtd->size, info->kmsg_size)); - cxt->rmmap =kcalloc (longcnt,sizeof (long ),GFP_KERNEL ); - cxt->usedmap =kcalloc (longcnt,sizeof (long ),GFP_KERNEL ); + cxt->rmmap =devm_kcalloc (&mtd->dev, longcnt,sizeof (long ),GFP_KERNEL ); + cxt->usedmap =devm_kcalloc (&mtd->dev, longcnt,sizeof (long ),GFP_KERNEL ); longcnt =BITS_TO_LONGS (div_u64 (mtd->size, mtd->erasesize)); - cxt->badmap =kcalloc (longcnt,sizeof (long ),GFP_KERNEL ); + cxt->badmap =devm_kcalloc (&mtd->dev, longcnt,sizeof (long ),GFP_KERNEL );if (!cxt->rmmap || !cxt->usedmap || !cxt->badmap)return ;
@@ -530,9 +530,6 @@ static void mtdpstore_notify_remove(strumtdpstore_flush_removed (cxt);unregister_pstore_device (&cxt->dev); -kfree (cxt->badmap); -kfree (cxt->usedmap); -kfree (cxt->rmmap); cxt->mtd =NULL ; cxt->index =-1 ; }
Greg Kroah-Hartman
maintainerPATCH 239/393 clocksource/drivers/stm32-lptimer: Use wakeup capable instead of init wakeup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexandre Torgue <[email protected]>
commit 96bf4b89a6ab22426ad83ef76e66c72a5a8daca0 upstream.
"wakeup-source" property describes a device which has wakeup capability but should not force this device as a wakeup source.
Rule: add
--- drivers/clocksource/timer-stm32-lp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/timer-stm32-lp.c +1 -3
@@ -168,9 +168,7 @@ static int stm32_clkevent_lp_probe(struc }if (of_property_read_bool (pdev->dev.parent->of_node,"wakeup-source" )) { - ret =device_init_wakeup (&pdev->dev, true); -if (ret) - goto out_clk_disable; +device_set_wakeup_capable (&pdev->dev, true); ret =dev_pm_set_wake_irq (&pdev->dev, irq);if (ret)
Greg Kroah-Hartman
maintainerPATCH 240/393 wifi: mt76: Add check for devm_kstrdup()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 4bc1da524b502999da28d287de4286c986a1af57 upstream.
Add check for the return value of devm_kstrdup() in mt76_get_of_data_from_mtd() to catch potential exception.
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/mediatek/mt76/eeprom.c +4 -0
@@ -95,6 +95,10 @@ int mt76_get_of_data_from_mtd(struct mt7#ifdef CONFIG_NL80211_TESTMODE dev->test_mtd.name =devm_kstrdup (dev->dev, part,GFP_KERNEL ); +if (!dev->test_mtd.name) { + ret = -ENOMEM ; + goto out_put_node; + } dev->test_mtd.offset = offset;#endif
Greg Kroah-Hartman
maintainerPATCH 241/393 wifi: mac80211: fix integer overflow in hwmp_route_info_get()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gavrilov Ilia <[email protected]>
commit d00c0c4105e5ab8a6a13ed23d701cceb285761fa upstream.
Since the new_metric and last_hop_metric variables can reach the MAX_METRIC(0xffffffff) value, an integer overflow may occur when multiplying them by 10/9. It can lead to incorrect behavior.
Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE.
--- net/mac80211/mesh_hwmp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/mac80211/mesh_hwmp.c +10 -4
@@ -367,6 +367,12 @@ u32 airtime_link_metric_get(struct ieee8return (u32 )result; } +/* Check that the first metric is at least 10% better than the second one */ +static bool is_metric_better (u32 x,u32 y) +{ +return (x < y) && (x < (y - x /10 )); +} +/** * hwmp_route_info_get - Update routing info to originator and transmitter *
@@ -458,8 +464,8 @@ static u32 hwmp_route_info_get(struct ie (mpath->sn == orig_sn && (rcu_access_pointer (mpath->next_hop) != sta ? -mult_frac (new_metric,10 ,9 ) : - new_metric) >= mpath->metric)) { + !is_metric_better (new_metric, mpath->metric) : + new_metric >= mpath->metric))) { process = false; fresh_info = false; }
@@ -533,8 +539,8 @@ static u32 hwmp_route_info_get(struct ieif ((mpath->flags &MESH_PATH_FIXED ) || ((mpath->flags &MESH_PATH_ACTIVE ) && ((rcu_access_pointer (mpath->next_hop) != sta ? -mult_frac (last_hop_metric,10 ,9 ) : - last_hop_metric) > mpath->metric))) + !is_metric_better (last_hop_metric, mpath->metric) : + last_hop_metric > mpath->metric)))) fresh_info = false; }else { mpath =mesh_path_add (sdata, ta);
Greg Kroah-Hartman
maintainerPATCH 242/393 wifi: mt76: mt7925: ensure wow pattern command align fw format
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yen Hsieh <[email protected]>
commit 8ae45b1f699bbc27ea8647093f794f671e77410b upstream.
Align the format of "struct mt7925_wow_pattern_tlv" with firmware to ensure proper functionality.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h +2 -2
@@ -566,8 +566,8 @@ struct mt7925_wow_pattern_tlv {u8 offset;u8 mask[MT76_CONNAC_WOW_MASK_MAX_LEN ];u8 pattern[MT76_CONNAC_WOW_PATTEN_MAX_LEN ]; -u8 rsv[7 ]; -} __packed; +u8 rsv[4 ]; +};struct roc_acquire_tlv {__le16 tag;
Greg Kroah-Hartman
maintainerPATCH 243/393 wifi: mt76: mt7925: fix country count limitation for CLC
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yen Hsieh <[email protected]>
commit 6458d760a0c0afd2fda11e83ed3e1125a252432f upstream.
Due to the increase in the number of power tables for 6Ghz on CLC, the variable nr_country is no longer sufficient to represent the total quantity. Therefore, we have switched to calculating the length of clc buf to obtain the correct power table.
--- drivers/net/wireless/mediatek/mt76/mt7925/mcu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +3 -2
@@ -3119,13 +3119,14 @@ __mt7925_mcu_set_clc(struct mt792x_dev * .env = env_cap, };int ret, valid_cnt =0 ; -u8 i, *pos; +u8 *pos, *last_pos;if (!clc)return 0 ; pos = clc->data +sizeof (*seg) * clc->nr_seg; -for (i =0 ; i < clc->nr_country; i++) { + last_pos = clc->data +le32_to_cpu (*(__le32 *)(clc->data +4 )); +while (pos < last_pos) {struct mt7925_clc_rule *rule = (struct mt7925_clc_rule *)pos; pos +=sizeof (*rule);
Greg Kroah-Hartman
maintainerPATCH 244/393 wifi: mt76: mt7925: fix the wrong link_idx when a p2p_device is present
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yen Hsieh <[email protected]>
commit 4bada9b0a29c185d45cc9512509edd6069fbfa79 upstream.
When the p2p device and MLO station are running concurrently, the p2p device will occupy the wrong link_idx when the MLO secondary link is added.
--- drivers/net/wireless/mediatek/mt76/mt76.h | 1 + drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 4 ++-- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 14 ++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -755,6 +755,7 @@ struct mt76_testmode_data {struct mt76_vif {u8 idx; +u8 link_idx;u8 omac_idx;u8 band_idx;u8 wmm_idx;
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +2 -2
@@ -1164,7 +1164,7 @@ int mt76_connac_mcu_uni_add_dev(struct m .tag = cpu_to_le16(DEV_INFO_ACTIVE), .len = cpu_to_le16(sizeof(struct req_tlv)), .active = enable, - .link_idx = mvif->idx, + .link_idx = mvif->link_idx, }, }; struct {
@@ -1187,7 +1187,7 @@ int mt76_connac_mcu_uni_add_dev(struct m .bmc_tx_wlan_idx = cpu_to_le16(wcid->idx), .sta_idx = cpu_to_le16(wcid->idx), .conn_state = 1, - .link_idx = mvif->idx, + .link_idx = mvif->link_idx, }, };int err, idx, cmd, len;
drivers/net/wireless/mediatek/mt76/mt7925/main.c +10 -4
@@ -356,10 +356,15 @@ static int mt7925_mac_link_bss_add(strucstruct mt76_txq *mtxq;int idx, ret =0 ; - mconf->mt76.idx =__ffs64 (~dev->mt76.vif_mask); -if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { - ret = -ENOSPC ; - goto out; +if (vif->type ==NL80211_IFTYPE_P2P_DEVICE ) { + mconf->mt76.idx = MT792x_MAX_INTERFACES; + }else { + mconf->mt76.idx =__ffs64 (~dev->mt76.vif_mask); + +if (mconf->mt76.idx >= MT792x_MAX_INTERFACES) { + ret = -ENOSPC ; + goto out; + } } mconf->mt76.omac_idx = ieee80211_vif_is_mld(vif) ?
@@ -367,6 +372,7 @@ static int mt7925_mac_link_bss_add(struc mconf->mt76.band_idx =0xff ; mconf->mt76.wmm_idx =ieee80211_vif_is_mld (vif) ?0 : mconf->mt76.idx %MT76_CONNAC_MAX_WMM_SETS ; + mconf->mt76.link_idx =hweight16 (mvif->valid_links);if (mvif->phy->mt76->chandef.chan->band !=NL80211_BAND_2GHZ ) mconf->mt76.basic_rates_idx = MT792x_BASIC_RATES_TBL +4 ;
Greg Kroah-Hartman
maintainerPATCH 245/393 wifi: mt76: mt7925: fix the wrong simultaneous cap for MLO
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Yen Hsieh <[email protected]>
commit 7dcea6fe33ee3d7cbb65baee0dd7adc76d1c9ddc upstream.
The mt7925 chip is only support a single radio, so the maximum number of simultaneous should be 0.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +1 -1
@@ -256,7 +256,7 @@ int mt7925_init_mlo_caps(struct mt792x_phy *phy) ext_capab[0 ].eml_capabilities = phy->eml_cap; ext_capab[0 ].mld_capa_and_ops = -u16_encode_bits (1 ,IEEE80211_MLD_CAP_OP_MAX_SIMUL_LINKS ); +u16_encode_bits (0 ,IEEE80211_MLD_CAP_OP_MAX_SIMUL_LINKS ); wiphy->flags |=WIPHY_FLAG_SUPPORTS_MLO ; wiphy->iftype_ext_capab = ext_capab;
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 246/393 io_uring/net: fix accept multishot handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit f6a89bf5278d6e15016a736db67043560d1b50d5 upstream.
REQ_F_APOLL_MULTISHOT doesn't guarantee it's executed from the multishot context, so a multishot accept may get executed inline, fail io_req_post_cqe(), and ask the core code to kill the request with -ECANCELED by returning IOU_STOP_MULTISHOT even when a socket has been accepted and installed.
--- io_uring/net.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/net.c +2 -0
@@ -1616,6 +1616,8 @@ retry: }io_req_set_res (req, ret, cflags); +if (!(issue_flags &IO_URING_F_MULTISHOT )) +return IOU_OK ;return IOU_STOP_MULTISHOT ; }
Greg Kroah-Hartman
maintainerPATCH 247/393 io_uring/net: fix io_req_post_cqe abuse by send bundle
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 6889ae1b4df1579bcdffef023e2ea9a982565dff upstream.
[ 114.987980][ T5313] WARNING: CPU: 6 PID: 5313 at io_uring/io_uring.c:872 io_req_post_cqe+0x12e/0x4f0 [ 114.991597][ T5313] RIP: 0010:io_req_post_cqe+0x12e/0x4f0 [ 115.001880][ T5313] Call Trace: [ 115.002222][ T5313] <TASK> [ 115.007813][ T5313] io_send+0x4fe/0x10f0 [ 115.009317][ T5313] io_issue_sqe+0x1a6/0x1740 [ 115.012094][ T5313] io_wq_submit_work+0x38b/0xed0 [ 115.013223][ T5313] io_worker_handle_work+0x62a/0x1600 [ 115.013876][ T5313] io_wq_worker+0x34f/0xdf0
As the comment states, io_req_post_cqe() should only be used by multishot requests, i.e. REQ_F_APOLL_MULTISHOT, which bundled sends are not. Add a flag signifying whether a request wants to post multiple CQEs. Eventually REQ_F_APOLL_MULTISHOT should imply the new flag, but that's left out for simplicity.
--- include/linux/io_uring_types.h | 3 +++ io_uring/io_uring.c | 4 ++-- io_uring/net.c | 1 + 3 files changed, 6 insertions(+), 2 deletions(-)
include/linux/io_uring_types.h +3 -0
@@ -457,6 +457,7 @@ enum {REQ_F_SKIP_LINK_CQES_BIT ,REQ_F_SINGLE_POLL_BIT ,REQ_F_DOUBLE_POLL_BIT , +REQ_F_MULTISHOT_BIT ,REQ_F_APOLL_MULTISHOT_BIT ,REQ_F_CLEAR_POLLIN_BIT , REQ_F_HASH_LOCKED_BIT,
@@ -530,6 +531,8 @@ enum {REQ_F_SINGLE_POLL =IO_REQ_FLAG (REQ_F_SINGLE_POLL_BIT ),/* double poll may active */ REQ_F_DOUBLE_POLL =IO_REQ_FLAG (REQ_F_DOUBLE_POLL_BIT ), +/* request posts multiple completions, should be set at prep time */ +REQ_F_MULTISHOT =IO_REQ_FLAG (REQ_F_MULTISHOT_BIT ),/* fast poll multishot mode */ REQ_F_APOLL_MULTISHOT = IO_REQ_FLAG(REQ_F_APOLL_MULTISHOT_BIT),/* recvmsg special flag, clear EPOLLIN */
io_uring/io_uring.c +2 -2
@@ -1821,7 +1821,7 @@ fail:* Don't allow any multishot execution from io-wq. It's more restrictive * than necessary and also cleaner. */ -if (req->flags &REQ_F_APOLL_MULTISHOT ) { +if (req->flags & (REQ_F_MULTISHOT |REQ_F_APOLL_MULTISHOT )) { err = -EBADFD ;if (!io_file_can_poll (req)) goto fail;
@@ -1832,7 +1832,7 @@ fail: goto fail;return ; }else { - req->flags &= ~REQ_F_APOLL_MULTISHOT ; + req->flags &= ~(REQ_F_APOLL_MULTISHOT |REQ_F_MULTISHOT ); } }
io_uring/net.c +1 -0
@@ -435,6 +435,7 @@ int io_sendmsg_prep(struct io_kiocb *req sr->msg_flags |=MSG_WAITALL ; sr->buf_group = req->buf_index; req->buf_list =NULL ; + req->flags |=REQ_F_MULTISHOT ; }#ifdef CONFIG_COMPAT
Greg Kroah-Hartman
maintainerPATCH 248/393 io_uring/kbuf: reject zero sized provided buffers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit cf960726eb65e8d0bfecbcce6cf95f47b1ffa6cc upstream.
This isn't fixing a real issue, but there's also zero point in going through group and buffer setup, when the buffers are going to be rejected once attempted to get used.
--- io_uring/kbuf.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/kbuf.c +2 -0
@@ -484,6 +484,8 @@ int io_provide_buffers_prep(struct io_ki p->nbufs = tmp; p->addr =READ_ONCE (sqe->addr); p->len =READ_ONCE (sqe->len); +if (!p->len) +return -EINVAL ;if (check_mul_overflow ((unsigned long )p->len, (unsigned long )p->nbufs, &size))
Greg Kroah-Hartman
maintainerPATCH 249/393 ASoC: codecs: wcd937x: fix a potential memory leak in wcd937x_soc_codec_probe()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 3e330acf4efd63876d673c046cd073a1d4ed57a8 upstream.
When snd_soc_dapm_new_controls() or snd_soc_dapm_add_routes() fails, wcd937x_soc_codec_probe() returns without releasing 'wcd937x->clsh_info', which is allocated by wcd_clsh_ctrl_alloc. Add wcd_clsh_ctrl_free() to prevent potential memory leak.
--- sound/soc/codecs/wcd937x.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/wcd937x.c +2 -0
@@ -2564,6 +2564,7 @@ static int wcd937x_soc_codec_probe(struc ARRAY_SIZE(wcd9375_dapm_widgets));if (ret <0 ) {dev_err (component->dev,"Failed to add snd_ctls\n" ); +wcd_clsh_ctrl_free (wcd937x->clsh_info);return ret; }
@@ -2571,6 +2572,7 @@ static int wcd937x_soc_codec_probe(struc ARRAY_SIZE(wcd9375_audio_map));if (ret <0 ) {dev_err (component->dev,"Failed to add routes\n" ); +wcd_clsh_ctrl_free (wcd937x->clsh_info);return ret; } }
Greg Kroah-Hartman
maintainerPATCH 250/393 ASoC: q6apm: add q6apm_get_hw_pointer helper
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 0badb5432fd525a00db5630c459b635e9d47f445 upstream.
Implement an helper function in q6apm to be able to read the current hardware pointer for both read and write buffers.
This should help q6apm-dai to get the hardware pointer consistently without it doing manual calculation, which could go wrong in some race conditions.
--- sound/soc/qcom/qdsp6/q6apm.c | 18 +++++++++++++++++- sound/soc/qcom/qdsp6/q6apm.h | 3 +++ 2 files changed, 20 insertions(+), 1 deletion(-)
sound/soc/qcom/qdsp6/q6apm.c +17 -1
@@ -494,6 +494,19 @@ int q6apm_read(struct q6apm_graph *graph }EXPORT_SYMBOL_GPL (q6apm_read); +int q6apm_get_hw_pointer (struct q6apm_graph *graph,int dir) +{ +struct audioreach_graph_data *data; + +if (dir ==SNDRV_PCM_STREAM_PLAYBACK ) + data = &graph->rx_data; +else + data = &graph->tx_data; + +return (int )atomic_read (&data->hw_ptr); +} +EXPORT_SYMBOL_GPL (q6apm_get_hw_pointer); +static int graph_callback (struct gpr_resp_pkt *data,void *priv,int op) {struct data_cmd_rsp_rd_sh_mem_ep_data_buffer_done_v2 *rd_done;
@@ -520,7 +533,8 @@ static int graph_callback(struct gpr_res done = data->payload; phys = graph->rx_data.buf[token].phys;mutex_unlock (&graph->lock); - +/* token numbering starts at 0 */ +atomic_set (&graph->rx_data.hw_ptr, token +1 );if (lower_32_bits (phys) == done->buf_addr_lsw &&upper_32_bits (phys) == done->buf_addr_msw) { graph->result.opcode = hdr->opcode;
@@ -553,6 +567,8 @@ static int graph_callback(struct gpr_res rd_done = data->payload; phys = graph->tx_data.buf[hdr->token].phys;mutex_unlock (&graph->lock); +/* token numbering starts at 0 */ +atomic_set (&graph->tx_data.hw_ptr, hdr->token +1 );if (upper_32_bits (phys) == rd_done->buf_addr_msw &&lower_32_bits (phys) == rd_done->buf_addr_lsw) {
sound/soc/qcom/qdsp6/q6apm.h +3 -0
@@ -2,6 +2,7 @@#ifndef __Q6APM_H__#define __Q6APM_H__#include <linux/types.h> +#include <linux/atomic.h> #include <linux/slab.h> #include <linux/wait.h> #include <linux/kernel.h>
@@ -77,6 +78,7 @@ struct audioreach_graph_data {uint32_t num_periods;uint32_t dsp_buf;uint32_t mem_map_handle; +atomic_t hw_ptr; };struct audioreach_graph {
@@ -150,4 +152,5 @@ int q6apm_enable_compress_module(structint q6apm_remove_initial_silence (struct device *dev,struct q6apm_graph *graph,uint32_t samples);int q6apm_remove_trailing_silence (struct device *dev,struct q6apm_graph *graph,uint32_t samples);int q6apm_set_real_module_id (struct device *dev,struct q6apm_graph *graph,uint32_t codec_id); +int q6apm_get_hw_pointer (struct q6apm_graph *graph,int dir);#endif /* __APM_GRAPH_ */
Greg Kroah-Hartman
maintainerPATCH 251/393 ASoC: q6apm-dai: schedule all available frames to avoid dsp under-runs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 3d4a4411aa8bbc3653ff22a1ff0432eb93d22ae0 upstream.
With the existing code, we are only setting up one period at a time, in a ping-pong buffer style. This triggers lot of underruns in the dsp leading to jitter noise during audio playback.
Fix this by scheduling all available periods, this will ensure that the dsp has enough buffer feed and ultimatley fixing the underruns and audio distortion.
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +23 -5
@@ -70,6 +70,7 @@ struct q6apm_dai_rtd {unsigned int bytes_received;unsigned int copied_total;uint16_t bits_per_sample; +snd_pcm_uframes_t queue_ptr;bool next_track;enum stream_state state;struct q6apm_graph *graph;
@@ -134,8 +135,6 @@ static void event_handler(uint32_t opcod prtd->pos += prtd->pcm_count;spin_unlock_irqrestore (&prtd->lock, flags);snd_pcm_period_elapsed (substream); -if (prtd->state ==Q6APM_STREAM_RUNNING ) -q6apm_write_async (prtd->graph, prtd->pcm_count,0 ,0 ,0 );break ;case APM_CLIENT_EVENT_DATA_READ_DONE :
@@ -294,6 +293,27 @@ static int q6apm_dai_prepare(struct snd_return 0 ; } +static int q6apm_dai_ack (struct snd_soc_component *component,struct snd_pcm_substream *substream) +{ +struct snd_pcm_runtime *runtime = substream->runtime; +struct q6apm_dai_rtd *prtd = runtime->private_data; +int i, ret =0 , avail_periods; + +if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) { + avail_periods = (runtime->control->appl_ptr - prtd->queue_ptr)/runtime->period_size; +for (i =0 ; i < avail_periods; i++) { + ret =q6apm_write_async (prtd->graph, prtd->pcm_count,0 ,0 ,NO_TIMESTAMP ); +if (ret <0 ) { +dev_err (component->dev,"Error queuing playback buffer %d\n" , ret); +return ret; + } + prtd->queue_ptr += runtime->period_size; + } + } + +return ret; +} +static int q6apm_dai_trigger (struct snd_soc_component *component,struct snd_pcm_substream *substream,int cmd) {
@@ -305,9 +325,6 @@ static int q6apm_dai_trigger(struct snd_case SNDRV_PCM_TRIGGER_START :case SNDRV_PCM_TRIGGER_RESUME :case SNDRV_PCM_TRIGGER_PAUSE_RELEASE : -/* start writing buffers for playback only as we already queued capture buffers */ -if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK ) - ret =q6apm_write_async (prtd->graph, prtd->pcm_count,0 ,0 ,0 );break ;case SNDRV_PCM_TRIGGER_STOP :/* TODO support be handled via SoftPause Module */
@@ -836,6 +853,7 @@ static const struct snd_soc_component_dr .hw_params = q6apm_dai_hw_params, .pointer = q6apm_dai_pointer, .trigger = q6apm_dai_trigger, + .ack = q6apm_dai_ack, .compress_ops = &q6apm_dai_compress_ops, .use_dai_pcm_id = true, };
Greg Kroah-Hartman
maintainerPATCH 252/393 ASoC: q6apm-dai: make use of q6apm_get_hw_pointer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit a93dad6f4e6a04a5943f6ee5686585f24abf7063 upstream.
With the existing code, the buffer position is only reset in pointer callback, which leaves the possiblity of it going over the size of buffer size and reporting incorrect position to userspace.
Without this patch, its possible to see errors like:
snd-x1e80100 sound: invalid position: pcmC0D0p:0, pos = 12288, buffer size = 12288, period size = 1536 snd-x1e80100 sound: invalid position: pcmC0D0p:0, pos = 12288, buffer size = 12288, period size = 1536
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +4 -19
@@ -64,7 +64,6 @@ struct q6apm_dai_rtd {phys_addr_t phys;unsigned int pcm_size;unsigned int pcm_count; -unsigned int pos;/* Buffer position */ unsigned int periods;unsigned int bytes_sent;unsigned int bytes_received;
@@ -124,23 +123,16 @@ static void event_handler(uint32_t opcod {struct q6apm_dai_rtd *prtd = priv;struct snd_pcm_substream *substream = prtd->substream; -unsigned long flags;switch (opcode) {case APM_CLIENT_EVENT_CMD_EOS_DONE : prtd->state =Q6APM_STREAM_STOPPED ;break ;case APM_CLIENT_EVENT_DATA_WRITE_DONE : -spin_lock_irqsave (&prtd->lock, flags); - prtd->pos += prtd->pcm_count; -spin_unlock_irqrestore (&prtd->lock, flags);snd_pcm_period_elapsed (substream);break ;case APM_CLIENT_EVENT_DATA_READ_DONE : -spin_lock_irqsave (&prtd->lock, flags); - prtd->pos += prtd->pcm_count; -spin_unlock_irqrestore (&prtd->lock, flags);snd_pcm_period_elapsed (substream);if (prtd->state ==Q6APM_STREAM_RUNNING )q6apm_read (prtd->graph);
@@ -247,7 +239,6 @@ static int q6apm_dai_prepare(struct snd_ } prtd->pcm_count =snd_pcm_lib_period_bytes (substream); - prtd->pos =0 ;/* rate and channels are sent to audio driver */ ret =q6apm_graph_media_format_shmem (prtd->graph, &cfg);if (ret <0 ) {
@@ -445,16 +436,12 @@ static snd_pcm_uframes_t q6apm_dai_pointstruct snd_pcm_runtime *runtime = substream->runtime;struct q6apm_dai_rtd *prtd = runtime->private_data;snd_pcm_uframes_t ptr; -unsigned long flags; -spin_lock_irqsave (&prtd->lock, flags); -if (prtd->pos == prtd->pcm_size) - prtd->pos =0 ; - - ptr =bytes_to_frames (runtime, prtd->pos); -spin_unlock_irqrestore (&prtd->lock, flags); + ptr =q6apm_get_hw_pointer (prtd->graph, substream->stream) * runtime->period_size; +if (ptr) +return ptr -1 ; -return ptr; +return 0 ; } static int q6apm_dai_hw_params(struct snd_soc_component *component,
@@ -669,8 +656,6 @@ static int q6apm_dai_compr_set_params(st prtd->pcm_size = runtime->fragments * runtime->fragment_size; prtd->bits_per_sample =16 ; - prtd->pos =0 ; -if (prtd->next_track != true) {memcpy (&prtd->codec, codec,sizeof (*codec));
Greg Kroah-Hartman
maintainerPATCH 253/393 ASoC: qdsp6: q6apm-dai: set 10 ms period and buffer alignment.
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 3107019501842c27334554ba9d6583b1f200f61f upstream.
DSP expects the periods to be aligned to fragment sizes, currently setting up to hw constriants on periods bytes is not going to work correctly as we can endup with periods sizes aligned to 32 bytes however not aligned to fragment size.
Update the constriants to use fragment size, and also set at step of 10ms for period size to accommodate DSP requirements of 10ms latency.
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +3 -2
@@ -385,13 +385,14 @@ static int q6apm_dai_open(struct snd_soc } } - ret =snd_pcm_hw_constraint_step (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_BYTES ,32 ); +/* setup 10ms latency to accommodate DSP restrictions */ + ret =snd_pcm_hw_constraint_step (runtime,0 ,SNDRV_PCM_HW_PARAM_PERIOD_SIZE ,480 );if (ret <0 ) {dev_err (dev,"constraint for period bytes step ret = %d\n" , ret); goto err; } - ret =snd_pcm_hw_constraint_step (runtime,0 ,SNDRV_PCM_HW_PARAM_BUFFER_BYTES ,32 ); + ret =snd_pcm_hw_constraint_step (runtime,0 ,SNDRV_PCM_HW_PARAM_BUFFER_SIZE ,480 );if (ret <0 ) {dev_err (dev,"constraint for buffer bytes step ret = %d\n" , ret); goto err;
Greg Kroah-Hartman
maintainerPATCH 254/393 ASoC: qdsp6: q6apm-dai: fix capture pipeline overruns.
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 5d01ed9b9939b4c726be74db291a982bc984c584 upstream.
Period sizes less than 6k for capture path triggers overruns in the dsp capture pipeline.
Change the period size and number of periods to value which DSP is happy with.
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +2 -2
@@ -24,8 +24,8 @@#define PLAYBACK_MIN_PERIOD_SIZE 128#define CAPTURE_MIN_NUM_PERIODS 2#define CAPTURE_MAX_NUM_PERIODS 8 -#define CAPTURE_MAX_PERIOD_SIZE 4096 -#define CAPTURE_MIN_PERIOD_SIZE 320 +#define CAPTURE_MAX_PERIOD_SIZE 65536 +#define CAPTURE_MIN_PERIOD_SIZE 6144#define BUFFER_BYTES_MAX (PLAYBACK_MAX_NUM_PERIODS * PLAYBACK_MAX_PERIOD_SIZE)#define BUFFER_BYTES_MIN (PLAYBACK_MIN_NUM_PERIODS * PLAYBACK_MIN_PERIOD_SIZE)#define COMPR_PLAYBACK_MAX_FRAGMENT_SIZE (128 * 1024)
Greg Kroah-Hartman
maintainerPATCH 255/393 ASoC: qdsp6: q6asm-dai: fix q6asm_dai_compr_set_params error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Klimov <[email protected]>
commit 7eccc86e90f04a0d758d16c08627a620ac59604d upstream.
In case of attempts to compress playback something, for instance, when audio routing is not set up correctly, the audio DSP is left in inconsistent state because we are not doing the correct things in the error path of q6asm_dai_compr_set_params().
So, when routing is not set up and compress playback is attempted the following errors are present (simplified log):
q6routing routing: Routing not setup for MultiMedia-1 Session q6asm-dai dais: Stream reg failed ret:-22
q6asm-dai dais: ASoC error (-22): at snd_soc_component_compr_set_params() on 17300000.remoteproc:glink-edge:apr:service@7:dais
After setting the correct routing the compress playback will always fail:
q6asm-dai dais: cmd = 0x10db3 returned error = 0x9
q6asm-dai dais: DSP returned error[9]
q6asm-dai dais: q6asm_open_write failed
q6asm-dai dais: ASoC error (-22): at snd_soc_component_compr_set_params() on 17300000.remoteproc:glink-edge:apr:service@7:dais
0x9 here means "Operation is already processed". The CMD_OPEN here was sent the second time hence DSP responds that it was already done.
Turns out the CMD_CLOSE should be sent after the q6asm_open_write() succeeded but something failed after that, for instance, routing setup.
Fix this by slightly reworking the error path inq6asm_dai_compr_set_params().
Tested on QRB5165 RB5 and SDM845 RB3 boards.
--- sound/soc/qcom/qdsp6/q6asm-dai.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
sound/soc/qcom/qdsp6/q6asm-dai.c +13 -6
@@ -892,9 +892,7 @@ static int q6asm_dai_compr_set_params(stif (ret <0 ) {dev_err (dev,"q6asm_open_write failed\n" ); -q6asm_audio_client_free (prtd->audio_client); - prtd->audio_client =NULL ; -return ret; + goto open_err; } }
@@ -903,7 +901,7 @@ static int q6asm_dai_compr_set_params(st prtd->session_id, dir);if (ret) {dev_err (dev,"Stream reg failed ret:%d\n" , ret); -return ret; + goto q6_err; } ret = __q6asm_dai_compr_set_codec_params(component, stream,
@@ -911,7 +909,7 @@ static int q6asm_dai_compr_set_params(st prtd->stream_id);if (ret) {dev_err (dev,"codec param setup failed ret:%d\n" , ret); -return ret; + goto q6_err; } ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys,
@@ -920,12 +918,21 @@ static int q6asm_dai_compr_set_params(stif (ret <0 ) {dev_err (dev,"Buffer Mapping failed ret:%d\n" , ret); -return -ENOMEM ; + ret = -ENOMEM ; + goto q6_err; } prtd->state =Q6ASM_STREAM_RUNNING ;return 0 ; + +q6_err: +q6asm_cmd (prtd->audio_client, prtd->stream_id,CMD_CLOSE ); + +open_err: +q6asm_audio_client_free (prtd->audio_client); + prtd->audio_client =NULL ; +return ret; } static int q6asm_dai_compr_set_metadata(struct snd_soc_component *component,
Greg Kroah-Hartman
maintainerPATCH 256/393 ALSA: hda/realtek: Enable Mute LED on HP OMEN 16 Laptop xd000xx
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sharan Kumar M <[email protected]>
commit e5182305a5199246dbcb4053299dcb1c8867b6ff upstream.
This patch adds the HP OMEN 16 Laptop xd000xx to enable mute led. it uses ALC245_FIXUP_HP_MUTE_LED_COEFBIT with a slight modification setting mute_led_coef.off to 0(it was set to 4 i guess
in that function) which i referred to your previous patch disscusion
https://bugzilla.kernel.org/show_bug.cgi?id=214735 .
i am not sure whether i can modify the current working function so i added another version calling ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT. and both works for me.
Tested on 6.13.4-arch1-1 to 6.14.0-arch1-1
--- sound/pci/hda/patch_realtek.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
sound/pci/hda/patch_realtek.c +22 -0
@@ -4744,6 +4744,22 @@ static void alc245_fixup_hp_mute_led_coe } } +static void alc245_fixup_hp_mute_led_v1_coefbit (struct hda_codec *codec, +const struct hda_fixup *fix, +int action) +{ +struct alc_spec *spec = codec->spec; + +if (action ==HDA_FIXUP_ACT_PRE_PROBE ) { + spec->mute_led_polarity =0 ; + spec->mute_led_coef.idx =0x0b ; + spec->mute_led_coef.mask =1 <<3 ; + spec->mute_led_coef.on =1 <<3 ; + spec->mute_led_coef.off =0 ; +snd_hda_gen_add_mute_led_cdev (codec, coef_mute_led_set); + } +} +/* turn on/off mic-mute LED per capture hook by coef bit */ static int coef_micmute_led_set (struct led_classdev *led_cdev,enum led_brightness brightness)
@@ -7851,6 +7867,7 @@ enum {ALC287_FIXUP_TAS2781_I2C ,ALC287_FIXUP_YOGA7_14ARB7_I2C ,ALC245_FIXUP_HP_MUTE_LED_COEFBIT , +ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT ,ALC245_FIXUP_HP_X360_MUTE_LEDS ,ALC287_FIXUP_THINKPAD_I2S_SPK , ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD,
@@ -10084,6 +10101,10 @@ static const struct hda_fixup alc269_fix .type = HDA_FIXUP_FUNC, .v.func = alc245_fixup_hp_mute_led_coefbit, }, + [ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT] = { + .type = HDA_FIXUP_FUNC, + .v.func = alc245_fixup_hp_mute_led_v1_coefbit, + }, [ALC245_FIXUP_HP_X360_MUTE_LEDS] = { .type = HDA_FIXUP_FUNC, .v.func = alc245_fixup_hp_mute_led_coefbit,
@@ -10569,6 +10590,7 @@ static const struct hda_quirk alc269_fixSND_PCI_QUIRK (0x103c ,0x8b97 ,"HP" ,ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF ),SND_PCI_QUIRK (0x103c ,0x8bb3 ,"HP Slim OMEN" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x103c ,0x8bb4 ,"HP Slim OMEN" ,ALC287_FIXUP_CS35L41_I2C_2 ), +SND_PCI_QUIRK (0x103c ,0x8bcd ,"HP Omen 16-xd0xxx" ,ALC245_FIXUP_HP_MUTE_LED_V1_COEFBIT ),SND_PCI_QUIRK (0x103c ,0x8bdd ,"HP Envy 17" ,ALC287_FIXUP_CS35L41_I2C_2 ),SND_PCI_QUIRK (0x103c ,0x8bde ,"HP Envy 17" ,ALC287_FIXUP_CS35L41_I2C_2 ), SND_PCI_QUIRK(0x103c, 0x8bdf, "HP Envy 15", ALC287_FIXUP_CS35L41_I2C_2),
Greg Kroah-Hartman
maintainerPATCH 257/393 accel/ivpu: Fix warning in ivpu_ipc_send_receive_internal()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacek Lawrynowicz <[email protected]>
commit 6b4568b675b14cf890c0c21779773c3e08e80ce5 upstream.
Warn if device is suspended only when runtime PM is enabled. Runtime PM is disabled during reset/recovery and it is not an error to use ivpu_ipc_send_receive_internal() in such cases.
--- drivers/accel/ivpu/ivpu_ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_ipc.c +2 -1
@@ -299,7 +299,8 @@ ivpu_ipc_send_receive_internal(struct ivstruct ivpu_ipc_consumer cons;int ret; -drm_WARN_ON (&vdev->drm,pm_runtime_status_suspended (vdev->drm.dev)); +drm_WARN_ON (&vdev->drm,pm_runtime_status_suspended (vdev->drm.dev) && +pm_runtime_enabled (vdev->drm.dev));ivpu_ipc_consumer_add (vdev, &cons, channel,NULL );
Greg Kroah-Hartman
maintainerPATCH 258/393 accel/ivpu: Fix deadlock in ivpu_ms_cleanup()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacek Lawrynowicz <[email protected]>
commit 9a6f56762d23a1f3af15e67901493c927caaf882 upstream.
Fix deadlock in ivpu_ms_cleanup() by preventing runtime resume after file_priv->ms_lock is acquired.
During a failure in runtime resume, a cold boot is executed, which calls ivpu_ms_cleanup_all(). This function calls ivpu_ms_cleanup() that acquires file_priv->ms_lock and causes the deadlock.
--- drivers/accel/ivpu/ivpu_ms.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/accel/ivpu/ivpu_ms.c +6 -0
@@ -4,6 +4,7 @@*/ #include <drm/drm_file.h> +#include <linux/pm_runtime.h> #include "ivpu_drv.h" #include "ivpu_gem.h"
@@ -299,6 +300,9 @@ unlock:void ivpu_ms_cleanup (struct ivpu_file_priv *file_priv) {struct ivpu_ms_instance *ms, *tmp; +struct ivpu_device *vdev = file_priv->vdev; + +pm_runtime_get_sync (vdev->drm.dev);mutex_lock (&file_priv->ms_lock);
@@ -311,6 +315,8 @@ void ivpu_ms_cleanup(struct ivpu_file_prfree_instance (file_priv, ms);mutex_unlock (&file_priv->ms_lock); + +pm_runtime_put_autosuspend (vdev->drm.dev); }void ivpu_ms_cleanup_all (struct ivpu_device *vdev)
Greg Kroah-Hartman
maintainerPATCH 259/393 bus: mhi: host: Fix race between unprepare and queue_buf
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Hugo <[email protected]>
commit 0686a818d77a431fc3ba2fab4b46bbb04e8c9380 upstream.
A client driver may use mhi_unprepare_from_transfer() to quiesce incoming data during the client driver's tear down. The client driver might also be processing data at the same time, resulting in a call to mhi_queue_buf() which will invoke mhi_gen_tre(). If mhi_gen_tre() runs after mhi_unprepare_from_transfer() has torn down the channel, a panic will occur due to an invalid dereference leading to a page fault.
This occurs because mhi_gen_tre() does not verify the channel state after locking it. Fix this by having mhi_gen_tre() confirm the channel state is valid, or return error to avoid accessing deinitialized data.
--- drivers/bus/mhi/host/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/bus/mhi/host/main.c +10 -6
@@ -1207,11 +1207,16 @@ int mhi_gen_tre(struct mhi_controller *mstruct mhi_ring_element *mhi_tre;struct mhi_buf_info *buf_info;int eot, eob, chain, bei; -int ret; +int ret =0 ;/* Protect accesses for reading and incrementing WP */ write_lock_bh (&mhi_chan->lock); +if (mhi_chan->ch_state !=MHI_CH_STATE_ENABLED ) { + ret = -ENODEV ; + goto out; + } + buf_ring = &mhi_chan->buf_ring; tre_ring = &mhi_chan->tre_ring;
@@ -1229,10 +1234,8 @@ int mhi_gen_tre(struct mhi_controller *mif (!info->pre_mapped) { ret = mhi_cntrl->map_single (mhi_cntrl, buf_info); -if (ret) { -write_unlock_bh (&mhi_chan->lock); -return ret; - } +if (ret) + goto out; } eob = !!(flags &MHI_EOB );
@@ -1250,9 +1253,10 @@ int mhi_gen_tre(struct mhi_controller *mmhi_add_ring_element (mhi_cntrl, tre_ring);mhi_add_ring_element (mhi_cntrl, buf_ring); +out:write_unlock_bh (&mhi_chan->lock); -return 0 ; +return ret; } int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
Greg Kroah-Hartman
maintainerPATCH 260/393 ext4: fix off-by-one error in do_split
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Artem Sadovnikov <[email protected]>
commit 94824ac9a8aaf2fb3c54b4bdde842db80ffa555d upstream.
Syzkaller detected a use-after-free issue in ext4_insert_dentry that was caused by out-of-bounds access due to incorrect splitting in do_split.
BUG: KASAN: use-after-free in ext4_insert_dentry+0x36a/0x6d0 fs/ext4/namei.c:2109 Write of size 251 at addr ffff888074572f14 by task syz-executor335/5847 CPU: 0 UID: 0 PID: 5847 Comm: syz-executor335 Not tainted 6.12.0-rc6-syzkaller-00318-ga9cda7c0ffed #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/30/2024 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x241/0x360 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:377 [inline] print_report+0x169/0x550 mm/kasan/report.c:488 kasan_report+0x143/0x180 mm/kasan/report.c:601 kasan_check_range+0x282/0x290 mm/kasan/generic.c:189 __asan_memcpy+0x40/0x70 mm/kasan/shadow.c:106 ext4_insert_dentry+0x36a/0x6d0 fs/ext4/namei.c:2109 add_dirent_to_buf+0x3d9/0x750 fs/ext4/namei.c:2154 make_indexed_dir+0xf98/0x1600 fs/ext4/namei.c:2351 ext4_add_entry+0x222a/0x25d0 fs/ext4/namei.c:2455 ext4_add_nondir+0x8d/0x290 fs/ext4/namei.c:2796 ext4_symlink+0x920/0xb50 fs/ext4/namei.c:3431 vfs_symlink+0x137/0x2e0 fs/namei.c:4615 do_symlinkat+0x222/0x3a0 fs/namei.c:4641 __do_sys_symlink fs/namei.c:4662 [inline] __se_sys_symlink fs/namei.c:4660 [inline] __x64_sys_symlink+0x7a/0x90 fs/namei.c:4660 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
The following loop is located right above 'if' statement.
for (i = count-1; i >= 0; i--) {
/* is more than half of this entry in 2nd half of the block? */
if (size + map[i].size/2 > blocksize/2)
break;
size += map[i].size;
move++;
}'i' in this case could go down to -1, in which case sum of active entries wouldn't exceed half the block size, but previous behaviour would also do split in half if sum would exceed at the very last block, which in case of having too many long name files in a single block could lead to out-of-bounds access and following use-after-free.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/namei.c +1 -1
@@ -1995,7 +1995,7 @@ static struct ext4_dir_entry_2 *do_split* split it in half by count; each resulting block will have at least * half the space free. */ -if (i >0 ) +if (i >=0 ) split = count - move;else split = count/2 ;
Greg Kroah-Hartman
maintainerPATCH 261/393 f2fs: fix to avoid atomicity corruption of atomic file
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeongjin Gil <[email protected]>
commit f098aeba04c9328571567dca45159358a250240c upstream.
In the case of the following call stack for an atomic file, FI_DIRTY_INODE is set, but FI_ATOMIC_DIRTIED is not subsequently set.
f2fs_file_write_iter
f2fs_map_blocks
f2fs_reserve_new_blocks
inc_valid_block_count
__mark_inode_dirty(dquot)
f2fs_dirty_inode
If FI_ATOMIC_DIRTIED is not set, atomic file can encounter corruption due to a mismatch between old file size and new data.
To resolve this issue, I changed to set FI_ATOMIC_DIRTIED when FI_DIRTY_INODE is set. This ensures that FI_DIRTY_INODE, which was previously cleared by the Writeback thread during the commit atomic, is set and i_size is updated.
--- fs/f2fs/inode.c | 4 +--- fs/f2fs/super.c | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-)
fs/f2fs/inode.c +1 -3
@@ -34,10 +34,8 @@ void f2fs_mark_inode_dirty_sync(struct iif (f2fs_inode_dirtied (inode, sync))return ; -if (f2fs_is_atomic_file (inode)) { -set_inode_flag (inode,FI_ATOMIC_DIRTIED ); +if (f2fs_is_atomic_file (inode))return ; - }mark_inode_dirty_sync (inode); }
fs/f2fs/super.c +4 -0
@@ -1515,6 +1515,10 @@ int f2fs_inode_dirtied(struct inode *inoinc_page_count (sbi,F2FS_DIRTY_IMETA ); }spin_unlock (&sbi->inode_lock[DIRTY_META ]); + +if (!ret &&f2fs_is_atomic_file (inode)) +set_inode_flag (inode,FI_ATOMIC_DIRTIED ); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 262/393 vdpa/mlx5: Fix oversized null mkey longer than 32bit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Si-Wei Liu <[email protected]>
commit a6097e0a54a5c24f8d577ffecbc35289ae281c2e upstream.
create_user_mr() has correct code to count the number of null keys used to fill in a hole for the memory map. However, fill_indir() does not follow the same to cap the range up to the 1GB limit correspondingly. Fill in more null keys for the gaps in between, so that null keys are correctly populated.
Message-Id: <[email protected]>
--- drivers/vdpa/mlx5/core/mr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/vdpa/mlx5/core/mr.c +5 -2
@@ -190,9 +190,12 @@ again: klm->bcount =cpu_to_be32 (klm_bcount (dmr->end - dmr->start)); preve = dmr->end; }else { +u64 bcount =min_t (u64, dmr->start - preve,MAX_KLM_SIZE ); + klm->key =cpu_to_be32 (mvdev->res.null_mkey); - klm->bcount =cpu_to_be32 (klm_bcount (dmr->start - preve)); - preve = dmr->start; + klm->bcount =cpu_to_be32 (klm_bcount (bcount)); + preve += bcount; + goto again; } }
Greg Kroah-Hartman
maintainerPATCH 263/393 udf: Fix inode_getblk() return value
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 6afdc60ec30b0a9390d11b7cebed79c857ce82aa upstream.
Smatch noticed that inode_getblk() can return 1 on successful mapping of a block instead of expected 0 after commit b405c1e58b73 ("udf: refactor udf_next_aext() to handle error"). This could confuse some of the callers and lead to strange failures (although the one reported by Smatch in udf_mkdir() is impossible to trigger in practice). Fix the return value of inode_getblk().
--- fs/udf/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/udf/inode.c +1 -0
@@ -810,6 +810,7 @@ static int inode_getblk(struct inode *in } map->oflags =UDF_BLK_MAPPED ; map->pblk =udf_get_lb_pblock (inode->i_sb, &eloc, offset); + ret =0 ; goto out_free; }
Greg Kroah-Hartman
maintainerPATCH 264/393 tpm: do not start chip while suspended
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thadeu Lima de Souza Cascardo <[email protected]>
commit 17d253af4c2c8a2acf84bb55a0c2045f150b7dfd upstream.
Checking TPM_CHIP_FLAG_SUSPENDED after the call to tpm_find_get_ops() can lead to a spurious tpm_chip_start() call:
[35985.503771] i2c i2c-1: Transfer while suspended [35985.503796] WARNING: CPU: 0 PID: 74 at drivers/i2c/i2c-core.h:56 __i2c_transfer+0xbe/0x810 [35985.503802] Modules linked in: [35985.503808] CPU: 0 UID: 0 PID: 74 Comm: hwrng Tainted: G W 6.13.0-next-20250203-00005-gfa0cb5642941 #19 9c3d7f78192f2d38e32010ac9c90fdc71109ef6f [35985.503814] Tainted: [W]=WARN [35985.503817] Hardware name: Google Morphius/Morphius, BIOS Google_Morphius.13434.858.0 10/26/2023 [35985.503819] RIP: 0010:__i2c_transfer+0xbe/0x810 [35985.503825] Code: 30 01 00 00 4c 89 f7 e8 40 fe d8 ff 48 8b 93 80 01 00 00 48 85 d2 75 03 49 8b 16 48 c7 c7 0a fb 7c a7 48 89 c6 e8 32 ad b0 fe <0f> 0b b8 94 ff ff ff e9 33 04 00 00 be 02 00 00 00 83 fd 02 0f 5 [35985.503828] RSP: 0018:ffffa106c0333d30 EFLAGS: 00010246 [35985.503833] RAX: 074ba64aa20f7000 RBX: ffff8aa4c1167120 RCX: 0000000000000000 [35985.503836] RDX: 0000000000000000 RSI: ffffffffa77ab0e4 RDI: 0000000000000001 [35985.503838] RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000 [35985.503841] R10: 0000000000000004 R11: 00000001000313d5 R12: ffff8aa4c10f1820 [35985.503843] R13: ffff8aa4c0e243c0 R14: ffff8aa4c1167250 R15: ffff8aa4c1167120 [35985.503846] FS: 0000000000000000(0000) GS:ffff8aa4eae00000(0000) knlGS:0000000000000000 [35985.503849] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [35985.503852] CR2: 00007fab0aaf1000 CR3: 0000000105328000 CR4: 00000000003506f0 [35985.503855] Call Trace: [35985.503859] <TASK> [35985.503863] ? __warn+0xd4/0x260 [35985.503868] ? __i2c_transfer+0xbe/0x810 [35985.503874] ? report_bug+0xf3/0x210 [35985.503882] ? handle_bug+0x63/0xb0 [35985.503887] ? exc_invalid_op+0x16/0x50 [35985.503892] ? asm_exc_invalid_op+0x16/0x20 [35985.503904] ? __i2c_transfer+0xbe/0x810 [35985.503913] tpm_cr50_i2c_transfer_message+0x24/0xf0 [35985.503920] tpm_cr50_i2c_read+0x8e/0x120 [35985.503928] tpm_cr50_request_locality+0x75/0x170 [35985.503935] tpm_chip_start+0x116/0x160 [35985.503942] tpm_try_get_ops+0x57/0x90 [35985.503948] tpm_find_get_ops+0x26/0xd0 [35985.503955] tpm_get_random+0x2d/0x80
Don't move forward with tpm_chip_start() inside tpm_try_get_ops(), unless TPM_CHIP_FLAG_SUSPENDED is not set. tpm_find_get_ops() will return NULL in such a failure case.
--- drivers/char/tpm/tpm-chip.c | 5 +++++ drivers/char/tpm/tpm-interface.c | 7 ------- 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/char/tpm/tpm-chip.c +5 -0
@@ -168,6 +168,11 @@ int tpm_try_get_ops(struct tpm_chip *chi goto out_ops;mutex_lock (&chip->tpm_mutex); + +/* tmp_chip_start may issue IO that is denied while suspended */ +if (chip->flags &TPM_CHIP_FLAG_SUSPENDED ) + goto out_lock; + rc =tpm_chip_start (chip);if (rc) goto out_lock;
drivers/char/tpm/tpm-interface.c +0 -7
@@ -445,18 +445,11 @@ int tpm_get_random(struct tpm_chip *chipif (!chip)return -ENODEV ; -/* Give back zero bytes, as TPM chip has not yet fully resumed: */ -if (chip->flags &TPM_CHIP_FLAG_SUSPENDED ) { - rc =0 ; - goto out; - } -if (chip->flags &TPM_CHIP_FLAG_TPM2 ) rc =tpm2_get_random (chip, out, max);else rc =tpm1_get_random (chip, out, max); -out:tpm_put_ops (chip);return rc; }
Greg Kroah-Hartman
maintainerPATCH 265/393 svcrdma: do not unregister device for listeners
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olga Kornievskaia <[email protected]>
commit 750037aa0a9f28d84df3dcf319a28423d69092fd upstream.
On an rdma-capable machine, a start/stop/start and then on a stop of a knfsd server would lead kref underflow warning because svc_rdma_free would indiscriminately unregister the rdma device but a listening transport never calls the rdma_rn_register() thus leading to kref going down to 0 on the 1st stop of the server and on the 2nd stop it leads to a problem.
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +2 -1
@@ -621,7 +621,8 @@ static void __svc_rdma_free(struct work_struct *work)/* Destroy the CM ID */ rdma_destroy_id (rdma->sc_cm_id); -rpcrdma_rn_unregister (device, &rdma->sc_rn); +if (!test_bit (XPT_LISTENER , &rdma->sc_xprt.xpt_flags)) +rpcrdma_rn_unregister (device, &rdma->sc_rn);kfree (rdma); }
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 266/393 soc: samsung: exynos-chipid: Add NULL pointer check in exynos_chipid_probe()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
commit c8222ef6cf29dd7cad21643228f96535cc02b327 upstream.
soc_dev_attr->revision could be NULL, thus,
a pointer check is added to prevent potential NULL pointer dereference. This is similar to the fix in commit 3027e7b15b02
("ice: Fix some null pointer dereference issues in ice_ptp.c").
This issue is found by our static analysis tool.
--- drivers/soc/samsung/exynos-chipid.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/soc/samsung/exynos-chipid.c +2 -0
@@ -131,6 +131,8 @@ static int exynos_chipid_probe(struct pl soc_dev_attr->revision =devm_kasprintf (&pdev->dev,GFP_KERNEL ,"%x" , soc_info.revision); +if (!soc_dev_attr->revision) +return -ENOMEM ; soc_dev_attr->soc_id =product_id_to_soc_id (soc_info.product_id);if (!soc_dev_attr->soc_id) {pr_err ("Unknown SoC\n" );
Greg Kroah-Hartman
maintainerPATCH 267/393 smb311 client: fix missing tcon check when mounting with linux/posix extensions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit b365b9d404b7376c60c91cd079218bfef11b7822 upstream.
When mounting the same share twice, once with the "linux" mount parameter (or equivalently "posix") and then once without (or e.g. with "nolinux"), we were incorrectly reusing the same tree connection for both mounts. This meant that the first mount of the share on the client, would cause subsequent mounts of that same share on the same client to ignore that mount parm ("linux" vs. "nolinux") and incorrectly reuse the same tcon.
--- fs/smb/client/connect.c | 2 ++ 1 file changed, 2 insertions(+)
fs/smb/client/connect.c +2 -0
@@ -2474,6 +2474,8 @@ static int match_tcon(struct cifs_tcon *return 0 ;if (tcon->nodelete != ctx->nodelete)return 0 ; +if (tcon->posix_extensions != ctx->linux_ext) +return 0 ;return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 268/393 ima: limit the number of open-writers integrity violations
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
commit 5b3cd801155f0b34b0b95942a5b057c9b8cad33e upstream.
Each time a file in policy, that is already opened for write, is opened for read, an open-writers integrity violation audit message is emitted and a violation record is added to the IMA measurement list. This occurs even if an open-writers violation has already been recorded.
Limit the number of open-writers integrity violations for an existing file open for write to one. After the existing file open for write closes (__fput), subsequent open-writers integrity violations may be emitted.
--- security/integrity/ima/ima.h | 1 + security/integrity/ima/ima_main.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
security/integrity/ima/ima.h +1 -0
@@ -182,6 +182,7 @@ struct ima_kexec_hdr {#define IMA_CHANGE_ATTR 2#define IMA_DIGSIG 3#define IMA_MUST_MEASURE 4 +#define IMA_EMITTED_OPENWRITERS 5/* IMA integrity metadata associated with an inode */ struct ima_iint_cache {
security/integrity/ima/ima_main.c +9 -2
@@ -137,8 +137,13 @@ static void ima_rdwr_violation_check(str }else {if (must_measure)set_bit (IMA_MUST_MEASURE , &iint->atomic_flags); -if (inode_is_open_for_write (inode) && must_measure) - send_writers = true; + +/* Limit number of open_writers violations */ +if (inode_is_open_for_write (inode) && must_measure) { +if (!test_and_set_bit (IMA_EMITTED_OPENWRITERS , + &iint->atomic_flags)) + send_writers = true; + } }if (!send_tomtou && !send_writers)
@@ -167,6 +172,8 @@ static void ima_check_last_writer(structif (atomic_read (&inode->i_writecount) ==1 ) {struct kstat stat; +clear_bit (IMA_EMITTED_OPENWRITERS , &iint->atomic_flags); + update =test_and_clear_bit (IMA_UPDATE_XATTR , &iint->atomic_flags); if ((iint->flags & IMA_NEW_FILE) ||
Greg Kroah-Hartman
maintainerPATCH 269/393 ima: limit the number of ToMToU integrity violations
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mimi Zohar <[email protected]>
commit a414016218ca97140171aa3bb926b02e1f68c2cc upstream.
Each time a file in policy, that is already opened for read, is opened for write, a Time-of-Measure-Time-of-Use (ToMToU) integrity violation audit message is emitted and a violation record is added to the IMA measurement list. This occurs even if a ToMToU violation has already been recorded.
Limit the number of ToMToU integrity violations per file open for read.
Note: The IMA_MAY_EMIT_TOMTOU atomic flag must be set from the reader side based on policy. This may result in a per file open for read ToMToU violation.
Since IMA_MUST_MEASURE is only used for violations, rename the atomic IMA_MUST_MEASURE flag to IMA_MAY_EMIT_TOMTOU.
--- security/integrity/ima/ima.h | 2 +- security/integrity/ima/ima_main.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-)
security/integrity/ima/ima.h +1 -1
@@ -181,7 +181,7 @@ struct ima_kexec_hdr {#define IMA_UPDATE_XATTR 1#define IMA_CHANGE_ATTR 2#define IMA_DIGSIG 3 -#define IMA_MUST_MEASURE 4 +#define IMA_MAY_EMIT_TOMTOU 4#define IMA_EMITTED_OPENWRITERS 5/* IMA integrity metadata associated with an inode */
security/integrity/ima/ima_main.c +4 -3
@@ -129,14 +129,15 @@ static void ima_rdwr_violation_check(strif (atomic_read (&inode->i_readcount) &&IS_IMA (inode)) {if (!iint) iint =ima_iint_find (inode); +/* IMA_MEASURE is set from reader side */ -if (iint &&test_bit (IMA_MUST_MEASURE , - &iint->atomic_flags)) +if (iint &&test_and_clear_bit (IMA_MAY_EMIT_TOMTOU , + &iint->atomic_flags)) send_tomtou = true; } }else {if (must_measure) -set_bit (IMA_MUST_MEASURE , &iint->atomic_flags); +set_bit (IMA_MAY_EMIT_TOMTOU , &iint->atomic_flags);/* Limit number of open_writers violations */ if (inode_is_open_for_write (inode) && must_measure) {
Greg Kroah-Hartman
maintainerPATCH 270/393 i3c: master: svc: Use readsb helper for reading MDB
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Chu <[email protected]>
commit c06acf7143bddaa3c0f7bedd8b99e48f6acb85c3 upstream.
The target can send the MDB byte followed by additional data bytes. The readl on MRDATAB reads one actual byte, but the readsl advances the destination pointer by 4 bytes. This causes the subsequent payload to be copied to wrong position in the destination buffer.
--- drivers/i3c/master/svc-i3c-master.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i3c/master/svc-i3c-master.c +1 -1
@@ -378,7 +378,7 @@ static int svc_i3c_master_handle_ibi(str slot->len < SVC_I3C_FIFO_SIZE) { mdatactrl =readl (master->regs +SVC_I3C_MDATACTRL ); count =SVC_I3C_MDATACTRL_RXCOUNT (mdatactrl); -readsl (master->regs +SVC_I3C_MRDATAB , buf, count); +readsb (master->regs +SVC_I3C_MRDATAB , buf, count); slot->len += count; buf += count; }
Greg Kroah-Hartman
maintainerPATCH 271/393 i3c: Add NULL pointer check in i3c_master_queue_ibi()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manjunatha Venkatesh <[email protected]>
commit bd496a44f041da9ef3afe14d1d6193d460424e91 upstream.
The I3C master driver may receive an IBI from a target device that has not been probed yet. In such cases, the master calls i3c_master_queue_ibi() to queue an IBI work task, leading to "Unable to handle kernel read from unreadable memory" and resulting in a kernel panic.
Typical IBI handling flow:
1. The I3C master scans target devices and probes their respective drivers.
2. The target device driver calls i3c_device_request_ibi() to enable IBI and assigns dev->ibi = ibi.
3. The I3C master receives an IBI from the target device and calls i3c_master_queue_ibi() to queue the target device driver’s IBI handler task.
However, since target device events are asynchronous to the I3C probe sequence, step 3 may occur before step 2, causing dev->ibi to be NULL, leading to a kernel panic.
Add a NULL pointer check in i3c_master_queue_ibi() to prevent accessing an uninitialized dev->ibi, ensuring stability.
--- drivers/i3c/master.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i3c/master.c +3 -0
@@ -2553,6 +2553,9 @@ static void i3c_master_unregister_i3c_de*/ void i3c_master_queue_ibi (struct i3c_dev_desc *dev,struct i3c_ibi_slot *slot) { +if (!dev->ibi || !slot) +return ; +atomic_inc (&dev->ibi->pending_ibis);queue_work (dev->ibi->wq, &slot->work); }
Greg Kroah-Hartman
maintainerPATCH 272/393 jbd2: remove wrong sb->s_sequence check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit e6eff39dd0fe4190c6146069cc16d160e71d1148 upstream.
Journal emptiness is not determined by sb->s_sequence == 0 but rather by sb->s_start == 0 (which is set a few lines above). Furthermore 0 is a valid transaction ID so the check can spuriously trigger. Remove the invalid WARN_ON.
--- fs/jbd2/journal.c | 1 - 1 file changed, 1 deletion(-)
fs/jbd2/journal.c +0 -1
@@ -1884,7 +1884,6 @@ int jbd2_journal_update_sb_log_tail(jour/* Log is no longer empty */ write_lock (&journal->j_state_lock); -WARN_ON (!sb->s_sequence); journal->j_flags &= ~JBD2_FLUSHED ;write_unlock (&journal->j_state_lock);
Greg Kroah-Hartman
maintainerPATCH 273/393 kbuild: exclude .rodata.(cst|str)* when building ranges
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kris Van Hees <[email protected]>
commit 87bb368d0637c466a8a77433837056f981d01991 upstream.
The .rodata.(cst|str)* sections are often resized during the final linking and since these sections do not cover actual symbols there is no need to include them in the modules.builtin.ranges data.
When these sections were included in processing and resizing occurred, modules were reported with ranges that extended beyond their true end, causing subsequent symbols (in address order) to be associated with the wrong module.
--- scripts/generate_builtin_ranges.awk | 5 +++++ 1 file changed, 5 insertions(+)
scripts/generate_builtin_ranges.awk +5 -0
@@ -282,6 +282,11 @@ ARGIND == 2 && !anchor && NF == 2 && $1 ~ /^0x/ && $2 !~ /^0x/ { # section. # ARGIND == 2 && sect && NF == 4 && /^ [^ \*]/ && !($1 in sect_addend) { + # There are a few sections with constant data (without symbols) that + # can get resized during linking, so it is best to ignore them. + if ($1 ~ /^\.rodata\.(cst|str)[0-9]/) + next; + if (!($1 in sect_base)) { sect_base[$1] = base;
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 274/393 leds: rgb: leds-qcom-lpg: Fix pwm resolution max for Hi-Res PWMs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
commit b7881eacc07fdf50be3f33c662997541bb59366d upstream.
Ideally, the requested duty cycle should never translate to a PWM value higher than the selected resolution (PWM size), but currently the best matched period is never reported back to the PWM consumer, so the consumer will still be using the requested period which is higher than the best matched one. This will result in PWM consumer requesting duty cycle values higher than the allowed PWM value.
For example, a consumer might request a period of 5ms while the best (closest) period the PWM hardware will do is 4.26ms. For this best matched resolution, if the selected resolution is 8-bit wide, when the consumer asks for a duty cycle of 5ms, the PWM value will be 300, which is outside of what the resolution allows. This will happen with all possible resolutions when selected.
Since for these Hi-Res PWMs, the current implementation is capping the PWM value at a 15-bit resolution, even when lower resolutions are selected, the value will be wrapped around by the HW internal logic to the selected resolution.
Fix the issue by capping the PWM value to the maximum value allowed by the selected resolution.
--- drivers/leds/rgb/leds-qcom-lpg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/rgb/leds-qcom-lpg.c +1 -1
@@ -529,7 +529,7 @@ static void lpg_calc_duty(struct lpg_chaunsigned int clk_rate;if (chan->subtype ==LPG_SUBTYPE_HI_RES_PWM ) { - max =LPG_RESOLUTION_15BIT -1 ; + max =BIT (lpg_pwm_resolution_hi_res[chan->pwm_resolution_sel]) -1 ; clk_rate = lpg_clk_rates_hi_res[chan->clk_sel]; }else { max =LPG_RESOLUTION_9BIT -1 ;
Greg Kroah-Hartman
maintainerPATCH 275/393 leds: rgb: leds-qcom-lpg: Fix calculation of best period Hi-Res PWMs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abel Vesa <[email protected]>
commit 2528eec7da0ec58fcae6d12cfa79a622c933d86b upstream.
When determining the actual best period by looping through all possible PWM configs, the resolution currently used is based on bit shift value which is off-by-one above the possible maximum PWM value allowed.
So subtract one from the resolution before determining the best period so that the maximum duty cycle requested by the PWM user won't result in a value above the maximum allowed by the selected resolution.
--- drivers/leds/rgb/leds-qcom-lpg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/leds/rgb/leds-qcom-lpg.c +3 -3
@@ -461,7 +461,7 @@ static int lpg_calc_freq(struct lpg_chan max_res =LPG_RESOLUTION_9BIT ; } - min_period =div64_u64 ((u64 )NSEC_PER_SEC * (1 << pwm_resolution_arr[0 ]), + min_period =div64_u64 ((u64 )NSEC_PER_SEC * ((1 << pwm_resolution_arr[0 ]) -1 ), clk_rate_arr[clk_len -1 ]);if (period <= min_period)return -EINVAL ;
@@ -482,7 +482,7 @@ static int lpg_calc_freq(struct lpg_chan*/ for (i =0 ; i < pwm_resolution_count; i++) { - resolution =1 << pwm_resolution_arr[i]; + resolution = (1 << pwm_resolution_arr[i]) -1 ;for (clk_sel =1 ; clk_sel < clk_len; clk_sel++) {u64 numerator = period * clk_rate_arr[clk_sel];
@@ -1291,7 +1291,7 @@ static int lpg_pwm_get_state(struct pwm_if (ret)return ret; - state->period =DIV_ROUND_UP_ULL ((u64 )NSEC_PER_SEC * (1 << resolution) * + state->period =DIV_ROUND_UP_ULL ((u64 )NSEC_PER_SEC * ((1 << resolution) -1 ) * pre_div * (1 << m), refclk); state->duty_cycle =DIV_ROUND_UP_ULL ((u64 )NSEC_PER_SEC * pwm_value * pre_div * (1 << m), refclk); }else {
Greg Kroah-Hartman
maintainerPATCH 276/393 mfd: ene-kb3930: Fix a potential NULL pointer dereference
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chenyuan Yang <[email protected]>
commit 4cdf1d2a816a93fa02f7b6b5492dc7f55af2a199 upstream.
The off_gpios could be NULL. Add missing check in the kb3930_probe(). This is similar to the issue fixed in commit b1ba8bcb2d1f ("backlight: hx8357: Fix potential NULL pointer dereference").
This was detected by our static analysis tool.
--- drivers/mfd/ene-kb3930.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/ene-kb3930.c +1 -1
@@ -162,7 +162,7 @@ static int kb3930_probe(struct i2c_cliendevm_gpiod_get_array_optional (dev,"off" ,GPIOD_IN );if (IS_ERR (ddata->off_gpios))return PTR_ERR (ddata->off_gpios); -if (ddata->off_gpios->ndescs <2 ) { +if (ddata->off_gpios && ddata->off_gpios->ndescs <2 ) {dev_err (dev,"invalid off-gpios property\n" );return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 277/393 mailbox: tegra-hsp: Define dimensioning masks in SoC data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kartik Rajput <[email protected]>
commit bf0c9fb462038815f5f502653fb6dba06e6af415 upstream.
Tegra264 has updated HSP_INT_DIMENSIONING register as follows:
* nSI is now BIT17:BIT21.
* nDB is now BIT12:BIT16.
Currently, we are using a static macro HSP_nINT_MASK to get the values from HSP_INT_DIMENSIONING register. This results in wrong values for nSI for HSP instances that supports 16 shared interrupts.
Define dimensioning masks in soc data and use them to parse nSI, nDB, nAS, nSS & nSM values.
--- drivers/mailbox/tegra-hsp.c | 72 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 60 insertions(+), 12 deletions(-)
drivers/mailbox/tegra-hsp.c +60 -12
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0-only /* -* Copyright (c) 2016-2023, NVIDIA CORPORATION. All rights reserved. +* Copyright (c) 2016-2025, NVIDIA CORPORATION. All rights reserved. */ #include <linux/delay.h>
@@ -28,12 +28,6 @@#define HSP_INT_FULL_MASK 0xff#define HSP_INT_DIMENSIONING 0x380 -#define HSP_nSM_SHIFT 0 -#define HSP_nSS_SHIFT 4 -#define HSP_nAS_SHIFT 8 -#define HSP_nDB_SHIFT 12 -#define HSP_nSI_SHIFT 16 -#define HSP_nINT_MASK 0xf#define HSP_DB_TRIGGER 0x0#define HSP_DB_ENABLE 0x4
@@ -97,6 +91,20 @@ struct tegra_hsp_soc {bool has_per_mb_ie;bool has_128_bit_mb;unsigned int reg_stride; + +/* Shifts for dimensioning register. */ +unsigned int si_shift; +unsigned int db_shift; +unsigned int as_shift; +unsigned int ss_shift; +unsigned int sm_shift; + +/* Masks for dimensioning register. */ +unsigned int si_mask; +unsigned int db_mask; +unsigned int as_mask; +unsigned int ss_mask; +unsigned int sm_mask; };struct tegra_hsp {
@@ -747,11 +755,11 @@ static int tegra_hsp_probe(struct platforeturn PTR_ERR (hsp->regs); value =tegra_hsp_readl (hsp,HSP_INT_DIMENSIONING ); - hsp->num_sm = (value >> HSP_nSM_SHIFT) & HSP_nINT_MASK; - hsp->num_ss = (value >> HSP_nSS_SHIFT) & HSP_nINT_MASK; - hsp->num_as = (value >> HSP_nAS_SHIFT) & HSP_nINT_MASK; - hsp->num_db = (value >> HSP_nDB_SHIFT) & HSP_nINT_MASK; - hsp->num_si = (value >> HSP_nSI_SHIFT) & HSP_nINT_MASK; + hsp->num_sm = (value >> hsp->soc->sm_shift) & hsp->soc->sm_mask; + hsp->num_ss = (value >> hsp->soc->ss_shift) & hsp->soc->ss_mask; + hsp->num_as = (value >> hsp->soc->as_shift) & hsp->soc->as_mask; + hsp->num_db = (value >> hsp->soc->db_shift) & hsp->soc->db_mask; + hsp->num_si = (value >> hsp->soc->si_shift) & hsp->soc->si_mask; err =platform_get_irq_byname_optional (pdev,"doorbell" );if (err >=0 )
@@ -915,6 +923,16 @@ static const struct tegra_hsp_soc tegra1 .has_per_mb_ie = false, .has_128_bit_mb = false, .reg_stride = 0x100, + .si_shift = 16, + .db_shift = 12, + .as_shift = 8, + .ss_shift = 4, + .sm_shift = 0, + .si_mask = 0xf, + .db_mask = 0xf, + .as_mask = 0xf, + .ss_mask = 0xf, + .sm_mask = 0xf, };static const struct tegra_hsp_soc tegra194_hsp_soc = {
@@ -922,6 +940,16 @@ static const struct tegra_hsp_soc tegra1 .has_per_mb_ie = true, .has_128_bit_mb = false, .reg_stride = 0x100, + .si_shift = 16, + .db_shift = 12, + .as_shift = 8, + .ss_shift = 4, + .sm_shift = 0, + .si_mask = 0xf, + .db_mask = 0xf, + .as_mask = 0xf, + .ss_mask = 0xf, + .sm_mask = 0xf, };static const struct tegra_hsp_soc tegra234_hsp_soc = {
@@ -929,6 +957,16 @@ static const struct tegra_hsp_soc tegra2 .has_per_mb_ie = false, .has_128_bit_mb = true, .reg_stride = 0x100, + .si_shift = 16, + .db_shift = 12, + .as_shift = 8, + .ss_shift = 4, + .sm_shift = 0, + .si_mask = 0xf, + .db_mask = 0xf, + .as_mask = 0xf, + .ss_mask = 0xf, + .sm_mask = 0xf, };static const struct tegra_hsp_soc tegra264_hsp_soc = {
@@ -936,6 +974,16 @@ static const struct tegra_hsp_soc tegra2 .has_per_mb_ie = false, .has_128_bit_mb = true, .reg_stride = 0x1000, + .si_shift = 17, + .db_shift = 12, + .as_shift = 8, + .ss_shift = 4, + .sm_shift = 0, + .si_mask = 0x1f, + .db_mask = 0x1f, + .as_mask = 0xf, + .ss_mask = 0xf, + .sm_mask = 0xf, };static const struct of_device_id tegra_hsp_match[] = {
Greg Kroah-Hartman
maintainerPATCH 278/393 locking/lockdep: Decrease nr_unused_locks if lock unused in zap_class()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boqun Feng <[email protected]>
commit 495f53d5cca0f939eaed9dca90b67e7e6fb0e30c upstream.
Currently, when a lock class is allocated, nr_unused_locks will be increased by 1, until it gets used: nr_unused_locks will be decreased by 1 in mark_lock(). However, one scenario is missed: a lock class may be zapped without even being used once. This could result into a situation that nr_unused_locks != 0 but no unused lock class is active in the system, and when cat /proc/lockdep_stats, a WARN_ON() will be triggered in a CONFIG_DEBUG_LOCKDEP=y kernel:
[...] DEBUG_LOCKS_WARN_ON(debug_atomic_read(nr_unused_locks) != nr_unused)
[...] WARNING: CPU: 41 PID: 1121 at kernel/locking/lockdep_proc.c:283 lockdep_stats_show+0xba9/0xbd0
And as a result, lockdep will be disabled after this.
Therefore, nr_unused_locks needs to be accounted correctly at zap_class() time.
--- kernel/locking/lockdep.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/locking/lockdep.c +3 -0
@@ -6223,6 +6223,9 @@ static void zap_class(struct pending_frehlist_del_rcu (&class->hash_entry);WRITE_ONCE (class->key,NULL );WRITE_ONCE (class->name,NULL ); +/* Class allocated but not used, -1 in nr_unused_locks */ +if (class->usage_mask ==0 ) +debug_atomic_dec (nr_unused_locks); nr_lock_classes--;__clear_bit (class - lock_classes, lock_classes_in_use);if (class - lock_classes == max_lock_class_idx)
Greg Kroah-Hartman
maintainerPATCH 279/393 lib: scatterlist: fix sg_split_phys to preserve original scatterlist offsets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: T Pratham <[email protected]>
commit 8b46fdaea819a679da176b879e7b0674a1161a5e upstream.
The split_sg_phys function was incorrectly setting the offsets of all scatterlist entries (except the first) to 0. Only the first scatterlist entry's offset and length needs to be modified to account for the skip. Setting the rest entries' offsets to 0 could lead to incorrect data access.
I am using this function in a crypto driver that I'm currently developing (not yet sent to mailing list). During testing, it was observed that the output scatterlists (except the first one) contained incorrect garbage data.
I narrowed this issue down to the call of sg_split(). Upon debugging inside this function, I found that this resetting of offset is the cause of the problem, causing the subsequent scatterlists to point to incorrect memory locations in a page. By removing this code, I am obtaining expected data in all the split output scatterlists. Thus, this was indeed causing observable runtime effects!
This patch removes the offending code, ensuring that the page offsets in the input scatterlist are preserved in the output scatterlist.
--- lib/sg_split.c | 2 -- 1 file changed, 2 deletions(-)
lib/sg_split.c +0 -2
@@ -88,8 +88,6 @@ static void sg_split_phys(struct sg_spliif (!j) { out_sg->offset += split->skip_sg0; out_sg->length -= split->skip_sg0; - }else { - out_sg->offset =0 ; }sg_dma_address (out_sg) =0 ;sg_dma_len (out_sg) =0 ;
Greg Kroah-Hartman
maintainerPATCH 280/393 mptcp: fix NULL pointer in can_accept_new_subflow
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gang Yan <[email protected]>
commit 443041deb5ef6a1289a99ed95015ec7442f141dc upstream.
When testing valkey benchmark tool with MPTCP, the kernel panics in 'mptcp_can_accept_new_subflow' because subflow_req->msk is NULL.
Call trace: mptcp_can_accept_new_subflow (./net/mptcp/subflow.c:63 (discriminator 4)) (P) subflow_syn_recv_sock (./net/mptcp/subflow.c:854) tcp_check_req (./net/ipv4/tcp_minisocks.c:863) tcp_v4_rcv (./net/ipv4/tcp_ipv4.c:2268) ip_protocol_deliver_rcu (./net/ipv4/ip_input.c:207) ip_local_deliver_finish (./net/ipv4/ip_input.c:234) ip_local_deliver (./net/ipv4/ip_input.c:254) ip_rcv_finish (./net/ipv4/ip_input.c:449) ...
According to the debug log, the same req received two SYN-ACK in a very short time, very likely because the client retransmits the syn ack due to multiple reasons.
Even if the packets are transmitted with a relevant time interval, they can be processed by the server on different CPUs concurrently). The 'subflow_req->msk' ownership is transferred to the subflow the first, and there will be a risk of a null pointer dereference here.
This patch fixes this issue by moving the 'subflow_req->msk' under the own_req == true conditional.
Note that the !msk check in subflow_hmac_valid() can be dropped, because the same check already exists under the own_req mpj branch where the code has been moved to.
--- net/mptcp/subflow.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
net/mptcp/subflow.c +8 -7
@@ -754,8 +754,6 @@ static bool subflow_hmac_valid(const str subflow_req =mptcp_subflow_rsk (req); msk = subflow_req->msk; -if (!msk) -return false; subflow_generate_hmac(READ_ONCE(msk->remote_key), READ_ONCE(msk->local_key),
@@ -853,12 +851,8 @@ static struct sock *subflow_syn_recv_soc }else if (subflow_req->mp_join) {mptcp_get_options (skb, &mp_opt); -if (!(mp_opt.suboptions &OPTION_MPTCP_MPJ_ACK ) || - !subflow_hmac_valid (req, &mp_opt) || - !mptcp_can_accept_new_subflow (subflow_req->msk)) { -SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINACKMAC ); +if (!(mp_opt.suboptions &OPTION_MPTCP_MPJ_ACK )) fallback = true; - } } create_child:
@@ -907,6 +901,13 @@ create_child:subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); goto dispose_child; } + +if (!subflow_hmac_valid (req, &mp_opt) || + !mptcp_can_accept_new_subflow (subflow_req->msk)) { +SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINACKMAC ); +subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); + goto dispose_child; + }/* move the msk reference ownership to the subflow */ subflow_req->msk =NULL ;
Greg Kroah-Hartman
maintainerPATCH 281/393 mptcp: only inc MPJoinAckHMacFailure for HMAC failures
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 21c02e8272bc95ba0dd44943665c669029b42760 upstream.
Recently, during a debugging session using local MPTCP connections, I noticed MPJoinAckHMacFailure was not zero on the server side. The counter was in fact incremented when the PM rejected new subflows, because the 'subflow' limit was reached.
The fix is easy, simply dissociating the two cases: only the HMAC validation check should increase MPTCP_MIB_JOINACKMAC counter.
--- net/mptcp/subflow.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/mptcp/subflow.c +6 -2
@@ -902,12 +902,16 @@ create_child: goto dispose_child; } -if (!subflow_hmac_valid (req, &mp_opt) || - !mptcp_can_accept_new_subflow (subflow_req->msk)) { +if (!subflow_hmac_valid (req, &mp_opt)) {SUBFLOW_REQ_INC_STATS (req,MPTCP_MIB_JOINACKMAC );subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); goto dispose_child; } + +if (!mptcp_can_accept_new_subflow (owner)) { +subflow_add_reset_reason (skb,MPTCP_RST_EPROHIBIT ); + goto dispose_child; + }/* move the msk reference ownership to the subflow */ subflow_req->msk =NULL ;
Greg Kroah-Hartman
maintainerPATCH 282/393 mtd: inftlcore: Add error check for inftl_read_oob()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit d027951dc85cb2e15924c980dc22a6754d100c7c upstream.
In INFTL_findwriteunit(), the return value of inftl_read_oob() need to be checked. A proper implementation can be found in INFTL_deleteblock(). The status will be set as SECTOR_IGNORE to break from the while-loop correctly if the inftl_read_oob() fails.
--- drivers/mtd/inftlcore.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/inftlcore.c +5 -4
@@ -482,10 +482,11 @@ static inline u16 INFTL_findwriteunit(st silly =MAX_LOOPS ;while (thisEUN <= inftl->lastEUN) { -inftl_read_oob (mtd, (thisEUN * inftl->EraseSize) + - blockofs,8 , &retlen, (char *)&bci); - - status = bci.Status | bci.Status1; +if (inftl_read_oob (mtd, (thisEUN * inftl->EraseSize) + + blockofs,8 , &retlen, (char *)&bci) <0 ) + status =SECTOR_IGNORE ; +else + status = bci.Status | bci.Status1;pr_debug ("INFTL: status of block %d in EUN %d is %x\n" , block , writeEUN, status);
Greg Kroah-Hartman
maintainerPATCH 283/393 mtd: rawnand: Add status chack in r852_ready()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
commit b79fe1829975556854665258cf4d2476784a89db upstream.
In r852_ready(), the dev get from r852_get_dev() need to be checked. An unstable device should not be ready. A proper implementation can be found in r852_read_byte(). Add a status check and return 0 when it is unstable.
--- drivers/mtd/nand/raw/r852.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/nand/raw/r852.c +3 -0
@@ -387,6 +387,9 @@ static int r852_wait(struct nand_chip *cstatic int r852_ready (struct nand_chip *chip) {struct r852_device *dev =r852_get_dev (nand_to_mtd (chip)); +if (dev->card_unstable) +return 0 ; +return !(r852_read_reg (dev,R852_CARD_STA ) &R852_CARD_STA_BUSY ); }
Greg Kroah-Hartman
maintainerPATCH 284/393 arm64: mops: Do not dereference src reg for a set operation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keir Fraser <[email protected]>
commit a13bfa4fe0d6949cea14718df2d1fe84c38cd113 upstream.
The source register is not used for SET* and reading it can result in a UBSAN out-of-bounds array access error, specifically when the MOPS exception is taken from a SET* sequence with XZR (reg 31) as the source. Architecturally this is the only case where a src/dst/size field in the ESR can be reported as 31.
Prior to 2de451a329cf662b the code in do_el0_mops() was benign as the use of pt_regs_read_reg() prevented the out-of-bounds access.
--- arch/arm64/include/asm/traps.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/traps.h +2 -2
@@ -109,10 +109,9 @@ static inline void arm64_mops_reset_regs(struct user_pt_regs *regs, unsigned lonint dstreg =ESR_ELx_MOPS_ISS_DESTREG (esr);int srcreg =ESR_ELx_MOPS_ISS_SRCREG (esr);int sizereg =ESR_ELx_MOPS_ISS_SIZEREG (esr); -unsigned long dst, src, size; +unsigned long dst, size; dst = regs->regs[dstreg]; - src = regs->regs[srcreg]; size = regs->regs[sizereg];/*
@@ -129,6 +128,7 @@ static inline void arm64_mops_reset_regs(struct user_pt_regs *regs, unsigned lon } }else {/* CPY* instruction */ +unsigned long src = regs->regs[srcreg];if (!(option_a ^ wrong_option)) {/* Format is from Option B */ if (regs->pstate &PSR_N_BIT ) {
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 285/393 arm64: tegra: Remove the Orin NX/Nano suspend key
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ninad Malwade <[email protected]>
commit bb8a3ad25f098b6ea9b1d0f522427b4ad53a7bba upstream.
As per the Orin Nano Dev Kit schematic, GPIO_G.02 is not available on this device family. It should not be used at all on Orin NX/Nano. Having this unused pin mapped as the suspend key can lead to unpredictable behavior for low power modes.
Orin NX/Nano uses GPIO_EE.04 as both a "power" button and a "suspend" button. However, we cannot have two gpio-keys mapped to the same GPIO. Therefore remove the "suspend" key.
--- arch/arm64/boot/dts/nvidia/tegra234-p3768-0000+p3767.dtsi | 7 ------- 1 file changed, 7 deletions(-)
arch/arm64/boot/dts/nvidia/tegra234-p3768-0000+p3767.dtsi +0 -7
@@ -227,13 +227,6 @@ wakeup-event-action = <EV_ACT_ASSERTED>; wakeup-source; }; - - key-suspend { - label = "Suspend"; - gpios = <&gpio TEGRA234_MAIN_GPIO(G, 2) GPIO_ACTIVE_LOW>; - linux,input-type = <EV_KEY>; - linux,code = <KEY_SLEEP>; - }; }; fan: pwm-fan {
Greg Kroah-Hartman
maintainerPATCH 286/393 arm64: mm: Correct the update of max_pfn
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhenhua Huang <[email protected]>
commit 89f43e1ce6f60d4f44399059595ac47f7a90a393 upstream.
Hotplugged memory can be smaller than the original memory. For example, on my target:
root@genericarmv8:~# cat /sys/kernel/debug/memblock/memory 0: 0x0000000064005000..0x0000000064023fff 0 NOMAP 1: 0x0000000064400000..0x00000000647fffff 0 NOMAP 2: 0x0000000068000000..0x000000006fffffff 0 DRV_MNG 3: 0x0000000088800000..0x0000000094ffefff 0 NONE 4: 0x0000000094fff000..0x0000000094ffffff 0 NOMAP max_pfn will affect read_page_owner. Therefore, it should first compare and then select the larger value for max_pfn.
--- arch/arm64/mm/mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/mm/mmu.c +2 -1
@@ -1360,7 +1360,8 @@ int arch_add_memory(int nid, u64 start,__remove_pgd_mapping (swapper_pg_dir,__phys_to_virt (start), size); else { - max_pfn =PFN_UP (start + size); +/* Address of hotplugged memory can be smaller */ + max_pfn =max (max_pfn,PFN_UP (start + size)); max_low_pfn = max_pfn; }