From patchwork Wed Dec 11 08:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 22287 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 584DDC32DD for ; Wed, 11 Dec 2024 08:44:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9EC5F67EA0; Wed, 11 Dec 2024 09:44:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="K6f2D8FX"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A6C066136 for ; Wed, 11 Dec 2024 09:44:40 +0100 (CET) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-2ef8c012913so2823795a91.3 for ; Wed, 11 Dec 2024 00:44:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1733906678; x=1734511478; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MgoBtlvR6GzfgMg1MnJVtj2p2Xxy0gCjmetb7vn5rBA=; b=K6f2D8FXScuMszFmVSvof0IjKSu3xBhF4QUaWb9wxXAAhu9KU84h3z0Q//BavnUJGn n2HHpjjDqCa7aSYxKOSAmBDhOi1iu7jfVXvTNQ+qipqr7PNjAgLUwD8i0UNW04rrs/S9 3B4y+XOsokauvX/XypUEW0FzLbcTaXfxwjtis= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733906678; x=1734511478; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MgoBtlvR6GzfgMg1MnJVtj2p2Xxy0gCjmetb7vn5rBA=; b=esfhaENcsgME7BrldpKKaXgckda79uTiM/PsWzaduQEUkJsGZn5xFLGYg9SYrLLbIm Wks29x4QzKtKPTM0IfQfgEzN4IZnrD8lK4LePfPre/DWDchydNnWo6JKPTAzoWO6x484 XFJ+E/31RdAKiK9A3iCtJ18uNvN7mUfL5Yvdi888Q9biBYBxaRuHTJJPytHFZ1MH65tI SKr055m+PcI9mv887gYDhJmbhk4fO8u253QwW3D57POB8G0nupcClA+ltlSXiuwAlTLF UHgv+AtgOzOmyeBJUnc7yTp2N5vOq695IleXFMqsbMCf1f5hacDwBmXls3iwx8/+5CtA Zocw== X-Gm-Message-State: AOJu0YzI66vNbHmLzv03LRf8t6YEUWBb5rxhMZ4TIqwn8tasNIPVnAOm oc+PnCM05oE9Ms3k/i3q4mpKknB6rmJaqZr+45maJ7sfKUv6MY7jDhfsePPvg+uYs7fp/Y0GE+c = X-Gm-Gg: ASbGncsGHznu0hLwur1TlBTaKO3S6uZllmpdDifvOUKKHNv3yWa2eLOT9bJFdapD160 hTpIwMfCD0xk+W+1OMOOmyVkr9QEcpdbAw8dvcaE2ZZ6iGqO6eayWx4nhtKZ/yvxCm0AWNY+7cj W4cCbXSKYCsLOUhZ9Ggnd1HRBqXwk3DIwR7laIRxxbzIIhRkqk/1GYPSaT5Wu0Wvx6fKFoJh5xU TEQSa6MhL80ludlvkUrN9CofJihgMFWewdQcjkMeqT8X5UkUPZmfw8DyOhFUXxHrK4OLEEyUDUG iw8p2Z4MNyKcen5yty/AwYAhccrvw1aIkvN+wp9ewqwlp/Xm4uOSLUAhVD8j X-Google-Smtp-Source: AGHT+IEhEzjuUU+i/0FIpSYDYWmfpR5CZIZ/tI/5xHTbDTezkgjqyvPUhx2RRCgb1exUOYFHzrv+7g== X-Received: by 2002:a17:90b:3b49:b0:2ee:cded:9ac7 with SMTP id 98e67ed59e1d1-2f127fea904mr3443781a91.20.1733906678365; Wed, 11 Dec 2024 00:44:38 -0800 (PST) Received: from chenghaoyang-low.c.googlers.com.com (112.212.229.35.bc.googleusercontent.com. [35.229.212.112]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2ef4600d109sm11064544a91.44.2024.12.11.00.44.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 00:44:37 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Kieran Bingham , Laurent Pinchart Subject: [PATCH v3] DmaBufAllocator: Make DmaSyncer non-copyable Date: Wed, 11 Dec 2024 08:44:27 +0000 Message-ID: <20241211084433.3039442-1-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog MIME-Version: 1.0 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" As DmaSyncer does sync start/end in the c'tor/d'tor, copying a DmaSyncer instance would trigger sync end earlier than expected. This patch makes it non-copyable to avoid the issue. Fixes: 39482d59fe71 ("DmaBufAllocator: Add Dma Buffer synchronization function & helper class") Signed-off-by: Harvey Yang Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/internal/dma_buf_allocator.h | 5 +++++ src/libcamera/dma_buf_allocator.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h index fc5de2c13edd..d26f8a74f4c6 100644 --- a/include/libcamera/internal/dma_buf_allocator.h +++ b/include/libcamera/internal/dma_buf_allocator.h @@ -60,9 +60,14 @@ public: explicit DmaSyncer(SharedFD fd, SyncType type = SyncType::ReadWrite); + DmaSyncer(DmaSyncer &&other) = default; + DmaSyncer &operator=(DmaSyncer &&other) = default; + ~DmaSyncer(); private: + LIBCAMERA_DISABLE_COPY(DmaSyncer) + void sync(uint64_t step); SharedFD fd_; diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index 3cc52f9686b0..a014c3b4263c 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -311,6 +311,18 @@ DmaSyncer::DmaSyncer(SharedFD fd, SyncType type) sync(DMA_BUF_SYNC_START); } +/** + * \fn DmaSyncer::DmaSyncer(DmaSyncer &&other); + * \param[in] other The other instance + * \brief Enable move on class DmaSyncer + */ + +/** + * \fn DmaSyncer::operator=(DmaSyncer &&other); + * \param[in] other The other instance + * \brief Enable move on class DmaSyncer + */ + DmaSyncer::~DmaSyncer() { sync(DMA_BUF_SYNC_END);