From patchwork Fri Nov 29 18:53:28 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: 22144 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 37072C31E9 for ; Fri, 29 Nov 2024 18:55:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 49E5B6603A; Fri, 29 Nov 2024 19:55:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TKsFC+m/"; dkim-atps=neutral Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 99F3E6601A for ; Fri, 29 Nov 2024 19:55:42 +0100 (CET) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-2153a73edd5so9225285ad.2 for ; Fri, 29 Nov 2024 10:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1732906541; x=1733511341; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UHaAzcY1zQFKwmFV571thm8Bftc2+UShocBYnjxTarE=; b=TKsFC+m/xwqme9JOHOVY+4ckH79l45yavq1bd+GR1KsD2Dqi9eifK7gYtRSCnO+exV c1X67BPMsiF9t3pVgU6+Opk0x15iLIiFUkwgzX6dmHRGQcrZKOIssge5dJg5dI/0EMno m9lxut7v4CgVxullO8UNTrWKVTh1GVzUREZJc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732906541; x=1733511341; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UHaAzcY1zQFKwmFV571thm8Bftc2+UShocBYnjxTarE=; b=QNhghp6i9tcgSn2GjOrcU62NwKVFZ7o2s4RQ9EWviVSaD6UQyDxY51xB6vXuZ+ElPP cBkSl/cbN5wUcH6v1KFWZ3Q5eyYpRzGWkawjKXXb0B0um6m3b5Xb0XeVtwulc8fmzE72 T+O0qKUEsbOB82oGkZwxotqs5Q7F6Hz6jXqxg1Nce5EtmwZ/v+2XKzt3bcKSUKAqfjtk AqAM3mLKOUKKYN33xMYO1EEQ86+asJew2Y7JO8yYAt0tiSDVjvfTdwVsNMD8fVXW++YH V9ePwRcK002BP55NHw4RSt26Rb6atuBxFGYMlPOmv3aJzCZsEDpIa3Zn61h9Co3f0pmj p6Eg== X-Gm-Message-State: AOJu0Yw/31c2FPauMgMboJuiDnye7BtEiwxdlCAT6QsoawkGpnQ0Cdr0 Fq9xs63cN6UOGA/rUbOEtKs7V6TRV2z56LYhbcfVtwzCOVSKShnHy3fLvVXip3H461BIMCFbsN4 = X-Gm-Gg: ASbGncst/aj87+Fie1Sg2ulEqc5t9b9qpn2GpIz1aQOo/qBvClkMSP9Ii43Rx9hJ9b8 6ngj0pxGH5ZiFcatO+OFkynt+BS6NiY0ovfLqIuJZMjF0EAloqbRs1ZdSgsKoYFHRbJOTXBbIfU gLMh2Kr6z7Gzvs9+WPNIck7FHAXf1DNkm64W6vIpDbb3uY/yRvmQ/aZ7/pJZz7BS3cTOXLwwStC UrxUwSj5QxZeaNNlqR1kXwdwwCq8Mgb86Dp2CV0SllwDryllGbXOLOTJtP1mBpxWoFjmzMY1Ouy 9sDB+W/416wWjn18W0i/GDZfhjuVymYRlly1WbsQ+ZJLbr/rVg6lRjdz X-Google-Smtp-Source: AGHT+IEgYSWbalAJV2k4wzaa4S2G1sePICmaTlYu7kgIYylFh7R38uuPS5YM+GQfTLlN+j/Ms9FZow== X-Received: by 2002:a17:902:e549:b0:215:5637:447 with SMTP id d9443c01a7336-2155637073amr7064765ad.51.1732906540848; Fri, 29 Nov 2024 10:55:40 -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 d9443c01a7336-21546470f46sm13661995ad.105.2024.11.29.10.55.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2024 10:55:40 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang Subject: [PATCH 1/1] DmaBufAllocator: Make DmaSyncer non-copyable Date: Fri, 29 Nov 2024 18:53:28 +0000 Message-ID: <20241129185533.3308449-2-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog In-Reply-To: <20241129185533.3308449-1-chenghaoyang@chromium.org> References: <20241129185533.3308449-1-chenghaoyang@chromium.org> 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" This fixes commit 39482d59fe7160740ea5dd61f3ed965a88d848ce. 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. Signed-off-by: Harvey Yang Reviewed-by: Kieran Bingham --- include/libcamera/internal/dma_buf_allocator.h | 5 +++++ src/libcamera/dma_buf_allocator.cpp | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/libcamera/internal/dma_buf_allocator.h b/include/libcamera/internal/dma_buf_allocator.h index fc5de2c13..0cb209630 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 &&) = default; + DmaSyncer &operator=(DmaSyncer &&) = 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 3cc52f968..5f517828d 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -311,6 +311,16 @@ DmaSyncer::DmaSyncer(SharedFD fd, SyncType type) sync(DMA_BUF_SYNC_START); } +/** + * \fn DmaSyncer::DmaSyncer(DmaSyncer &&) = default; + * \brief Enable move on class DmaSyncer + */ + +/** + * \fn DmaSyncer::operator=(DmaSyncer &&) = default; + * \brief Enable move on class DmaSyncer + */ + DmaSyncer::~DmaSyncer() { sync(DMA_BUF_SYNC_END);