From patchwork Wed Mar 3 17:04:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 11480 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 A5B57BD1F1 for ; Wed, 3 Mar 2021 17:04:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2BE9D68A9A; Wed, 3 Mar 2021 18:04:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eQH9NhWt"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BAD1868A7E for ; Wed, 3 Mar 2021 18:04:29 +0100 (CET) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 334C68CA; Wed, 3 Mar 2021 18:04:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614791069; bh=kxQxlT+lrxej072+vlEhrUPeDgjqoG4oz3kLgaHiRN8=; h=From:To:Cc:Subject:Date:From; b=eQH9NhWtsZeq12ilxyb/FCZwsm5TvFDFOvR9uGS0sj3+0wWGO1HPnI4DYKd+fKnuu x2/7whIywUYu/ezKPwluWqqs76Sr/f6UCMlUba1YYILbygYs51vAWvVIwKVCH1rrpN m8q1ymQ5XlDW87/6tY7u1t0jt9EusfWzBw9o67Ds= From: Kieran Bingham To: libcamera devel Date: Wed, 3 Mar 2021 17:04:23 +0000 Message-Id: <20210303170426.189648-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 0/3] IPU3 Stability 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" While working on the IPU3 IPA, some crashes have been occuring on shutdown races. Patches 2/3 and 3/3 at least presently work around those issues, and while they may be suitable for integration now - both suggest that more work is needed to ensure that the IPU3 pipeline handler is stable and implemented correctly. Patch 2/3 highlights that we may need to take more concern over the lifetime management of a Request and the associated FrameInfo that is supported with that. Patch 3/3 shows that the IPU3 Pipeline handler is queueing buffers after it has released the buffers on the video nodes, and needs further consideration as well (though I beleive that patch is still worthy of integration on it's own). The issue leading to what would be a crash without patch 3/3 is when shutting down, the IPA running in parallel can emit an event from: void IPU3CameraData::queueFrameAction() as case ipa::ipu3::ActionParamFilled: which then goes on to queue a buffer to the three relevant V4L2 devices: imgu_->param_->queueBuffer(info->paramBuffer); imgu_->stat_->queueBuffer(info->statBuffer); imgu_->input_->queueBuffer(info->rawBuffer); This is occuring after those devices have released their buffers, and thus the v4l2 buffer cache (cache_) is deleted and set to nullptr, resulting in a segmentation fault within the V4L2VideoDevice otherwise. Kieran Bingham (3): libcamera: pipeline: ipu3: Fix spelling error libcamera: pipeline: ipu3: Ensure that IPU3Frames::info is not used after delete libcamera: v4l2_videodevice: Prevent queueing buffers without a cache src/libcamera/pipeline/ipu3/frames.cpp | 2 +- src/libcamera/pipeline/ipu3/ipu3.cpp | 20 ++++++++++++++++++-- src/libcamera/v4l2_videodevice.cpp | 10 ++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) Tested-by: Jacopo Mondi