Add AMD ISP4 driver
Subsystems (2)
Bin Du
maintainerv5 cover Add AMD ISP4 driver
Hello,
AMD ISP4 is the AMD image processing gen 4 which can be found in HP ZBook Ultra G1a 14 inch Mobile Workstation PC (Ryzen AI Max 300 Series)
(https://ubuntu.com/certified/202411-36043)
This patch series introduces the initial driver support for the AMD ISP4.
Patch summary:
- Powers up/off and initializes ISP HW
- Configures and kicks off ISP FW
- Interacts with APP using standard V4l2 interface by video node
- Controls ISP HW and interacts with ISP FW to do image processing
- Supports enum/set output image format and resolution
- Supports queueing buffer from app and dequeuing ISP filled buffer to App
- It is verified on qv4l2, cheese and qcam
- It is verified together with following patches
platform/x86: Add AMD ISP platform config (https://lore.kernel.org/all/[email protected]/) pinctrl: amd: isp411: Add amdisp GPIO pinctrl (https://github.com/torvalds/linux/commit/e97435ab09f3ad7b6a588dd7c4e45a96699bbb4a) drm/amd/amdgpu: Add GPIO resources required for amdisp (https://gitlab.freedesktop.org/agd5f/linux/-/commit/ad0f5966ed8297aa47b3184192b00b7379ae0758) drm/amd/amdgpu: Declare isp firmware binary file (https://gitlab.freedesktop.org/agd5f/linux/-/commit/35345917bc9f7c86152b270d9d93c220230b667f)
AMD ISP4 Key features:
- Processes bayer raw data from the connected sensor and output them to different YUV formats
- Downscale input image to different output image resolution
- Pipeline to do image processing on the input image including demosaic, denoise, 3A, etc.
----------
Changes v4 -> v5:
- Transitioned VIDEOBUF2_V4L2 from 'depends' to 'select' within Kconfig.
- Standardized object file naming conventions in the Makefile and sorted entries alphabetically.
- Removed the unused macro definition to_isp4_device.
- Eliminated unused members mem_domain and mem_align from struct isp4if_gpu_mem_info.
- Deleted unused fields mc_addr and gpu_pkg from struct isp4if_cmd_element.
- Removed obsolete pltf_data, i2c_nb, and notifier elements from struct isp4_device.
- Updated platform_get_irq failure handling to return its actual result rather than -ENODEV.
- Refined inclusion of header files for clarity and efficiency.
- Appended comments following #endif statements in header files.
- Improved implementation of isp4if_gpu_mem_free and isp4if_dealloc_fw_gpumem.
- Removed isp4if_append_cmd_2_cmdq and revised isp4if_send_fw_cmd accordingly.
- Enhanced isp4if_clear_cmdq and isp4if_clear_bufq by eliminating unnecessary list_del operations.
- Adopted completion mechanism instead of wait queue and condition for command completion notifications.
- Employed memset to ensure proper zeroing of padding bits in structures shared between ISP driver and firmware.
- Streamlined IRQs, reducing total from four to two, retaining only essential ones.
- Optimized IRQ handler logic using a while loop for greater efficiency.
- Introduced dynamic IRQ enable/disable functionality based on camera status (open/close).
- Applied distinct identifiers to differentiate multiple threads and IRQs.
- Removed unnecessary initialization of local variables.
- Refined camera start/stop workflow to mitigate potential synchronization concerns.
- Replaced all remaining mutex with guard mutex.
- Enhanced command and buffer queue performance by substituting mutexes with spinlocks.
- Removed redundant isp4sd_init_meta_buf function and its references.
- Limited firmware logging activities to the stream1 thread.
- Relocated v4l2_device_unregister_subdev() and media_entity_cleanup() calls from isp4_capture_remove to isp4sd_deinit.
- Resolved media device registration sequence issues.
- Modified stream processing thread behavior to await IRQ without a timeout.
- Addressed cleanup procedures in video device initialization and deinitialization routines.
- Corrected typos and made other cosmetic improvements.
Changes v3 -> v4:
- Replace one mutex with guard mutex.
- Remove unnecessary bus_info initialization of v4l2_capability.
- Drop V4L2_CAP_IO_MC from capabilities of v4l2_capability.
- Modify document with better SOC description.
- Fix Test x86 failure in Media CI test https://linux-media.pages.freedesktop.org/-/users/patchwork/-/jobs/83470456/artifacts/report.htm
- Modify some commit messages by describing changes in imperative mood.
- Add media-ctl output in cover letter.
- Create separated dedicated amdgpu patch to add declaration MODULE_FIRMWARE("amdgpu/isp_4_1_1.bin");
- Fix typo errors and other cosmetic issues.
- Add DRM_AMD_ISP dependency in Kconfig.
Changes v2 -> v3:
- All the dependent patches in other modules (drm/amd/amdgpu, platform/x86, pinctrl/amd) merged on upstream mainline kernel (https://github.com/torvalds/linux) v6.17.
- Removed usage of amdgpu structs in ISP driver. Added helper functions in amdgpu accepting opaque params from ISP driver to allocate and release ISP GART buffers.
- Moved sensor and MIPI phy control entirely into ISP FW instead of the previous hybrid approach controlling sensor from both FW and x86 (sensor driver).
- Removed phy configuration and sensor binding as x86 (sensor driver) had relinquished the sensor control for ISP FW. With this approach the driver will be exposed as web camera like interface.
- New FW with built-in sensor driver is submitted on upstream linux-firmware repo (https://gitlab.com/kernel-firmware/linux-firmware/).
- Please note the new FW submitted is not directly compatible with OEM Kernel ISP4.0 (https://github.com/amd/Linux_ISP_Kernel/tree/4.0) and the previous ISP V2 patch series.
- If intend to use the new FW, please rebuild OEM ISP4.0 Kernel with CONFIG_VIDEO_OV05C10=N and CONFIG_PINCTRL_AMDISP=Y.
- Included critical fixes from Sultan Alsawaf branch (https://github.com/kerneltoast/kernel_x86_laptop.git) related to managing lifetime of isp buffers.
media: amd: isp4: Add missing refcount tracking to mmap memop
media: amd: isp4: Don't put or unmap the dmabuf when detaching
media: amd: isp4: Don't increment refcount when dmabuf export fails
media: amd: isp4: Fix possible use-after-free in isp4vid_vb2_put()
media: amd: isp4: Always export a new dmabuf from get_dmabuf memop
media: amd: isp4: Fix implicit dmabuf lifetime tracking
media: amd: isp4: Fix possible use-after-free when putting implicit dmabuf
media: amd: isp4: Simplify isp4vid_get_dmabuf() arguments
media: amd: isp4: Move up buf->vaddr check in isp4vid_get_dmabuf()
media: amd: isp4: Remove unused userptr memops
media: amd: isp4: Add missing cleanup on error in isp4vid_vb2_alloc()
media: amd: isp4: Release queued buffers on error in start_streaming
- Addressed all code related upstream comments
- Fix typo errors and other cosmetic issues.
Changes v1 -> v2:
- Fix media CI test errors and valid warnings
- Reduce patch number in the series from 9 to 8 by merging MAINTAINERS adding patch to the first patch
- In patch 5
- do modification to use remote endpoint instead of local endpoint
- use link frequency and port number as start phy parameter instead of extra added phy-id and phy-bit-rate property of endpoint
----------
It passes v4l2 compliance test, the test reports for:
(a) amd_isp_capture device /dev/video0
Compliance test for amd_isp_capture device /dev/video0:
-------------------------------------------------------
atg@atg-HP-PV:~/bin$ ./v4l2-compliance -d /dev/video0 v4l2-compliance 1.29.0-5348, 64 bits, 64-bit time_t v4l2-compliance SHA: 75e3f0e2c2cb 2025-03-17 18:12:17
Compliance test for amd_isp_capture device /dev/video0:
Driver Info:
Driver name : amd_isp_capture
Card type : amd_isp_capture
Bus info : platform:amd_isp_capture
Driver version : 6.14.0
Capabilities : 0xa4200001 Video Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x24200001
Video Capture
I/O MC
Streaming
Extended Pix Format
Media Driver Info:
Driver name : amd_isp_capture
Model : amd_isp41_mdev
Serial :
Bus info : platform:amd_isp_capture
Media version : 6.14.0
Hardware revision: 0x00000000 (0)
Driver version : 6.14.0Interface Info:
ID : 0x03000005
Type : V4L Video
Entity Info:
ID : 0x00000003 (3)
Name : Preview
Function : V4L2 I/O
Pad 0x01000004 : 0: Sink
Link 0x02000007: from remote pad 0x1000002 of entity 'amd isp4' (Image Signal Processor): Data, Enabled, ImmutableRequired ioctls:
test MC information (see 'Media Driver Info' above): OK test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0
Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported) test blocking wait: OK
Total for amd_isp_capture device /dev/video0: 49, Succeeded: 49, Failed: 0, Warnings: 0
The media-ctl output of media device /dev/media0:
-------------------------------------------------------
atg@atg-HP-PV:~$ media-ctl -p -d /dev/media0 Media controller API version 6.17.0
Media device information
------------------------
driver amd_isp_capture
model amd_isp41_mdev
serial
bus info platform:amd_isp_capture hw revision 0x0 driver version 6.17.0
Device topology
- entity 1: amd isp4 (1 pad, 1 link, 0 routes) type V4L2 subdev subtype Unknown flags 0
pad0: Source
-> "Preview":0 [ENABLED,IMMUTABLE]
- entity 3: Preview (1 pad, 1 link)
type Node subtype V4L flags 0 device node name /dev/video0
pad0: Sink
<- "amd isp4":0 [ENABLED,IMMUTABLE]
Please review and provide feedback.
Many thanks,
Bin Du (7):
media: platform: amd: Introduce amd isp4 capture driver
media: platform: amd: low level support for isp4 firmware
media: platform: amd: Add isp4 fw and hw interface
media: platform: amd: isp4 subdev and firmware loading handling added
media: platform: amd: isp4 video node and buffers handling added
media: platform: amd: isp4 debug fs logging and more descriptive
errors
Documentation: add documentation of AMD isp 4 driver
Documentation/admin-guide/media/amdisp4-1.rst | 63 + Documentation/admin-guide/media/amdisp4.dot | 6 + .../admin-guide/media/v4l-drivers.rst | 1 + MAINTAINERS | 25 + drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 3 + drivers/media/platform/amd/Makefile | 3 + drivers/media/platform/amd/isp4/Kconfig | 14 + drivers/media/platform/amd/isp4/Makefile | 10 + drivers/media/platform/amd/isp4/isp4.c | 209 +++ drivers/media/platform/amd/isp4/isp4.h | 21 + drivers/media/platform/amd/isp4/isp4_debug.c | 271 ++++ drivers/media/platform/amd/isp4/isp4_debug.h | 41 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 314 +++++ drivers/media/platform/amd/isp4/isp4_hw_reg.h | 124 ++ .../media/platform/amd/isp4/isp4_interface.c | 923 +++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 147 ++ drivers/media/platform/amd/isp4/isp4_subdev.c | 1172 ++++++++++++++++ drivers/media/platform/amd/isp4/isp4_subdev.h | 128 ++ drivers/media/platform/amd/isp4/isp4_video.c | 1179 +++++++++++++++++ drivers/media/platform/amd/isp4/isp4_video.h | 84 ++ 22 files changed, 4740 insertions(+) create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst create mode 100644 Documentation/admin-guide/media/amdisp4.dot create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.c create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.h create mode 100644 drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h create mode 100644 drivers/media/platform/amd/isp4/isp4_hw_reg.h create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.c create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.h create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.c create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.h create mode 100644 drivers/media/platform/amd/isp4/isp4_video.c create mode 100644 drivers/media/platform/amd/isp4/isp4_video.h
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 1/7 media: platform: amd: Introduce amd isp4 capture driver
AMD isp4 capture is a v4l2 media device which implements media controller interface. It has one sub-device (AMD ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now. Also add ISP4 driver related entry info into the MAINTAINERS file
--- MAINTAINERS | 13 +++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 3 + drivers/media/platform/amd/Makefile | 3 + drivers/media/platform/amd/isp4/Kconfig | 14 +++ drivers/media/platform/amd/isp4/Makefile | 6 ++ drivers/media/platform/amd/isp4/isp4.c | 121 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 20 ++++ 9 files changed, 182 insertions(+) create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Kconfig create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h
MAINTAINERS +13 -0
@@ -1133,6 +1133,19 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git F: drivers/iommu/amd/ F: include/linux/amd-iommu.h +AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/Kconfig +F: drivers/media/platform/amd/isp4/Makefile +F: drivers/media/platform/amd/isp4/isp4.c +F: drivers/media/platform/amd/isp4/isp4.h + AMD KFD M: Felix Kuehling <[email protected]> L: [email protected]
drivers/media/platform/Kconfig +1 -0
@@ -63,6 +63,7 @@ config VIDEO_MUX # Platform drivers - Please keep it alphabetically sorted source "drivers/media/platform/allegro-dvt/Kconfig" +source "drivers/media/platform/amd/Kconfig" source "drivers/media/platform/amlogic/Kconfig" source "drivers/media/platform/amphion/Kconfig" source "drivers/media/platform/aspeed/Kconfig"
drivers/media/platform/Makefile +1 -0
@@ -6,6 +6,7 @@ # Place here, alphabetically sorted by directory # (e. g. LC_ALL=C sort Makefile) obj-y += allegro-dvt/ +obj-y += amd/ obj-y += amlogic/ obj-y += amphion/ obj-y += aspeed/
drivers/media/platform/amd/Kconfig new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +source "drivers/media/platform/amd/isp4/Kconfig"
drivers/media/platform/amd/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-y += isp4/
drivers/media/platform/amd/isp4/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0+ + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + depends on DRM_AMD_ISP && VIDEO_DEV + select VIDEOBUF2_CORE + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_V4L2 + select VIDEO_V4L2_SUBDEV_API + help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for video capture. + To compile this driver as a module, choose M here. The module will + be called amd_capture.
drivers/media/platform/amd/isp4/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.o +amd_capture-objs := isp4.o
drivers/media/platform/amd/isp4/isp4.c new file +121 -0
121 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_device { +struct v4l2_device v4l2_dev; +struct media_device mdev; +struct platform_device *pdev; +}; + +#endif /* _ISP4_H_ */
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 2/7 media: platform: amd: low level support for isp4 firmware
In reply to Bin DuLow level functions for accessing the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware. Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.
--- MAINTAINERS | 1 + drivers/media/platform/amd/isp4/isp4_hw_reg.h | 119 ++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 drivers/media/platform/amd/isp4/isp4_hw_reg.h
MAINTAINERS +1 -0
@@ -1145,6 +1145,7 @@ F: drivers/media/platform/amd/isp4/Kconfig F: drivers/media/platform/amd/isp4/Makefile F: drivers/media/platform/amd/isp4/isp4.c F: drivers/media/platform/amd/isp4/isp4.h +F: drivers/media/platform/amd/isp4/isp4_hw_reg.h AMD KFD M: Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 3/7 media: platform: amd: Add isp4 fw and hw interface
In reply to Bin DuISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu. The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contain ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start. Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.
--- MAINTAINERS | 3 + drivers/media/platform/amd/isp4/Makefile | 3 +- .../platform/amd/isp4/isp4_fw_cmd_resp.h | 314 +++++++ .../media/platform/amd/isp4/isp4_interface.c | 887 ++++++++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 144 +++ 5 files changed, 1350 insertions(+), 1 deletion(-) create mode 100644 drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.c create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.h
MAINTAINERS +3 -0
@@ -1145,7 +1145,10 @@ F: drivers/media/platform/amd/isp4/Kconfig F: drivers/media/platform/amd/isp4/Makefile F: drivers/media/platform/amd/isp4/isp4.c F: drivers/media/platform/amd/isp4/isp4.h +F: drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h F: drivers/media/platform/amd/isp4/isp4_hw_reg.h +F: drivers/media/platform/amd/isp4/isp4_interface.c +F: drivers/media/platform/amd/isp4/isp4_interface.h AMD KFD M: Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +2 -1
@@ -3,4 +3,5 @@ # Copyright (C) 2025 Advanced Micro Devices, Inc. obj-$(CONFIG_AMD_ISP4) += amd_capture.o -amd_capture-objs := isp4.o +amd_capture-objs := isp4.o \ + isp4_interface.o
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +314 -0
314 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.c new file +887 -0
887 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.h new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 4/7 media: platform: amd: isp4 subdev and firmware loading handling added
In reply to Bin DuIsp4 sub-device is implementing v4l2 sub-device interface. It has one capture video node, and supports only preview stream. It manages firmware states, stream configuration. Add interrupt handling and notification for isp firmware to isp-subdevice.
--- MAINTAINERS | 2 + drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4.c | 120 +- drivers/media/platform/amd/isp4/isp4.h | 5 +- .../media/platform/amd/isp4/isp4_interface.c | 6 +- .../media/platform/amd/isp4/isp4_interface.h | 2 +- drivers/media/platform/amd/isp4/isp4_subdev.c | 1074 +++++++++++++++++ drivers/media/platform/amd/isp4/isp4_subdev.h | 121 ++ 8 files changed, 1302 insertions(+), 31 deletions(-) create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.c create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.h
MAINTAINERS +2 -0
@@ -1149,6 +1149,8 @@ F: drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h F: drivers/media/platform/amd/isp4/isp4_hw_reg.h F: drivers/media/platform/amd/isp4/isp4_interface.c F: drivers/media/platform/amd/isp4/isp4_interface.h +F: drivers/media/platform/amd/isp4/isp4_subdev.c +F: drivers/media/platform/amd/isp4/isp4_subdev.h AMD KFD M: Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +2 -1
@@ -4,4 +4,5 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ - isp4_interface.o + isp4_interface.o \ + isp4_subdev.o
drivers/media/platform/amd/isp4/isp4.c +96 -24
190 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4.h +3 -2
@@ -6,13 +6,14 @@#ifndef _ISP4_H_#define _ISP4_H_ -#include <media/v4l2-device.h> -#include <media/videobuf2-memops.h> +#include <drm/amd/isp.h> +#include "isp4_subdev.h" #define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio)struct isp4_device {struct v4l2_device v4l2_dev; +struct isp4_subdev isp_subdev;struct media_device mdev;struct platform_device *pdev; };
drivers/media/platform/amd/isp4/isp4_interface.c +3 -3
@@ -155,7 +155,7 @@ static void isp4if_dealloc_fw_gpumem(struct isp4_interface *ispif)isp4if_gpu_mem_free (ispif, &ispif->fw_cmd_resp_buf);for (i =0 ; i <ISP4IF_MAX_STREAM_BUF_COUNT ; i++) -isp4if_gpu_mem_free (ispif, &ispif->metainfo_buf_pool[i]); +isp4if_gpu_mem_free (ispif, &ispif->meta_info_buf[i]); }static int isp4if_alloc_fw_gpumem (struct isp4_interface *ispif)
@@ -173,9 +173,9 @@ static int isp4if_alloc_fw_gpumem(struct isp4_interface *ispif) goto error_no_memory;for (i =0 ; i <ISP4IF_MAX_STREAM_BUF_COUNT ; i++) { - ispif->metainfo_buf_pool[i] = + ispif->meta_info_buf[i] =isp4if_gpu_mem_alloc (ispif,ISP4IF_META_INFO_BUF_SIZE ); -if (!ispif->metainfo_buf_pool[i]) +if (!ispif->meta_info_buf[i]) goto error_no_memory; }
drivers/media/platform/amd/isp4/isp4_interface.h +1 -1
@@ -94,7 +94,7 @@ struct isp4_interface {/* ISP fw buffers */ struct isp4if_gpu_mem_info *fw_cmd_resp_buf;struct isp4if_gpu_mem_info *fw_mem_pool; -struct isp4if_gpu_mem_info *metainfo_buf_pool[ISP4IF_MAX_STREAM_BUF_COUNT ]; +struct isp4if_gpu_mem_info *meta_info_buf[ISP4IF_MAX_STREAM_BUF_COUNT ]; };static inline void isp4if_split_addr64 (u64 addr,u32 *lo,u32 *hi)
drivers/media/platform/amd/isp4/isp4_subdev.c new file +1074 -0
1,074 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_subdev.h new file +121 -0
121 lines not on this page · raw message
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 5/7 media: platform: amd: isp4 video node and buffers handling added
In reply to Bin DuIsp video implements v4l2 video interface and supports NV12 and YUYV. It manages buffers, pipeline power and state. Cherry-picked Sultan's DMA buffer related fix from branch v6.16-drm-tip-isp4-for-amd on
https://github.com/kerneltoast/kernel_x86_laptop.git
--- MAINTAINERS | 2 + drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4.c | 14 +- drivers/media/platform/amd/isp4/isp4_subdev.c | 94 +- drivers/media/platform/amd/isp4/isp4_subdev.h | 2 + drivers/media/platform/amd/isp4/isp4_video.c | 1179 +++++++++++++++++ drivers/media/platform/amd/isp4/isp4_video.h | 84 ++ 7 files changed, 1370 insertions(+), 8 deletions(-) create mode 100644 drivers/media/platform/amd/isp4/isp4_video.c create mode 100644 drivers/media/platform/amd/isp4/isp4_video.h
MAINTAINERS +2 -0
@@ -1151,6 +1151,8 @@ F: drivers/media/platform/amd/isp4/isp4_interface.c F: drivers/media/platform/amd/isp4/isp4_interface.h F: drivers/media/platform/amd/isp4/isp4_subdev.c F: drivers/media/platform/amd/isp4/isp4_subdev.h +F: drivers/media/platform/amd/isp4/isp4_video.c +F: drivers/media/platform/amd/isp4/isp4_video.h AMD KFD M: Felix Kuehling <[email protected]>
drivers/media/platform/amd/isp4/Makefile +2 -1
@@ -5,4 +5,5 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ isp4_interface.o \ - isp4_subdev.o + isp4_subdev.o \ + isp4_video.o
drivers/media/platform/amd/isp4/isp4.c +13 -1
@@ -146,6 +146,16 @@ static int isp4_capture_probe(struct platform_device *pdev) goto err_unreg_v4l2; } + ret =media_create_pad_link (&isp_dev->isp_subdev.sdev.entity, +0 , &isp_dev->isp_subdev.isp_vdev.vdev.entity, +0 , +MEDIA_LNK_FL_ENABLED | +MEDIA_LNK_FL_IMMUTABLE ); +if (ret) { +dev_err (dev,"fail to create pad link %d\n" , ret); + goto err_isp4_deinit; + } + ret =media_device_register (&isp_dev->mdev);if (ret) {dev_err (dev,"fail to register media device %d\n" , ret);
@@ -160,6 +170,7 @@ static int isp4_capture_probe(struct platform_device *pdev)isp4sd_deinit (&isp_dev->isp_subdev); err_unreg_v4l2:v4l2_device_unregister (&isp_dev->v4l2_dev); +media_device_cleanup (&isp_dev->mdev);return dev_err_probe (dev, ret,"isp probe fail\n" ); }
@@ -169,8 +180,9 @@ static void isp4_capture_remove(struct platform_device *pdev)struct isp4_device *isp_dev =platform_get_drvdata (pdev);media_device_unregister (&isp_dev->mdev); -v4l2_device_unregister (&isp_dev->v4l2_dev);isp4sd_deinit (&isp_dev->isp_subdev); +v4l2_device_unregister (&isp_dev->v4l2_dev); +media_device_cleanup (&isp_dev->mdev); }static struct platform_driver isp4_capture_drv = {
drivers/media/platform/amd/isp4/isp4_subdev.c +88 -6
164 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_subdev.h +2 -0
@@ -17,6 +17,7 @@#include "isp4_fw_cmd_resp.h" #include "isp4_hw_reg.h" #include "isp4_interface.h" +#include "isp4_video.h" /* * one is for none sesnor specefic response which is not used now
@@ -93,6 +94,7 @@ struct isp4_subdev_thread_param {struct isp4_subdev {struct v4l2_subdev sdev;struct isp4_interface ispif; +struct isp4vid_dev isp_vdev;struct media_pad sdev_pad;
drivers/media/platform/amd/isp4/isp4_video.c new file +1179 -0
1,179 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_video.h new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 7/7 Documentation: add documentation of AMD isp 4 driver
In reply to Bin DuAdd documentation for AMD ISP 4 and describe the main components
--- Documentation/admin-guide/media/amdisp4-1.rst | 63 +++++++++++++++++++ Documentation/admin-guide/media/amdisp4.dot | 6 ++ .../admin-guide/media/v4l-drivers.rst | 1 + MAINTAINERS | 2 + 4 files changed, 72 insertions(+) create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst create mode 100644 Documentation/admin-guide/media/amdisp4.dot
Documentation/admin-guide/media/amdisp4-1.rst new file +63 -0
@@ -0,0 +1,63 @@ +.. SPDX-License-Identifier: GPL-2.0 + +.. include:: <isonum.txt> + +==================================== +AMD Image Signal Processor (amdisp4) +==================================== + +Introduction +============ + +This file documents the driver for the AMD ISP4 that is part of +AMD Ryzen AI Max 300 Series. + +The driver is located under drivers/media/platform/amd/isp4 and uses +the Media-Controller API. + +The driver exposes one video capture device to userspace and provide +web camera like interface. Internally the video device is connected +to the isp4 sub-device responsible for communication with the CCPU FW. + +Topology +======== + +.. _amdisp4_topology_graph: + +.. kernel-figure:: amdisp4.dot + :alt: Diagram of the media pipeline topology + :align: center + + + +The driver has 1 sub-device: Representing isp4 image signal processor. +The driver has 1 video device: Capture device for retrieving images. + +- ISP4 Image Signal Processing Subdevice Node + +--------------------------------------------- + +The isp4 is represented as a single V4L2 subdev, the sub-device does not +provide interface to the user space. The sub-device is connected to one video node +(isp4_capture) with immutable active link. The sub-device represents ISP with +connected sensor similar to smart cameras (sensors with integrated ISP). +sub-device has only one link to the video device for capturing the frames. +The sub-device communicates with CCPU FW for streaming configuration and +buffer management. + + +- isp4_capture - Frames Capture Video Node + +------------------------------------------ + +Isp4_capture is a capture device to capture frames to memory. +The entity is connected to isp4 sub-device. The video device +provides web camera like interface to userspace. It supports +mmap and dma buf types of memory. + +Capturing Video Frames Example +============================== + +.. code-block:: bash + + v4l2-ctl "-d" "/dev/video0" "--set-fmt-video=width=1920,height=1080,pixelformat=NV12" "--stream-mmap" "--stream-count=10"
Documentation/admin-guide/media/amdisp4.dot new file +6 -0
@@ -0,0 +1,6 @@ +digraph board { + rankdir=TB + n00000001 [label="{{} | amd isp4\n | {<port0> 0}}", shape=Mrecord, style=filled, fillcolor=green] + n00000001:port0 -> n00000003 [style=bold] + n00000003 [label="Preview\n/dev/video0", shape=box, style=filled, fillcolor=yellow] +}
Documentation/admin-guide/media/v4l-drivers.rst +1 -0
@@ -9,6 +9,7 @@ Video4Linux (V4L) driver-specific documentation .. toctree:: :maxdepth: 2 + amdisp4-1 bttv c3-isp cafe_ccic
MAINTAINERS +2 -0
@@ -1139,6 +1139,8 @@ M: Nirujogi Pratap <[email protected]> L: [email protected] S: Maintained T: git git://linuxtv.org/media.git +F: Documentation/admin-guide/media/amdisp4-1.rst +F: Documentation/admin-guide/media/amdisp4.dot F: drivers/media/platform/amd/Kconfig F: drivers/media/platform/amd/Makefile F: drivers/media/platform/amd/isp4/Kconfig
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v5 6/7 media: platform: amd: isp4 debug fs logging and more descriptive errors
In reply to Bin DuAdd debug fs for isp4 driver and add more detailed descriptive error info to some of the log message
--- MAINTAINERS | 2 + drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4.c | 4 + drivers/media/platform/amd/isp4/isp4_debug.c | 271 ++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_debug.h | 41 +++ drivers/media/platform/amd/isp4/isp4_hw_reg.h | 5 + .../media/platform/amd/isp4/isp4_interface.c | 62 +++- .../media/platform/amd/isp4/isp4_interface.h | 3 + drivers/media/platform/amd/isp4/isp4_subdev.c | 30 +- drivers/media/platform/amd/isp4/isp4_subdev.h | 5 + 10 files changed, 404 insertions(+), 20 deletions(-) create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.c create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.h
MAINTAINERS +2 -0
@@ -1145,6 +1145,8 @@ F: drivers/media/platform/amd/isp4/Kconfig F: drivers/media/platform/amd/isp4/Makefile F: drivers/media/platform/amd/isp4/isp4.c F: drivers/media/platform/amd/isp4/isp4.h +F: drivers/media/platform/amd/isp4/isp4_debug.c +F: drivers/media/platform/amd/isp4/isp4_debug.h F: drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h F: drivers/media/platform/amd/isp4/isp4_hw_reg.h F: drivers/media/platform/amd/isp4/isp4_interface.c
drivers/media/platform/amd/isp4/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ + isp4_debug.o \ isp4_interface.o \ isp4_subdev.o \ isp4_video.o
drivers/media/platform/amd/isp4/isp4.c +4 -0
@@ -10,6 +10,7 @@#include <media/v4l2-ioctl.h> #include "isp4.h" +#include "isp4_debug.h" #include "isp4_hw_reg.h" #define ISP4_DRV_NAME "amd_isp_capture"
@@ -163,6 +164,7 @@ static int isp4_capture_probe(struct platform_device *pdev) }platform_set_drvdata (pdev, isp_dev); +isp_debugfs_create (isp_dev);return 0 ;
@@ -179,6 +181,8 @@ static void isp4_capture_remove(struct platform_device *pdev) {struct isp4_device *isp_dev =platform_get_drvdata (pdev); +isp_debugfs_remove (isp_dev); +media_device_unregister (&isp_dev->mdev);isp4sd_deinit (&isp_dev->isp_subdev);v4l2_device_unregister (&isp_dev->v4l2_dev);
drivers/media/platform/amd/isp4/isp4_debug.c new file +271 -0
271 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_debug.h new file +41 -0
41 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_hw_reg.h +5 -0
@@ -14,6 +14,11 @@#define ISP_SYS_INT0_ACK 0x62018#define ISP_CCPU_CNTL 0x62054#define ISP_STATUS 0x62058 +#define ISP_LOG_RB_BASE_LO0 0x62148 +#define ISP_LOG_RB_BASE_HI0 0x6214c +#define ISP_LOG_RB_SIZE0 0x62150 +#define ISP_LOG_RB_RPTR0 0x62154 +#define ISP_LOG_RB_WPTR0 0x62158#define ISP_RB_BASE_LO1 0x62170#define ISP_RB_BASE_HI1 0x62174#define ISP_RB_SIZE1 0x62178
drivers/media/platform/amd/isp4/isp4_interface.c +49 -13
156 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.h +3 -0
@@ -28,6 +28,8 @@#define ISP4IF_META_INFO_BUF_SIZE ALIGN(sizeof(struct isp4fw_meta_info), 0x8000)#define ISP4IF_MAX_STREAM_BUF_COUNT 8 +#define ISP4IF_FW_LOG_RINGBUF_SIZE (2 * 1024 * 1024) +#define ISP4IF_MAX_CMD_RESPONSE_BUF_SIZE (4 * 1024)#define GET_ISP4IF_REG_BASE (ispif) (((ispif))->mmio)
@@ -92,6 +94,7 @@ struct isp4_interface {u32 aligned_rb_chunk_size;/* ISP fw buffers */ +struct isp4if_gpu_mem_info *fw_log_buf;struct isp4if_gpu_mem_info *fw_cmd_resp_buf;struct isp4if_gpu_mem_info *fw_mem_pool;struct isp4if_gpu_mem_info *meta_info_buf[ISP4IF_MAX_STREAM_BUF_COUNT ];
drivers/media/platform/amd/isp4/isp4_subdev.c +23 -7
@@ -6,6 +6,7 @@#include <linux/pm_domain.h> #include <linux/units.h> +#include "isp4_debug.h" #include "isp4_fw_cmd_resp.h" #include "isp4_interface.h" #include "isp4_subdev.h"
@@ -279,7 +280,9 @@ static int isp4sd_setup_output(struct isp4_subdev *isp_subdev,return -EINVAL ; } -dev_dbg (dev,"channel: w:h=%u:%u,lp:%u,cp%u\n" , +dev_dbg (dev,"channel:%s,fmt %s,w:h=%u:%u,lp:%u,cp%u\n" , +isp4dbg_get_out_ch_str (cmd_ch_prop.ch), +isp4dbg_get_img_fmt_str (cmd_ch_prop.image_prop.image_format), cmd_ch_prop.image_prop.width, cmd_ch_prop.image_prop.height, cmd_ch_prop.image_prop.luma_pitch, cmd_ch_prop.image_prop.chroma_pitch);
@@ -302,6 +305,9 @@ static int isp4sd_setup_output(struct isp4_subdev *isp_subdev,return ret; } +dev_dbg (dev,"enable channel %s\n" , +isp4dbg_get_out_ch_str (cmd_ch_en.ch)); +if (!sensor_info->start_stream_cmd_sent) { ret =isp4sd_kickoff_stream (isp_subdev, out_prop->width, out_prop->height);
@@ -425,8 +431,9 @@ static void isp4sd_fw_resp_cmd_done(struct isp4_subdev *isp_subdev,isp4if_rm_cmd_from_cmdq (ispif, para->cmd_seq_num, para->cmd_id);struct device *dev = isp_subdev->dev; -dev_dbg (dev,"stream %d,cmd (0x%08x)(%d),seq %u, ele %p\n" , +dev_dbg (dev,"stream %d,cmd %s(0x%08x)(%d),seq %u, ele %p\n" , stream_id, +isp4dbg_get_cmd_str (para->cmd_id), para->cmd_id, para->cmd_status, para->cmd_seq_num, ele);
@@ -478,8 +485,9 @@ isp4sd_preview_done(struct isp4_subdev *isp_subdev, pcb->preview.status =ISP4VID_BUF_DONE_STATUS_SUCCESS ; } }else if (meta->preview.enabled) { -dev_err (dev,"fail bad preview status %u\n" , - meta->preview.status); +dev_err (dev,"fail bad preview status %u(%s)\n" , + meta->preview.status, +isp4dbg_get_buf_done_str (meta->preview.status)); }return prev;
@@ -543,14 +551,18 @@ static void isp4sd_fw_resp_frame_done(struct isp4_subdev *isp_subdev, pcb.poc = meta->poc; pcb.cam_id =0 ; -dev_dbg (dev,"ts:%llu,streamId:%d,poc:%u,preview_en:%u,(%i)\n" , +dev_dbg (dev,"ts:%llu,streamId:%d,poc:%u,preview_en:%u,%s(%i)\n" ,ktime_get_ns (), stream_id, meta->poc, meta->preview.enabled, +isp4dbg_get_buf_done_str (meta->preview.status), meta->preview.status); prev =isp4sd_preview_done (isp_subdev, meta, &pcb); -if (pcb.preview.status !=ISP4VID_BUF_DONE_STATUS_ABSENT ) +if (pcb.preview.status !=ISP4VID_BUF_DONE_STATUS_ABSENT ) { +isp4dbg_show_bufmeta_info (dev,"prev" , &meta->preview, + &pcb.preview.buf);isp4vid_notify (&isp_subdev->isp_vdev, &pcb); + }isp4if_dealloc_buffer_node (prev);
@@ -568,6 +580,9 @@ static void isp4sd_fw_resp_func(struct isp4_subdev *isp_subdev,struct device *dev = isp_subdev->dev;struct isp4fw_resp resp; +if (stream_id ==ISP4IF_STREAM_ID_1 ) +isp_fw_log_print (isp_subdev); +while (true) {int ret;
@@ -587,7 +602,8 @@ static void isp4sd_fw_resp_func(struct isp4_subdev *isp_subdev, &resp.param.frame_done);break ;default : -dev_err (dev,"-><- fail respid (0x%x)\n" , +dev_err (dev,"-><- fail respid %s(0x%x)\n" , +isp4dbg_get_resp_str (resp.resp_id), resp.resp_id);break ; }
drivers/media/platform/amd/isp4/isp4_subdev.h +5 -0
@@ -114,6 +114,11 @@ struct isp4_subdev {void __iomem *mmio;struct isp4_subdev_thread_param isp_resp_para[ISP4SD_MAX_FW_RESP_STREAM_NUM ];int irq[ISP4SD_MAX_FW_RESP_STREAM_NUM ]; +#ifdef CONFIG_DEBUG_FS +struct dentry *debugfs_dir; +bool enable_fw_log; +char *fw_log_output; +#endif }; int isp4sd_init(struct isp4_subdev *isp_subdev, struct v4l2_device *v4l2_dev,
Signature · 1 line
2.34.1
Re: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
In reply to Bin DuQuoted 12 lines · Bin Du
drivers/media/platform/amd/isp4/isp4.c new file +6
-0@@ -0,0 +1,121 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h>
drivers/media/platform/amd/isp4/isp4.c line 16
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> + +#include "isp4.h" + +#define VIDEO_BUF_NUM 5 + +#define ISP4_DRV_NAME "amd_isp_capture" + +const char *isp4_irq_name[] = {
Why isn't this static?
Quoted 67 lines
drivers/media/platform/amd/isp4/isp4.c new file +67
-0+"isp_irq_stream1" , +"isp_irq_global" +}; + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { +0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ +4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ +return IRQ_HANDLED ; +} + +static int isp4_capture_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct isp4_device *isp_dev; +int i, irq, ret; + + isp_dev =devm_kzalloc (dev,sizeof (*isp_dev),GFP_KERNEL ); +if (!isp_dev) +return -ENOMEM ; + + isp_dev->pdev = pdev; + dev->init_name =ISP4_DRV_NAME ; + +for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { + irq =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +if (irq <0 ) +return dev_err_probe (dev, irq, +"fail to get irq %d\n" , + isp4_ringbuf_interrupt_num[i]); + ret =devm_request_irq (dev, irq, isp4_irq_handler,0 , + isp4_irq_name[i], dev); +if (ret) +return dev_err_probe (dev, ret,"fail to req irq %d\n" , + irq); + } + +/* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + +/* Initialize media device */ +strscpy (isp_dev->mdev.model,"amd_isp41_mdev" , +sizeof (isp_dev->mdev.model)); +snprintf (isp_dev->mdev.bus_info,sizeof (isp_dev->mdev.bus_info), +"platform:%s" ,ISP4_DRV_NAME ); + isp_dev->mdev.dev = dev; +media_device_init (&isp_dev->mdev); + +/* register v4l2 device */ +snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name), +"AMD-V4L2-ROOT" ); + ret =v4l2_device_register (dev, &isp_dev->v4l2_dev); +if (ret) +return dev_err_probe (dev, ret, +"fail register v4l2 device\n" ); + + ret =media_device_register (&isp_dev->mdev); +if (ret) { +dev_err (dev,"fail to register media device %d\n" , ret); + goto err_unreg_v4l2; + } + +platform_set_drvdata (pdev, isp_dev);
drivers/media/platform/amd/isp4/isp4.c line 93
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev); + +return 0 ; + +err_unreg_v4l2: +v4l2_device_unregister (&isp_dev->v4l2_dev); + +return dev_err_probe (dev, ret,"isp probe fail\n" );
No, don't print generic error thus multiple errors. Drop this and keep informative dev_err_probe() in applicable places.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ +struct isp4_device *isp_dev =platform_get_drvdata (pdev); +
drivers/media/platform/amd/isp4/isp4.c line 109
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+media_device_unregister (&isp_dev->mdev); +v4l2_device_unregister (&isp_dev->v4l2_dev); +} + +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name =ISP4_DRV_NAME , + .owner =THIS_MODULE ,
It is v5 but you still did not run standard tools. You try to upstream 12 year old code without cleaning it up.
Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1 for gcc and clang. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
drivers/media/platform/amd/isp4/isp4.c line 115
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME );
You should not need MODULE_ALIAS() in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries or MODULE_DEVICE_TABLE()). MODULE_ALIAS() is not a substitute for incomplete ID table.
Best regards,
Krzysztof
Du, Bin
maintainerRe: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
Many thanks for the review, Krzysztof
Quoted 17 lines · Krzysztof Kozlowski
Quoted 16 lines · Bin Du
drivers/media/platform/amd/isp4/isp4.c new file +10
-0@@ -0,0 +1,121 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> + +#include "isp4.h"
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 16
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ +#define VIDEO_BUF_NUM 5 + +#define ISP4_DRV_NAME "amd_isp_capture" + +const char *isp4_irq_name[] = {Why isn't this static?
Sure, will set it to static and check other similar variables.
Quoted 72 lines
Quoted 72 lines
drivers/media/platform/amd/isp4/isp4.c new file +72
-0+"isp_irq_stream1" , +"isp_irq_global" +}; + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { +0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ +4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ +return IRQ_HANDLED ; +} + +static int isp4_capture_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct isp4_device *isp_dev; +int i, irq, ret; + + isp_dev =devm_kzalloc (dev,sizeof (*isp_dev),GFP_KERNEL ); +if (!isp_dev) +return -ENOMEM ; + + isp_dev->pdev = pdev; + dev->init_name =ISP4_DRV_NAME ; + +for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { + irq =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +if (irq <0 ) +return dev_err_probe (dev, irq, +"fail to get irq %d\n" , + isp4_ringbuf_interrupt_num[i]); + ret =devm_request_irq (dev, irq, isp4_irq_handler,0 , + isp4_irq_name[i], dev); +if (ret) +return dev_err_probe (dev, ret,"fail to req irq %d\n" , + irq); + } + +/* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + +/* Initialize media device */ +strscpy (isp_dev->mdev.model,"amd_isp41_mdev" , +sizeof (isp_dev->mdev.model)); +snprintf (isp_dev->mdev.bus_info,sizeof (isp_dev->mdev.bus_info), +"platform:%s" ,ISP4_DRV_NAME ); + isp_dev->mdev.dev = dev; +media_device_init (&isp_dev->mdev); + +/* register v4l2 device */ +snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name), +"AMD-V4L2-ROOT" ); + ret =v4l2_device_register (dev, &isp_dev->v4l2_dev); +if (ret) +return dev_err_probe (dev, ret, +"fail register v4l2 device\n" ); + + ret =media_device_register (&isp_dev->mdev); +if (ret) { +dev_err (dev,"fail to register media device %d\n" , ret); + goto err_unreg_v4l2; + } + +platform_set_drvdata (pdev, isp_dev); + +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev); + +return 0 ;
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c line 93
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+ +err_unreg_v4l2: +v4l2_device_unregister (&isp_dev->v4l2_dev); + +return dev_err_probe (dev, ret,"isp probe fail\n" );No, don't print generic error thus multiple errors. Drop this and keep informative
dev_err_probe()in applicable places.
Very good suggestion, will implement it accordingly.
Quoted 11 lines
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ +struct isp4_device *isp_dev =platform_get_drvdata (pdev); + +media_device_unregister (&isp_dev->mdev); +v4l2_device_unregister (&isp_dev->v4l2_dev); +} + +static struct platform_driver isp4_capture_drv = {
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 109
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+ .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name = ISP4_DRV_NAME, + .owner = THIS_MODULE,It is v5 but you still did not run standard tools. You try to upstream 12 year old code without cleaning it up.
yes, no need to set .owner because the core will do it. Will clean it up.
Quoted 7 lines
Please run standard kernel tools for static analysis, like coccinelle, smatch and sparse, and fix reported warnings. Also please check for warnings when building with W=1 for gcc and clang. Most of these commands (checks or W=1 build) can build specific targets, like some directory, to narrow the scope to only your code. The code here looks like it needs a fix. Feel free to get in touch if the warning is not clear.
Really appreciate the instructions, will set up what you suggested and address the warnings. Suppose it can catch the issues you mentioned above.
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4.c line 115
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME );You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries orMODULE_DEVICE_TABLE()).MODULE_ALIAS()is not a substitute for incomplete ID table.
Thanks for the clarification, yes, MODULE_ALIAS() does not apply in our case and should be removed.
Quoted 3 lines
Best regards,
Krzysztof
Signature · 2 lines
Regards, Bin
Re: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
Quoted 13 lines · Bin
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4.c line 115
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME );You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries orMODULE_DEVICE_TABLE()).MODULE_ALIAS()is not a substitute for incomplete ID table.
Quoted 2 lines
Thanks for the clarification, yes,
MODULE_ALIAS()does not apply in our case and should be removed.
You don't have ID table, so probably this should be fixed, unless it is instantiated by some other driver, e.g. as MFD. That's the only typical use case for alias in the drivers.
Best regards,
Krzysztof
Du, Bin
maintainerRe: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
Thanks Krzysztof.
Quoted 14 lines · Krzysztof Kozlowski
Quoted 13 lines · Bin
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4.c line 115
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME );You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries orMODULE_DEVICE_TABLE()).MODULE_ALIAS()is not a substitute for incomplete ID table.
Quoted 8 lines
Quoted 2 lines
Thanks for the clarification, yes,
MODULE_ALIAS()does not apply in our case and should be removed.You don't have ID table, so probably this should be fixed, unless it is instantiated by some other driver, e.g. as MFD. That's the only typical use case for alias in the drivers.
Yes, our device is a MFD, so alias works for it, as alternative, we can add module device table, it should work either, could you please indicate your preferred option?
Quoted 2 lines
Best regards,
Krzysztof
Signature · 2 lines
Regards, Bin
Re: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
Quoted 21 lines · Bin
Thanks Krzysztof.
Quoted 18 lines · Krzysztof Kozlowski
Quoted 15 lines · Bin
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4.c line 115
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME );You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries orMODULE_DEVICE_TABLE()).MODULE_ALIAS()is not a substitute for incomplete ID table.Thanks for the clarification, yes,
MODULE_ALIAS()does not apply in our case and should be removed.
Quoted 9 lines
Quoted 4 lines
You don't have ID table, so probably this should be fixed, unless it is instantiated by some other driver, e.g. as MFD. That's the only typical use case for alias in the drivers.
Yes, our device is a MFD, so alias works for it, as alternative, we can add module device table, it should work either, could you please indicate your preferred option?
So it is spawned by drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.c or drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c ?
If so, then your code is fine, that's correct use of MODULE_ALIAS.
Best regards,
Krzysztof
Du, Bin
maintainerRe: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
Quoted 27 lines · Krzysztof Kozlowski
Quoted 26 lines · Bin
Thanks Krzysztof.
Quoted 22 lines · Krzysztof Kozlowski
Quoted 13 lines · Bin
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4.c line 115
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME );You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries orMODULE_DEVICE_TABLE()).MODULE_ALIAS()is not a substitute for incomplete ID table.Quoted 2 lines
Thanks for the clarification, yes,
MODULE_ALIAS()does not apply in our case and should be removed.You don't have ID table, so probably this should be fixed, unless it is instantiated by some other driver, e.g. as MFD. That's the only typical use case for alias in the drivers.
Quoted 9 lines
Quoted 4 lines
Yes, our device is a MFD, so alias works for it, as alternative, we can add module device table, it should work either, could you please indicate your preferred option?
So it is spawned by
drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.cordrivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c?
yes, it's spawned by drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c
Quoted 2 lines
If so, then your code is fine, that's correct use of
MODULE_ALIAS.
Thanks for the quick confirmation, so, we'll keep it.
Quoted 2 lines
Best regards,
Krzysztof
Signature · 2 lines
Regards, Bin
Du, Bin
maintainerRe: [PATCH v5 1/7] media: platform: amd: Introduce amd isp4 capture driver
Hi Krzysztof,
We’ve set up the clang build and kernel static analysis tools and found additional warnings aside from those you noted. We will resolve these issues and submit version 6, including fixes for other version 5 review comments, by end of this week. Many thanks.
Quoted 50 lines · Bin
Quoted 27 lines · Krzysztof Kozlowski
Quoted 26 lines · Bin
Thanks Krzysztof.
Quoted 22 lines · Krzysztof Kozlowski
Quoted 13 lines · Bin
Quoted 12 lines
Review
Quoted 6 lines
+ }
(quoted diff) +5
-0+}; + +module_platform_driver(isp4_capture_drv); + +MODULE_ALIAS("platform:" ISP4_DRV_NAME);You should not need
MODULE_ALIAS()in normal cases. If you need it, usually it means your device ID table is wrong (e.g. misses either entries orMODULE_DEVICE_TABLE()).MODULE_ALIAS()is not a substitute for incomplete ID table.Quoted 2 lines
Thanks for the clarification, yes,
MODULE_ALIAS()does not apply in our case and should be removed.You don't have ID table, so probably this should be fixed, unless it is instantiated by some other driver, e.g. as MFD. That's the only typical use case for alias in the drivers.
Quoted 9 lines
Quoted 4 lines
Yes, our device is a MFD, so alias works for it, as alternative, we can add module device table, it should work either, could you please indicate your preferred option?
So it is spawned by
drivers/gpu/drm/amd/amdgpu/isp_v4_1_0.cordrivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c?yes, it's spawned by
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.cQuoted 2 lines
If so, then your code is fine, that's correct use of
MODULE_ALIAS.Thanks for the quick confirmation, so, we'll keep it.
Quoted 2 lines
Best regards,
Krzysztof
Signature · 2 lines
Regards, Bin
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't protecting the list_del() anymore. I also checked the compiler output when using guard() versus scoped_guard() in that function and there is no difference:
sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()
So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using disable_irq_nosync() to disable the IRQ from the CPU's side.
2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?
3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Sultan
From 83fd6cffdc34204495044c28f384488c3a8ae08b Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <[email protected]>
Date: Wed, 5 Nov 2025 00:57:55 -0800
Subject: [PATCH] amd isp4 v5 fixes round 1
--- drivers/media/platform/amd/isp4/isp4.c | 5 +- drivers/media/platform/amd/isp4/isp4_debug.c | 6 +- .../media/platform/amd/isp4/isp4_interface.c | 33 ++-- .../media/platform/amd/isp4/isp4_interface.h | 6 +- drivers/media/platform/amd/isp4/isp4_subdev.c | 168 +++++++----------- drivers/media/platform/amd/isp4/isp4_video.c | 26 +-- drivers/media/platform/amd/isp4/isp4_video.h | 23 +-- 7 files changed, 96 insertions(+), 171 deletions(-)
drivers/media/platform/amd/isp4/isp4.c +2 -3
@@ -115,9 +115,8 @@ static int isp4_capture_probe(struct platform_device *pdev)return dev_err_probe (dev, irq[i],"fail to get irq %d\n" , isp4_ringbuf_interrupt_num[i]); -irq_set_status_flags (irq[i],IRQ_NOAUTOEN ); - ret =devm_request_irq (dev, irq[i], isp4_irq_handler,0 , isp4_irq_name[i], - isp_dev); + ret =devm_request_irq (dev, irq[i], isp4_irq_handler, +IRQF_NO_AUTOEN , isp4_irq_name[i], isp_dev);if (ret)return dev_err_probe (dev, ret,"fail to req irq %d\n" , irq[i]); }
drivers/media/platform/amd/isp4/isp4_debug.c +3 -3
@@ -56,11 +56,11 @@ static u32 isp_fw_fill_rb_log(struct isp4_subdev *isp, u8 *sys, u32 rb_size)else if (wr_ptr < rd_ptr) cnt = rb_size - rd_ptr;else - goto unlock_and_quit; + goto quit;if (cnt > rb_size) {dev_err (dev,"fail bad fw log size %u\n" , cnt); - goto unlock_and_quit; + goto quit; }memcpy (buf + offset, (u8 *)(sys + rd_ptr), cnt);
@@ -72,7 +72,7 @@ static u32 isp_fw_fill_rb_log(struct isp4_subdev *isp, u8 *sys, u32 rb_size)isp4hw_wreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_RPTR0 , rd_ptr); -unlock_and_quit: +quit:return total_cnt; }
drivers/media/platform/amd/isp4/isp4_interface.c +16 -17
@@ -16,6 +16,8 @@ ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK | \ ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK) +#define ISP4IF_FW_CMD_TIMEOUT (HZ / 2) +struct isp4if_rb_config {const char *name;u32 index;
@@ -281,10 +283,9 @@ struct isp4if_cmd_element *isp4if_rm_cmd_from_cmdq(struct isp4_interface *ispif, u32 cmd_id) {struct isp4if_cmd_element *buf_node; -struct isp4if_cmd_element *tmp_node; scoped_guard(spinlock, &ispif->cmdq_lock) -list_for_each_entry_safe (buf_node, tmp_node, &ispif->cmdq, list) { +list_for_each_entry (buf_node, &ispif->cmdq, list) {if (buf_node->seq_num == seq_num && buf_node->cmd_id == cmd_id) {list_del (&buf_node->list);
@@ -372,14 +373,14 @@ static inline enum isp4if_stream_id isp4if_get_fw_stream(u32 cmd_id)return ISP4IF_STREAM_ID_1 ; } -static int isp4if_send_fw_cmd (struct isp4_interface *ispif,u32 cmd_id,void *package, +static int isp4if_send_fw_cmd (struct isp4_interface *ispif,u32 cmd_id,const void *package,u32 package_size,struct completion *cmd_complete,u32 *seq) {enum isp4if_stream_id stream =isp4if_get_fw_stream (cmd_id);struct isp4if_cmd_element *cmd_ele =NULL ;struct isp4if_rb_config *rb_config;struct device *dev = ispif->dev; -struct isp4fw_cmd cmd = {}; +struct isp4fw_cmd cmd;u32 seq_num;u32 rreg;u32 wreg;
@@ -393,7 +394,7 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id, void *pa/* * The struct will be shared with ISP FW, use memset() to guarantee padding bits are -* zeroed, since this may not guarantee on all compilers. +* zeroed, since this is not guaranteed on all compilers. */ memset (&cmd,0 ,sizeof (cmd)); rb_config = &isp4if_resp_rb_config[stream];
@@ -477,7 +478,7 @@ static int isp4if_send_buffer(struct isp4_interface *ispif, struct isp4if_img_bu/* * The struct will be shared with ISP FW, use memset() to guarantee padding bits are -* zeroed, since this may not guarantee on all compilers. +* zeroed, since this is not guaranteed on all compilers. */ memset (&cmd,0 ,sizeof (cmd)); cmd.buffer_type =BUFFER_TYPE_PREVIEW ;
@@ -778,13 +779,13 @@ int isp4if_f2h_resp(struct isp4_interface *ispif, enum isp4if_stream_id stream,return 0 ; } -int isp4if_send_command (struct isp4_interface *ispif,u32 cmd_id,void *package,u32 package_size) +int isp4if_send_command (struct isp4_interface *ispif,u32 cmd_id,const void *package,u32 package_size) {return isp4if_send_fw_cmd (ispif, cmd_id, package, package_size,NULL ,NULL ); } -int isp4if_send_command_sync (struct isp4_interface *ispif,u32 cmd_id,void *package, -u32 package_size,u32 timeout) +int isp4if_send_command_sync (struct isp4_interface *ispif,u32 cmd_id,const void *package, +u32 package_size) {DECLARE_COMPLETION_ONSTACK (cmd_completion);struct device *dev = ispif->dev;
@@ -798,12 +799,9 @@ int isp4if_send_command_sync(struct isp4_interface *ispif, u32 cmd_id, void *pacreturn ret; } - ret =wait_for_completion_timeout (&cmd_completion,msecs_to_jiffies (timeout)); -if (ret ==0 ) { -struct isp4if_cmd_element *ele; - - ele =isp4if_rm_cmd_from_cmdq (ispif, seq, cmd_id); -kfree (ele); + ret =wait_for_completion_timeout (&cmd_completion,ISP4IF_FW_CMD_TIMEOUT ); +if (!ret) { +kfree (isp4if_rm_cmd_from_cmdq (ispif, seq, cmd_id));return -ETIMEDOUT ; }
@@ -842,8 +840,9 @@ struct isp4if_img_buf_node *isp4if_dequeue_buffer(struct isp4_interface *ispif) {struct isp4if_img_buf_node *buf_node; -scoped_guard (spinlock, &ispif->bufq_lock) - buf_node = list_first_entry_or_null(&ispif->bufq, typeof(*buf_node), node); +guard (spinlock)(&ispif->bufq_lock); + + buf_node =list_first_entry_or_null (&ispif->bufq,typeof (*buf_node), node);if (buf_node)list_del (&buf_node->node);
drivers/media/platform/amd/isp4/isp4_interface.h +3 -3
@@ -115,11 +115,11 @@ static inline u64 isp4if_join_addr64(u32 lo, u32 hi)int isp4if_f2h_resp (struct isp4_interface *ispif,enum isp4if_stream_id stream,void *response); -int isp4if_send_command (struct isp4_interface *ispif,u32 cmd_id,void *package, +int isp4if_send_command (struct isp4_interface *ispif,u32 cmd_id,const void *package,u32 package_size); -int isp4if_send_command_sync (struct isp4_interface *ispif,u32 cmd_id,void *package, -u32 package_size,u32 timeout); +int isp4if_send_command_sync (struct isp4_interface *ispif,u32 cmd_id,const void *package, +u32 package_size);struct isp4if_cmd_element *isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif,u32 seq_num,u32 cmd_id);
drivers/media/platform/amd/isp4/isp4_subdev.c +67 -101
317 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_video.c +3 -23
@@ -60,12 +60,10 @@ static const struct v4l2_fract isp4vid_tpfs[] = { { 1, ISP4VID_MAX_PREVIEW_FPS } }; -static void isp4vid_handle_frame_done (struct isp4vid_dev *isp_vdev, -const struct isp4if_img_buf_info *img_buf, -bool done_suc) +void isp4vid_handle_frame_done (struct isp4vid_dev *isp_vdev, +const struct isp4if_img_buf_info *img_buf) {struct isp4vid_capture_buffer *isp4vid_buf; -enum vb2_buffer_state state;void *vbuf; scoped_guard(mutex, &isp_vdev->buf_list_lock) {
@@ -95,30 +93,12 @@ static void isp4vid_handle_frame_done(struct isp4vid_dev *isp_vdev,vb2_set_plane_payload (&isp4vid_buf->vb2.vb2_buf,0 , isp_vdev->format.sizeimage); - state = done_suc ?VB2_BUF_STATE_DONE :VB2_BUF_STATE_ERROR ; -vb2_buffer_done (&isp4vid_buf->vb2.vb2_buf, state); +vb2_buffer_done (&isp4vid_buf->vb2.vb2_buf,VB2_BUF_STATE_DONE );dev_dbg (isp_vdev->dev,"call vb2_buffer_done(size=%u)\n" , isp_vdev->format.sizeimage); } -s32 isp4vid_notify (void *cb_ctx,struct isp4vid_framedone_param *evt_param) -{ -struct isp4vid_dev *isp4vid_vdev = cb_ctx; - -if (evt_param->preview.status !=ISP4VID_BUF_DONE_STATUS_ABSENT ) { -bool suc; - - suc = (evt_param->preview.status == -ISP4VID_BUF_DONE_STATUS_SUCCESS ); -isp4vid_handle_frame_done (isp4vid_vdev, - &evt_param->preview.buf, - suc); - } - -return 0 ; -} -static unsigned int isp4vid_vb2_num_users (void *buf_priv) {struct isp4vid_vb2_buf *buf = buf_priv;
drivers/media/platform/amd/isp4/isp4_video.h +2 -21
@@ -11,26 +11,6 @@#include "isp4_interface.h" -enum isp4vid_buf_done_status { -/* It means no corresponding image buf in fw response */ -ISP4VID_BUF_DONE_STATUS_ABSENT , -ISP4VID_BUF_DONE_STATUS_SUCCESS , -ISP4VID_BUF_DONE_STATUS_FAILED -}; - -struct isp4vid_buf_done_info { -enum isp4vid_buf_done_status status; -struct isp4if_img_buf_info buf; -}; - -/* call back parameter for CB_EVT_ID_FRAME_DONE */ -struct isp4vid_framedone_param { -s32 poc; -s32 cam_id; -s64 time_stamp; -struct isp4vid_buf_done_info preview; -}; -struct isp4vid_capture_buffer {/* * struct vb2_v4l2_buffer must be the first element
@@ -79,6 +59,7 @@ int isp4vid_dev_init(struct isp4vid_dev *isp_vdev,void isp4vid_dev_deinit (struct isp4vid_dev *isp_vdev); -s32 isp4vid_notify (void *cb_ctx,struct isp4vid_framedone_param *evt_param); +void isp4vid_handle_frame_done (struct isp4vid_dev *isp_vdev, +const struct isp4if_img_buf_info *img_buf);#endif /* _ISP4_VIDEO_H_ */
Signature · 1 line
2.51.2
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8isp4_interface.o //guard()5652a0306da22ea741d80a9e03a787d0f71758a8isp4_interface.o //scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?
Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Thanks,
Sultan
From 482166e2ac974e4e27f190237accba397bb99652 Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <[email protected]>
Date: Mon, 10 Nov 2025 00:22:51 -0800
Subject: [PATCH] media: platform: amd: Big squash of fixes/cleanup on top of
v5 patchset
-Rewrote IRQ handling to disable/enable interrupts using ISP register since
it is faster
-Rewrote ringbuffer handling in isp4if_f2h_resp(), fixing the safety checks
to check the read pointer before doing memcpy possibly out-of-bounds on the ringbuffer. Also simplified the ringbuffer logic a lot.
-Fixed a regression in v4 -> v5 where isp4if_dequeue_buffer() didn't
protect the list_del with bufq_lock
-Fixed a subtle use-after-free possibility when the timeout is hit on a
sync command at the same time the command finishes, existed since v1
-Added missing pm_runtime_disable() to isp4_capture_remove() and to
isp4_capture_probe() error path
-Cleaned up all remaining stray semicolons after curly close braces -Added missing memset for FW command struct in isp4sd_stop_stream() -Removed streams 2 and 3 from ISP4IF_FW_RESP_RB_IRQ_EN_MASK so they don't
get enabled in the interrupt enable register
-Added error handling to cleanup kthreads when there is a failure in
starting a kthread
-Fixed a race on kthread creation where it is possible the waitqueue head
isn't initialized by the time it is used in the IRQ handler, because the kthread was responsible for initializing the waitqueue head
-Removed an always false status check in isp4sd_pwroff_and_deinit() -Fixed isp4sd_init_stream() getting called in isp4sd_start_stream() even
after a stream is started, and reordered all of those status checks to come before isp4sd_init_stream()
-Fixed error handling in isp4sd_start_stream() to return the received
error from a function that failed
-Moved dbg message in isp4sd_stop_stream() to go under the lock because it
reads output_info->start_status
-Removed the GET_*_REG_BASE() macros, unnecessary and redundant -Fixed incorrect err message in isp4sd_init_stream() due to copy/paste
error
-Lots of dead code cleanup and small code style cleanups throughout
--- drivers/media/platform/amd/isp4/isp4.c | 155 ++++--- drivers/media/platform/amd/isp4/isp4.h | 2 + drivers/media/platform/amd/isp4/isp4_debug.c | 18 +- .../media/platform/amd/isp4/isp4_interface.c | 347 ++++++---------- .../media/platform/amd/isp4/isp4_interface.h | 19 +- drivers/media/platform/amd/isp4/isp4_subdev.c | 386 +++++++----------- drivers/media/platform/amd/isp4/isp4_subdev.h | 5 +- drivers/media/platform/amd/isp4/isp4_video.c | 47 +-- drivers/media/platform/amd/isp4/isp4_video.h | 23 +- 9 files changed, 418 insertions(+), 584 deletions(-)
drivers/media/platform/amd/isp4/isp4.c +90 -65
@@ -18,72 +18,95 @@ (ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK | \ ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK) -const char *isp4_irq_name[] = { -"isp_irq_global" , -"isp_irq_stream1" +static const struct { +const char *name; +u32 status_mask; +u32 en_mask; +u32 ack_mask; +u32 rb_int_num; +} isp4_irq[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { +/* The IRQ order is aligned with the isp4_subdev.fw_resp_thread order */ + { + .name ="isp_irq_global" , + .status_mask =ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK , + .en_mask =ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK , + .ack_mask =ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK , + .rb_int_num =4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ + }, + { + .name ="isp_irq_stream1" , + .status_mask =ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK , + .en_mask =ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK , + .ack_mask =ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK , + .rb_int_num =0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ + }, }; -const u32 isp4_irq_status_mask[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { -/* global response */ -ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK , -/* stream 1 response */ -ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK -}; - -const u32 isp4_irq_ack_mask[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { -/* global ack */ -ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK , -/* stream 1 ack */ -ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK -}; - -/* irq num, the irq order is aligend with the isp4_subdev.fw_resp_thread order */ -static const u32 isp4_ringbuf_interrupt_num[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { -4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ -0 /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ -}; - -static void isp4_wake_up_resp_thread (struct isp4_subdev *isp_subdev,u32 index) +void isp4_intr_enable (struct isp4_subdev *isp_subdev,u32 index,bool enable) { -if (isp_subdev && index <ISP4SD_MAX_FW_RESP_STREAM_NUM ) { -struct isp4sd_thread_handler *thread_ctx = &isp_subdev->fw_resp_thread[index]; - - thread_ctx->wq_cond =1 ; -wake_up_interruptible (&thread_ctx->waitq); - } +u32 intr_en; + +/* Synchronize ISP_SYS_INT0_EN writes with the IRQ handler's writes */ +spin_lock_irq (&isp_subdev->irq_lock); + intr_en =isp4hw_rreg (GET_ISP4IF_REG_BASE (isp_subdev),ISP_SYS_INT0_EN ); +if (enable) + intr_en |= isp4_irq[index].en_mask; +else + intr_en &= ~isp4_irq[index].en_mask; +isp4hw_wreg (isp_subdev->mmio,ISP_SYS_INT0_EN , intr_en); +spin_unlock_irq (&isp_subdev->irq_lock); } -static void isp4_resp_interrupt_notify (struct isp4_subdev *isp_subdev,u32 intr_status) +static void isp4_wake_up_resp_thread (struct isp4_subdev *isp_subdev,u32 index) { -u32 intr_ack =0 ; - -for (size_t i =0 ; i <ARRAY_SIZE (isp4_irq_status_mask); i++) { -if (intr_status & isp4_irq_status_mask[i]) { -disable_irq_nosync (isp_subdev->irq[i]); -isp4_wake_up_resp_thread (isp_subdev, i); - - intr_ack |= isp4_irq_ack_mask[i]; - } - } +struct isp4sd_thread_handler *thread_ctx = &isp_subdev->fw_resp_thread[index]; -/* clear ISP_SYS interrupts */ -isp4hw_wreg (ISP4_GET_ISP_REG_BASE (isp_subdev),ISP_SYS_INT0_ACK , intr_ack); + thread_ctx->resp_ready = true; +wake_up_interruptible (&thread_ctx->waitq); }static irqreturn_t isp4_irq_handler (int irq,void *arg) { -struct isp4_device *isp_dev = arg; -struct isp4_subdev *isp_subdev; -u32 isp_sys_irq_status; -u32 r1; - - isp_subdev = &isp_dev->isp_subdev; -/* check ISP_SYS interrupts status */ - r1 =isp4hw_rreg (ISP4_GET_ISP_REG_BASE (isp_subdev),ISP_SYS_INT0_STATUS ); - - isp_sys_irq_status = r1 &ISP4_FW_RESP_RB_IRQ_STATUS_MASK ; +struct isp4_subdev *isp_subdev = arg; +u32 intr_ack =0 , intr_en, intr_status; +int seen =0 ; + +/* Get the ISP_SYS interrupt status */ + intr_status =isp4hw_rreg (isp_subdev->mmio,ISP_SYS_INT0_STATUS ); + intr_status &=ISP4_FW_RESP_RB_IRQ_STATUS_MASK ; + +/* Synchronize ISP_SYS_INT0_EN r/w with isp4_enable_interrupt() */ +spin_lock (&isp_subdev->irq_lock); + intr_en =isp4hw_rreg (isp_subdev->mmio,ISP_SYS_INT0_EN ); + +/* Find which _enabled_ ISP_SYS interrupts fired */ +for (size_t i =0 ; i <ARRAY_SIZE (isp4_irq); i++) { +if ((intr_en & isp4_irq[i].en_mask) && + (intr_status & isp4_irq[i].status_mask)) { + intr_ack |= isp4_irq[i].ack_mask; + intr_en &= ~isp4_irq[i].en_mask; + seen |=BIT (i); + } + } -isp4_resp_interrupt_notify (isp_subdev, isp_sys_irq_status); +/* +* Disable the ISP_SYS interrupts that fired. Must be done before waking +* the response threads, since they re-enable interrupts when finished. +*/ +isp4hw_wreg (isp_subdev->mmio,ISP_SYS_INT0_EN , intr_en); +spin_unlock (&isp_subdev->irq_lock); + +/* +* Clear the ISP_SYS interrupts. This must be done _after_ the +* interrupts are disabled, so that ISP FW won't flag any new interrupts +* on these streams, and thus we don't need to clear interrupts again +* before re-enabling them. +*/ +isp4hw_wreg (isp_subdev->mmio,ISP_SYS_INT0_ACK , intr_ack); + +/* Wake up the response threads */ +for (int i; (i =ffs (seen)); seen = (seen >> i) << i) +isp4_wake_up_resp_thread (isp_subdev, i -1 );return IRQ_HANDLED ; }
@@ -109,15 +132,14 @@ static int isp4_capture_probe(struct platform_device *pdev)if (IS_ERR (isp_subdev->mmio))return dev_err_probe (dev,PTR_ERR (isp_subdev->mmio),"isp ioremap fail\n" ); -for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { - irq[i] =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +for (i =0 ; i <ARRAY_SIZE (isp4_irq); i++) { + irq[i] =platform_get_irq (pdev, isp4_irq[i].rb_int_num);if (irq[i] <0 )return dev_err_probe (dev, irq[i],"fail to get irq %d\n" , - isp4_ringbuf_interrupt_num[i]); + isp4_irq[i].rb_int_num); -irq_set_status_flags (irq[i],IRQ_NOAUTOEN ); - ret =devm_request_irq (dev, irq[i], isp4_irq_handler,0 , isp4_irq_name[i], - isp_dev); + ret =devm_request_irq (dev, irq[i], isp4_irq_handler, +IRQF_NO_AUTOEN , isp4_irq[i].name, isp_subdev);if (ret)return dev_err_probe (dev, ret,"fail to req irq %d\n" , irq[i]); }
@@ -132,8 +154,6 @@ static int isp4_capture_probe(struct platform_device *pdev) isp_dev->mdev.dev = dev;media_device_init (&isp_dev->mdev); -pm_runtime_set_suspended (dev); -pm_runtime_enable (dev);/* register v4l2 device */ snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name),"AMD-V4L2-ROOT" );
@@ -141,10 +161,13 @@ static int isp4_capture_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"fail register v4l2 device\n" ); +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev); +spin_lock_init (&isp_subdev->irq_lock); ret =isp4sd_init (&isp_dev->isp_subdev, &isp_dev->v4l2_dev, irq);if (ret) {dev_err (dev,"fail init isp4 sub dev %d\n" , ret); - goto err_unreg_v4l2; + goto err_pm_disable; } ret = media_create_pad_link(&isp_dev->isp_subdev.sdev.entity,
@@ -170,16 +193,17 @@ static int isp4_capture_probe(struct platform_device *pdev) err_isp4_deinit:isp4sd_deinit (&isp_dev->isp_subdev); -err_unreg_v4l2: +err_pm_disable: +pm_runtime_disable (dev);v4l2_device_unregister (&isp_dev->v4l2_dev);media_device_cleanup (&isp_dev->mdev); -return dev_err_probe (dev, ret,"isp probe fail\n" ); }static void isp4_capture_remove (struct platform_device *pdev) {struct isp4_device *isp_dev =platform_get_drvdata (pdev); +struct device *dev = &pdev->dev;isp_debugfs_remove (isp_dev);
@@ -187,6 +211,7 @@ static void isp4_capture_remove(struct platform_device *pdev)isp4sd_deinit (&isp_dev->isp_subdev);v4l2_device_unregister (&isp_dev->v4l2_dev);media_device_cleanup (&isp_dev->mdev); +pm_runtime_disable (dev); }static struct platform_driver isp4_capture_drv = {
drivers/media/platform/amd/isp4/isp4.h +2 -0
@@ -18,4 +18,6 @@ struct isp4_device { struct platform_device *pdev; }; +void isp4_intr_enable (struct isp4_subdev *isp_subdev,u32 index,bool enable); +#endif /* _ISP4_H_ */
drivers/media/platform/amd/isp4/isp4_debug.c +9 -9
@@ -47,8 +47,8 @@ static u32 isp_fw_fill_rb_log(struct isp4_subdev *isp, u8 *sys, u32 rb_size)guard (mutex)(&ispif->isp4if_mutex); - rd_ptr =isp4hw_rreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_RPTR0 ); - wr_ptr =isp4hw_rreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_WPTR0 ); + rd_ptr =isp4hw_rreg (isp->mmio,ISP_LOG_RB_RPTR0 ); + wr_ptr =isp4hw_rreg (isp->mmio,ISP_LOG_RB_WPTR0 ); do { if (wr_ptr > rd_ptr)
@@ -56,11 +56,11 @@ static u32 isp_fw_fill_rb_log(struct isp4_subdev *isp, u8 *sys, u32 rb_size)else if (wr_ptr < rd_ptr) cnt = rb_size - rd_ptr;else - goto unlock_and_quit; + goto quit;if (cnt > rb_size) {dev_err (dev,"fail bad fw log size %u\n" , cnt); - goto unlock_and_quit; + goto quit; }memcpy (buf + offset, (u8 *)(sys + rd_ptr), cnt);
@@ -70,9 +70,9 @@ static u32 isp_fw_fill_rb_log(struct isp4_subdev *isp, u8 *sys, u32 rb_size) rd_ptr = (rd_ptr + cnt) % rb_size; }while (rd_ptr < wr_ptr); -isp4hw_wreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_RPTR0 , rd_ptr); +isp4hw_wreg (isp->mmio,ISP_LOG_RB_RPTR0 , rd_ptr); -unlock_and_quit: +quit:return total_cnt; }
@@ -159,7 +159,7 @@ char *isp4dbg_get_buf_done_str(u32 status)default :return "Unknown Buf Done Status" ; } -}; +}char *isp4dbg_get_img_fmt_str (int fmt/* enum isp4fw_image_format * */ ) {
@@ -233,7 +233,7 @@ char *isp4dbg_get_cmd_str(u32 cmd)return ISP4DBG_MACRO_2_STR (CMD_ID_ENABLE_OUT_CHAN );default :return "unknown cmd" ; - }; + } }char *isp4dbg_get_resp_str (u32 cmd)
@@ -245,7 +245,7 @@ char *isp4dbg_get_resp_str(u32 cmd)return ISP4DBG_MACRO_2_STR (RESP_ID_NOTI_FRAME_DONE );default :return "unknown respid" ; - }; + } }char *isp4dbg_get_if_stream_str (u32 stream/* enum fw_cmd_resp_stream_id */ )
drivers/media/platform/amd/isp4/isp4_interface.c +134 -213
522 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.h +10 -9
@@ -48,10 +48,10 @@ enum isp4if_status { };struct isp4if_gpu_mem_info { -u64 mem_size; -u64 gpu_mc_addr; -void *sys_addr; -void *mem_handle; +u64 mem_size; +u64 gpu_mc_addr; +void *sys_addr; +void *mem_handle; };struct isp4if_img_buf_info {
@@ -71,7 +71,8 @@ struct isp4if_cmd_element {struct list_head list;u32 seq_num;u32 cmd_id; -struct completion *cmd_complete; +struct completion cmd_done; +atomic_t refcnt; };struct isp4_interface {
@@ -113,13 +114,13 @@ static inline u64 isp4if_join_addr64(u32 lo, u32 hi)return (((u64 )hi) <<32 ) | (u64 )lo; } -int isp4if_f2h_resp (struct isp4_interface *ispif,enum isp4if_stream_id stream,void *response); +int isp4if_f2h_resp (struct isp4_interface *ispif,enum isp4if_stream_id stream,void *resp); -int isp4if_send_command (struct isp4_interface *ispif,u32 cmd_id,void *package, +int isp4if_send_command (struct isp4_interface *ispif,u32 cmd_id,const void *package,u32 package_size); -int isp4if_send_command_sync (struct isp4_interface *ispif,u32 cmd_id,void *package, -u32 package_size,u32 timeout); +int isp4if_send_command_sync (struct isp4_interface *ispif,u32 cmd_id,const void *package, +u32 package_size);struct isp4if_cmd_element *isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif,u32 seq_num,u32 cmd_id);
drivers/media/platform/amd/isp4/isp4_subdev.c +155 -231
732 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_subdev.h +3 -2
@@ -46,7 +46,7 @@ enum isp4sd_status {/* used to indicate the status of sensor, output stream */ enum isp4sd_start_status { -ISP4SD_START_STATUS_NOT_START , +ISP4SD_START_STATUS_OFF ,ISP4SD_START_STATUS_STARTED ,ISP4SD_START_STATUS_START_FAIL , };
@@ -83,7 +83,7 @@ struct isp4sd_sensor_info {struct isp4sd_thread_handler {struct task_struct *thread;wait_queue_head_t waitq; -int wq_cond; +bool resp_ready; };struct isp4_subdev_thread_param {
@@ -114,6 +114,7 @@ struct isp4_subdev {void __iomem *mmio;struct isp4_subdev_thread_param isp_resp_para[ISP4SD_MAX_FW_RESP_STREAM_NUM ];int irq[ISP4SD_MAX_FW_RESP_STREAM_NUM ]; +spinlock_t irq_lock;#ifdef CONFIG_DEBUG_FS struct dentry *debugfs_dir;bool enable_fw_log;
drivers/media/platform/amd/isp4/isp4_video.c +13 -34
106 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_video.h +2 -21
@@ -11,26 +11,6 @@#include "isp4_interface.h" -enum isp4vid_buf_done_status { -/* It means no corresponding image buf in fw response */ -ISP4VID_BUF_DONE_STATUS_ABSENT , -ISP4VID_BUF_DONE_STATUS_SUCCESS , -ISP4VID_BUF_DONE_STATUS_FAILED -}; - -struct isp4vid_buf_done_info { -enum isp4vid_buf_done_status status; -struct isp4if_img_buf_info buf; -}; - -/* call back parameter for CB_EVT_ID_FRAME_DONE */ -struct isp4vid_framedone_param { -s32 poc; -s32 cam_id; -s64 time_stamp; -struct isp4vid_buf_done_info preview; -}; -struct isp4vid_capture_buffer {/* * struct vb2_v4l2_buffer must be the first element
@@ -79,6 +59,7 @@ int isp4vid_dev_init(struct isp4vid_dev *isp_vdev,void isp4vid_dev_deinit (struct isp4vid_dev *isp_vdev); -s32 isp4vid_notify (void *cb_ctx,struct isp4vid_framedone_param *evt_param); +void isp4vid_handle_frame_done (struct isp4vid_dev *isp_vdev, +const struct isp4if_img_buf_info *img_buf);#endif /* _ISP4_VIDEO_H_ */
Signature · 1 line
2.51.2
Du, Bin
maintainerThank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 8 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Quoted 2 lines
Thanks,
Sultan
Signature · 2 lines
Regards, Bin
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)
Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)
When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
I will try to identify the cause this week.
Sultan
Du, Bin
maintainerQuoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +0 -0
@@ -97,7 +97,7 @@
#define ADDR_SPACE_TYPE_GPU_VA 4
-#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024)
+#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)
/*
* standard ISP mipicsi=>isp
drivers/media/platform/amd/isp4/isp4_subdev.c +0 -0
@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ;
}
-static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev, bool irq_enabled)
{
struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;
@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)
return 0;
}- for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
- disable_irq(isp_subdev->irq[i]);
+ if (irq_enabled)
+ for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
+ disable_irq(isp_subdev->irq[i]);
isp4sd_stop_resp_proc_threads(isp_subdev);
dev_dbg(dev, "isp_subdev stop resp proc streads suc");@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)
return 0;
err_unlock_and_close:
- isp4sd_pwroff_and_deinit(isp_subdev);
+ isp4sd_pwroff_and_deinit(isp_subdev, false);
return -EINVAL;
}@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)
if (on)
return isp4sd_pwron_and_init(isp_subdev);
else- return isp4sd_pwroff_and_deinit(isp_subdev);
+ return isp4sd_pwroff_and_deinit(isp_subdev, true);
}
static const struct v4l2_subdev_core_ops isp4sd_core_ops = {
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in isp_kernel_buffer_alloc() which you mentioned in another thread.
Quoted 3 lines
I will try to identify the cause this week.
Sultan
Signature · 2 lines
Regards, Bin
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }
Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {
No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1 -1
@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp
drivers/media/platform/amd/isp4/isp4_subdev.c +6 -5
@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;
@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );
@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }
@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {
Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.
Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading amd_capture with the v4 driver doesn't recover the ISP when this happens.
As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Thanks,
Sultan
Quoted 230 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 3 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.
Quoted 7 lines
As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Thanks,
Sultan
A small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Sultan
Du, Bin
maintainerThanks Sultan for your information.
Quoted 231 lines · Sultan Alsawaf
Quoted 230 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 3 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.
Quoted 5 lines
Quoted 5 lines
As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Quoted 12 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
Quoted 1 line
Sultan
Signature · 2 lines
Regards, Bin
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 222 lines · Sultan Alsawaf
Quoted 221 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.Quoted 5 lines
Quoted 5 lines
As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload amd_capture. Or maybe it is the sensor that is stuck in a broken state?
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e
Author: Pratap Nirujogi <[email protected]>
Date: Thu Aug 21 15:40:45 2025 -0400
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6
Sultan
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?
Here is the log output when I try to start cheese after unloading and reloading amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):
==> opened cheese
==> cheese froze after a few seconds
==> closed cheese
[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit
a89515d3ff79f12099f7a51b0f4932b881b7720e
Author: Pratap Nirujogi <[email protected]>
Date: Thu Aug 21 15:40:45 2025 -0400
Quoted 8 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Du, Bin
maintainerQuoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info
Quoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22
Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 29 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit
a89515d3ff79f12099f7a51b0f4932b881b7720e
Author: Pratap Nirujogi <[email protected]>
Date: Thu Aug 21 15:40:45 2025 -0400Quoted 8 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, Bin
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400
Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, Bin
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let rd_ptr == wr_ptr upon filling the ringbuffer, even though rd_ptr == wr_ptr is supposed to indicate the ringbuffer is empty.
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change ISP_SYS_INT0_ACK behavior so that it also clears the acked interrupts from ISP_SYS_INT0_EN.
2. Change ISP_SYS_INT0_EN behavior so that it only enables the interrupts in the provided mask, so RMW of ISP_SYS_INT0_EN in the driver won't be necessary to re-enable interrupts for a stream.
Sultan
From f17548068518afdbe4cd3aea2631ffd9c0cea206 Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <[email protected]>
Date: Mon, 17 Nov 2025 23:15:57 -0800
Subject: [PATCH v2] media: platform: amd: Big squash of fixes/cleanup on top
of v5 patchset
-Rewrote IRQ handling to disable/enable interrupts using ISP register since
it is faster
-Rewrote ringbuffer handling in isp4if_f2h_resp(), fixing the safety checks
to check the read pointer before doing memcpy possibly out-of-bounds on the ringbuffer. Also simplified the ringbuffer logic a lot.
-Rewrote ringbuffer handling in isp4if_is_cmdq_rb_full(), fixing an
off-by-one in the safety checks that could let rd_ptr == wr_ptr when the ringbuf is full
-Rewrote ringbuffer handling in isp4if_insert_isp_fw_cmd(), simplifying it
a lot
-Fixed a regression in v4 -> v5 where isp4if_dequeue_buffer() didn't
protect the list_del with bufq_lock
-Fixed a subtle use-after-free possibility when the timeout is hit on a
sync command at the same time the command finishes, existed since v1
-Added missing pm_runtime_disable() to isp4_capture_remove() and to
isp4_capture_probe() error path
-Cleaned up all remaining stray semicolons after curly close braces -Cleaned up and improved macro definitions in isp4_interface.h -Removed needless (u8 *) casts
-Added missing memset for FW command struct in isp4sd_stop_stream() -Removed streams 2 and 3 from ISP4IF_FW_RESP_RB_IRQ_EN_MASK so they don't
get enabled in the interrupt enable register
-Added error handling to cleanup kthreads when there is a failure in
starting a kthread
-Fixed a race on kthread creation where it is possible the waitqueue head
isn't initialized by the time it is used in the IRQ handler, because the kthread was responsible for initializing the waitqueue head
-Removed an always false status check in isp4sd_pwroff_and_deinit() -Fixed isp4sd_init_stream() getting called in isp4sd_start_stream() even
after a stream is started, and reordered all of those status checks to come before isp4sd_init_stream()
-Fixed error handling in isp4sd_start_stream() to return the received
error from a function that failed
-Moved dbg message in isp4sd_stop_stream() to go under the lock because it
reads output_info->start_status
-Removed the GET_*_REG_BASE() macros, unnecessary and redundant -Removed isp4sd_is_stream_running()
-Fixed incorrect err message in isp4sd_init_stream() due to copy/paste
error
-Optimized struct isp4fw_buffer interface to turn the three buffers into an
array with a single u64 address instead of high/low u32 addresses
-Optimized struct isp4fw_resp_param_package to combine the pkg high/low
addresses into a single u64
-Optimized struct isp4_interface to remove FW ring buffer configs -Removed isp4sd_is_stream_running
-Removed isp4if_split_addr64() and isp4if_join_addr64(), no longer needed -Removed pdev member from struct isp4_device, unneeded -Corrected 'isp_mmip' parameter name typo in isp4if_init() -Eliminated a hole in struct isp4_subdev
-Lots of dead code cleanup and small code style cleanups throughout
---
v1 -> v2 changes:
-Rewrote ringbuffer handling in isp4if_is_cmdq_rb_full(), fixing an
off-by-one in the safety checks that could let rd_ptr == wr_ptr when the ringbuf is full
-Optimized struct isp4fw_buffer interface to turn the three buffers into an
array with a single u64 address instead of high/low u32 addresses
-Optimized struct isp4fw_resp_param_package to combine the pkg high/low
addresses into a single u64
-Optimized struct isp4_interface to remove FW ring buffer configs -Better IRQ handling, holds the irq lock for less time
-Removed isp4sd_is_stream_running()
-Corrected 'isp_mmip' parameter name typo in isp4if_init() -Rewrote ringbuffer handling in isp4if_insert_isp_fw_cmd(), simplifying it
a lot
-Cleaned up and improved macro definitions in isp4_interface.h -Removed needless (u8 *) casts
-Removed GET_ISP4IF_REG_BASE()
-Removed isp4if_split_addr64() and isp4if_join_addr64(), no longer needed -Removed pdev member from struct isp4_device, unneeded -Eliminated a hole in struct isp4_subdev
--- drivers/media/platform/amd/isp4/isp4.c | 154 ++--- drivers/media/platform/amd/isp4/isp4.h | 5 +- drivers/media/platform/amd/isp4/isp4_debug.c | 28 +- .../platform/amd/isp4/isp4_fw_cmd_resp.h | 18 +- .../media/platform/amd/isp4/isp4_interface.c | 534 +++++++----------- .../media/platform/amd/isp4/isp4_interface.h | 72 +-- drivers/media/platform/amd/isp4/isp4_subdev.c | 439 ++++++-------- drivers/media/platform/amd/isp4/isp4_subdev.h | 7 +- drivers/media/platform/amd/isp4/isp4_video.c | 49 +- drivers/media/platform/amd/isp4/isp4_video.h | 23 +- 10 files changed, 519 insertions(+), 810 deletions(-)
drivers/media/platform/amd/isp4/isp4.c +88 -66
@@ -18,72 +18,93 @@ (ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK | \ ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK) -const char *isp4_irq_name[] = { -"isp_irq_global" , -"isp_irq_stream1" +static const struct { +const char *name; +u32 status_mask; +u32 en_mask; +u32 ack_mask; +u32 rb_int_num; +} isp4_irq[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { +/* The IRQ order is aligned with the isp4_subdev.fw_resp_thread order */ + { + .name ="isp_irq_global" , + .status_mask =ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK , + .en_mask =ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK , + .ack_mask =ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK , + .rb_int_num =4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ + }, + { + .name ="isp_irq_stream1" , + .status_mask =ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK , + .en_mask =ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK , + .ack_mask =ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK , + .rb_int_num =0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ + }, }; -const u32 isp4_irq_status_mask[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { -/* global response */ -ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK , -/* stream 1 response */ -ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK -}; - -const u32 isp4_irq_ack_mask[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { -/* global ack */ -ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK , -/* stream 1 ack */ -ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK -}; - -/* irq num, the irq order is aligend with the isp4_subdev.fw_resp_thread order */ -static const u32 isp4_ringbuf_interrupt_num[ISP4SD_MAX_FW_RESP_STREAM_NUM ] = { -4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ -0 /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ -}; - -static void isp4_wake_up_resp_thread (struct isp4_subdev *isp_subdev,u32 index) +void isp4_intr_enable (struct isp4_subdev *isp_subdev,u32 index,bool enable) { -if (isp_subdev && index <ISP4SD_MAX_FW_RESP_STREAM_NUM ) { -struct isp4sd_thread_handler *thread_ctx = &isp_subdev->fw_resp_thread[index]; - - thread_ctx->wq_cond =1 ; -wake_up_interruptible (&thread_ctx->waitq); - } +u32 intr_en; + +/* Synchronize ISP_SYS_INT0_EN writes with the IRQ handler's writes */ +spin_lock_irq (&isp_subdev->irq_lock); + intr_en =isp4hw_rreg (isp_subdev->mmio,ISP_SYS_INT0_EN ); +if (enable) + intr_en |= isp4_irq[index].en_mask; +else + intr_en &= ~isp4_irq[index].en_mask; +isp4hw_wreg (isp_subdev->mmio,ISP_SYS_INT0_EN , intr_en); +spin_unlock_irq (&isp_subdev->irq_lock); } -static void isp4_resp_interrupt_notify (struct isp4_subdev *isp_subdev,u32 intr_status) +static void isp4_wake_up_resp_thread (struct isp4_subdev *isp_subdev,u32 index) { -u32 intr_ack =0 ; - -for (size_t i =0 ; i <ARRAY_SIZE (isp4_irq_status_mask); i++) { -if (intr_status & isp4_irq_status_mask[i]) { -disable_irq_nosync (isp_subdev->irq[i]); -isp4_wake_up_resp_thread (isp_subdev, i); - - intr_ack |= isp4_irq_ack_mask[i]; - } - } +struct isp4sd_thread_handler *thread_ctx = &isp_subdev->fw_resp_thread[index]; -/* clear ISP_SYS interrupts */ -isp4hw_wreg (ISP4_GET_ISP_REG_BASE (isp_subdev),ISP_SYS_INT0_ACK , intr_ack); + thread_ctx->resp_ready = true; +wake_up_interruptible (&thread_ctx->waitq); }static irqreturn_t isp4_irq_handler (int irq,void *arg) { -struct isp4_device *isp_dev = arg; -struct isp4_subdev *isp_subdev; -u32 isp_sys_irq_status; -u32 r1; - - isp_subdev = &isp_dev->isp_subdev; -/* check ISP_SYS interrupts status */ - r1 =isp4hw_rreg (ISP4_GET_ISP_REG_BASE (isp_subdev),ISP_SYS_INT0_STATUS ); - - isp_sys_irq_status = r1 &ISP4_FW_RESP_RB_IRQ_STATUS_MASK ; +struct isp4_subdev *isp_subdev = arg; +u32 intr_ack =0 , intr_en =0 , intr_status; +int seen =0 ; + +/* Get the ISP_SYS interrupt status */ + intr_status =isp4hw_rreg (isp_subdev->mmio,ISP_SYS_INT0_STATUS ); + intr_status &=ISP4_FW_RESP_RB_IRQ_STATUS_MASK ; + +/* Find which ISP_SYS interrupts fired */ +for (size_t i =0 ; i <ARRAY_SIZE (isp4_irq); i++) { +if (intr_status & isp4_irq[i].status_mask) { + intr_ack |= isp4_irq[i].ack_mask; + intr_en |= isp4_irq[i].en_mask; + seen |=BIT (i); + } + } -isp4_resp_interrupt_notify (isp_subdev, isp_sys_irq_status); +/* +* Disable the ISP_SYS interrupts that fired. Must be done before waking +* the response threads, since they re-enable interrupts when finished. +* The lock synchronizes RMW of INT0_EN with isp4_enable_interrupt(). +*/ +spin_lock (&isp_subdev->irq_lock); + intr_en =isp4hw_rreg (isp_subdev->mmio,ISP_SYS_INT0_EN ) & ~intr_en; +isp4hw_wreg (isp_subdev->mmio,ISP_SYS_INT0_EN , intr_en); +spin_unlock (&isp_subdev->irq_lock); + +/* +* Clear the ISP_SYS interrupts. This must be done after the interrupts +* are disabled, so that ISP FW won't flag any new interrupts on these +* streams, and thus we don't need to clear interrupts again before +* re-enabling them in the response thread. +*/ +isp4hw_wreg (isp_subdev->mmio,ISP_SYS_INT0_ACK , intr_ack); + +/* Wake up the response threads */ +for (int i; (i =ffs (seen)); seen = (seen >> i) << i) +isp4_wake_up_resp_thread (isp_subdev, i -1 );return IRQ_HANDLED ; }
@@ -101,7 +122,6 @@ static int isp4_capture_probe(struct platform_device *pdev)if (!isp_dev)return -ENOMEM ; - isp_dev->pdev = pdev; dev->init_name =ISP4_DRV_NAME ; isp_subdev = &isp_dev->isp_subdev;
@@ -109,15 +129,14 @@ static int isp4_capture_probe(struct platform_device *pdev)if (IS_ERR (isp_subdev->mmio))return dev_err_probe (dev,PTR_ERR (isp_subdev->mmio),"isp ioremap fail\n" ); -for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { - irq[i] =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +for (i =0 ; i <ARRAY_SIZE (isp4_irq); i++) { + irq[i] =platform_get_irq (pdev, isp4_irq[i].rb_int_num);if (irq[i] <0 )return dev_err_probe (dev, irq[i],"fail to get irq %d\n" , - isp4_ringbuf_interrupt_num[i]); + isp4_irq[i].rb_int_num); -irq_set_status_flags (irq[i],IRQ_NOAUTOEN ); - ret =devm_request_irq (dev, irq[i], isp4_irq_handler,0 , isp4_irq_name[i], - isp_dev); + ret =devm_request_irq (dev, irq[i], isp4_irq_handler, +IRQF_NO_AUTOEN , isp4_irq[i].name, isp_subdev);if (ret)return dev_err_probe (dev, ret,"fail to req irq %d\n" , irq[i]); }
@@ -132,8 +151,6 @@ static int isp4_capture_probe(struct platform_device *pdev) isp_dev->mdev.dev = dev;media_device_init (&isp_dev->mdev); -pm_runtime_set_suspended (dev); -pm_runtime_enable (dev);/* register v4l2 device */ snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name),"AMD-V4L2-ROOT" );
@@ -141,10 +158,13 @@ static int isp4_capture_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"fail register v4l2 device\n" ); +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev); +spin_lock_init (&isp_subdev->irq_lock); ret =isp4sd_init (&isp_dev->isp_subdev, &isp_dev->v4l2_dev, irq);if (ret) {dev_err (dev,"fail init isp4 sub dev %d\n" , ret); - goto err_unreg_v4l2; + goto err_pm_disable; } ret = media_create_pad_link(&isp_dev->isp_subdev.sdev.entity,
@@ -170,16 +190,17 @@ static int isp4_capture_probe(struct platform_device *pdev) err_isp4_deinit:isp4sd_deinit (&isp_dev->isp_subdev); -err_unreg_v4l2: +err_pm_disable: +pm_runtime_disable (dev);v4l2_device_unregister (&isp_dev->v4l2_dev);media_device_cleanup (&isp_dev->mdev); -return dev_err_probe (dev, ret,"isp probe fail\n" ); }static void isp4_capture_remove (struct platform_device *pdev) {struct isp4_device *isp_dev =platform_get_drvdata (pdev); +struct device *dev = &pdev->dev;isp_debugfs_remove (isp_dev);
@@ -187,6 +208,7 @@ static void isp4_capture_remove(struct platform_device *pdev)isp4sd_deinit (&isp_dev->isp_subdev);v4l2_device_unregister (&isp_dev->v4l2_dev);media_device_cleanup (&isp_dev->mdev); +pm_runtime_disable (dev); }static struct platform_driver isp4_capture_drv = {
drivers/media/platform/amd/isp4/isp4.h +2 -3
@@ -9,13 +9,12 @@#include <drm/amd/isp.h> #include "isp4_subdev.h" -#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) -struct isp4_device {struct v4l2_device v4l2_dev;struct isp4_subdev isp_subdev;struct media_device mdev; -struct platform_device *pdev; }; +void isp4_intr_enable (struct isp4_subdev *isp_subdev,u32 index,bool enable); +#endif /* _ISP4_H_ */
drivers/media/platform/amd/isp4/isp4_debug.c +14 -14
@@ -21,7 +21,7 @@ void isp_debugfs_create(struct isp4_device *isp_dev) isp_dev->isp_subdev.debugfs_dir, &isp_dev->isp_subdev.enable_fw_log); isp_dev->isp_subdev.fw_log_output = -devm_kzalloc (&isp_dev->pdev->dev, +devm_kzalloc (isp_dev->isp_subdev.dev,ISP4DBG_FW_LOG_RINGBUF_SIZE +32 ,GFP_KERNEL ); }
@@ -32,23 +32,23 @@ void isp_debugfs_remove(struct isp4_device *isp_dev) isp_dev->isp_subdev.debugfs_dir =NULL ; } -static u32 isp_fw_fill_rb_log (struct isp4_subdev *isp,u8 *sys,u32 rb_size) +static u32 isp_fw_fill_rb_log (struct isp4_subdev *isp,void *sys,u32 rb_size) {struct isp4_interface *ispif = &isp->ispif; +char *buf = isp->fw_log_output;struct device *dev = isp->dev; -u8 *buf = isp->fw_log_output;u32 rd_ptr, wr_ptr;u32 total_cnt =0 ;u32 offset =0 ;u32 cnt; -if (!sys || rb_size ==0 ) +if (!sys || !rb_size)return 0 ;guard (mutex)(&ispif->isp4if_mutex); - rd_ptr =isp4hw_rreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_RPTR0 ); - wr_ptr =isp4hw_rreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_WPTR0 ); + rd_ptr =isp4hw_rreg (isp->mmio,ISP_LOG_RB_RPTR0 ); + wr_ptr =isp4hw_rreg (isp->mmio,ISP_LOG_RB_WPTR0 ); do { if (wr_ptr > rd_ptr)
@@ -56,23 +56,23 @@ static u32 isp_fw_fill_rb_log(struct isp4_subdev *isp, u8 *sys, u32 rb_size)else if (wr_ptr < rd_ptr) cnt = rb_size - rd_ptr;else - goto unlock_and_quit; + goto quit;if (cnt > rb_size) {dev_err (dev,"fail bad fw log size %u\n" , cnt); - goto unlock_and_quit; + goto quit; } -memcpy (buf + offset, (u8 *)(sys + rd_ptr), cnt); +memcpy (buf + offset, sys + rd_ptr, cnt); offset += cnt; total_cnt += cnt; rd_ptr = (rd_ptr + cnt) % rb_size; }while (rd_ptr < wr_ptr); -isp4hw_wreg (ISP4_GET_ISP_REG_BASE (isp),ISP_LOG_RB_RPTR0 , rd_ptr); +isp4hw_wreg (isp->mmio,ISP_LOG_RB_RPTR0 , rd_ptr); -unlock_and_quit: +quit:return total_cnt; }
@@ -159,7 +159,7 @@ char *isp4dbg_get_buf_done_str(u32 status)default :return "Unknown Buf Done Status" ; } -}; +}char *isp4dbg_get_img_fmt_str (int fmt/* enum isp4fw_image_format * */ ) {
@@ -233,7 +233,7 @@ char *isp4dbg_get_cmd_str(u32 cmd)return ISP4DBG_MACRO_2_STR (CMD_ID_ENABLE_OUT_CHAN );default :return "unknown cmd" ; - }; + } }char *isp4dbg_get_resp_str (u32 cmd)
@@ -245,7 +245,7 @@ char *isp4dbg_get_resp_str(u32 cmd)return ISP4DBG_MACRO_2_STR (RESP_ID_NOTI_FRAME_DONE );default :return "unknown respid" ; - }; + } }char *isp4dbg_get_if_stream_str (u32 stream/* enum fw_cmd_resp_stream_id */ )
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +5 -13
@@ -201,8 +201,7 @@ struct isp4fw_resp_cmd_done { };struct isp4fw_resp_param_package { -u32 package_addr_lo;/* The low 32 bit addr of the pkg address. */ -u32 package_addr_hi;/* The high 32 bit addr of the pkg address. */ +u64 package_addr;/* The pkg address. */ u32 package_size;/* The total pkg size in bytes. */ u32 package_check_sum;/* The byte sum of the pkg. */ };
@@ -262,17 +261,10 @@ struct isp4fw_buffer { u32 vmid : 16; } bit; } vmid_space; -u32 buf_base_a_lo;/* Low address of buffer A */ -u32 buf_base_a_hi;/* High address of buffer A */ -u32 buf_size_a;/* Buffer size of buffer A */ - -u32 buf_base_b_lo;/* Low address of buffer B */ -u32 buf_base_b_hi;/* High address of buffer B */ -u32 buf_size_b;/* Buffer size of buffer B */ - -u32 buf_base_c_lo;/* Low address of buffer C */ -u32 buf_base_c_hi;/* High address of buffer C */ -u32 buf_size_c;/* Buffer size of buffer C */ +struct { +u64 addr; +u32 size; + } __packed bufs[3]; };struct isp4fw_buffer_meta_info {
drivers/media/platform/amd/isp4/isp4_interface.c +194 -340
755 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.h +26 -46
114 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_subdev.c +170 -269
798 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_subdev.h +4 -3
@@ -46,7 +46,7 @@ enum isp4sd_status {/* used to indicate the status of sensor, output stream */ enum isp4sd_start_status { -ISP4SD_START_STATUS_NOT_START , +ISP4SD_START_STATUS_OFF ,ISP4SD_START_STATUS_STARTED ,ISP4SD_START_STATUS_START_FAIL , };
@@ -83,7 +83,7 @@ struct isp4sd_sensor_info {struct isp4sd_thread_handler {struct task_struct *thread;wait_queue_head_t waitq; -int wq_cond; +bool resp_ready; };struct isp4_subdev_thread_param {
@@ -114,9 +114,10 @@ struct isp4_subdev {void __iomem *mmio;struct isp4_subdev_thread_param isp_resp_para[ISP4SD_MAX_FW_RESP_STREAM_NUM ];int irq[ISP4SD_MAX_FW_RESP_STREAM_NUM ]; +spinlock_t irq_lock;#ifdef CONFIG_DEBUG_FS -struct dentry *debugfs_dir;bool enable_fw_log; +struct dentry *debugfs_dir;char *fw_log_output;#endif };
drivers/media/platform/amd/isp4/isp4_video.c +14 -35
114 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_video.h +2 -21
@@ -11,26 +11,6 @@#include "isp4_interface.h" -enum isp4vid_buf_done_status { -/* It means no corresponding image buf in fw response */ -ISP4VID_BUF_DONE_STATUS_ABSENT , -ISP4VID_BUF_DONE_STATUS_SUCCESS , -ISP4VID_BUF_DONE_STATUS_FAILED -}; - -struct isp4vid_buf_done_info { -enum isp4vid_buf_done_status status; -struct isp4if_img_buf_info buf; -}; - -/* call back parameter for CB_EVT_ID_FRAME_DONE */ -struct isp4vid_framedone_param { -s32 poc; -s32 cam_id; -s64 time_stamp; -struct isp4vid_buf_done_info preview; -}; -struct isp4vid_capture_buffer {/* * struct vb2_v4l2_buffer must be the first element
@@ -79,6 +59,7 @@ int isp4vid_dev_init(struct isp4vid_dev *isp_vdev,void isp4vid_dev_deinit (struct isp4vid_dev *isp_vdev); -s32 isp4vid_notify (void *cb_ctx,struct isp4vid_framedone_param *evt_param); +void isp4vid_handle_frame_done (struct isp4vid_dev *isp_vdev, +const struct isp4if_img_buf_info *img_buf);#endif /* _ISP4_VIDEO_H_ */
Signature · 1 line
2.51.2
Du, Bin
maintainerQuoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 33 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made on top of v5. Most of my changes should be self-explanatory; feel free to ask further about specific changes if you have any questions.
I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured I should send what I've got so far.
FYI, there is a regression in
isp4if_dequeue_buffer()where the bufq lock isn't protecting thelist_del()anymore. I also checked the compiler output when usingguard()versusscoped_guard()in that function and there is no difference:sha1sum: 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard() 5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So
guard()should be used there again, which I've done in my patch.I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is faster to use that than using
disable_irq_nosync()to disable the IRQ from the CPU's side.2. When the IRQ is re-enabled in
isp4sd_fw_resp_func(), is there anything beforehand to mask all pending interrupts from the ISP so that there isn't a bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP when the ISP posts a new response _after_ the kthread determines there are no more new responses but _before_ the
enable_irq()inisp4sd_fw_resp_func()?Quoted 5 lines
4. Why are some lines much longer than before? It seems inconsistent that now there is a mix of several lines wrapped to 80 cols and many lines going beyond 80 cols. And there are multiple places where code is wrapped before reaching 80 cols even with lots of room left, specifically for cases where it wouldn't hurt readability to put more characters onto each line.
Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, Bin
Quoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?
Quoted 6 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.
Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.
I'm not sure I understand your point. Are you saying that ISP_SYS_INT0_EN only considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.
Quoted 1 line
Sultan
Signature · 2 lines
Regards, Bin
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 42 lines · Sultan Alsawaf
Hi Bin,
Quoted 38 lines · Sultan Alsawaf
Hi Bin,
To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.Quoted 7 lines
I've attached a new, complete patch of changes to apply on top of v5. You may ignore the incomplete patch from my previous email and use the new one instead.
I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every time you use cheese after using it one time, the video will freeze after 30-60 seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet; can you try to reproduce it?
Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?
I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
Quoted 8 lines
Quoted 7 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.
Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.
Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.
No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack) results in:
regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack) results in:
regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
regmap[ISP_SYS_INT0_EN] &= ~intr_ack;2. Current behavior of ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en) results in:
regmap[ISP_SYS_INT0_EN] = intr_en;
Proposed behavior of ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en) results in:
regmap[ISP_SYS_INT0_EN] |= intr_en;
And to disable an interrupt with this design, you can write to ISP_SYS_INT0_ACK.
Sultan
Quoted 360 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 49 lines · Sultan Alsawaf
Hi Bin,
On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
Quoted 6 lines
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
You're the first report I've heard of this.
Are you using storage encryption or a storage password of any kind (software or hardware) by chance?
If you are can you please describe it?
Also can you generate a report using amd-s2idle? I don't think it's going to flag anything but I would like to confirm.
Quoted 69 lines
Quoted 9 lines
Quoted 8 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack; regmap[ISP_SYS_INT0_EN] &= ~intr_ack;
2. Current behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] =
intr_en;Proposed behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] |=
intr_en;And to disable an interrupt with this design, you can write to
ISP_SYS_INT0_ACK.Sultan
Quoted 372 lines · Mario Limonciello
Quoted 360 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 70 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
Quoted 6 lines
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
You're the first report I've heard of this.
Quoted 7 lines
Are you using storage encryption or a storage password of any kind (software or hardware) by chance?
If you are can you please describe it?
Also can you generate a report using amd-s2idle? I don't think it's going to flag anything but I would like to confirm.
The issue is mentioned on a Reddit post [1]. A specific comment mentions amd_iommu=off fixing the issue [2], which is where I got the idea to do that.
You will find conflicting reports about this issue online, with some people saying it doesn't happen anymore after some kernel update [3], and others saying it worked until something updated [4].
The reason for all the conflicting reports online is because this issue only occurs when S0i3 is reached, and I suspect that no one realized there's a delay before S0i3 is entered. Reaching S0i3 appears to take at least 60 seconds *after* suspending the laptop. If S0i3 isn't entered, then you *can* wake the laptop but there will always be this message indicating S0i3 wasn't hit:
[ 107.428836] amd_pmc AMDI000B:00: Last suspend didn't reach deepest state
I am using LUKS1 encryption on my storage (software encryption). However, I'm not sure any of my configuration info is relevant because I reproduced the issue from a live USB using HP's OEM Ubuntu image [5], with nothing else physically plugged into the laptop and not connected to anything over WiFi or Bluetooth.
I had the thought of generating a report using amd-s2idle a couple months ago... except I have no way to wake the machine from suspend at all. I have to hold the the power button to do a hard shutdown. I tried using no_console_suspend but of course userspace processes are frozen so systemd couldn't record anything for me. I tried UART over USB and connected the output to another laptop but it would only work for a few seconds right after booting up the laptop (could've just been because I was using PL2303 serial converters, which aren't so great).
I have also tried several different combinations of settings toggled on/off in the BIOS setup menu, as well as resetting to the factory default values, without any change in behavior.
I'm at a loss on how I can retrieve some debug info for this issue. :/
[1] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/hp_zbook_ultra_g1a_ubuntu_fully_working_now_or/
[2] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd4cldp/
[3] https://forum.level1techs.com/t/the-ultimate-arch-secureboot-guide-for-ryzen-ai-max-ft-hp-g1a-128gb-8060s-monster-laptop/230652#hibernate-suspend-and-kernel-versions-16
[4] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd1xbtd/
[5] https://ftp.hp.com/pub/softpaq/sp158501-159000/stella-noble-oem-24.04b-20250422-107.iso
Sultan
Quoted 388 lines · Sultan Alsawaf
Quoted 372 lines · Mario Limonciello
Quoted 360 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 83 lines · Sultan Alsawaf
On Mon, Nov 10, 2025 at 05:46:28PM +0800, Du, Bin wrote:
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream
[ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam
[ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in
v4 -> v5 that is not fixed by any of my changes.Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1 From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
Quoted 6 lines
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
You're the first report I've heard of this.
Quoted 7 lines
Are you using storage encryption or a storage password of any kind (software or hardware) by chance?
If you are can you please describe it?
Also can you generate a report using amd-s2idle? I don't think it's going to flag anything but I would like to confirm.
The issue is mentioned on a Reddit post [1]. A specific comment mentions amd_iommu=off fixing the issue [2], which is where I got the idea to do that.
You will find conflicting reports about this issue online, with some people saying it doesn't happen anymore after some kernel update [3], and others saying it worked until something updated [4].
Quoted 7 lines
The reason for all the conflicting reports online is because this issue only occurs when S0i3 is reached, and I suspect that no one realized there's a delay before S0i3 is entered. Reaching S0i3 appears to take at least 60 seconds *after* suspending the laptop. If S0i3 isn't entered, then you *can* wake the laptop but there will always be this message indicating S0i3 wasn't hit:
[ 107.428836] amd_pmc AMDI000B:00: Last suspend didn't reach deepest state
It shouldn't take 60 seconds to enter s0i3. It should be ~5 seconds. So are you saying that if you have IOMMU enabled and interrupt the suspend around 20 seconds later you get that you didn't reach deepest sleep state, and if you wait longer it hangs?
Quoted 4 lines
I am using LUKS1 encryption on my storage (software encryption). However, I'm not sure any of my configuration info is relevant because I reproduced the issue from a live USB using HP's OEM Ubuntu image [5], with nothing else physically plugged into the laptop and not connected to anything over WiFi or Bluetooth.
Is the SSD a SED? Anything for storage password set in BIOS?
Quoted 9 lines
I had the thought of generating a report using amd-s2idle a couple months ago... except I have no way to wake the machine from suspend at all. I have to hold the the power button to do a hard shutdown. I tried using
no_console_suspendbut of course userspace processes are frozen so systemd couldn't record anything for me. I tried UART over USB and connected the output to another laptop but it would only work for a few seconds right after booting up the laptop (could've just been because I was using PL2303 serial converters, which aren't so great).
Quoted 5 lines
I have also tried several different combinations of settings toggled on/off in the BIOS setup menu, as well as resetting to the factory default values, without any change in behavior.
I'm at a loss on how I can retrieve some debug info for this issue. :/
You are on the latest BIOS presumably, right?
If you schedule a suspend with amd-s2idle for ~10 seconds, does it reproduce too?
Quoted 8 lines
[1] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/hp_zbook_ultra_g1a_ubuntu_fully_working_now_or/
[2] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd4cldp/
[3] https://forum.level1techs.com/t/the-ultimate-arch-secureboot-guide-for-ryzen-ai-max-ft-hp-g1a-128gb-8060s-monster-laptop/230652#hibernate-suspend-and-kernel-versions-16
[4] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd1xbtd/
[5] https://ftp.hp.com/pub/softpaq/sp158501-159000/stella-noble-oem-24.04b-20250422-107.isoSultan
Quoted 424 lines · Mario Limonciello
Quoted 388 lines · Sultan Alsawaf
Quoted 372 lines · Mario Limonciello
Quoted 360 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 153 lines · Bin
On 11/11/2025 5:05 PM, Sultan Alsawaf wrote:
On Mon, Nov 10, 2025 at 05:46:28PM +0800, Du, Bin wrote:
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream
[ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam
[ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in
v4 -> v5 that is not fixed by any of my changes.Hi Sultan, could you please try following modifications on top of v5 to see
if it helps?diff --git a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
index 39c2265121f9..d571b3873edb 100644
--- a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
+++ b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4
-#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024)
+#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/*
* standard ISP mipicsi=>isp
diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c
b/drivers/media/platform/amd/isp4/isp4_subdev.c
index 248d10076ae8..acbc80aa709e 100644
--- a/drivers/media/platform/amd/isp4/isp4_subdev.c
+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct
isp4_subdev *isp_subdev)
return 0;
}-static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)
+static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev, bool
irq_enabled)
{
struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;
@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev
*isp_subdev)
return 0;
}- for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
- disable_irq(isp_subdev->irq[i]);
+ if (irq_enabled)
+ for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
+ disable_irq(isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads(isp_subdev);
dev_dbg(dev, "isp_subdev stop resp proc streads suc");
@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev
*isp_subdev)return 0;
err_unlock_and_close:
- isp4sd_pwroff_and_deinit(isp_subdev);
+ isp4sd_pwroff_and_deinit(isp_subdev, false);
return -EINVAL;
}@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int
on)
if (on)
return isp4sd_pwron_and_init(isp_subdev);
else
- return isp4sd_pwroff_and_deinit(isp_subdev);
+ return isp4sd_pwroff_and_deinit(isp_subdev, true);
}static const struct v4l2_subdev_core_ops isp4sd_core_ops = {
No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to
NULL in isp_kernel_buffer_alloc() which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1 From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
Quoted 6 lines
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
You're the first report I've heard of this.
Quoted 7 lines
Are you using storage encryption or a storage password of any kind (software or hardware) by chance?
If you are can you please describe it?
Also can you generate a report using amd-s2idle? I don't think it's going to flag anything but I would like to confirm.
The issue is mentioned on a Reddit post [1]. A specific comment mentions amd_iommu=off fixing the issue [2], which is where I got the idea to do that.
You will find conflicting reports about this issue online, with some people saying it doesn't happen anymore after some kernel update [3], and others saying it worked until something updated [4].
Quoted 7 lines
The reason for all the conflicting reports online is because this issue only occurs when S0i3 is reached, and I suspect that no one realized there's a delay before S0i3 is entered. Reaching S0i3 appears to take at least 60 seconds *after* suspending the laptop. If S0i3 isn't entered, then you *can* wake the laptop but there will always be this message indicating S0i3 wasn't hit:
[ 107.428836] amd_pmc AMDI000B:00: Last suspend didn't reach deepest stateIt shouldn't take 60 seconds to enter s0i3. It should be ~5 seconds. So are you saying that if you have IOMMU enabled and interrupt the suspend around 20 seconds later you get that you didn't reach deepest sleep state, and if you wait longer it hangs?
Quoted 4 lines
I am using LUKS1 encryption on my storage (software encryption). However, I'm not sure any of my configuration info is relevant because I reproduced the issue from a live USB using HP's OEM Ubuntu image [5], with nothing else physically plugged into the laptop and not connected to anything over WiFi or Bluetooth.
Is the SSD a SED? Anything for storage password set in BIOS?
Quoted 13 lines
I had the thought of generating a report using amd-s2idle a couple months ago... except I have no way to wake the machine from suspend at all. I have to hold the the power button to do a hard shutdown. I tried using
no_console_suspendbut of course userspace processes are frozen so systemd couldn't record anything for me. I tried UART over USB and connected the output to another laptop but it would only work for a few seconds right after booting up the laptop (could've just been because I was using PL2303 serial converters, which aren't so great).I have also tried several different combinations of settings toggled on/off in the BIOS setup menu, as well as resetting to the factory default values, without any change in behavior.
Quoted 6 lines
Quoted 1 line
I'm at a loss on how I can retrieve some debug info for this issue. :/
You are on the latest BIOS presumably, right?
If you schedule a suspend with amd-s2idle for ~10 seconds, does it reproduce too?
Oh my God, I ran amd-s2idle test and got this:
❌ IOMMU is misconfigured: missing MSFT0201 ACPI device
[...]
🚫 Your system does not meet s2idle prerequisites!
🗣 Explanations for your system
🚦 Device MSFT0201 missing from ACPI tables
The ACPI device MSFT0201 is required for suspend to work when the IOMMU is enabled. Please check your BIOS settings and if configured correctly, report a bug to your system vendor. For more information on this failure see:https://gitlab.freedesktop.org/drm/amd/-/issues/3738#note_2667140
So then I reenabled Pluton in the BIOS and waking from suspend works now!!!
This had slipped past my test with BIOS settings reset to factory defaults because the BIOS has a separate button to reset *security settings* to factory defaults. And Pluton is one of those security settings.
When I had Pluton disabled, it always took at least 60 seconds to enter S0i3, measured on a stopwatch. Now S0i3 entry takes much less time as you say.
Well, that fixes a bunch of struggles I had with this laptop. :) Thank you!
Also, since I have your attention on S0i3, there is always this warning splat printed on resume from S0i3, both with and without IOMMU enabled:
[ 366.694362] ------------[ cut here ]------------ [ 366.694367] amdgpu 0000:c3:00.0: SMU uninitialized but power ungate requested for 16! [ 366.694427] WARNING: CPU: 12 PID: 3122 at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:398 smu_dpm_set_power_gate+0x1d7/0x1f0 [amdgpu] [ 366.694640] Modules linked in: ccm hid_sensor_gyro_3d hid_sensor_prox hid_sensor_trigger industrialio_triggered_buffer kfifo_buf hid_sensor_iio_common industrialio hid_sensor_hub rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device amd_capture videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc pinctrl_amdisp i2c_designware_amdisp uhid cmac algif_hash algif_skcipher af_alg bnep uinput nls_iso8859_1 vfat fat snd_acp_legacy_mach joydev snd_acp_mach mousedev intel_rapl_msr snd_soc_nau8821 snd_hda_scodec_cs35l56_spi intel_rapl_common snd_acp3x_rn amdgpu snd_acp70 snd_ctl_led snd_acp_i2s snd_acp_pdm snd_soc_dmic snd_acp_pcm snd_sof_amd_acp70 snd_sof_amd_acp63 snd_sof_amd_vangogh snd_sof_amd_rembrandt snd_hda_codec_alc269 snd_sof_amd_renoir snd_hda_scodec_component snd_sof_amd_acp snd_sof_pci snd_hda_codec_realtek_lib snd_sof_xtensa_dsp snd_hda_codec_generic snd_sof snd_sof_utils snd_pci_ps snd_soc_acpi_amd_match snd_amd_sdw_acpi soundwire_amd soundwire_generic_allocation mt7925e soundwire_bus [ 366.694715] snd_hda_codec_atihdmi mt7925_common snd_soc_sdca snd_hda_codec_hdmi mt792x_lib snd_soc_core mt76_connac_lib snd_compress drm_panel_backlight_quirks amdxcp btusb ac97_bus drm_buddy snd_hda_intel mt76 snd_pcm_dmaengine btrtl drm_exec snd_rpl_pci_acp6x drm_suballoc_helper snd_hda_codec btintel drm_ttm_helper btbcm mac80211 snd_hda_scodec_cs35l56_i2c snd_acp_pci snd_hda_core ttm btmtk ucsi_acpi snd_hda_scodec_cs35l56 snd_amd_acpi_mach libarc4 snd_intel_dspcfg snd_hda_cirrus_scodec i2c_algo_bit typec_ucsi snd_acp_legacy_common spd5118 snd_intel_sdw_acpi bluetooth drm_display_helper snd_soc_cs35l56_shared snd_pci_acp6x snd_hwdep snd_soc_cs_amp_lib typec hp_wmi cfg80211 cs_dsp cec kvm_amd snd_pci_acp5x snd_pcm hid_multitouch ecdh_generic roles sp5100_tco sparse_keymap wmi_bmof amd_pmf kvm snd_timer snd_rn_pci_acp3x i2c_hid_acpi snd_acp_config video amdtee serial_multi_instantiate i2c_hid irqbypass i2c_piix4 snd snd_soc_acpi amdxdna snd_pci_acp3x soundcore amd_sfh platform_profile wmi i2c_smbus rfkill [ 366.694807] wireless_hotkey thunderbolt amd_pmc gpu_sched rapl mac_hid i2c_dev sg crypto_user loop nfnetlink ip_tables x_tables dm_crypt encrypted_keys trusted asn1_encoder tee dm_mod polyval_clmulni ghash_clmulni_intel aesni_intel nvme nvme_core serio_raw nvme_keyring ccp nvme_auth [ 366.694840] CPU: 12 UID: 0 PID: 3122 Comm: kworker/u129:47 Tainted: G W 6.17.7 #1 PREEMPT [ 366.694846] Tainted: [W]=WARN [ 366.694848] Hardware name: HP HP ZBook Ultra G1a 14 inch Mobile Workstation PC/8D01, BIOS X89 Ver. 01.03.02 06/18/2025 [ 366.694852] Workqueue: async async_run_entry_fn [ 366.694867] RIP: 0010:smu_dpm_set_power_gate+0x1d7/0x1f0 [amdgpu] [ 366.694974] Code: 85 ed 75 03 48 8b 2f 89 74 24 04 e8 f3 85 da cb 44 8b 44 24 04 48 89 d9 48 89 ea 48 89 c6 48 c7 c7 48 80 fc c1 e8 c9 0d 63 cb <0f> 0b b8 a1 ff ff ff e9 a1 fe ff ff e9 3b b3 3b 00 e9 36 b3 3b 00 [ 366.694977] RSP: 0018:ffff8fad27387ce8 EFLAGS: 00010246 [ 366.694981] RAX: 0000000000000000 RBX: ffffffffc2006846 RCX: 0000000000000027 [ 366.694984] RDX: ffff8fcbde51abc8 RSI: 0000000000000001 RDI: ffff8fcbde51abc0 [ 366.694985] RBP: ffff8fad016afc80 R08: 0000000000000000 R09: 00000000ffffdfff [ 366.694986] R10: ffffffff8e6d5da0 R11: ffff8fad27387b88 R12: ffff8fad25a80000 [ 366.694987] R13: ffff8fad25a96680 R14: 0000000000000001 R15: ffffffffc1e7ce80 [ 366.694989] FS: 0000000000000000(0000) GS:ffff8fcc4fe73000(0000) knlGS:0000000000000000 [ 366.694990] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 366.694992] CR2: 00007f58f6956408 CR3: 0000000116015000 CR4: 0000000000f50ef0 [ 366.694993] PKRU: 55555554 [ 366.694995] Call Trace: [ 366.695003] <TASK> [ 366.695007] amdgpu_dpm_set_powergating_by_smu+0xf1/0x110 [amdgpu] [ 366.695136] _genpd_power_on+0x83/0x120 [ 366.695149] genpd_sync_power_on.part.0+0x66/0xc0 [ 366.695154] genpd_finish_resume+0x6f/0xd0 [ 366.695157] ? genpd_thaw_noirq+0x10/0x10 [ 366.695159] dpm_run_callback.isra.0+0x28/0x90 [ 366.695166] device_resume_noirq+0xc7/0x210 [ 366.695169] async_resume_noirq+0x1c/0x30 [ 366.695171] async_run_entry_fn+0x1f/0xa0 [ 366.695175] process_one_work+0x173/0x270 [ 366.695183] worker_thread+0x2d7/0x410 [ 366.695188] ? rescuer_thread+0x4e0/0x4e0 [ 366.695191] kthread+0xe6/0x1e0 [ 366.695196] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695199] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695202] ret_from_fork+0xf0/0x110 [ 366.695211] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695214] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695217] ret_from_fork_asm+0x11/0x20 [ 366.695224] </TASK> [ 366.695225] ---[ end trace 0000000000000000 ]---
Quoted 9 lines
Quoted 8 lines
[1] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/hp_zbook_ultra_g1a_ubuntu_fully_working_now_or/
[2] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd4cldp/
[3] https://forum.level1techs.com/t/the-ultimate-arch-secureboot-guide-for-ryzen-ai-max-ft-hp-g1a-128gb-8060s-monster-laptop/230652#hibernate-suspend-and-kernel-versions-16
[4] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd1xbtd/
[5] https://ftp.hp.com/pub/softpaq/sp158501-159000/stella-noble-oem-24.04b-20250422-107.isoSultan
Sultan
Quoted 20 lines
Quoted 7 lines
Quoted 2 lines
I'm at a loss on how I can retrieve some debug info for this issue. :/
You are on the latest BIOS presumably, right?
If you schedule a suspend with amd-s2idle for ~10 seconds, does it reproduce too?
Oh my God, I ran
amd-s2idle testand got this:❌ IOMMU is misconfigured: missing MSFT0201 ACPI device
[...]
🚫 Your system does not meet s2idle prerequisites!
🗣 Explanations for your system
🚦 Device MSFT0201 missing from ACPI tables
The ACPI device MSFT0201 is required for suspend to work when the IOMMU is enabled. Please check your BIOS settings and if configured correctly, report a bug to your system vendor. For more information on this failure see:https://gitlab.freedesktop.org/drm/amd/-/issues/3738#note_2667140So then I reenabled Pluton in the BIOS and waking from suspend works now!!!
Quoted 8 lines
This had slipped past my test with BIOS settings reset to factory defaults because the BIOS has a separate button to reset *security settings* to factory defaults. And Pluton is one of those security settings.
When I had Pluton disabled, it always took at least 60 seconds to enter S0i3, measured on a stopwatch. Now S0i3 entry takes much less time as you say.
Well, that fixes a bunch of struggles I had with this laptop. :) Thank you!
Well that's great news to hear. I'm glad that check in amd-s2idle has come in handy.
Quoted 3 lines
Also, since I have your attention on S0i3, there is always this warning splat printed on resume from S0i3, both with and without IOMMU enabled:
Yes; I'm aware of this, Pratap is looking at how to approach it. It should be functionally harmless at least.
Quoted 38 lines
[ 366.694362] ------------[ cut here ]------------ [ 366.694367] amdgpu 0000:c3:00.0: SMU uninitialized but power ungate requested for 16! [ 366.694427] WARNING: CPU: 12 PID: 3122 at drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:398 smu_dpm_set_power_gate+0x1d7/0x1f0 [amdgpu] [ 366.694640] Modules linked in: ccm hid_sensor_gyro_3d hid_sensor_prox hid_sensor_trigger industrialio_triggered_buffer kfifo_buf hid_sensor_iio_common industrialio hid_sensor_hub rfcomm snd_seq_dummy snd_hrtimer snd_seq snd_seq_device amd_capture videobuf2_memops videobuf2_v4l2 videobuf2_common videodev mc pinctrl_amdisp i2c_designware_amdisp uhid cmac algif_hash algif_skcipher af_alg bnep uinput nls_iso8859_1 vfat fat snd_acp_legacy_mach joydev snd_acp_mach mousedev intel_rapl_msr snd_soc_nau8821 snd_hda_scodec_cs35l56_spi intel_rapl_common snd_acp3x_rn amdgpu snd_acp70 snd_ctl_led snd_acp_i2s snd_acp_pdm snd_soc_dmic snd_acp_pcm snd_sof_amd_acp70 snd_sof_amd_acp63 snd_sof_amd_vangogh snd_sof_amd_rembrandt snd_hda_codec_alc269 snd_sof_amd_renoir snd_hda_scodec_component snd_sof_amd_acp snd_sof_pci snd_hda_codec_realtek_lib snd_sof_xtensa_dsp snd_hda_codec_generic snd_sof snd_sof_utils snd_pci_ps snd_soc_acpi_amd_match snd_amd_sdw_acpi soundwire_amd soundwire_generic_allocation mt7925e soundwire_bus [ 366.694715] snd_hda_codec_atihdmi mt7925_common snd_soc_sdca snd_hda_codec_hdmi mt792x_lib snd_soc_core mt76_connac_lib snd_compress drm_panel_backlight_quirks amdxcp btusb ac97_bus drm_buddy snd_hda_intel mt76 snd_pcm_dmaengine btrtl drm_exec snd_rpl_pci_acp6x drm_suballoc_helper snd_hda_codec btintel drm_ttm_helper btbcm mac80211 snd_hda_scodec_cs35l56_i2c snd_acp_pci snd_hda_core ttm btmtk ucsi_acpi snd_hda_scodec_cs35l56 snd_amd_acpi_mach libarc4 snd_intel_dspcfg snd_hda_cirrus_scodec i2c_algo_bit typec_ucsi snd_acp_legacy_common spd5118 snd_intel_sdw_acpi bluetooth drm_display_helper snd_soc_cs35l56_shared snd_pci_acp6x snd_hwdep snd_soc_cs_amp_lib typec hp_wmi cfg80211 cs_dsp cec kvm_amd snd_pci_acp5x snd_pcm hid_multitouch ecdh_generic roles sp5100_tco sparse_keymap wmi_bmof amd_pmf kvm snd_timer snd_rn_pci_acp3x i2c_hid_acpi snd_acp_config video amdtee serial_multi_instantiate i2c_hid irqbypass i2c_piix4 snd snd_soc_acpi amdxdna snd_pci_acp3x soundcore amd_sfh platform_profile wmi i2c_smbus rfkill [ 366.694807] wireless_hotkey thunderbolt amd_pmc gpu_sched rapl mac_hid i2c_dev sg crypto_user loop nfnetlink ip_tables x_tables dm_crypt encrypted_keys trusted asn1_encoder tee dm_mod polyval_clmulni ghash_clmulni_intel aesni_intel nvme nvme_core serio_raw nvme_keyring ccp nvme_auth [ 366.694840] CPU: 12 UID: 0 PID: 3122 Comm: kworker/u129:47 Tainted: G W 6.17.7 #1 PREEMPT [ 366.694846] Tainted: [W]=WARN [ 366.694848] Hardware name: HP HP ZBook Ultra G1a 14 inch Mobile Workstation PC/8D01, BIOS X89 Ver. 01.03.02 06/18/2025 [ 366.694852] Workqueue: async async_run_entry_fn [ 366.694867] RIP: 0010:smu_dpm_set_power_gate+0x1d7/0x1f0 [amdgpu] [ 366.694974] Code: 85 ed 75 03 48 8b 2f 89 74 24 04 e8 f3 85 da cb 44 8b 44 24 04 48 89 d9 48 89 ea 48 89 c6 48 c7 c7 48 80 fc c1 e8 c9 0d 63 cb <0f> 0b b8 a1 ff ff ff e9 a1 fe ff ff e9 3b b3 3b 00 e9 36 b3 3b 00 [ 366.694977] RSP: 0018:ffff8fad27387ce8 EFLAGS: 00010246 [ 366.694981] RAX: 0000000000000000 RBX: ffffffffc2006846 RCX: 0000000000000027 [ 366.694984] RDX: ffff8fcbde51abc8 RSI: 0000000000000001 RDI: ffff8fcbde51abc0 [ 366.694985] RBP: ffff8fad016afc80 R08: 0000000000000000 R09: 00000000ffffdfff [ 366.694986] R10: ffffffff8e6d5da0 R11: ffff8fad27387b88 R12: ffff8fad25a80000 [ 366.694987] R13: ffff8fad25a96680 R14: 0000000000000001 R15: ffffffffc1e7ce80 [ 366.694989] FS: 0000000000000000(0000) GS:ffff8fcc4fe73000(0000) knlGS:0000000000000000 [ 366.694990] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 366.694992] CR2: 00007f58f6956408 CR3: 0000000116015000 CR4: 0000000000f50ef0 [ 366.694993] PKRU: 55555554 [ 366.694995] Call Trace: [ 366.695003] <TASK> [ 366.695007] amdgpu_dpm_set_powergating_by_smu+0xf1/0x110 [amdgpu] [ 366.695136] _genpd_power_on+0x83/0x120 [ 366.695149] genpd_sync_power_on.part.0+0x66/0xc0 [ 366.695154] genpd_finish_resume+0x6f/0xd0 [ 366.695157] ? genpd_thaw_noirq+0x10/0x10 [ 366.695159] dpm_run_callback.isra.0+0x28/0x90 [ 366.695166] device_resume_noirq+0xc7/0x210 [ 366.695169] async_resume_noirq+0x1c/0x30 [ 366.695171] async_run_entry_fn+0x1f/0xa0 [ 366.695175] process_one_work+0x173/0x270 [ 366.695183] worker_thread+0x2d7/0x410 [ 366.695188] ? rescuer_thread+0x4e0/0x4e0 [ 366.695191] kthread+0xe6/0x1e0
Quoted 16 lines
[ 366.695196] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695199] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695202] ret_from_fork+0xf0/0x110 [ 366.695211] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695214] ? kthread_queue_delayed_work+0x80/0x80 [ 366.695217] ret_from_fork_asm+0x11/0x20 [ 366.695224] </TASK> [ 366.695225] ---[ end trace 0000000000000000 ]---Quoted 6 lines
Quoted 6 lines
[1] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/hp_zbook_ultra_g1a_ubuntu_fully_working_now_or/
[2] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd4cldp/
[3] https://forum.level1techs.com/t/the-ultimate-arch-secureboot-guide-for-ryzen-ai-max-ft-hp-g1a-128gb-8060s-monster-laptop/230652#hibernate-suspend-and-kernel-versions-16
[4] https://www.reddit.com/r/AMDLaptops/comments/1mmrlgz/comment/nd1xbtd/
[5] https://ftp.hp.com/pub/softpaq/sp158501-159000/stella-noble-oem-24.04b-20250422-107.iso
Maybe share some pointers over to these threads about your findings too!
Quoted 429 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 64 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support. Apologies for my delayed reply for being occupied a little with other matters.
Quoted 49 lines · Sultan Alsawaf
Hi Bin,
On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution is greatly appreciated, will let you know if there is any question or problem.
Quoted 5 lines
BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)Quoted 6 lines
Quoted 3 lines
And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100% reproducible and any other fail or err in the log?
Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
Quoted 8 lines
Quoted 7 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of
ISP_SYS_INT0_ACK:isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack) results in: regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack; regmap[ISP_SYS_INT0_EN] &= ~intr_ack;2. Current behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] =
intr_en;Proposed behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:
Quoted 6 lines
regmap[ISP_SYS_INT0_EN] |=
intr_en;And to disable an interrupt with this design, you can write to
ISP_SYS_INT0_ACK.Sultan
Hi Bin,
Thanks to Mario's help, I'm running with the IOMMU enabled now and as a result, I'm able to use the v5 driver without issue. No more freezes!
Since I'm able to use v5 now, I was able to perform more testing on my big v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch I sent before.
I found a regression in my big patch where stopping the stream would fail 100% of the time, tested by opening and then closing cheese. I've attached a small fix for this.
Please apply media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch.
With these two patches applied on top of v5, everything works well for me. :)
FYI, I think there is an issue in the FW's error handling, because that bug in my big patch breaks the ISP until I reboot the laptop, with the same symptoms as what I reported before when I was testing v5 with IOMMU disabled (and _without_ any of my changes to the driver).
Maybe you can take advantage of the bug I caused, and use it to find why the ISP or sensor never recovers after the driver fails to disable the stream.
Cheers,
Sultan
From db21ee18ac1e3eacf8fada691495f086aa636794 Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <[email protected]>
Date: Fri, 21 Nov 2025 18:25:31 -0800
Subject: [PATCH] media: platform: amd: Don't wait for cmd_done under
isp4if_mutex
This fixes a regression in "[PATCH v2] media: platform: amd: Big squash of fixes/cleanup on top of v5 patchset" (and in the v1 version) where waiting for completion of a command was accidentally moved underneath isp4if_mutex, causing the following error every time when closing the camera:
[ 56.136720] amd_isp_capture amd_isp_capture: fail to disable stream [ 56.643383] amd_isp_capture amd_isp_capture: fail to stop steam [ 56.643531] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)
Fix it by moving the wait outside of isp4if_mutex, and also moving unrelated operations outside of the isp4if_mutex scope as an optimization.
--- .../media/platform/amd/isp4/isp4_interface.c | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-)
drivers/media/platform/amd/isp4/isp4_interface.c +50 -50
@@ -388,35 +388,6 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id, const voreturn -EINVAL ; } -/* Allocate the sync command object early and outside of the lock */ -if (sync) { - ele =kmalloc (sizeof (*ele),GFP_KERNEL ); -if (!ele) -return -ENOMEM ; - -/* Get two references: one for the resp thread, one for us */ -atomic_set (&ele->refcnt,2 ); -init_completion (&ele->cmd_done); - } - -guard (mutex)(&ispif->isp4if_mutex); - - ret =read_poll_timeout (isp4if_is_cmdq_rb_full, ret, !ret,ISP4IF_MAX_SLEEP_TIME *1000 , -ISP4IF_MAX_SLEEP_COUNT *ISP4IF_MAX_SLEEP_TIME *1000 , false, - ispif, stream); -if (ret) { -struct isp4if_rb_config *rb_config = &isp4if_resp_rb_config[stream]; -u32 rd_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_rptr); -u32 wr_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_wptr); - -dev_err (dev, -"failed to get free cmdq slot, stream %s(%d),rd %u, wr %u\n" , -isp4dbg_get_if_stream_str (stream), - stream, rd_ptr, wr_ptr); - ret = -ETIMEDOUT ; - goto free_ele; - } -/* * The struct will be shared with ISP FW, use memset() to guarantee padding bits are * zeroed, since this is not guaranteed on all compilers.
@@ -432,34 +403,63 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id, const vobreak ;default :dev_err (dev,"fail bad stream id %d\n" , stream); - ret = -EINVAL ; - goto free_ele; +return -EINVAL ; + } + +/* Allocate the sync command object early and outside of the lock */ +if (sync) { + ele =kmalloc (sizeof (*ele),GFP_KERNEL ); +if (!ele) +return -ENOMEM ; + +/* Get two references: one for the resp thread, one for us */ +atomic_set (&ele->refcnt,2 ); +init_completion (&ele->cmd_done); }if (package && package_size)memcpy (cmd.cmd_param, package, package_size); - seq_num = ispif->host2fw_seq_num++; - cmd.cmd_seq_num = seq_num; - cmd.cmd_check_sum =isp4if_compute_check_sum (&cmd,sizeof (cmd) -sizeof (u32)); + scoped_guard(mutex, &ispif->isp4if_mutex) { + ret =read_poll_timeout (isp4if_is_cmdq_rb_full, ret, !ret, +ISP4IF_MAX_SLEEP_TIME *1000 , +ISP4IF_MAX_SLEEP_COUNT *ISP4IF_MAX_SLEEP_TIME *1000 , + false, ispif, stream); +if (ret) { +struct isp4if_rb_config *rb_config = &isp4if_resp_rb_config[stream]; +u32 rd_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_rptr); +u32 wr_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_wptr); + +dev_err (dev, +"failed to get free cmdq slot, stream %s(%d),rd %u, wr %u\n" , +isp4dbg_get_if_stream_str (stream), + stream, rd_ptr, wr_ptr); + ret = -ETIMEDOUT ; + goto free_ele; + } -/* -* only append the fw cmd to queue when its response needs to be waited for, -* currently there are only two such commands, disable channel and stop stream -* which are only sent after close camera -*/ -if (ele) { - ele->seq_num = seq_num; - ele->cmd_id = cmd_id; - scoped_guard(spinlock, &ispif->cmdq_lock) -list_add_tail (&ele->list, &ispif->cmdq); - } + seq_num = ispif->host2fw_seq_num++; + cmd.cmd_seq_num = seq_num; + cmd.cmd_check_sum =isp4if_compute_check_sum (&cmd,sizeof (cmd) -sizeof (u32)); + +/* +* only append the fw cmd to queue when its response needs to be waited for, +* currently there are only two such commands, disable channel and stop stream +* which are only sent after close camera +*/ +if (ele) { + ele->seq_num = seq_num; + ele->cmd_id = cmd_id; + scoped_guard(spinlock, &ispif->cmdq_lock) +list_add_tail (&ele->list, &ispif->cmdq); + } - ret =isp4if_insert_isp_fw_cmd (ispif, stream, &cmd); -if (ret) { -dev_err (dev,"fail for insert_isp_fw_cmd camId %s(0x%08x)\n" , -isp4dbg_get_cmd_str (cmd_id), cmd_id); - goto err_dequeue_ele; + ret =isp4if_insert_isp_fw_cmd (ispif, stream, &cmd); +if (ret) { +dev_err (dev,"fail for insert_isp_fw_cmd camId %s(0x%08x)\n" , +isp4dbg_get_cmd_str (cmd_id), cmd_id); + goto err_dequeue_ele; + } }if (ele) {
Signature · 1 line
2.52.0
Quoted 459 lines · Sultan Alsawaf
Quoted 429 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 74 lines · Sultan Alsawaf
Quoted 70 lines · Bin
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Quoted 9 lines
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream [ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam [ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in v4 -> v5 that is not fixed by any of my changes.
Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
Quoted 8 lines
Quoted 7 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of
ISP_SYS_INT0_ACK:isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack) results in: regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack; regmap[ISP_SYS_INT0_EN] &= ~intr_ack;2. Current behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] =
intr_en;Proposed behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:Quoted 6 lines
regmap[ISP_SYS_INT0_EN] |=
intr_en;And to disable an interrupt with this design, you can write to
ISP_SYS_INT0_ACK.Sultan
Hi Bin,
Thanks to Mario's help, I'm running with the IOMMU enabled now and as a result, I'm able to use the v5 driver without issue. No more freezes!
Since I'm able to use v5 now, I was able to perform more testing on my big v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch I sent before.
I found a regression in my big patch where stopping the stream would fail 100% of the time, tested by opening and then closing cheese. I've attached a small fix for this.
Please apply media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch.
With these two patches applied on top of v5, everything works well for me. :)
FYI, I think there is an issue in the FW's error handling, because that bug in my big patch breaks the ISP until I reboot the laptop, with the same symptoms as what I reported before when I was testing v5 with IOMMU disabled (and _without_ any of my changes to the driver).
Quoted 5 lines
Maybe you can take advantage of the bug I caused, and use it to find why the ISP or sensor never recovers after the driver fails to disable the stream.
Cheers,
Sultan
Oops, I based media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v1 of my big patch on accident, so it doesn't apply cleanly on v2 big patch.
I've attached a corrected version that is based on top of _v2_ of my big patch.
Sorry for the churn!
Sultan
From 80619e49f1d94e22fd2677709bc3bc0048793d9e Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <[email protected]>
Date: Fri, 21 Nov 2025 19:10:05 -0800
Subject: [PATCH v2] media: platform: amd: Don't wait for cmd_done under
isp4if_mutex
This fixes a regression in "[PATCH v2] media: platform: amd: Big squash of fixes/cleanup on top of v5 patchset" (and in the v1 version) where waiting for completion of a command was accidentally moved underneath isp4if_mutex, causing the following error every time when closing the camera:
[ 56.136720] amd_isp_capture amd_isp_capture: fail to disable stream [ 56.643383] amd_isp_capture amd_isp_capture: fail to stop steam [ 56.643531] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)
Fix it by moving the wait outside of isp4if_mutex, and also moving unrelated operations outside of the isp4if_mutex scope as an optimization.
---
v1 -> v2 changes:
-Rebased onto v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch, since
this patch was accidentally based on v1 of the big squash patch
--- .../media/platform/amd/isp4/isp4_interface.c | 97 +++++++++---------- 1 file changed, 48 insertions(+), 49 deletions(-)
drivers/media/platform/amd/isp4/isp4_interface.c +48 -49
@@ -339,34 +339,6 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id, const voreturn -EINVAL ; } -/* Allocate the sync command object early and outside of the lock */ -if (sync) { - ele =kmalloc (sizeof (*ele),GFP_KERNEL ); -if (!ele) -return -ENOMEM ; - -/* Get two references: one for the resp thread, one for us */ -atomic_set (&ele->refcnt,2 ); -init_completion (&ele->cmd_done); - } - -guard (mutex)(&ispif->isp4if_mutex); - - ret =read_poll_timeout (isp4if_is_cmdq_rb_full, ret, !ret,ISP4IF_RB_FULL_SLEEP_US , -ISP4IF_RB_FULL_TIMEOUT_US , false, ispif, stream); -if (ret) { -struct isp4if_rb_config *rb_config = &isp4if_resp_rb_config[stream]; -u32 rd_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_rptr); -u32 wr_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_wptr); - -dev_err (dev, -"failed to get free cmdq slot, stream %s(%d),rd %u, wr %u\n" , -isp4dbg_get_if_stream_str (stream), - stream, rd_ptr, wr_ptr); - ret = -ETIMEDOUT ; - goto free_ele; - } -/* * The struct will be shared with ISP FW, use memset() to guarantee padding bits are * zeroed, since this is not guaranteed on all compilers.
@@ -382,34 +354,61 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id, const vobreak ;default :dev_err (dev,"fail bad stream id %d\n" , stream); - ret = -EINVAL ; - goto free_ele; +return -EINVAL ; + } + +/* Allocate the sync command object early and outside of the lock */ +if (sync) { + ele =kmalloc (sizeof (*ele),GFP_KERNEL ); +if (!ele) +return -ENOMEM ; + +/* Get two references: one for the resp thread, one for us */ +atomic_set (&ele->refcnt,2 ); +init_completion (&ele->cmd_done); }if (package && package_size)memcpy (cmd.cmd_param, package, package_size); - seq_num = ispif->host2fw_seq_num++; - cmd.cmd_seq_num = seq_num; - cmd.cmd_check_sum =isp4if_compute_check_sum (&cmd,sizeof (cmd) -sizeof (u32)); + scoped_guard(mutex, &ispif->isp4if_mutex) { + ret =read_poll_timeout (isp4if_is_cmdq_rb_full, ret, !ret,ISP4IF_RB_FULL_SLEEP_US , +ISP4IF_RB_FULL_TIMEOUT_US , false, ispif, stream); +if (ret) { +struct isp4if_rb_config *rb_config = &isp4if_resp_rb_config[stream]; +u32 rd_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_rptr); +u32 wr_ptr =isp4hw_rreg (ispif->mmio, rb_config->reg_wptr); + +dev_err (dev, +"failed to get free cmdq slot, stream %s(%d),rd %u, wr %u\n" , +isp4dbg_get_if_stream_str (stream), + stream, rd_ptr, wr_ptr); + ret = -ETIMEDOUT ; + goto free_ele; + } -/* -* only append the fw cmd to queue when its response needs to be waited for, -* currently there are only two such commands, disable channel and stop stream -* which are only sent after close camera -*/ -if (ele) { - ele->seq_num = seq_num; - ele->cmd_id = cmd_id; - scoped_guard(spinlock, &ispif->cmdq_lock) -list_add_tail (&ele->list, &ispif->cmdq); - } + seq_num = ispif->host2fw_seq_num++; + cmd.cmd_seq_num = seq_num; + cmd.cmd_check_sum =isp4if_compute_check_sum (&cmd,sizeof (cmd) -sizeof (u32)); + +/* +* only append the fw cmd to queue when its response needs to be waited for, +* currently there are only two such commands, disable channel and stop stream +* which are only sent after close camera +*/ +if (ele) { + ele->seq_num = seq_num; + ele->cmd_id = cmd_id; + scoped_guard(spinlock, &ispif->cmdq_lock) +list_add_tail (&ele->list, &ispif->cmdq); + } - ret =isp4if_insert_isp_fw_cmd (ispif, stream, &cmd); -if (ret) { -dev_err (dev,"fail for insert_isp_fw_cmd cmd_id %s(0x%08x)\n" , -isp4dbg_get_cmd_str (cmd_id), cmd_id); - goto err_dequeue_ele; + ret =isp4if_insert_isp_fw_cmd (ispif, stream, &cmd); +if (ret) { +dev_err (dev,"fail for insert_isp_fw_cmd cmd_id %s(0x%08x)\n" , +isp4dbg_get_cmd_str (cmd_id), cmd_id); + goto err_dequeue_ele; + } }if (ele) {
Signature · 1 line
2.52.0
Quoted 466 lines · Sultan Alsawaf
Quoted 459 lines · Sultan Alsawaf
Quoted 429 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 152 lines · Bin
Quoted 83 lines · Sultan Alsawaf
On Mon, Nov 10, 2025 at 05:46:28PM +0800, Du, Bin wrote:
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream
[ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam
[ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in
v4 -> v5 that is not fixed by any of my changes.Hi Sultan, could you please try following modifications on top of v5 to see if it helps?
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;drivers/media/platform/amd/isp4/isp4_subdev.c +3
-2@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg(dev, "isp_subdev stop resp proc streads suc");drivers/media/platform/amd/isp4/isp4_subdev.c +0
-0@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ;
err_unlock_and_close:drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1-isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ;}
drivers/media/platform/amd/isp4/isp4_subdev.c +1
-1@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }Quoted 1 line
static const struct
v4l2_subdev_core_opsisp4sd_core_ops= {No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to NULL in
isp_kernel_buffer_alloc()which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
Quoted 8 lines
Quoted 7 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of
ISP_SYS_INT0_ACK:isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack) results in: regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack; regmap[ISP_SYS_INT0_EN] &= ~intr_ack;2. Current behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] =
intr_en;Proposed behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:Quoted 6 lines
regmap[ISP_SYS_INT0_EN] |=
intr_en;And to disable an interrupt with this design, you can write to
ISP_SYS_INT0_ACK.Sultan
Hi Bin,
Thanks to Mario's help, I'm running with the IOMMU enabled now and as a result, I'm able to use the v5 driver without issue. No more freezes!
Since I'm able to use v5 now, I was able to perform more testing on my big v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch I sent before.
I found a regression in my big patch where stopping the stream would fail 100% of the time, tested by opening and then closing cheese. I've attached a small fix for this.
Please apply media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch.
With these two patches applied on top of v5, everything works well for me. :)
FYI, I think there is an issue in the FW's error handling, because that bug in my big patch breaks the ISP until I reboot the laptop, with the same symptoms as what I reported before when I was testing v5 with IOMMU disabled (and _without_ any of my changes to the driver).
Quoted 5 lines
Maybe you can take advantage of the bug I caused, and use it to find why the ISP or sensor never recovers after the driver fails to disable the stream.
Cheers,
Sultan
Quoted 8 lines
Oops, I based media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v1 of my big patch on accident, so it doesn't apply cleanly on v2 big patch.
I've attached a corrected version that is based on top of _v2_ of my big patch.
Sorry for the churn!
Sultan
Hi Bin,
I have attached another fix for a regression caused by my big patch.
To summarize, apply the following patches on top of the v5 driver in this order:
1. v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch [1]
2. v2-media-platform-amd-Don-t-wait-for-cmd_done-under-.patch [2]
3. media-platform-amd-Fix-inverted-logic-typo-in-isp4if.patch [attached]
[1] https://lore.kernel.org/all/aRwhuNmPRlPGxIia@sultan-box/2-v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch
[2] https://lore.kernel.org/all/aSErtOOG5X5JG8Kl@sultan-box/2-v2-media-platform-amd-Don-t-wait-for-cmd_done-under-.patch
Thanks,
Sultan
From 5a1091ddbfa9858633085d14b31c86e11c57c858 Mon Sep 17 00:00:00 2001
From: Sultan Alsawaf <[email protected]>
Date: Mon, 24 Nov 2025 18:48:19 -0800
Subject: [PATCH] media: platform: amd: Fix inverted logic typo in
isp4if_is_cmdq_rb_full()
Fixes a regression from "[PATCH v2] media: platform: amd: Big squash of fixes/cleanup on top of v5 patchset".
When bytes_free is *less than or equal to* the size of a fw command, then the ringbuf is full. Fix the inverted logic typo that used > instead of <= for the comparison.
Resolves low preview frame rate observed in Zoom.
--- drivers/media/platform/amd/isp4/isp4_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/amd/isp4/isp4_interface.c +1 -1
@@ -260,7 +260,7 @@ static bool isp4if_is_cmdq_rb_full(struct isp4_interface *ispif, enum isp4if_str* wr_ptr when the ringbuf is full, because rd_ptr == wr_ptr is supposed * to indicate that the ringbuf is empty. */ -return bytes_free >sizeof (struct isp4fw_cmd ); +return bytes_free <=sizeof (struct isp4fw_cmd ); } struct isp4if_cmd_element *isp4if_rm_cmd_from_cmdq(struct isp4_interface *ispif, u32 seq_num,
Signature · 1 line
2.52.0
Du, Bin
maintainerQuoted 480 lines · Sultan Alsawaf
Quoted 466 lines · Sultan Alsawaf
Quoted 459 lines · Sultan Alsawaf
Quoted 429 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
Quoted 153 lines · Bin
On 11/11/2025 5:05 PM, Sultan Alsawaf wrote:
On Mon, Nov 10, 2025 at 05:46:28PM +0800, Du, Bin wrote:
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream
[ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam
[ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in
v4 -> v5 that is not fixed by any of my changes.Hi Sultan, could you please try following modifications on top of v5 to see
if it helps?diff --git a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
index 39c2265121f9..d571b3873edb 100644
--- a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
+++ b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4
-#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024)
+#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/*
* standard ISP mipicsi=>isp
diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c
b/drivers/media/platform/amd/isp4/isp4_subdev.c
index 248d10076ae8..acbc80aa709e 100644
--- a/drivers/media/platform/amd/isp4/isp4_subdev.c
+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct
isp4_subdev *isp_subdev)
return 0;
}-static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)
+static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev, bool
irq_enabled)
{
struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;
@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev
*isp_subdev)
return 0;
}- for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
- disable_irq(isp_subdev->irq[i]);
+ if (irq_enabled)
+ for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
+ disable_irq(isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads(isp_subdev);
dev_dbg(dev, "isp_subdev stop resp proc streads suc");
@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev
*isp_subdev)return 0;
err_unlock_and_close:
- isp4sd_pwroff_and_deinit(isp_subdev);
+ isp4sd_pwroff_and_deinit(isp_subdev, false);
return -EINVAL;
}@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int
on)
if (on)
return isp4sd_pwron_and_init(isp_subdev);
else
- return isp4sd_pwroff_and_deinit(isp_subdev);
+ return isp4sd_pwroff_and_deinit(isp_subdev, true);
}static const struct v4l2_subdev_core_ops isp4sd_core_ops = {
No difference sadly; same symptoms as before. FYI, your email client broke the patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols, replaced tabs with spaces, and removed leading spaces on each context line, so I had to apply it manually. To confirm I applied it correctly, here is my diff:
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h +1
-1@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4 -#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) +#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/* * standard ISP mipicsi=>isp drivers/media/platform/amd/isp4/isp4_subdev.c +6
-5@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)return 0 ; } -static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev) +static int isp4sd_pwroff_and_deinit (struct isp4_subdev *isp_subdev,bool irq_enabled) {struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;unsigned int perf_state =ISP4SD_PERFORMANCE_STATE_LOW ;@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)return 0 ; } -for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) -disable_irq (isp_subdev->irq[i]); +if (irq_enabled) +for (int i =0 ; i <ISP4SD_MAX_FW_RESP_STREAM_NUM ; i++) +disable_irq (isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads (isp_subdev);dev_dbg (dev,"isp_subdev stop resp proc streads suc" );@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)return 0 ; err_unlock_and_close: -isp4sd_pwroff_and_deinit (isp_subdev); +isp4sd_pwroff_and_deinit (isp_subdev, false);return -EINVAL ; }@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)if (on)return isp4sd_pwron_and_init (isp_subdev);else -return isp4sd_pwroff_and_deinit (isp_subdev); +return isp4sd_pwroff_and_deinit (isp_subdev, true); }static const struct v4l2_subdev_core_ops isp4sd_core_ops = {Quoted 2 lines
On the other hand, please also add the patch in amdgpu which sets *bo to
NULL in isp_kernel_buffer_alloc() which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I tested with IRQs kept enabled all the time and the issue still occurs.
I did observe that ISP stops sending interrupts when the video stream freezes. And, if I replicate the bug enough times, it seems to permanently break FW until a full machine reboot. Reloading
amd_capturewith the v4 driver doesn't recover the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe? I am assuming hardware doesn't need too long to settle after hard reset, maybe a few hundred milliseconds? This would ensure ISP FW is always in a working state when the driver is loaded.
Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
Quoted 8 lines
Quoted 7 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack; regmap[ISP_SYS_INT0_EN] &= ~intr_ack;
2. Current behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] =
intr_en;Proposed behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:Quoted 6 lines
regmap[ISP_SYS_INT0_EN] |=
intr_en;And to disable an interrupt with this design, you can write to
ISP_SYS_INT0_ACK.Sultan
Hi Bin,
Thanks to Mario's help, I'm running with the IOMMU enabled now and as a result, I'm able to use the v5 driver without issue. No more freezes!
Since I'm able to use v5 now, I was able to perform more testing on my big v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch I sent before.
I found a regression in my big patch where stopping the stream would fail 100% of the time, tested by opening and then closing cheese. I've attached a small fix for this.
Please apply media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch.
With these two patches applied on top of v5, everything works well for me. :)
FYI, I think there is an issue in the FW's error handling, because that bug in my big patch breaks the ISP until I reboot the laptop, with the same symptoms as what I reported before when I was testing v5 with IOMMU disabled (and _without_ any of my changes to the driver).
Quoted 5 lines
Maybe you can take advantage of the bug I caused, and use it to find why the ISP or sensor never recovers after the driver fails to disable the stream.
Cheers,
SultanQuoted 8 lines
Oops, I based media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v1 of my big patch on accident, so it doesn't apply cleanly on v2 big patch.
I've attached a corrected version that is based on top of _v2_ of my big patch.
Sorry for the churn!
Sultan
Hi Bin,
I have attached another fix for a regression caused by my big patch.
Quoted 9 lines
To summarize, apply the following patches on top of the v5 driver in this order:
1. v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch [1]
2. v2-media-platform-amd-Don-t-wait-for-cmd_done-under-.patch [2]
3. media-platform-amd-Fix-inverted-logic-typo-in-isp4if.patch [attached][1] https://lore.kernel.org/all/aRwhuNmPRlPGxIia@sultan-box/2-v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch
[2] https://lore.kernel.org/all/aSErtOOG5X5JG8Kl@sultan-box/2-v2-media-platform-amd-Don-t-wait-for-cmd_done-under-.patch
Thank you very much, Sultan, for your outstanding contributions. We truly value your patches, testing efforts, debugging, and fixes. We intend to adopt most of your suggestions, but we will retain the definitions of struct isp4fw_resp_param_package and struct isp4fw_buffer, along with their related implementations. These are shared with ISP FW, so keeping them helps us prevent potential issues from misalignment.
On the other hand, if you are agreeable, we would be pleased to add you as a co-developer.
Quoted 2 lines
Thanks,
Sultan
Signature · 2 lines
Regards, Bin
Quoted 493 lines · Bin
Quoted 480 lines · Sultan Alsawaf
Quoted 466 lines · Sultan Alsawaf
Quoted 459 lines · Sultan Alsawaf
Quoted 429 lines · Sultan Alsawaf
Quoted 348 lines · Bin
Quoted 339 lines · Sultan Alsawaf
Quoted 324 lines · Bin
Quoted 288 lines · Sultan Alsawaf
Quoted 232 lines · Sultan Alsawaf
Quoted 231 lines · Bin
Thanks Sultan for your information.
Quoted 227 lines · Sultan Alsawaf
Quoted 226 lines · Sultan Alsawaf
On Tue, Nov 11, 2025 at 05:58:10PM +0800, Du, Bin wrote:
On 11/11/2025 5:05 PM, Sultan Alsawaf wrote:
On Mon, Nov 10, 2025 at 05:46:28PM +0800, Du, Bin wrote:
Thank you, Sultan, for your time, big effort, and constant support.
Apologies for my delayed reply for being occupied a little with other
matters.On 11/10/2025 4:33 PM, Sultan Alsawaf wrote:
Hi Bin,On Wed, Nov 05, 2025 at 01:25:58AM -0800, Sultan Alsawaf wrote:
Hi Bin,To expedite review, I've attached a patch containing a bunch of fixes I've made
on top of v5. Most of my changes should be self-explanatory; feel free to ask
further about specific changes if you have any questions.I haven't had a chance to review all of the v4 -> v5 changes yet, but I figured
I should send what I've got so far.FYI, there is a regression in isp4if_dequeue_buffer() where the bufq lock isn't
protecting the list_del() anymore. I also checked the compiler output when using
guard() versus scoped_guard() in that function and there is no difference:sha1sum:
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // guard()
5652a0306da22ea741d80a9e03a787d0f71758a8 isp4_interface.o // scoped_guard()So guard() should be used there again, which I've done in my patch.
I also have a few questions:
1. Does ISP FW provide a register interface to disable the IRQ? If so, it is
faster to use that than using disable_irq_nosync() to disable the IRQ from
the CPU's side.2. When the IRQ is re-enabled in isp4sd_fw_resp_func(), is there anything
beforehand to mask all pending interrupts from the ISP so that there isn't a
bunch of stale interrupts firing as soon the IRQ is re-enabled?3. Is there any risk of deadlock due to the stream kthread racing with the ISP
when the ISP posts a new response _after_ the kthread determines there are no
more new responses but _before_ the enable_irq() in isp4sd_fw_resp_func()?4. Why are some lines much longer than before? It seems inconsistent that now
there is a mix of several lines wrapped to 80 cols and many lines going
beyond 80 cols. And there are multiple places where code is wrapped before
reaching 80 cols even with lots of room left, specifically for cases where it
wouldn't hurt readability to put more characters onto each line.I've attached a new, complete patch of changes to apply on top of v5. You may
ignore the incomplete patch from my previous email and use the new one instead.I made many changes and also answered questions 1-3 myself.
Please apply this on top of v5 and let me know if you have any questions.
Sure, will review, apply and test your patch accordingly. Your contribution
is greatly appreciated, will let you know if there is any question or
problem.BTW, I noticed a strange regression in v5 even without any of my changes: every
time you use cheese after using it one time, the video will freeze after 30-60
seconds with this message printed to dmesg:
[ 2032.716559] amd_isp_capture amd_isp_capture: -><- fail respid unknown respid(0x30002)And the video never unfreezes. I haven't found the cause for the regression yet;
can you try to reproduce it?Really weird, we don't see this issue either in dev or QA test. Is it 100%
reproducible and any other fail or err in the log?Yes, it's 100% reproducible. There's no other message in dmesg, only that one.
Sometimes there is a stop stream error when I close cheese after it froze:
[ 656.540307] amd_isp_capture amd_isp_capture: fail to disable stream
[ 657.046633] amd_isp_capture amd_isp_capture: fail to stop steam
[ 657.047224] amd_isp_capture amd_isp_capture: disabling streaming failed (-110)When I revert to v4 I cannot reproduce it at all. It seems to be something in
v4 -> v5 that is not fixed by any of my changes.Hi Sultan, could you please try following modifications on top of v5 to see
if it helps?diff --git a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
index 39c2265121f9..d571b3873edb 100644
--- a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
+++ b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
@@ -97,7 +97,7 @@#define ADDR_SPACE_TYPE_GPU_VA 4
-#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024)
+#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)/*
* standard ISP mipicsi=>isp
diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c
b/drivers/media/platform/amd/isp4/isp4_subdev.c
index 248d10076ae8..acbc80aa709e 100644
--- a/drivers/media/platform/amd/isp4/isp4_subdev.c
+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
@@ -697,7 +697,7 @@ static int isp4sd_stop_resp_proc_threads(struct
isp4_subdev *isp_subdev)
return 0;
}-static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)
+static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev, bool
irq_enabled)
{
struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;
@@ -716,8 +716,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev
*isp_subdev)
return 0;
}- for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
- disable_irq(isp_subdev->irq[i]);
+ if (irq_enabled)
+ for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
+ disable_irq(isp_subdev->irq[i]);isp4sd_stop_resp_proc_threads(isp_subdev);
dev_dbg(dev, "isp_subdev stop resp proc streads suc");
@@ -813,7 +814,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev
*isp_subdev)return 0;
err_unlock_and_close:
- isp4sd_pwroff_and_deinit(isp_subdev);
+ isp4sd_pwroff_and_deinit(isp_subdev, false);
return -EINVAL;
}@@ -985,7 +986,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int
on)
if (on)
return isp4sd_pwron_and_init(isp_subdev);
else
- return isp4sd_pwroff_and_deinit(isp_subdev);
+ return isp4sd_pwroff_and_deinit(isp_subdev, true);
}static const struct v4l2_subdev_core_ops isp4sd_core_ops = {
No difference sadly; same symptoms as before. FYI, your email client broke the
patch formatting so I couldn't apply it; it hard wrapped some lines to 80 cols,
replaced tabs with spaces, and removed leading spaces on each context line, so I
had to apply it manually. To confirm I applied it correctly, here is my diff:diff --git a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
index 39c2265121f9..d571b3873edb 100644
--- a/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
+++ b/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h
@@ -97,7 +97,7 @@
#define ADDR_SPACE_TYPE_GPU_VA 4
-#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024)
+#define FW_MEMORY_POOL_SIZE (100 * 1024 * 1024)
/*
* standard ISP mipicsi=>isp
diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c
index 4bd2ebf0f694..500ef0af8a41 100644
--- a/drivers/media/platform/amd/isp4/isp4_subdev.c
+++ b/drivers/media/platform/amd/isp4/isp4_subdev.c
@@ -669,7 +669,7 @@ static int isp4sd_stop_resp_proc_threads(struct isp4_subdev *isp_subdev)
return 0;
}
-static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)
+static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev, bool irq_enabled)
{
struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info;
unsigned int perf_state = ISP4SD_PERFORMANCE_STATE_LOW;
@@ -688,8 +688,9 @@ static int isp4sd_pwroff_and_deinit(struct isp4_subdev *isp_subdev)
return 0;
}
- for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
- disable_irq(isp_subdev->irq[i]);
+ if (irq_enabled)
+ for (int i = 0; i < ISP4SD_MAX_FW_RESP_STREAM_NUM; i++)
+ disable_irq(isp_subdev->irq[i]);
isp4sd_stop_resp_proc_threads(isp_subdev);
dev_dbg(dev, "isp_subdev stop resp proc streads suc");
@@ -785,7 +786,7 @@ static int isp4sd_pwron_and_init(struct isp4_subdev *isp_subdev)
return 0;
err_unlock_and_close:
- isp4sd_pwroff_and_deinit(isp_subdev);
+ isp4sd_pwroff_and_deinit(isp_subdev, false);
return -EINVAL;
}
@@ -957,7 +958,7 @@ static int isp4sd_set_power(struct v4l2_subdev *sd, int on)
if (on)
return isp4sd_pwron_and_init(isp_subdev);
else
- return isp4sd_pwroff_and_deinit(isp_subdev);
+ return isp4sd_pwroff_and_deinit(isp_subdev, true);
}
static const struct v4l2_subdev_core_ops isp4sd_core_ops = {On the other hand, please also add the patch in amdgpu which sets *bo to
NULL in isp_kernel_buffer_alloc() which you mentioned in another thread.Yep, I have been doing all v5 testing with that patch applied.
BTW, I have verified the IRQ changes are not the cause for the regression; I
tested with IRQs kept enabled all the time and the issue still occurs.I did observe that ISP stops sending interrupts when the video stream freezes.
And, if I replicate the bug enough times, it seems to permanently break FW until
a full machine reboot. Reloading amd_capture with the v4 driver doesn't recover
the ISP when this happens.As an improvement to the driver, can we do a hard reset of ISP on driver probe?
I am assuming hardware doesn't need too long to settle after hard reset, maybe
a few hundred milliseconds? This would ensure ISP FW is always in a working
state when the driver is loaded.Quoted 7 lines
Quoted 3 lines
Actually, each time the camera is activated, the ISP driver powers on the ISP and initiates its firmware from the beginning; when the camera is closed, the ISP is powered off..
Hmm, well I am able to put the ISP in a completely unusable state that doesn't recover when I unload and reload
amd_capture. Or maybe it is the sensor that is stuck in a broken state?Here is the log output when I try to start cheese after unloading and reloading
amd_capture, where the ISP is in the broken state that requires rebooting the laptop (annotated with notes of what I saw/did at each point in time):==> opened cheese
==> cheese froze after a few seconds
==> closed cheese[ 34.570823] amd_isp_capture amd_isp_capture: fail to disable stream [ 35.077503] amd_isp_capture amd_isp_capture: fail to stop steam [ 35.077525] amd_isp_capture amd_isp_capture: disabling streaming failed (-110) ==> unloaded amd_capture ==> loaded amd_capture ==> opened cheese [ 308.039721] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.043961] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.044188] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044194] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044196] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044197] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044198] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044199] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044200] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044201] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.044202] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.065226] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.174814] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.177807] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.178036] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178043] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178044] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178045] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178046] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178047] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178048] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178049] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.178050] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.198776] amd_isp_capture amd_isp_capture: power up isp fail -22 [ 308.306835] amd_isp_capture amd_isp_capture: ISP CCPU FW boot failed [ 308.311533] amd_isp_capture amd_isp_capture: fail to start isp_subdev interface [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311723] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311724] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_infoQuoted 9 lines
[ 308.311725] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311726] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.311727] amd_isp_capture amd_isp_capture: invalid mem_info [ 308.335281] amd_isp_capture amd_isp_capture: power up isp fail -22Thanks Sultan for the detailed info, I agree with you, tend to believe it may related to the sensor, I will follow up with the FW team to investigate further.
Quoted 19 lines
Quoted 19 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Thanks,
SultanA small update: I reproduced the issue on v4, but it took several more cycles of closing/opening cheese and waiting 30s compared to v5.
Quoted 8 lines
Quoted 6 lines
Right now my best guess is that this is a timing issue with respect to FW that was exposed by the v5 changes. v5 introduced slight changes in code timing, like with the mutex locks getting replaced by spin locks.
I'll try to insert mdelays to see if I can expose the issue that way on v4.
Could you kindly provide the FW used?
commit a89515d3ff79f12099f7a51b0f4932b881b7720e Author: Pratap Nirujogi <[email protected]> Date: Thu Aug 21 15:40:45 2025 -0400Quoted 13 lines
Quoted 8 lines
Quoted 6 lines
amdgpu: Update ISP FW for isp v4.1.1
From internal git commit:
24557b7326e539183b3bc44cf8e1496c74d383d6Signed-off-by Pratap Nirujogi <[email protected]>Sultan
Sultan
Signature · 2 lines
Regards, BinQuoted 5 lines
Thanks, Bin. I looked deeper at the code and didn't find any reason the issue could be due to the driver. Also, the problem happens outside of cheese for me (like in Chromium with Zoom meetings), so v5 of the driver is pretty much unusable for me until this issue is fixed. :(
Quoted 7 lines
Oh, really sad to hear that :(, there must be some difference between our platforms because we still can't reproduce the issue you mentioned, to help on this, would you share more info like your Ubuntu version, Kernel version/source, ISP driver version, BIOS version, .config used to build the kernel, FW: commit
a89515d3ff79f12099f7a51b0f4932b881b7720e. Just wondering, if possible, could you provide the kernel image either so we can directly test on it. Also, the HW is not broken, right?I figured out why you cannot reproduce the issue. You need to pass amd_iommu=off on the kernel command line to trigger the issue.
The reason I am using amd_iommu=off is because this laptop otherwise doesn't ever wake from suspend under Linux once it reaches the S0i3 state. The keyboard, power button, and lid do not respond to wake up the laptop from suspend. This happens 100% of the time once S0i3 is reached, and occurs on the OEM Ubuntu image from HP as well. The only fix I have found is to pass amd_iommu=off, which other owners of this laptop also found fixes the issue.
Quoted 8 lines
Quoted 7 lines
I've attached a v2 of my big patch, which includes more improvements and another ringbuffer bug fix. Please check the ringbuffer logic on the FW side to make sure FW doesn't have the same bug, where it may let
rd_ptr==wr_ptrupon filling the ringbuffer, even thoughrd_ptr==wr_ptris supposed to indicate the ringbuffer is empty.Quoted 4 lines
Thank you for your huge contribution. We'll review, verify, and merge as much as possible into v6 and hope this marks the final significant update. We typically avoid large changes to reduce regression risks and minimize additional debugging, testing, and schedule impact.
I understand. Don't worry, that is indeed the final significant update. Please let me know which changes you don't merge in, since it could be an important change. And thank you for considering my changes! :)
And please be sure to check the ringbuffer code in FW to see if it has the same bug I found in the driver.
Quoted 14 lines
Quoted 5 lines
Also, I have a suggestion for a FW change to improve IRQ handling in the driver:
1. Change
ISP_SYS_INT0_ACKbehavior so that it also clears the acked interrupts fromISP_SYS_INT0_EN.Based on my understanding, this pertains to the hardware design and cannot be modified.
Quoted 4 lines
2. Change
ISP_SYS_INT0_ENbehavior so that it only enables the interrupts in the provided mask, so RMW ofISP_SYS_INT0_ENin the driver won't be necessary to re-enable interrupts for a stream.Quoted 4 lines
I'm not sure I understand your point. Are you saying that
ISP_SYS_INT0_ENonly considers '1' in the mask and ignores '0'? If that's the case, I'm curious about how to disable an interrupt. Also, this is also determined by the hardware design.No worries, it's not a big deal. Just a small optimization I thought of.
My idea was:
1. Current behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack;
Proposed behavior of
ISP_SYS_INT0_ACK:
isp4hw_wreg(mmio, ISP_SYS_INT0_ACK, intr_ack)results in:regmap[ISP_SYS_INT0_STATUS] &= ~intr_ack; regmap[ISP_SYS_INT0_EN] &= ~intr_ack;
2. Current behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:regmap[ISP_SYS_INT0_EN] =
intr_en;Proposed behavior of
ISP_SYS_INT0_EN:
isp4hw_wreg(mmio, ISP_SYS_INT0_EN, intr_en)results in:Quoted 6 lines
regmap[ISP_SYS_INT0_EN] |=
intr_en;And to disable an interrupt with this design, you can write to
ISP_SYS_INT0_ACK.Sultan
Hi Bin,
Thanks to Mario's help, I'm running with the IOMMU enabled now and as a result, I'm able to use the v5 driver without issue. No more freezes!
Since I'm able to use v5 now, I was able to perform more testing on my big v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch I sent before.
I found a regression in my big patch where stopping the stream would fail 100% of the time, tested by opening and then closing cheese. I've attached a small fix for this.
Please apply media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch.
With these two patches applied on top of v5, everything works well for me. :)
FYI, I think there is an issue in the FW's error handling, because that bug in my big patch breaks the ISP until I reboot the laptop, with the same symptoms as what I reported before when I was testing v5 with IOMMU disabled (and _without_ any of my changes to the driver).
Quoted 5 lines
Maybe you can take advantage of the bug I caused, and use it to find why the ISP or sensor never recovers after the driver fails to disable the stream.
Cheers,
SultanQuoted 8 lines
Oops, I based media-platform-amd-Don-t-wait-for-cmd_done-under-isp.patch on top of v1 of my big patch on accident, so it doesn't apply cleanly on v2 big patch.
I've attached a corrected version that is based on top of _v2_ of my big patch.
Sorry for the churn!
Sultan
Hi Bin,
I have attached another fix for a regression caused by my big patch.
Quoted 9 lines
To summarize, apply the following patches on top of the v5 driver in this order:
1. v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch [1]
2. v2-media-platform-amd-Don-t-wait-for-cmd_done-under-.patch [2]
3. media-platform-amd-Fix-inverted-logic-typo-in-isp4if.patch [attached][1] https://lore.kernel.org/all/aRwhuNmPRlPGxIia@sultan-box/2-v2-media-platform-amd-Big-squash-of-fixes-cleanup-on.patch
[2] https://lore.kernel.org/all/aSErtOOG5X5JG8Kl@sultan-box/2-v2-media-platform-amd-Don-t-wait-for-cmd_done-under-.patch
Quoted 6 lines
Thank you very much, Sultan, for your outstanding contributions. We truly value your patches, testing efforts, debugging, and fixes. We intend to adopt most of your suggestions, but we will retain the definitions of struct
isp4fw_resp_param_packageand structisp4fw_buffer, along with their related implementations. These are shared with ISP FW, so keeping them helps us prevent potential issues from misalignment.
No problem, thanks for letting me know. And I'm happy to hear that my efforts are appreciated. :)
Quoted 3 lines
On the other hand, if you are agreeable, we would be pleased to add you as a co-developer.
Sure! :)
Sultan