From patchwork Tue Apr 22 21:58:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23216 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 27CA7C32A2 for ; Tue, 22 Apr 2025 21:59:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EE68B68AD8; Tue, 22 Apr 2025 23:59:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="u1daEMSh"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FFDA617E3 for ; Tue, 22 Apr 2025 23:59:26 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-43cef035a3bso39939665e9.1 for ; Tue, 22 Apr 2025 14:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745359165; x=1745963965; 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=L2Y6auKQbWbB47K5RKdIYrjH8wAq46MTq5RtJq3yzk8=; b=u1daEMShs9VIRRXUukPCi0faMNDUJWEHNsNdbMlRfAwYmvXg8+S9bTLQlaptCtZze2 u0l5qw+q+FJi1ju8LHD6O1ddtsv9qzRXyRZCKUTTrMuFy9qlJhXcPOc73lq9mnXbCyvu qX1pKl7OB5oKyvRJIAcSuLN/9tsGB6FFSSIxl75e3sgX1lOafZ1lyu1cTDaMwYODIo8n AUgit+LAorAqPs9vrJXDSsa0bx5B+sMpKf33rsA6E3qrcgp+8ivNTzDGgXlrcTCEiTHu dGQSKG0KHOEOidBt1iycYxoKPaaK3UQKYY8Jw2SQdBZWSdAkZVAZdt8SpFPHtz6pVXEQ Kdew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745359165; x=1745963965; 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=L2Y6auKQbWbB47K5RKdIYrjH8wAq46MTq5RtJq3yzk8=; b=JOGmg3U6XTNvmjuLxO4HcBhDLLSv430wBLT58kGBhdq51KkFlRm6SndSMwNm4m+dEA EaU4+asyalVrj1KTnRC5vlKa+8FM+DM/9Kb3EMbxu3lXDDJSuluQSgQCIFPVrBJZat8/ +pb0mT1WwZf5EXYGvRxbm0+P8mIMMeb8r0eNNRN6miBMwUUGDE4skg2KBOAA/sUBHW3D wy3kUhb6Zy1197IJmPQG9sDUDAJElTNZdrGzeDrbn8Ok7EDVHqI1lnwTzd1cBOCRqH03 YREk8mLpUw7Vivdw3VPSxoMmupsylFJEDmLQeA8+cnR3idZGPEMbEDwB/zuA7Oxv22va fhHw== X-Gm-Message-State: AOJu0Yx6QXjsJ0Lqe2mRPt5Pi5OdPuWZQhRnRFHMAbuEBFyxkmapCjYz XtCCDLhXSQmLlra7tQOPedIgEJEyif/shGitNBlqxmwdHqruDY36/QxBT1HFP9QT8qL+8dJVxdw uCfM= X-Gm-Gg: ASbGncsUU4nBRvnoagcb/QtrKbyW+BG70shmupn7wDq5az9zb+ado6OJ2gYgxOFdNzw TSlG2TwyNiptOXb/27bzTE46mXStQOa5Obg4bp1aiVy4YaaRoVaRAPQQPnCnGCQ80aWyu8If3ur 23+s9TqPU0UhcjnEv55ADWh7NwmowuyV0GsC61l2GaBp8/ggjGKGTPAkdiADbO4wHAEc5lVaDwl J3Q0CyysKM6hCCScAtas/JB3Sg+eOdqk0SCUhtMqzxO1Vn7eNrx+O52XW7XfdOdnpCgBoCohxBo FCiQCVe+EWmPzH56ozEfBkOxV9kVgzF2HlFlLmQA+LNwSvndTIO4xtamD/NPvcTsAQd5pv5BKgy +LBVCvUdEP0zUu1lpofio X-Google-Smtp-Source: AGHT+IEdb5JRZXYkKfavS9mMAPjUvQO/riVMgzKTbQoEzy/XbjElgaJf4tCCwrVEFScRQpYE60JxdQ== X-Received: by 2002:a05:600c:1911:b0:43d:9d5:474d with SMTP id 5b1f17b1804b1-4406aa8b882mr160895285e9.0.1745359165425; Tue, 22 Apr 2025 14:59:25 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-44092d2eccesm2726615e9.20.2025.04.22.14.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 14:59:25 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH 03/27] libcamera: dma_buf_allocator: Favour udmabuf over cma heap allocations Date: Tue, 22 Apr 2025 22:58:56 +0100 Message-ID: <20250422215920.4297-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250422215920.4297-1-bryan.odonoghue@linaro.org> References: <20250422215920.4297-1-bryan.odonoghue@linaro.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" When /dev/dma_heap/linux,cma or /dev/dma_heap/system exist currently we favour allocation from this type of heap over /dev/udmabuf. We ought to favour udmabuf though - udmabuf is the preferred method by various distros for security reasons - Contiguous memory is a scarce resource Change the ordering of the allocator lookup so that the udmabuf lookup comes first. Fixes: ea4baaacc325 ("libcamera: DmaBufAllocator: Support allocating from /dev/udmabuf") Signed-off-by: Bryan O'Donoghue --- src/libcamera/dma_buf_allocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/dma_buf_allocator.cpp b/src/libcamera/dma_buf_allocator.cpp index d8c62dd6..722ffd46 100644 --- a/src/libcamera/dma_buf_allocator.cpp +++ b/src/libcamera/dma_buf_allocator.cpp @@ -45,10 +45,10 @@ static constexpr std::array providerInfos = { { * /dev/dma_heap/linux,cma is the CMA dma-heap. When the cma heap size is * specified on the kernel command line, this gets renamed to "reserved". */ + { DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf, "/dev/udmabuf" }, { DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap, "/dev/dma_heap/linux,cma" }, { DmaBufAllocator::DmaBufAllocatorFlag::CmaHeap, "/dev/dma_heap/reserved" }, { DmaBufAllocator::DmaBufAllocatorFlag::SystemHeap, "/dev/dma_heap/system" }, - { DmaBufAllocator::DmaBufAllocatorFlag::UDmaBuf, "/dev/udmabuf" }, } }; LOG_DEFINE_CATEGORY(DmaBufAllocator)