From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796096047; b=lyjNp4/yBF7KUpxFw1cgEW3M3UW4op7gKxrepaK0vFKK9X8UnJQbs3jwRg9zK7ITZaXS WGzNVL5ykSaNZj1kPdxX61icVyxq83gTUUUVbjY6LkZWURAkDXpKTsLID70E/KlZfFVCu IEeNLfSzvysYF+bNJ2R7pWkOVeWFRk7wJACti9uGj0F/2lpHOAeXMMzNG06sqUviNkLqN pvS9dIgvm3gqPNwZu1nn2iAR4nxQdlCi+ShGRcBdnyn2zPW138Xnb7K2aUF3w68NyZfjS rTGU/QqGLeQbi/4QTZiKXsslXjDiNNjdjd5/VU0keijDUEOL9RkDVO4I0SzOXML5CIg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796096047; h=Received:DKIM-Signature:Message-ID:Date:MIME-Version:User-Agent: Subject:Content-Language:To:Cc:References:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=21lzg/bZyQwnPACmtRxz94T2Q5ZhyHGD7V7iMNPjiW4=; b=MJEDnxPiB6cxSpKGYN+fG9qx8bKde8zP+6BN6DXJrArN9qNSHqusYo13RRKygy2ELnR6 ZELSbhLjqhoNmWPqzCLHv7Yhlo9LKTUKyx/02sFhAGbWOrUeodmV/VfN0qPBITNSKEW9n zp7WJuO+CopNi2zFoJyWdAe+uoBHejPkRJrqPxbpJ9ELHhLFaxaf+h8YJzSHE9DnIXFy4 d0yOGXcYIhdc0xcX0kSE449xUHBpDtCkOHPQAmoybCU0l5cDVeOODf/R4zGOOWOFngOi4 YWripTcPLTLc8qZFguiM34F4MmRI7ZDHG6CX5oBFDvThC5lmUeOHMcRuyJae7974dpA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BSq3kgKo; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 470F8606A31A; Tue, 1 Dec 2026 03:34:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=BSq3kgKo Received: by smtp.kernel.org (Postfix) with ESMTPSA id 188A31F00893; Tue, 1 Dec 2026 03:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796096046; bh=21lzg/bZyQwnPACmtRxz94T2Q5ZhyHGD7V7iMNPjiW4=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=BSq3kgKoFUza6hMlxlTd+KZO/Vak0TagwPeyvgICXA/1/lXQmT9cD4/7SWrZksu9Z MG39K6Huofstd8O4RcFzguahIJDdrLNuufxYfW1e7HcuUsmLYtjHBTWaO5X7t7Ubtj 1ihMzSnFMxWGlwV/K5DiMzBZw16OqdNyrZkwFFzFRpMM2zozER2VEP2iaz44P6eCtp fJc2BWAlk4+HUjKEmKoUb+g9SEQQ9iZBKGHDKkpjlaekqmvWiP8M1cYBL9WaHRg9uj z4Z5oVvXd6EmNNc3CQTyjaCWPPS2E2UbUA8ULCfIdVn510cNwb3R5Vg7aJhtk8Os09 k/x/iCdn78hZQ== Message-ID: <16072e48-919b-4e27-b7cd-9c118d5942b2@kernel.org> Date: Mon, 30 Nov 2026 21:34:03 -0600 X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path Content-Language: en-US To: Bin Du , mateoamadoares@gmail.com, Nirujogi Pratap , Mauro Carvalho Chehab Cc: Sakari Ailus , linux-media@vger.kernel.org, stable@vger.kernel.org, "Li, King" , "Chan, Benjamin (Koon Pan)" , devnull+caspar.adriani.proton.me@kernel.org References: <20261130-isp4-start-stream-deadlock-v1-0-9bf5a6647ef9@gmail.com> <20261130-isp4-start-stream-deadlock-v1-1-9bf5a6647ef9@gmail.com> <97a0a9ae-454d-4aa1-b78b-6bfc7e549c72@amd.com> From: Mario Limonciello In-Reply-To: <97a0a9ae-454d-4aa1-b78b-6bfc7e549c72@amd.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/30/26 21:06, Bin Du wrote: > Hi Mateo, > > Thanks for investigating and testing this. > > Caspar Adriani submitted the same fix on October 28: > https://lore.kernel.org/all/20261028-isp4-start-stream-deadlock-v1-1-babd80273148@proton.me/ > What's the hold up on merging that? It seems it's got tags up the wazoo and has been just sitting around. > Regards, > Bin > > On 12/1/2026 6:24 AM, Mateo Amado Ares via B4 Relay wrote: >> [You don't often get email from devnull+mateoamadoares.gmail.com@kernel.org. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] >> >> From: Mateo Amado Ares >> >> isp4sd_start_stream() holds ops_mutex via guard(mutex) and, when >> isp4sd_init_stream() or isp4sd_setup_output() fails, jumps to >> err_stop_stream and calls isp4sd_stop_stream(). That helper takes the >> same ops_mutex, re-acquiring a non-recursive mutex already held by the >> current thread, so any stream start failure deadlocks in VIDIOC_STREAMON: >> >> INFO: task ThreadPoolSingl:893936 blocked for more than 245 seconds. >> INFO: task ThreadPoolSingl:893936 is blocked on a mutex likely owned by task ThreadPoolSingl:893936. >> isp4sd_stop_stream.isra.0+0x52/0x200 [amd_isp4_capture] >> isp4sd_enable_streams.cold+0x60/0x2ad [amd_isp4_capture] >> v4l2_subdev_enable_streams+0x27f/0x400 [videodev] >> call_s_stream+0x48/0x110 [videodev] >> isp4vid_qops_start_streaming+0x114/0x190 [amd_isp4_capture] >> vb2_start_streaming+0x67/0x130 [videobuf2_common] >> vb2_core_streamon+0x98/0xf0 [videobuf2_common] >> >> The task is unkillable, every later open of the video node blocks on the >> same mutex, and the camera is unusable until reboot. >> >> Move the body of isp4sd_stop_stream() into __isp4sd_stop_stream(), which >> expects ops_mutex to be held, and call it from the error path. >> isp4sd_stop_stream() keeps taking the lock for the disable_streams path. >> >> This is the same bug as the one fixed in isp4sd_pwron_and_init() by >> commit ef46d80a7015 ("media: amd: isp4: fix self-deadlock in >> isp4sd_pwron_and_init() error path"). >> >> Fixes: 4e5e7a7ddb4a ("media: platform: amd: isp4 subdev and firmware loading handling added") >> Cc: stable@vger.kernel.org >> Assisted-by: Claude:claude-opus-5-5 >> Signed-off-by: Mateo Amado Ares >> --- >> drivers/media/platform/amd/isp4/isp4_subdev.c | 15 +++++++++++---- >> 1 file changed, 11 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/media/platform/amd/isp4/isp4_subdev.c b/drivers/media/platform/amd/isp4/isp4_subdev.c >> index a108d90..08512f0 100644 >> --- a/drivers/media/platform/amd/isp4/isp4_subdev.c >> +++ b/drivers/media/platform/amd/isp4/isp4_subdev.c >> @@ -745,15 +745,15 @@ err_module_disable: >> return -EINVAL; >> } >> >> -static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev, >> - struct v4l2_subdev_state *state, u32 pad) >> +static void __isp4sd_stop_stream(struct isp4_subdev *isp_subdev, >> + struct v4l2_subdev_state *state, u32 pad) >> { >> struct isp4sd_sensor_info *sensor_info = &isp_subdev->sensor_info; >> struct isp4sd_output_info *output_info = &sensor_info->output_info; >> struct isp4_interface *ispif = &isp_subdev->ispif; >> struct device *dev = isp_subdev->dev; >> >> - guard(mutex)(&isp_subdev->ops_mutex); >> + lockdep_assert_held(&isp_subdev->ops_mutex); >> dev_dbg(dev, "status %i\n", output_info->start_status); >> >> if (output_info->start_status == ISP4SD_START_STATUS_STARTED) { >> @@ -786,6 +786,13 @@ static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev, >> } >> >> isp4sd_uninit_stream(isp_subdev, state, pad); >> +} >> + >> +static int isp4sd_stop_stream(struct isp4_subdev *isp_subdev, >> + struct v4l2_subdev_state *state, u32 pad) >> +{ >> + guard(mutex)(&isp_subdev->ops_mutex); >> + __isp4sd_stop_stream(isp_subdev, state, pad); >> >> /* >> * Return success to ensure the stop process proceeds, >> @@ -836,7 +843,7 @@ static int isp4sd_start_stream(struct isp4_subdev *isp_subdev, >> return 0; >> >> err_stop_stream: >> - isp4sd_stop_stream(isp_subdev, state, pad); >> + __isp4sd_stop_stream(isp_subdev, state, pad); >> return ret; >> } >> >> >> -- >> 2.56.1 >> >