From patchwork Tue Feb 25 15:06:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22856 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 2A9FCBDB1C for ; Tue, 25 Feb 2025 15:06:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 31D8C6871B; Tue, 25 Feb 2025 16:06:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="CNQt4P4N"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E886F61855 for ; Tue, 25 Feb 2025 16:06:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1740495987; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ltUI7n+ag8/V7R4VnurUD0hejTzdqxzCZbSFYuIAyaM=; b=CNQt4P4Nqetd1dWvmYrDympqHtzaYkTjfOCdpHV/DHf2GbPZCQCTd4zJXpah3RUHzRBDtN EgoZN9yL3ius79TpgsE/KORijOpdNONPtAb3kI7NtaEAFiFkqleQ6JVSWKBcgboChIIuGo wBGlPgUtxHreu9Wqr3ltLfkelIRhDP0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-50-mLGxJUFVMP-Mp_Q2KdVTRg-1; Tue, 25 Feb 2025 10:06:24 -0500 X-MC-Unique: mLGxJUFVMP-Mp_Q2KdVTRg-1 X-Mimecast-MFC-AGG-ID: mLGxJUFVMP-Mp_Q2KdVTRg_1740495983 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 09BD5180056F; Tue, 25 Feb 2025 15:06:23 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.45.224.119]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1A4C5180035F; Tue, 25 Feb 2025 15:06:20 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Stanislaw Gruszka , Laurent Pinchart , Kieran Bingham Subject: [PATCH v3 0/6] Fix occasional software ISP assertion error on stop Date: Tue, 25 Feb 2025 16:06:06 +0100 Message-ID: <20250225150614.20195-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gHOmZSrA30MZfL_Kpug9zHn6xdpirxBSTEFU4xEtBrk_1740495983 X-Mimecast-Originator: redhat.com X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" When software ISP is stopped, there can be pending messages in the message queue that will attempt to call the already stopped IPA, resulting in an assertion error like this: FATAL default soft_ipa_proxy.cpp:456 assertion "state_ == ProxyRunning" failed in processStatsThread() This patch series fixes the problem and also attempts to prevent other problems related to message handling when or after software ISP is stopped. Changes in v3: - Missing include added. - I/O buffers are popped from the deque’s of queued buffers rather than searched there + assertion to check it’s the intended buffer added. - Returned pending input buffers are canceled. - The thread.cpp formatting patch dropped. - The dispatching modifications patch split to several patches as suggested by Laurent. - Thread::removeMessages() documentation improved as suggested by Laurent. - SoftwareIsp::running_ dropped in the patch adding explicit SoftwareIsp messages removal. - Formatting fixes suggested by Laurent. Changes in v2: - The receiver check in Thread::dispatchMessages moved to the right place. Milan Zamazal (6): libcamera: software_isp: Emit ispStatsReady only if IPA is running libcamera: software_isp: Handle queued output buffers on stop libcamera: software_isp: Handle queued input buffers on stop libcamera: base: thread: Support dispatching for a specific receiver libcamera: software_isp: Dispatch messages on stop utils: ipc: Only dispatch messages for proxy when stopping thread include/libcamera/base/thread.h | 3 +- .../internal/software_isp/software_isp.h | 3 ++ src/libcamera/base/thread.cpp | 21 ++++++----- src/libcamera/software_isp/software_isp.cpp | 36 +++++++++++++++++-- .../libcamera_templates/proxy_functions.tmpl | 2 +- 5 files changed, 53 insertions(+), 12 deletions(-) Tested-by: Stanislaw Gruszka