From nobody Thu Oct 9 20:25:17 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 CA0A4288504; Mon, 16 Jun 2025 16:30:50 +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=1750091452; cv=none; b=mZ4ie9X4PEbh44bhQzUW7v/XomaujrzIyjpRkQmaQTL58nOU81FaIiIYy8vIsq2fKP92GfcP9valrOs4MauOeSGcyJ+hFjT88lVE68ND+b2KdAqXhkqDb8Lhvat5iO4YE2xFciIPal5vATqGv5MGMj0Nf+OXoFl6fF99k3UmgdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750091452; c=relaxed/simple; bh=c/F3YDMzIOEB6Wh0HFZbiwLZKlVEVxQsVuqbS/vOm1Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hA5l6UtKZaQg4tK/Y1ve1bobtN1HTErJSHECvXhmYu429SJSvcUEeXHjOnNnb7eB5RancFIJ0pTIBBrmnkQQNXKLfaNk3I8EmOeCjHRjzCMaz8k9Xe652/OQTPzXXQOWvj3HpCJiO293tJrcekLzT0OXa9aIHzcr7fhq7WNGyi4= 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=qzgr2Frw; 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="qzgr2Frw" Received: from [192.168.0.172] (mob-5-90-141-184.net.vodafone.it [5.90.141.184]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DA0C3C64; Mon, 16 Jun 2025 18:30:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750091437; bh=c/F3YDMzIOEB6Wh0HFZbiwLZKlVEVxQsVuqbS/vOm1Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qzgr2FrwWDXNFS+KVsvRQjX5cPFQ8kE83mnkXZfPW6ISqeWOv55wasmOOFNdwrx0r Eo6bElkA4eMOC5eTg/E/y8u0Bgh2g6b1vwZIBMzT4O4K5pPKJ8tH0Sm9UOepQSEeau KKSXIohva0r1np1RfczU9NmCj2oY5QAhIzQw511w= From: Jacopo Mondi Date: Mon, 16 Jun 2025 18:30:37 +0200 Subject: [PATCH v2 1/2] media: vsp1: vsp1_dl: Detect double list release 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: <20250616-vsp1_dl_list_count-v2-1-7d3f43fb1306@ideasonboard.com> References: <20250616-vsp1_dl_list_count-v2-0-7d3f43fb1306@ideasonboard.com> In-Reply-To: <20250616-vsp1_dl_list_count-v2-0-7d3f43fb1306@ideasonboard.com> To: Laurent Pinchart , Kieran Bingham , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2095; i=jacopo.mondi+renesas@ideasonboard.com; h=from:subject:message-id; bh=c/F3YDMzIOEB6Wh0HFZbiwLZKlVEVxQsVuqbS/vOm1Q=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoUEa3X/a4NoGuLPxH9evmEVCoXp0Is0h9gDwZq 8nX0kdWgm2JAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaFBGtwAKCRByNAaPFqFW PMakD/91zbeazs+qQDvuLiCOvaIXb8eTBwDDKMb2O4SWbtUxyWOiDMNHS9HBZ6SWxUUxHg2qUvq AqZJhcZgNYrxmmTlHj48+PQgaMVhcFpXrFs9aQ70vrk/uSpLf5AhAXzuzWllkEO9rWzvO0FFPLU WqyReV8JJIZvsAv6nGMSivseOplzChECvOr4c/b4Z1JpO9IUEYmY18sGe6e27kZEdJiaWqI9st2 vPQfF1upGCG3oDHblaZxUIkGkmftSmLNVtwx/hT/2GC3ZTXi9bnXLvBiPfnHSANksuDyPZpkoy7 yxeaT36dkQntk9qdyXcwYPeAJ3HIpxmg5dTJianFPouBKtpV25TJNCC8VOTrIS6kCfzAI2wnRhr kcsx+KQyGf29G0gssidU7U+qZS3dmdKGDdtgogo9zZz240Jo3ZcOs3eB1eu/IxKGrin0uABEPOI qXDEyE3f3e8OvbbjhLnLjlyPhtVCLC0fjasHW76B71VZbTE4yZUJonFeT769ZJ0d185M/yvTDJo Mty5u+vc9mGXduUdyg4lAEsL6jVKz5PxUYcHo6jTh8dmTlreG2L8zO6nMg78lwoJI0MfUQGdYAm vsmbWGoFqaESZaVU9x0YGz/GmMWB473kqc+lw4PNkMitb/EpPTs3lnchRMRuYxVWOzYQM0SCIZv syAViOHvY5sq2ug== X-Developer-Key: i=jacopo.mondi+renesas@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B In order to detect invalid usage pattern such as double list_put() calls, add an 'allocated' flag to each display list. Set the flag whenever a list is get() and clear it when the list is put(). Warn if a list not marked as allocated is returned to the pool of available display lists. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/platform/renesas/vsp1/vsp1_dl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_dl.c b/drivers/media/= platform/renesas/vsp1/vsp1_dl.c index bb8228b198249943399719b5f37c337fc43eed5b..18617cbb168703b851a9b437fa6= 2f18425934c68 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_dl.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_dl.c @@ -176,6 +176,7 @@ struct vsp1_dl_cmd_pool { * @bodies: list of extra display list bodies * @pre_cmd: pre command to be issued through extended dl header * @post_cmd: post command to be issued through extended dl header + * @allocated: flag to detect double list release * @has_chain: if true, indicates that there's a partition chain * @chain: entry in the display list partition chain * @flags: display list flags, a combination of VSP1_DL_FRAME_END_* @@ -194,6 +195,8 @@ struct vsp1_dl_list { struct vsp1_dl_ext_cmd *pre_cmd; struct vsp1_dl_ext_cmd *post_cmd; =20 + bool allocated; + bool has_chain; struct list_head chain; =20 @@ -617,6 +620,7 @@ struct vsp1_dl_list *vsp1_dl_list_get(struct vsp1_dl_ma= nager *dlm) * display list can assert list_empty() if it is not in a chain. */ INIT_LIST_HEAD(&dl->chain); + dl->allocated =3D true; } =20 spin_unlock_irqrestore(&dlm->lock, flags); @@ -657,6 +661,13 @@ static void __vsp1_dl_list_put(struct vsp1_dl_list *dl) */ dl->body0->num_entries =3D 0; =20 + /* + * Return the display list to the 'free' pool. If the list had already + * been returned be loud about it. + */ + WARN_ON_ONCE(!dl->allocated); + dl->allocated =3D false; + list_add_tail(&dl->list, &dl->dlm->free); } =20 --=20 2.49.0 From nobody Thu Oct 9 20:25:17 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 552BC288C3A; Mon, 16 Jun 2025 16:30:53 +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=1750091454; cv=none; b=VOZbl2gtToNrsEJWrZL9C5ewrDIn3lReEeKAjNR3fySS6a+0uJyMgkI/7/XkJ1/oqTEPFkUHBBP29hdAZ/oBTtPYPDlU+zCrT7WSgApGuA5dGp5ZxlcOANjZVH6T1wb6nDxdQ3o6gKa63pm8t1tmuVnDkX0zb8IZV/IndW1JVQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750091454; c=relaxed/simple; bh=hQ7LAtYwL7CCEF1tm2AqnVat+ZPScl50ILEGM1zg5ns=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z6WROWuelQwwChN/dHXtTrspGjCoE8ghfjOyA7g7QKriYSBCI1TmnnuaaHvUW2lys/eiVs4yqPyx6imQfCpEHX+iEfx3vzceFkaiThnujjtniZPEHUMn5JBth8cB4h/yVKR30/LIO/4iI5rIe/dpBbC7581tlTSQklY1lmuMXj0= 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=Yi1rYGT2; 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="Yi1rYGT2" Received: from [192.168.0.172] (mob-5-90-141-184.net.vodafone.it [5.90.141.184]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E2F7C6C; Mon, 16 Jun 2025 18:30:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1750091438; bh=hQ7LAtYwL7CCEF1tm2AqnVat+ZPScl50ILEGM1zg5ns=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Yi1rYGT20sILw6XF5So3R7wF7o7CUwg8HDA9Zcb8a2IvGA/jUN2QLOCijx2yrVU2e WAxJo/j9UAIuC3aRr1BUPVkXnRSHM000dLwX6cWOS6uYWP0xiSEqJW//K9YyemV7ux 4j5Dsh69KrHa0rh5nC+GEqn3V2PuZzMcTkRN/AUA= From: Jacopo Mondi Date: Mon, 16 Jun 2025 18:30:38 +0200 Subject: [PATCH v2 2/2] media: vsp1: vsp1_dl: Count display lists 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: <20250616-vsp1_dl_list_count-v2-2-7d3f43fb1306@ideasonboard.com> References: <20250616-vsp1_dl_list_count-v2-0-7d3f43fb1306@ideasonboard.com> In-Reply-To: <20250616-vsp1_dl_list_count-v2-0-7d3f43fb1306@ideasonboard.com> To: Laurent Pinchart , Kieran Bingham , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Jacopo Mondi X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2126; i=jacopo.mondi+renesas@ideasonboard.com; h=from:subject:message-id; bh=hQ7LAtYwL7CCEF1tm2AqnVat+ZPScl50ILEGM1zg5ns=; b=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBoUEa3/HkIZWNcA1meJpW4L5kwdFMz8n2NBjMm8 2LmrhoO69uJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaFBGtwAKCRByNAaPFqFW PBDlEACJoCq3L9fqPgAOawxFGQB1noWDz/pK0cK8mJwAq6KtPMIZpJR1Grpa7g9q4oLlPASjdrO e6w2xCnw+o6mUZSW8K4JYazFqke2dCkqp/XKwNYra+emgsMoB5sh+x4vv0Vk86CD9HgYb7wL3uG UwkNYB7tM7P65wPvlRbjqn2LwMR7am8R3/03Ig9DniUkYW1rhoacek1a3L1dm4BLzcWKZpj3GHe uGVWbzonOSIyu8JuteAVMf9c9GuQxJkq2SkheAQq6VyxDI7NnEBdFDpG06YGGLdQf0qzJzTJ9cn V+hK1WB5JCVdGBrGAonKVg8v2Hmu7fVNUSsO1cYNs3YN2TzhwnTJB9Yr0qHb9PrnkIiEy9hMRuI E6lNRP/RwKnpo3pCbPsIesAl3lsiHKNX2mN6J72aVF/GCXIkxcAN/vixLfZ4bMui1fgFpLRhukj 50QqTnpqRHgBGVjWdeGn5Q6nMPEE4LyrvB8XL4zAY+48OnfXUoIdr67SFvsRpfnvZvoOeW4fYDT jDJ2PIAPExbR8T8dXsk7wCaLzIn07hkIJNoPF1XDJcxXsPHnaIxc78AxV/j6fW4BKUBPqc+KDVp jlghsSdOrzHF1nm8YkWbkT05j6uutS9stEZnSBKTsx9iMLsLYtXJHBeZvDGBBOtTt29u4s9pSJi 1A8TNex1FTeVb2g== X-Developer-Key: i=jacopo.mondi+renesas@ideasonboard.com; a=openpgp; fpr=72392EDC88144A65C701EA9BA5826A2587AD026B To detect leaks of display lists, store in the display list manager the number of allocated display lists when the manager is created and verify that when the display manager is reset the same number of lists is allocated. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- drivers/media/platform/renesas/vsp1/vsp1_dl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_dl.c b/drivers/media/= platform/renesas/vsp1/vsp1_dl.c index 18617cbb168703b851a9b437fa62f18425934c68..3713730c6ad8739935851e4da46= 4fc8f23da6180 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_dl.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_dl.c @@ -215,6 +215,7 @@ struct vsp1_dl_list { * @pending: list waiting to be queued to the hardware * @pool: body pool for the display list bodies * @cmdpool: commands pool for extended display list + * @list_count: number of allocated display lists */ struct vsp1_dl_manager { unsigned int index; @@ -229,6 +230,8 @@ struct vsp1_dl_manager { =20 struct vsp1_dl_body_pool *pool; struct vsp1_dl_cmd_pool *cmdpool; + + size_t list_count; }; =20 /* -----------------------------------------------------------------------= ------ @@ -1078,6 +1081,7 @@ void vsp1_dlm_setup(struct vsp1_device *vsp1) void vsp1_dlm_reset(struct vsp1_dl_manager *dlm) { unsigned long flags; + size_t list_count; =20 spin_lock_irqsave(&dlm->lock, flags); =20 @@ -1085,8 +1089,11 @@ void vsp1_dlm_reset(struct vsp1_dl_manager *dlm) __vsp1_dl_list_put(dlm->queued); __vsp1_dl_list_put(dlm->pending); =20 + list_count =3D list_count_nodes(&dlm->free); spin_unlock_irqrestore(&dlm->lock, flags); =20 + WARN_ON_ONCE(list_count !=3D dlm->list_count); + dlm->active =3D NULL; dlm->queued =3D NULL; dlm->pending =3D NULL; @@ -1155,6 +1162,7 @@ struct vsp1_dl_manager *vsp1_dlm_create(struct vsp1_d= evice *vsp1, =20 list_add_tail(&dl->list, &dlm->free); } + dlm->list_count =3D prealloc; =20 if (vsp1_feature(vsp1, VSP1_HAS_EXT_DL)) { dlm->cmdpool =3D vsp1_dl_cmd_pool_create(vsp1, --=20 2.49.0