All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Cc: linux-renesas-soc@vger.kernel.org
Subject: [kmsxx] [PATCH] testpat: Fix memory mapping in threaded drawing
Date: Tue, 14 Nov 2023 21:30:36 +0200	[thread overview]
Message-ID: <20231114193036.27049-1-laurent.pinchart@ideasonboard.com> (raw)

The IFramebuffer::map() function is not thread-safe, which is why the
threaded implementation of draw_test_pattern_impl() maps all planes
before starting to draw. A typo slipped in the code, resulting in only
plane 0 being mapped. This didn't result in an immediate segfault, as
drawing operations in the worker threads map the remaining planes.
However, due to the implementation of DumbFramebuffer::map(), this can
result in the same plane being mapped multiple times, with only one of
the mapping recorded in the mapping cache. The other mappings are then
leaked, leading not only to extra memory consumption, but also to the
DRM device never being released even after the destruction of the Card
object.

Fix this.

Fixes: 40d96062a37c ("Revert "testpat: remove threaded drawing"")
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
I've noticed this issue when running the DU KMS tests, when the tests
run right after multi-planar format tests would sometimes fail, while
running fine in isolation. It was "fun" to debug, for some definition of
"fun".
---
 kms++util/src/testpat.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index 78c9d19a5ad7..1102588cc9f7 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -173,7 +173,7 @@ static void draw_test_pattern_impl(IFramebuffer& fb, YUVType yuvt)
 
 	// Create the mmaps before starting the threads
 	for (unsigned i = 0; i < fb.num_planes(); ++i)
-		fb.map(0);
+		fb.map(i);
 
 	unsigned num_threads = thread::hardware_concurrency();
 	vector<thread> workers;

base-commit: c23e7548ee317c043660f9b992388257e99f1776
-- 
Regards,

Laurent Pinchart


             reply	other threads:[~2023-11-14 19:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14 19:30 Laurent Pinchart [this message]
2023-11-15  6:57 ` [kmsxx] [PATCH] testpat: Fix memory mapping in threaded drawing Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231114193036.27049-1-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=tomi.valkeinen@ideasonboard.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.