From nobody Thu Oct 9 13:34:55 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE1D0C2D1; Tue, 17 Jun 2025 13:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168458; cv=none; b=d2iQV0DfCRRNv1FW+PjvZPrt7MZYfLnFn37R2wo8VKcYsYWUOyhfZ683euA5f2iOTJRjFfZl5pkM2SNtoBsHavpd2RP/ZR2eSrt5/agAEWHFo7DNqtguc2BL0DRhy4kphFq942VTEbHq+mlFqneS7eumTDyE+vAeZbGjv31Vbm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168458; c=relaxed/simple; bh=t3v2gCfs3hvB2F8i2l+4fa99QiR0O16IHlX1eprudQU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZO/FAqodSDSdZX6x6hsi+QSQpYtc1WN6RkTFa3gSVb9VWVjJ9hBM7ua5FGLsMDRXyklLtlKz+IuwR7gtSPi9PKkk1VtyljfnkRtcbTz5IVQbKidTjwb8QUjWaxkBl/qYhofx8cs2tBejN4oE0xxXYoGi4pZ0Je/GB95ng7s8m6U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=lCg8jExe; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lCg8jExe" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id ECB242A4B; Tue, 17 Jun 2025 15:54:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750168442; bh=t3v2gCfs3hvB2F8i2l+4fa99QiR0O16IHlX1eprudQU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lCg8jExe+FK/U16zxToF1FnP0JTKhF+iLvsMrizss/kNRPN23uu82u3bMMXPaLzzT DPpgXcMWz/wZ13HRQTSd+N42g3jGhhipq0NTW7HFxNESlyhVdTFoQ6511XRu2WNhtD JF5JXhGxH5SzqXDHmCsE2auVMcsAu0GyL24FVO5g= From: Jacopo Mondi Date: Tue, 17 Jun 2025 15:53:59 +0200 Subject: [PATCH v8 1/4] media: pisp_be: Drop reference to non-existing function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-1-e58ae199c17d@ideasonboard.com> References: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> In-Reply-To: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> To: Naushir Patuck , Nick Hollinghurst , David Plowman , Dave Stevenson , Laurent Pinchart , Raspberry Pi Kernel Maintenance , Mauro Carvalho Chehab , Florian Fainelli , Broadcom internal kernel review list , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1264; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=t3v2gCfs3hvB2F8i2l+4fa99QiR0O16IHlX1eprudQU=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoUXOEefIqfHkyLanL11HSFQZXFl3/OcOSvD9DF T3Ct5kBOIeJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaFFzhAAKCRByNAaPFqFW PEmED/9uRRqnVk6h3i9fAs+SnLvMZo8sFhDHTiVIKnpcyGfIyCzHejwz0wG1eS8lqRiz94QKMQ0 xiLnF//2R+KUAHgqTMz0Mfht6fB3c3L5Pdo7EcmdMjmRjCTN53brl37Dze5L4bRf6CslTtcPW5D osQRCWnJ5T/c8XxTtQpYme3D6dJVavnMgFz3eOuHgrT1z/zhJh2H3d97PunPoPwlsjYi40QDBoF VpAFXexzgjnBL81EI1RyiGOASCN8t2hc+BliiI6/vIWsMV2ZLtWFi6jVAaflUViTHhWaeR57qvw vqKb1EwqR+Cfs/ZYLaQH9uCaGiyTR12ydW1nxqm84PsFHgdnJpr2e9c4noqLiQEnVLigYnAXtF3 1vZW6nU9qHRRfFNXl2heLCUwo5lIhRy27zE2OBF2zaYvr7tTm7nhaCSvzYXwXilJzSj27EvQ+Xn Ryh30xEQ/66UBaN5wwzArI9uEBE0uXZyJJQ8FiNT8r57CiBTdc4CSuwrKV4SC8yA2Y22h5EcGYM bInVn3ZsT7fx5XxNN44eQfERkoWD/MaxKsisU2msoFuZLHuoBYYyyLo4wSBpNcoKDM+e/J6A038 pg3g4sMnnxr8ovUtuG/BAg0vA+AxI2lk1/zdvKF905ZWs6vE2dFBIpBtvSxVEGPAgJCH9w2fcQ6 gkqxcfDT9x8cIdA== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B A comment in the pisp_be driver references the pispbe_schedule_internal() function which doesn't exist. Drop it. Reviewed-by: Laurent Pinchart Reviewed-by: Naushir Patuck Signed-off-by: Jacopo Mondi --- drivers/media/platform/raspberrypi/pisp_be/pisp_be.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c b/drivers= /media/platform/raspberrypi/pisp_be/pisp_be.c index 7596ae1f7de6671484d4d351015b234829f642d4..b1449245f39436d02c9c710916e= 2d0605606a327 100644 --- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c +++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c @@ -368,10 +368,7 @@ static void pispbe_xlate_addrs(struct pispbe_dev *pisp= be, ret =3D pispbe_get_planes_addr(addrs, buf[MAIN_INPUT_NODE], &pispbe->node[MAIN_INPUT_NODE]); if (ret <=3D 0) { - /* - * This shouldn't happen; pispbe_schedule_internal should insist - * on an input. - */ + /* Shouldn't happen, we have validated an input is available. */ dev_warn(pispbe->dev, "ISP-BE missing input\n"); hw_en->bayer_enables =3D 0; hw_en->rgb_enables =3D 0; --=20 2.49.0 From nobody Thu Oct 9 13:34:55 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5ACF2E2667; Tue, 17 Jun 2025 13:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168461; cv=none; b=Z6P3M49+afad8XON8sIMbW6+6RSHdVO77oA3xTZkDNb5w5TwbrsW1ODE8pz630Murf3C41GUyydqZ4owA0pMgyK0yVsvVNbPLbduiCZNtRRQPVg/lUJe+OyWZJwSyTtiJEaN0A6OVjp4D+0yQWHH7fwb4eFPxhXHICn5EMd1DmM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168461; c=relaxed/simple; bh=LQpsALkTPotTLV0L5B38pVMNZD6nPoEHZMe5t0uCYmY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ATpJ02sE9YbATUOdugYxrKIsVlg5iHLlFqzVIap2JBfZM9cANQV8YFTMqgreOLqA4oJ0m0iXR1VlT4uV0U9Bb5ctrNLrVWm0zcjf0Xh+lnJMX2YyIpQ3nV+lKJHmAU1RHz5jckUDA9pXJwDRlM6WH4lWcpbxkMgyH65LgBs7CeU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=NHU7vyyc; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="NHU7vyyc" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D7A762A6E; Tue, 17 Jun 2025 15:54:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750168443; bh=LQpsALkTPotTLV0L5B38pVMNZD6nPoEHZMe5t0uCYmY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NHU7vyycIFe0HBI4fykD18fkCNWRJLcihiOR6Xb9oRBhD/2MDLRHkuy4YcDM0yitV Q2fTWUGVLzkljeGrVyxnkFu2hSxHaj3Q9Ef6saGv1cppCXizoUXf0w2cNnTPHKcvdF 8i/ardEtnZow0qmslyN5HaJAtvfAFkesHcXL6sow= From: Jacopo Mondi Date: Tue, 17 Jun 2025 15:54:00 +0200 Subject: [PATCH v8 2/4] media: pisp_be: Remove config validation from schedule() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-2-e58ae199c17d@ideasonboard.com> References: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> In-Reply-To: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> To: Naushir Patuck , Nick Hollinghurst , David Plowman , Dave Stevenson , Laurent Pinchart , Raspberry Pi Kernel Maintenance , Mauro Carvalho Chehab , Florian Fainelli , Broadcom internal kernel review list , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3083; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=LQpsALkTPotTLV0L5B38pVMNZD6nPoEHZMe5t0uCYmY=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoUXOEe7cRNKLlBfoyNp4m4u6p8xuPVwbfvEjPn apV/+o47TWJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaFFzhAAKCRByNAaPFqFW PNckEACr0tkqemhNUDeWmwwqOg6XrM4nHAm6A1FMlo9IyBTo0B6fPO/frB3qCVVv9UPybKTrSgh 8GJ4j0yzPfhAyEBYpmNU2/ghXGCttalOPzgC8YU6prLapngYH4LXncVFsGPF19wqHNZk+9R8sBa ktooy16Cw6m4wfl5Huv+9YCZIQ7RuSpluTuiWzdOVSV1Iu+d/M02eDEiCrc1eu2A021VTL07TqK ZN22ZtJ6rmKIsKJihvYKuAnAufyjUOY7PhzKOcwFUCE4/YvqGni9wuQnnnfnE2jVhKNEVYguXCN mhaNqvnez8g6Nw1r4OvVw2TYzMtzkJq8BsZG2lXzwAjqtWKSSMTYLRsAbQ0MrDp3jbMgi1VwDgU MEjBJlbf9vMWwc5mH9xp0Hl+0NguN+9Tsn5q68essJCktZ8/FvP5dvWz7tLg5AwBMzC5TtWM3vp GhWOAaJHsSUbkkzhHz50Z07G9J52rfNX1FlQ2wmUT7psI5muXik0jTi5f6qxT67gmrh42HkTCvj xrGwj8QmbWXoxUoewggDR/uqYna5+4b8hLuTOQDqMMWb3j9NViIHGtHSZrvY/1Tpo5Z2z8FtSWs D21ZT9+xdBHBA6xqPQ4JOTBNXbm7D4FPO7Lk1OeHs9Rh9y7AgCPOqH1323BM33QHsHcPKUsn5l9 aIBenMFybodxJZw== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B The config parameters buffer is already validated in pisp_be_validate_config() at .buf_prepare() time. However some of the same validations are also performed at pispbe_schedule() time. In particular the function checks that: 1) config.num_tiles is valid 2) At least one of the BAYER or RGB input is enabled The input config validation is already performed in pisp_be_validate_config() and while job.hw_enables is modified by pispbe_xlate_addrs(), the function only resets the input masks if - there is no input buffer available, but pispbe_prepare_job() fails before calling pispbe_xlate_addrs() in this case - bayer_enable is 0, but in this case rgb_enable is valid as guaranteed by pisp_be_validate_config() - only outputs are reset in rgb_enable For this reasons there is no need to repeat the check at pispbe_schedule() time. The num_tiles validation can be moved to pisp_be_validate_config() as well. As num_tiles is a u32 it can'be be < 0, so change the sanity check accordingly. Reviewed-by: Laurent Pinchart Reviewed-by: Naushir Patuck Signed-off-by: Jacopo Mondi --- .../media/platform/raspberrypi/pisp_be/pisp_be.c | 25 ++++++------------= ---- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c b/drivers= /media/platform/raspberrypi/pisp_be/pisp_be.c index b1449245f39436d02c9c710916e2d0605606a327..92c452891d6c2d68aff9aa269c0= 6fa1af77e3885 100644 --- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c +++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c @@ -588,24 +588,6 @@ static void pispbe_schedule(struct pispbe_dev *pispbe,= bool clear_hw_busy) pispbe->hw_busy =3D true; spin_unlock_irqrestore(&pispbe->hw_lock, flags); =20 - if (job.config->num_tiles <=3D 0 || - job.config->num_tiles > PISP_BACK_END_NUM_TILES || - !((job.hw_enables.bayer_enables | job.hw_enables.rgb_enables) & - PISP_BE_BAYER_ENABLE_INPUT)) { - /* - * Bad job. We can't let it proceed as it could lock up - * the hardware, or worse! - * - * For now, just force num_tiles to 0, which causes the - * H/W to do something bizarre but survivable. It - * increments (started,done) counters by more than 1, - * but we seem to survive... - */ - dev_dbg(pispbe->dev, "Bad job: invalid number of tiles: %u\n", - job.config->num_tiles); - job.config->num_tiles =3D 0; - } - pispbe_queue_job(pispbe, &job); =20 return; @@ -703,6 +685,13 @@ static int pisp_be_validate_config(struct pispbe_dev *= pispbe, return -EIO; } =20 + if (config->num_tiles =3D=3D 0 || + config->num_tiles > PISP_BACK_END_NUM_TILES) { + dev_dbg(dev, "%s: Invalid number of tiles: %d\n", __func__, + config->num_tiles); + return -EINVAL; + } + /* Ensure output config strides and buffer sizes match the V4L2 formats. = */ fmt =3D &pispbe->node[TDN_OUTPUT_NODE].format; if (bayer_enables & PISP_BE_BAYER_ENABLE_TDN_OUTPUT) { --=20 2.49.0 From nobody Thu Oct 9 13:34:55 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C75092E266D; Tue, 17 Jun 2025 13:54:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168462; cv=none; b=QtsSQbu/TQOfemWrZFc2AZ0kpTFq0wmvbFz7NRqHWiRyXLXw70MvN2dsa88XOEUCvcn3hqNkSt0Oig2hDVE7Y9poW082jDgWXBVwYmwBqrY5eeH/V8TyhPLxSig1DsZNCaa6Kh/i9K77UrSL7TLIKAZbUn690+Tf13MrrunH1xA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168462; c=relaxed/simple; bh=zLWUmTcdF9adcPs5sOucY95zm4UbUzb7NCAlC66nylg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WVQ0cfr44txtDO/OUesTKmnUX4d1v3WLlTrw98trQdOTFda8zyiMsGGNUCsiqOGQKyYbPKDwRTC0g2I1XAAxWlhQ6aN00+uaLxP0+dy6Si2fxEd5gJy6syrW18Y5PUOT5DLaJDoLpp7s0ToUSUo6tt/lRZPKddsJLbEd3d8XfBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=dvD8y1ng; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dvD8y1ng" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C2944416A; Tue, 17 Jun 2025 15:54:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750168444; bh=zLWUmTcdF9adcPs5sOucY95zm4UbUzb7NCAlC66nylg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dvD8y1ngVsWGCCo34CnldmtYescnOeuQYyDnkSVsIpMdF6MQGq5sfCFgZkX3b0O9Q bCTaDN1GVDbWPnlcM3jzWnH5NqWFC9pgFdV8mQ8ssPHM28Dx+9cCyDc0m9nYnJT9G+ mA/dzPbSMzlKCYojruy/xhZ0MvWyjPbLP+MK0iwA= From: Jacopo Mondi Date: Tue, 17 Jun 2025 15:54:01 +0200 Subject: [PATCH v8 3/4] media: pisp_be: Split jobs creation and scheduling Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-3-e58ae199c17d@ideasonboard.com> References: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> In-Reply-To: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> To: Naushir Patuck , Nick Hollinghurst , David Plowman , Dave Stevenson , Laurent Pinchart , Raspberry Pi Kernel Maintenance , Mauro Carvalho Chehab , Florian Fainelli , Broadcom internal kernel review list , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=13294; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=zLWUmTcdF9adcPs5sOucY95zm4UbUzb7NCAlC66nylg=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoUXOET8qwukmp2Xr6MaHpwF3jHH7/SeoNsYEaU SW/vnHaR72JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaFFzhAAKCRByNAaPFqFW PHwDD/9uo9s5b4CVlyjoBUwIQYK0FR4bnGigRubQRk1W79XQfYDot2z6yArmWRkrAy0l2CeuFMw eSHPYoYhjR3vGrS6XAKpkvFLNtk6rCVAa2HvHyudk0BvbX27pDqEVjsPQFwJMzS9e3j890MfdnZ RGad4WEMBsUVawc8+77FCptBZVtNVQSPFQxtC4dI4yihReuCkD8VNnO86vtEIlZSTghUFQAkIB5 KerMlrVjptvdsShbNZwrBTX2HPcANeIyHWhcJpU1rDMtzIL5d3tf7Z0yYGmgKy6umpkleA4+Xjg 5k5VcKF9xcINfNIgSjSzo8oSdmegoLLTyN3d1zCawLIXVnZVenrvtkGMw1wqSb1Pu8LdPCrPQNa zp8UbWcImVGJ2tKZVJTM5c3bg9Lt4MoBGrhH+tyzRzsCrYEMDZYszYHNnKIVA0PgKQfBbmOGXLB SQ0PyMX9Tqeimh5vq0oqDkPQwIlX6PInvQTEs/XhI+f/39ky3/xbwIcBLe7if1nxcHsf/zSug3B iTMsM5iZj6c5Jnsoevz80H5n9e5e0OVvhmFf2tSZXH4JeVBcoJGLuRDRWMnbDnteucIdFvPWG+H F8PPoqdpVbxPhAtbwP+7766na73JU/KyPeZfBxyEiTQBHrXnjXlJORLzlzeUFOBlpzommpFV4rk BFNz2IYdy33M8Tw== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B Currently the 'pispbe_schedule()' function does two things: 1) Tries to assemble a job by inspecting all the video node queues to make sure all the required buffers are available 2) Submit the job to the hardware The pispbe_schedule() function is called at: - video device start_streaming() time - video device qbuf() time - irq handler As assembling a job requires inspecting all queues, it is a rather time consuming operation which is better not run in IRQ context. To avoid executing the time consuming job creation in interrupt context split the job creation and job scheduling in two distinct operations. When a well-formed job is created, append it to the newly introduced 'pispbe->job_queue' where it will be dequeued from by the scheduling routine. As the per-node 'ready_queue' buffer list is only accessed in vb2 ops callbacks, protected by the node->queue_lock mutex, it is not necessary to guard it with a dedicated spinlock so drop it. Also use the spin_lock_irq() variant in all functions not called from an IRQ context where the spin_lock_irqsave() version was used. Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- .../media/platform/raspberrypi/pisp_be/pisp_be.c | 161 +++++++++++------= ---- 1 file changed, 87 insertions(+), 74 deletions(-) diff --git a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c b/drivers= /media/platform/raspberrypi/pisp_be/pisp_be.c index 92c452891d6c2d68aff9aa269c06fa1af77e3885..ccc6cb99868b842ac0d295f9ec2= 8470303e60788 100644 --- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c +++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -161,8 +162,6 @@ struct pispbe_node { struct mutex node_lock; /* vb2_queue lock */ struct mutex queue_lock; - /* Protect pispbe_node->ready_queue and pispbe_buffer->ready_list */ - spinlock_t ready_lock; struct list_head ready_queue; struct vb2_queue queue; struct v4l2_format format; @@ -190,6 +189,8 @@ struct pispbe_hw_enables { =20 /* Records a job configuration and memory addresses. */ struct pispbe_job_descriptor { + struct list_head queue; + struct pispbe_buffer *buffers[PISPBE_NUM_NODES]; dma_addr_t hw_dma_addrs[N_HW_ADDRESSES]; struct pisp_be_tiles_config *config; struct pispbe_hw_enables hw_enables; @@ -215,8 +216,10 @@ struct pispbe_dev { unsigned int sequence; u32 streaming_map; struct pispbe_job queued_job, running_job; - spinlock_t hw_lock; /* protects "hw_busy" flag and streaming_map */ + /* protects "hw_busy" flag, streaming_map and job_queue */ + spinlock_t hw_lock; bool hw_busy; /* non-zero if a job is queued or is being started */ + struct list_head job_queue; int irq; u32 hw_version; u8 done, started; @@ -440,42 +443,48 @@ static void pispbe_xlate_addrs(struct pispbe_dev *pis= pbe, * For Output0, Output1, Tdn and Stitch, a buffer only needs to be * available if the blocks are enabled in the config. * - * Needs to be called with hw_lock held. + * If all the buffers required to form a job are available, append the + * job descriptor to the job queue to be later queued to the HW. * * Returns 0 if a job has been successfully prepared, < 0 otherwise. */ -static int pispbe_prepare_job(struct pispbe_dev *pispbe, - struct pispbe_job_descriptor *job) +static int pispbe_prepare_job(struct pispbe_dev *pispbe) { + struct pispbe_job_descriptor __free(kfree) *job =3D NULL; struct pispbe_buffer *buf[PISPBE_NUM_NODES] =3D {}; + unsigned int streaming_map; unsigned int config_index; struct pispbe_node *node; - unsigned long flags; =20 - lockdep_assert_held(&pispbe->hw_lock); + lockdep_assert_irqs_enabled(); =20 - memset(job, 0, sizeof(struct pispbe_job_descriptor)); + scoped_guard(spinlock_irq, &pispbe->hw_lock) { + static const u32 mask =3D BIT(CONFIG_NODE) | BIT(MAIN_INPUT_NODE); =20 - if (((BIT(CONFIG_NODE) | BIT(MAIN_INPUT_NODE)) & - pispbe->streaming_map) !=3D - (BIT(CONFIG_NODE) | BIT(MAIN_INPUT_NODE))) - return -ENODEV; + if ((pispbe->streaming_map & mask) !=3D mask) + return -ENODEV; + + /* + * Take a copy of streaming_map: nodes activated after this + * point are ignored when preparing this job. + */ + streaming_map =3D pispbe->streaming_map; + } + + job =3D kzalloc(sizeof(*job), GFP_KERNEL); + if (!job) + return -ENOMEM; =20 node =3D &pispbe->node[CONFIG_NODE]; - spin_lock_irqsave(&node->ready_lock, flags); buf[CONFIG_NODE] =3D list_first_entry_or_null(&node->ready_queue, struct pispbe_buffer, ready_list); - if (buf[CONFIG_NODE]) { - list_del(&buf[CONFIG_NODE]->ready_list); - pispbe->queued_job.buf[CONFIG_NODE] =3D buf[CONFIG_NODE]; - } - spin_unlock_irqrestore(&node->ready_lock, flags); - - /* Exit early if no config buffer has been queued. */ if (!buf[CONFIG_NODE]) return -ENODEV; =20 + list_del(&buf[CONFIG_NODE]->ready_list); + job->buffers[CONFIG_NODE] =3D buf[CONFIG_NODE]; + config_index =3D buf[CONFIG_NODE]->vb.vb2_buf.index; job->config =3D &pispbe->config[config_index]; job->tiles =3D pispbe->config_dma_addr + @@ -495,7 +504,7 @@ static int pispbe_prepare_job(struct pispbe_dev *pispbe, continue; =20 buf[i] =3D NULL; - if (!(pispbe->streaming_map & BIT(i))) + if (!(streaming_map & BIT(i))) continue; =20 if ((!(rgb_en & PISP_BE_RGB_ENABLE_OUTPUT0) && @@ -522,25 +531,28 @@ static int pispbe_prepare_job(struct pispbe_dev *pisp= be, node =3D &pispbe->node[i]; =20 /* Pull a buffer from each V4L2 queue to form the queued job */ - spin_lock_irqsave(&node->ready_lock, flags); buf[i] =3D list_first_entry_or_null(&node->ready_queue, struct pispbe_buffer, ready_list); if (buf[i]) { list_del(&buf[i]->ready_list); - pispbe->queued_job.buf[i] =3D buf[i]; + job->buffers[i] =3D buf[i]; } - spin_unlock_irqrestore(&node->ready_lock, flags); =20 if (!buf[i] && !ignore_buffers) goto err_return_buffers; } =20 - pispbe->queued_job.valid =3D true; - /* Convert buffers to DMA addresses for the hardware */ pispbe_xlate_addrs(pispbe, job, buf); =20 + scoped_guard(spinlock_irq, &pispbe->hw_lock) { + list_add_tail(&job->queue, &pispbe->job_queue); + } + + /* Set job to NULL to avoid automatic release due to __free(). */ + job =3D NULL; + return 0; =20 err_return_buffers: @@ -551,33 +563,37 @@ static int pispbe_prepare_job(struct pispbe_dev *pisp= be, continue; =20 /* Return the buffer to the ready_list queue */ - spin_lock_irqsave(&n->ready_lock, flags); list_add(&buf[i]->ready_list, &n->ready_queue); - spin_unlock_irqrestore(&n->ready_lock, flags); } =20 - memset(&pispbe->queued_job, 0, sizeof(pispbe->queued_job)); - return -ENODEV; } =20 static void pispbe_schedule(struct pispbe_dev *pispbe, bool clear_hw_busy) { - struct pispbe_job_descriptor job; - unsigned long flags; - int ret; + struct pispbe_job_descriptor *job; + + scoped_guard(spinlock_irqsave, &pispbe->hw_lock) { + if (clear_hw_busy) + pispbe->hw_busy =3D false; =20 - spin_lock_irqsave(&pispbe->hw_lock, flags); + if (pispbe->hw_busy) + return; =20 - if (clear_hw_busy) - pispbe->hw_busy =3D false; + job =3D list_first_entry_or_null(&pispbe->job_queue, + struct pispbe_job_descriptor, + queue); + if (!job) + return; =20 - if (pispbe->hw_busy) - goto unlock_and_return; + list_del(&job->queue); =20 - ret =3D pispbe_prepare_job(pispbe, &job); - if (ret) - goto unlock_and_return; + for (unsigned int i =3D 0; i < PISPBE_NUM_NODES; i++) + pispbe->queued_job.buf[i] =3D job->buffers[i]; + pispbe->queued_job.valid =3D true; + + pispbe->hw_busy =3D true; + } =20 /* * We can kick the job off without the hw_lock, as this can @@ -585,16 +601,8 @@ static void pispbe_schedule(struct pispbe_dev *pispbe,= bool clear_hw_busy) * only when the following job has been queued and an interrupt * is rised. */ - pispbe->hw_busy =3D true; - spin_unlock_irqrestore(&pispbe->hw_lock, flags); - - pispbe_queue_job(pispbe, &job); - - return; - -unlock_and_return: - /* No job has been queued, just release the lock and return. */ - spin_unlock_irqrestore(&pispbe->hw_lock, flags); + pispbe_queue_job(pispbe, job); + kfree(job); } =20 static void pispbe_isr_jobdone(struct pispbe_dev *pispbe, @@ -846,18 +854,16 @@ static void pispbe_node_buffer_queue(struct vb2_buffe= r *buf) container_of(vbuf, struct pispbe_buffer, vb); struct pispbe_node *node =3D vb2_get_drv_priv(buf->vb2_queue); struct pispbe_dev *pispbe =3D node->pispbe; - unsigned long flags; =20 dev_dbg(pispbe->dev, "%s: for node %s\n", __func__, NODE_NAME(node)); - spin_lock_irqsave(&node->ready_lock, flags); list_add_tail(&buffer->ready_list, &node->ready_queue); - spin_unlock_irqrestore(&node->ready_lock, flags); =20 /* * Every time we add a buffer, check if there's now some work for the hw * to do. */ - pispbe_schedule(pispbe, false); + if (!pispbe_prepare_job(pispbe)) + pispbe_schedule(pispbe, false); } =20 static int pispbe_node_start_streaming(struct vb2_queue *q, unsigned int c= ount) @@ -865,17 +871,16 @@ static int pispbe_node_start_streaming(struct vb2_que= ue *q, unsigned int count) struct pispbe_node *node =3D vb2_get_drv_priv(q); struct pispbe_dev *pispbe =3D node->pispbe; struct pispbe_buffer *buf, *tmp; - unsigned long flags; int ret; =20 ret =3D pm_runtime_resume_and_get(pispbe->dev); if (ret < 0) goto err_return_buffers; =20 - spin_lock_irqsave(&pispbe->hw_lock, flags); - node->pispbe->streaming_map |=3D BIT(node->id); - node->pispbe->sequence =3D 0; - spin_unlock_irqrestore(&pispbe->hw_lock, flags); + scoped_guard(spinlock_irq, &pispbe->hw_lock) { + node->pispbe->streaming_map |=3D BIT(node->id); + node->pispbe->sequence =3D 0; + } =20 dev_dbg(pispbe->dev, "%s: for node %s (count %u)\n", __func__, NODE_NAME(node), count); @@ -883,17 +888,16 @@ static int pispbe_node_start_streaming(struct vb2_que= ue *q, unsigned int count) node->pispbe->streaming_map); =20 /* Maybe we're ready to run. */ - pispbe_schedule(pispbe, false); + if (!pispbe_prepare_job(pispbe)) + pispbe_schedule(pispbe, false); =20 return 0; =20 err_return_buffers: - spin_lock_irqsave(&pispbe->hw_lock, flags); list_for_each_entry_safe(buf, tmp, &node->ready_queue, ready_list) { list_del(&buf->ready_list); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_QUEUED); } - spin_unlock_irqrestore(&pispbe->hw_lock, flags); =20 return ret; } @@ -902,8 +906,9 @@ static void pispbe_node_stop_streaming(struct vb2_queue= *q) { struct pispbe_node *node =3D vb2_get_drv_priv(q); struct pispbe_dev *pispbe =3D node->pispbe; + struct pispbe_job_descriptor *job, *temp; struct pispbe_buffer *buf; - unsigned long flags; + LIST_HEAD(tmp_list); =20 /* * Now this is a bit awkward. In a simple M2M device we could just wait @@ -915,11 +920,7 @@ static void pispbe_node_stop_streaming(struct vb2_queu= e *q) * This may return buffers out of order. */ dev_dbg(pispbe->dev, "%s: for node %s\n", __func__, NODE_NAME(node)); - spin_lock_irqsave(&pispbe->hw_lock, flags); do { - unsigned long flags1; - - spin_lock_irqsave(&node->ready_lock, flags1); buf =3D list_first_entry_or_null(&node->ready_queue, struct pispbe_buffer, ready_list); @@ -927,15 +928,26 @@ static void pispbe_node_stop_streaming(struct vb2_que= ue *q) list_del(&buf->ready_list); vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); } - spin_unlock_irqrestore(&node->ready_lock, flags1); } while (buf); - spin_unlock_irqrestore(&pispbe->hw_lock, flags); =20 vb2_wait_for_all_buffers(&node->queue); =20 - spin_lock_irqsave(&pispbe->hw_lock, flags); + spin_lock_irq(&pispbe->hw_lock); pispbe->streaming_map &=3D ~BIT(node->id); - spin_unlock_irqrestore(&pispbe->hw_lock, flags); + + if (pispbe->streaming_map =3D=3D 0) { + /* + * If all nodes have stopped streaming release all jobs + * without holding the lock. + */ + list_splice_init(&pispbe->job_queue, &tmp_list); + } + spin_unlock_irq(&pispbe->hw_lock); + + list_for_each_entry_safe(job, temp, &tmp_list, queue) { + list_del(&job->queue); + kfree(job); + } =20 pm_runtime_mark_last_busy(pispbe->dev); pm_runtime_put_autosuspend(pispbe->dev); @@ -1393,7 +1405,6 @@ static int pispbe_init_node(struct pispbe_dev *pispbe= , unsigned int id) mutex_init(&node->node_lock); mutex_init(&node->queue_lock); INIT_LIST_HEAD(&node->ready_queue); - spin_lock_init(&node->ready_lock); =20 node->format.type =3D node->buf_type; pispbe_node_def_fmt(node); @@ -1677,6 +1688,8 @@ static int pispbe_probe(struct platform_device *pdev) if (!pispbe) return -ENOMEM; =20 + INIT_LIST_HEAD(&pispbe->job_queue); + dev_set_drvdata(&pdev->dev, pispbe); pispbe->dev =3D &pdev->dev; platform_set_drvdata(pdev, pispbe); --=20 2.49.0 From nobody Thu Oct 9 13:34:55 2025 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3A452E8881; Tue, 17 Jun 2025 13:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168464; cv=none; b=Jjx6tdpnWLnnn7Uvbnsg9YNRJ/v7a+u0Uv5JkAlWvPL/THvGfR03nxsydJMY0+pvxeJuEaF1AZiFCuvBNZWlS6CKpj5JrlVbo7zAqY+J6oJBGZTcqmGvXxMp3wN1lvp/Gxj37r62NHgX/xnRY4ToWUk0MXzyulM46fGZ4IPNt5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750168464; c=relaxed/simple; bh=+zqqmKIUftUfrElMykNoEhWSaAdLvXt5iznvaoygcTU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MUu4ZOjCbrud3m6PH5QPI5V9Epe2t0Sh0xEqpbS7hbw7YX0bQl57VUl5xchY6jzeIEBYmhcTJwvnATi+dQPwYSQuhpAKeACOMdMQwH+79zBr2Chabu8QwdpA6La0wjNmbwZeDeTvtWThFofGP++wng+LF2erwPEWOEf5dpgfAvg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=HZx1zX53; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HZx1zX53" Received: from [192.168.1.102] (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BE7BA4371; Tue, 17 Jun 2025 15:54:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750168445; bh=+zqqmKIUftUfrElMykNoEhWSaAdLvXt5iznvaoygcTU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HZx1zX53qc58axyY+buCnKjSNgBYyNb281iQ+d8JoeKYrFZZWX3+Uq7/tc9kqNKlx a1/Qcm2aoy5sOg+iSbY+pNP1HmmG87SmilEjPDO3A0IytziFsH+5ccIqEEf/s2TiPZ 22rJvmVLKMOIunr402Td3u51fw2mZjU5VIXmY+WI= From: Jacopo Mondi Date: Tue, 17 Jun 2025 15:54:02 +0200 Subject: [PATCH v8 4/4] media: pisp_be: Fix pm_runtime underrun in probe Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-4-e58ae199c17d@ideasonboard.com> References: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> In-Reply-To: <20250617-pispbe-mainline-split-jobs-handling-v6-v8-0-e58ae199c17d@ideasonboard.com> To: Naushir Patuck , Nick Hollinghurst , David Plowman , Dave Stevenson , Laurent Pinchart , Raspberry Pi Kernel Maintenance , Mauro Carvalho Chehab , Florian Fainelli , Broadcom internal kernel review list , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jacopo Mondi , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3265; i=jacopo.mondi@ideasonboard.com; h=from:subject:message-id; bh=+zqqmKIUftUfrElMykNoEhWSaAdLvXt5iznvaoygcTU=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoUXOEbA+dXnVyiD4fxG8s5bJd//kD7Vj5ntMJc MB1aGNB5uSJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaFFzhAAKCRByNAaPFqFW PO2QD/9FWbjUfguHOEg9Va0TjkdMBLIiy4tT32D8DssRg/qq2p4rWJPSjE1Hjabozj8wAgpJ8Br puM+Lgw2lxhq1t5DSJvKQkkEirD3uedtCHet2vwU95CswdHsnqljKsytl67N623aNIgE9cVBEYF APlOPUuY81umvgcQeYmTVdvOHGXphD5IRSuJPDiXb+FcxZWozgMIkkM3Mc5muYq6RImez9DGOKT iT9C/A1isjiYMu3nYac3kMWods8nBeibf/nsrblNt3dvEo0mRqwUf/S+YunHLZMH1+8GZasW1SB H5Uh4zeUlPKLBChdkjBJDZBMCUAlPPcfMxb46pYfmw/iZvZ3yU16Q5o9r9uwVBztwBGkdOK2yGQ K2vmzZMSPFPzaxKPfXkb77G2QVOBxFId3FwBaXQwcviPRoEyPvonGhpb/Zs3BzsDr0RH0eo407D CjRtH6tQo/KXPI14oFJGBY4JczLbJjK6zxtTtVM4baqlfZxakT6zXDS7qsE6+iQJM3JqYTDR2sr PNY2qS9g8jZ5AkyURyU7s5FeHytuA8Qd/pJhqXaCFGQWiel6O2DR33bBjXww6HGkQ+WxWTo4ucL Fw0sAxJZyaETE+CFXpcjIrtDpwelnpBxtr2B90KZs4joHTNuCJcFaUgPDdrEZFBP8jr6XjzubjE 1rp2/O83LtcxvZw== X-Developer-Key: i=jacopo.mondi@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B During the probe() routine, the PiSP BE driver needs to power up the interface in order to identify and initialize the hardware. The driver resumes the interface by calling the pispbe_runtime_resume() function directly, without going through the pm_runtime helpers, but later suspends it by calling pm_runtime_put_autosuspend(). This causes a PM usage count imbalance at probe time, notified by the runtime_pm framework with the below message in the system log: pispbe 1000880000.pisp_be: Runtime PM usage count underflow! Fix this by resuming the interface using the pm runtime helpers instead of calling the resume function directly and use the pm_runtime framework in the probe() error path. While at it, remove manual suspend of the interface in the remove() function. The driver cannot be unloaded if in use, so simply disable runtime pm. To simplify the implementation, make the driver depend on PM as the RPI5 platform where the ISP is integrated in uses the PM framework by default. Fixes: 12187bd5d4f8 ("media: raspberrypi: Add support for PiSP BE") Cc: stable@vger.kernel.org Reviewed-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- drivers/media/platform/raspberrypi/pisp_be/Kconfig | 1 + drivers/media/platform/raspberrypi/pisp_be/pisp_be.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/raspberrypi/pisp_be/Kconfig b/drivers/m= edia/platform/raspberrypi/pisp_be/Kconfig index 46765a2e4c4d1573757ff842f208834216e582cb..a9e51fd94aadc6add70f883bfce= a0c9fa91f0c4b 100644 --- a/drivers/media/platform/raspberrypi/pisp_be/Kconfig +++ b/drivers/media/platform/raspberrypi/pisp_be/Kconfig @@ -3,6 +3,7 @@ config VIDEO_RASPBERRYPI_PISP_BE depends on V4L_PLATFORM_DRIVERS depends on VIDEO_DEV depends on ARCH_BCM2835 || COMPILE_TEST + depends on PM select VIDEO_V4L2_SUBDEV_API select MEDIA_CONTROLLER select VIDEOBUF2_DMA_CONTIG diff --git a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c b/drivers= /media/platform/raspberrypi/pisp_be/pisp_be.c index ccc6cb99868b842ac0d295f9ec28470303e60788..be794a12362020f42b3cf5bd291= b4a1625543b5f 100644 --- a/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c +++ b/drivers/media/platform/raspberrypi/pisp_be/pisp_be.c @@ -1725,7 +1725,7 @@ static int pispbe_probe(struct platform_device *pdev) pm_runtime_use_autosuspend(pispbe->dev); pm_runtime_enable(pispbe->dev); =20 - ret =3D pispbe_runtime_resume(pispbe->dev); + ret =3D pm_runtime_resume_and_get(pispbe->dev); if (ret) goto pm_runtime_disable_err; =20 @@ -1747,7 +1747,7 @@ static int pispbe_probe(struct platform_device *pdev) disable_devs_err: pispbe_destroy_devices(pispbe); pm_runtime_suspend_err: - pispbe_runtime_suspend(pispbe->dev); + pm_runtime_put(pispbe->dev); pm_runtime_disable_err: pm_runtime_dont_use_autosuspend(pispbe->dev); pm_runtime_disable(pispbe->dev); @@ -1761,7 +1761,6 @@ static void pispbe_remove(struct platform_device *pde= v) =20 pispbe_destroy_devices(pispbe); =20 - pispbe_runtime_suspend(pispbe->dev); pm_runtime_dont_use_autosuspend(pispbe->dev); pm_runtime_disable(pispbe->dev); } --=20 2.49.0