Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp778360lqo; Wed, 8 May 2024 14:55:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXB0TpmkCO6yam92J9fplfcRDftDhHDwM5eLFkR5T3+kvZzAjt73s1GbtT2XHJ1/8aXULLvBYtX1x+03mCeqsAQuw5hTGWSSmvTVpbwYg== X-Google-Smtp-Source: AGHT+IEaM81XqYj7Buqet2ddr3W9F33AM6vxHqCCynFyrzFg3bQ7KM+/05KKmCRd8UA6BMOcEAUQ X-Received: by 2002:ac2:5ede:0:b0:51f:3cb3:48a4 with SMTP id 2adb3069b0e04-5217c27740dmr2250612e87.1.1715205312651; Wed, 08 May 2024 14:55:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715205312; cv=pass; d=google.com; s=arc-20160816; b=vcDAMa9TLmCo3e/DEd6wWdj4u+Kl+eXXYSCXPT8Fbwvc+7jr+OixuvOO62PjsdBsIA oeZSVnEM3SJ0Y+tSRFQWg7JVPio+M3MPbgOw9dynx3n3Bi6WKuQIwZ+vavbrlkn8WXoO dhQfJewnQhTtK/jtPr9/d8I/ZJW1+H/CtpuTQtrFPaywCbZaEontCIGHf4SNQ+mrOq7t 1wXfibcqt04vDUaa+doT3rocphp8GkJPdqUoxBMRc+LApZiF8UHMn9RUrNp9zMU/A/cW vTZTgMz6XSw7fleigLvtK9kxXWJ0tl9KYwwyc+QpxiNPZVyndmqd2BJU9RnyMoGanttk I22Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=499jW8E5jJ7T8CA5aj1OaRgaaA9vl+avL3eUj7/OgYQ=; fh=WgBAu34gfTanlhq8bt4NkM2FmbnhIt9Kp29SLt3I4Oc=; b=xA9sEdSIvnJTzpwDfIxOmaesLx/3YUZNHFx8jt5RhbMNUh0jfE4iUA1w3HECs1xWu2 PdXJo7ld7o4jI4MQCwj4tYL2BswfkE/XNifZSWJYYqSKZlSZu3+H17KtkQf9OVT1T/p3 3YkKLJwMeMAqSv/lOPK1q/TITIplZMumFLl3DsCG9MRoPr9pOQbyGUIZ4WoYccy3M0gW BWUmOP7SxY3KMoceAGR6NpQGjyN+b5rgdjQfcgx9vuFf74VFAn/CSTXMDVTg+oSTIplU C6vd9tY0VvC8JsHs8twZtTMKD+JqbrQW2aNfgDg3H23NNGTStxgQ/PxZ3qRSQmdWTCu9 0CrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="Lngs/k/w"; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-173862-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173862-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c2d4d02si25748a12.296.2024.05.08.14.55.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 14:55:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173862-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b="Lngs/k/w"; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-173862-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173862-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 355BD1F232B4 for ; Wed, 8 May 2024 21:55:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A89713281F; Wed, 8 May 2024 21:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Lngs/k/w" 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 BA2ED82862; Wed, 8 May 2024 21:55:00 +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=1715205302; cv=none; b=RtTCmU2t/JAPX8c0Y2JzE3dshOezY9afuQfIbiSUyvCBBohNeCFrrZJNeFVt+ieloUGSbEFjOX/fqktzPYE+4X0STVr4LqK8aoqPSOvGz/MtNwlUSqZjlbYls5T6RrZLFfmLs6w6Wr8segDhbKMyoTK1XZKsANTayuHf5fOZgg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715205302; c=relaxed/simple; bh=dgQ14T7IWo3V5R5DFVrfrvyMq34UxkAK3satbMJu2i4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fuCFqUAs66vzFQNFlb8Ss2ilVBpnTP6G4ArbKZbA3ZXwP2yDfnjJ/A2vWn8Np6MC+Ks5W+j6rK2jKyvFj/JTAM89kYGWOEODBuShDAgQ+HWddKJqg83FPr4EWQNQwgFoOR0lCob+yXpORx3xvRvK+lPYIBvF7efwktuxji3+oLw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (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=Lngs/k/w; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AF36616D4; Wed, 8 May 2024 23:54:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1715205295; bh=dgQ14T7IWo3V5R5DFVrfrvyMq34UxkAK3satbMJu2i4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Lngs/k/wwpmHemT1wGeOaMh+WqgUSB8rYzqf5OvEUah3M/U0kv8F3XMydwvtuCVcl jWEaWpSKHvzvqilNyrOh/tOZO5/TnzuKr2Bf0V6AX2d99MubyfSnv3vvnSX1AyISLw 2tQ7lOlWezSB/rlPYm1nO6WD1iSd3Eb2VsCg4m2o= Date: Thu, 9 May 2024 00:54:50 +0300 From: Laurent Pinchart To: Daniel Vetter Cc: Dmitry Baryshkov , Bryan O'Donoghue , Hans de Goede , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?utf-8?B?S8O2bmln?= , Lennart Poettering , Robert Mader , Sebastien Bacher , Linux Media Mailing List , "dri-devel@lists.freedesktop.org" , linaro-mm-sig@lists.linaro.org, Linux Kernel Mailing List , Milan Zamazal , Maxime Ripard , Andrey Konovalov Subject: Re: Safety of opening up /dev/dma_heap/* to physically present users (udev uaccess tag) ? Message-ID: <20240508215450.GC24860@pendragon.ideasonboard.com> References: <3c0c7e7e-1530-411b-b7a4-9f13e0ff1f9e@redhat.com> <20240507184049.GC20390@pendragon.ideasonboard.com> 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-Disposition: inline In-Reply-To: On Wed, May 08, 2024 at 10:39:58AM +0200, Daniel Vetter wrote: > On Tue, May 07, 2024 at 10:59:42PM +0300, Dmitry Baryshkov wrote: > > On Tue, 7 May 2024 at 21:40, Laurent Pinchart wrote: > > > On Tue, May 07, 2024 at 06:19:18PM +0300, Dmitry Baryshkov wrote: > > > > On Tue, 7 May 2024 at 18:15, Bryan O'Donoghue wrote: > > > > > On 07/05/2024 16:09, Dmitry Baryshkov wrote: > > > > > > Ah, I see. Then why do you require the DMA-ble buffer at all? If you are > > > > > > providing data to VPU or DRM, then you should be able to get the buffer > > > > > > from the data-consuming device. > > > > > > > > > > Because we don't necessarily know what the consuming device is, if any. > > > > > > > > > > Could be VPU, could be Zoom/Hangouts via pipewire, could for argument > > > > > sake be GPU or DSP. > > > > > > > > > > Also if we introduce a dependency on another device to allocate the > > > > > output buffers - say always taking the output buffer from the GPU, then > > > > > we've added another dependency which is more difficult to guarantee > > > > > across different arches. > > > > > > > > Yes. And it should be expected. It's a consumer who knows the > > > > restrictions on the buffer. As I wrote, Zoom/Hangouts should not > > > > require a DMA buffer at all. > > > > > > Why not ? If you want to capture to a buffer that you then compose on > > > the screen without copying data, dma-buf is the way to go. That's the > > > Linux solution for buffer sharing. > > > > Yes. But it should be allocated by the DRM driver. As Sima wrote, > > there is no guarantee that the buffer allocated from dma-heaps is > > accessible to the GPU. > > > > > > > > > Applications should be able to allocate > > > > the buffer out of the generic memory. > > > > > > If applications really want to copy data and degrade performance, they > > > are free to shoot themselves in the foot of course. Applications (or > > > compositors) need to support copying as a fallback in the worst case, > > > but all components should at least aim for the zero-copy case. > > > > I'd say that they should aim for the optimal case. It might include > > both zero-copying access from another DMA master or simple software > > processing of some kind. > > > > > > GPUs might also have different > > > > requirements. Consider GPUs with VRAM. It might be beneficial to > > > > allocate a buffer out of VRAM rather than generic DMA mem. > > > > > > Absolutely. For that we need a centralized device memory allocator in > > > userspace. An effort was started by James Jones in 2016, see [1]. It has > > > unfortunately stalled. If I didn't have a camera framework to develop, I > > > would try to tackle that issue :-) > > > > I'll review the talk. However the fact that the effort has stalled > > most likely means that 'one fits them all' approach didn't really fly > > well. We have too many usecases. > > I think there's two reasons: > > - It's a really hard problem with many aspects. Where you need to allocate > the buffer is just one of the myriad of issues a common allocator needs > to solve. The other large problem is picking up an optimal pixel format. I wonder if that could be decoupled from the allocation. That could help moving forward. > - Every linux-based os has their own solution for these, and the one that > suffers most has an entirely different one from everyone else: Android > uses binder services to allow apps to make these allocations, keep track > of them and make sure there's no abuse. And if there is, it can just > nuke the app. -- Regards, Laurent Pinchart