Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp356582lqo; Wed, 8 May 2024 01:41:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXudHv/15B4NIcea/tGFETqqmQY6Ia9G9lkeSqC/mSAqZ0Fs6DRDJcKyOLujOM96dWDN1NxtBM1aUmE2+5y5FQa2wjrb6Z1KuXFnqZ9jA== X-Google-Smtp-Source: AGHT+IHcNj/+bKb1Ykgkzdvoa96Hj83MtYQxRwvKD6keQYXoKx+LPPAxYp02ydJZ/EdOtumynyZZ X-Received: by 2002:a05:6102:3e93:b0:47c:549c:d6a3 with SMTP id ada2fe7eead31-47f3c292acamr2189966137.2.1715157707863; Wed, 08 May 2024 01:41:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715157707; cv=pass; d=google.com; s=arc-20160816; b=rj+ZFlIzWIem+sc68GlfQzslPVdxW/jbh4g6PpK+om32svw6rf6fLLsWA6c9ttCRm+ Q8xZKyQjBGKjfKncb1OH3YKsjAmorm1TOjj/0JZR5czKbWUc7ojQi62RBK/tN6/7OXTj rxxbTCMxORhYl1kKHcifHhDwBq272kVL5Na71uEKdCMHITZ8ON4l8zRVY2jF8zErAWpl Mr+cO2trgrQvbY7DHTA+8kWeE+qaiQK91A0H5MJUSruZqvubsUY5V09ekEDRAhIOiyqF VIk58rGZMbwYP0ycoQMk1svgxX0r3knzUwKqGKrYiu4oylcAnx4VcgCEuyrrniFxuuHI 2Nag== 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:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=TjDECsAq9W3dnXC6ANhg0GrZ6XSPEO0XVnHc2JQoQ80=; fh=tuCg6StswYvHKNfWUBrRQiRghHTY39+RwZ0naLeOxyY=; b=lEoPCmjHEayWMUe+BKbIhx42+Z6hUnCWaFOILxh7Pv7wHthXxUVffwrBrf1JWS5U06 obIsYUwHAhjuze8hlFHb2chRvLcu49eegIT9FGSklFmxYP17vbgP2HRkamRWQpmFNQaI aELxf0dRFNxDdu8XpwFLzN+IsfwBwjDn/Gbnn5lrzpRh27AgfQB+ErwhXnXSXtywRKkf PaIzTnv0uqUqOU9YLM+96w2q//tLN7J7LyFEP36EJ7UDQwi/4JegtP2PKG6exwmjX5um /h8o6GuZHd33dH6MfvvHrvPQUe8LOk163UClpcdexGNvhFqfNGkeooJjHvpt0dGNjXfH PUgw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Q9LMcMBr; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-172933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172933-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dv11-20020ad44eeb000000b006a0d71437f6si13421936qvb.535.2024.05.08.01.41.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:41:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=Q9LMcMBr; arc=pass (i=1 dkim=pass dkdomain=ffwll.ch); spf=pass (google.com: domain of linux-kernel+bounces-172933-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172933-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 889451C2380E for ; Wed, 8 May 2024 08:41:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DE8C74C0D; Wed, 8 May 2024 08:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="Q9LMcMBr" Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8CEB53801 for ; Wed, 8 May 2024 08:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715157604; cv=none; b=VMeCGQx2XT3l4wqYTlUtvc7pS49CKlolMfyuXKFin7IvPODRVA31/7vZInJnsKbtuXXHP8ILqRgoUZsMlr1JUlck3AcnNDFWGQ9Ltd7qpwNgkpGqJ1Wcp0xn8pLpPE+vU3EC8AR/PH5wzxBfCaZVN8QZi0GybWbWpWgyPkiqoxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715157604; c=relaxed/simple; bh=1xSdGCgIU8aP178mgDcqVTSMC4s/XSolT45EILTJaS0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=r55jg/E/2ANyXGq4CCdZ3fWx7mYufuYfvraslCO1qQOrZ6E9DOs9X+jNfjeIkm6FKMkvXGSuwcIoPfPlp/brtND6wJScOdB0j5MF08pvHPoKBrDtt5x9nKEnG0B0VeK3xrbIigkcvZMHUBp1Jb09BwA2gLqCooSNxfdQ/03a2IY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch; spf=none smtp.mailfrom=ffwll.ch; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b=Q9LMcMBr; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ffwll.ch Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a59a86fb052so133845366b.0 for ; Wed, 08 May 2024 01:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; t=1715157601; x=1715762401; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=TjDECsAq9W3dnXC6ANhg0GrZ6XSPEO0XVnHc2JQoQ80=; b=Q9LMcMBrrO1pijrJ6yt38tdbUmu9EEbhwWk6FIARqLVgs88gF0ErEWanzHtX3Xrcnf MZ1u0gIm5miDIPo26b5FA6l+ofLuLzdG4w6utu8/V531ps3GQm9zLirklaIUUtmT3ung n8rnHrjIr0vbRoUVFrY2SQV/9M9cRE6VTEGdM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715157601; x=1715762401; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TjDECsAq9W3dnXC6ANhg0GrZ6XSPEO0XVnHc2JQoQ80=; b=PVs8+88EE/MeuzLvUHnWwvqmsT/x3bNhHzvJ7PS0MHT5+q+d8+NsLJPPXpqKDkcObe AR6F3vZSYiwVZlgzOFBAR99Rh07mbdxBellhjFDhqca0bKDhw2+Wy25fgm9r/mNvRh4c Lr0Oh2noAZ6Y+x9g5LRqd2Z8AymEIhqiVIO4OtbLMqg7xtE/hjJuKa6oGFaRsgZ+DPdp QNrCB/MEY7sldql/wTPR5dRbWJkPl6B6aCK9eurDBkSbA3RXD7wQyjADFG6gsgMOdpzG 5eAWv+8NXOZOHpChI5nbc6YXVpBfgrIsm1qn17EHea2LEo7l8VS3fxsyeNpgOPElewrU 7D6A== X-Forwarded-Encrypted: i=1; AJvYcCVgFb08hntRggySdIDTdvf88H0FBU7wDN8xjBupwDPUkC5BCkW3ZJ7fvLYFN0qfchR2wTMcWVgKMngPb8EgSaq7Y2JA80bbxHd/q89Z X-Gm-Message-State: AOJu0YzaA47KBIm8PIT/HaE9M6FEZlHKRdGHR1jY721BbA+qE6fbjFx0 kJ8XWLuLwHEFqLyn7v96V3Wu1EsA5h6DWqwfYn6l5xGyPcOE2q8IJx1qCkQQ6dA= X-Received: by 2002:a17:906:ccce:b0:a59:cf59:f7ff with SMTP id a640c23a62f3a-a59fb94f3c4mr140742766b.2.1715157601017; Wed, 08 May 2024 01:40:01 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id bi11-20020a170907368b00b00a59f73fb086sm1155563ejc.196.2024.05.08.01.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 01:40:00 -0700 (PDT) Date: Wed, 8 May 2024 10:39:58 +0200 From: Daniel Vetter To: Dmitry Baryshkov Cc: Laurent Pinchart , Bryan O'Donoghue , Hans de Goede , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?iso-8859-1?Q?K=F6nig?= , 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: Mail-Followup-To: Dmitry Baryshkov , Laurent Pinchart , Bryan O'Donoghue , Hans de Goede , Sumit Semwal , Benjamin Gaignard , Brian Starkey , John Stultz , "T.J. Mercier" , Christian =?iso-8859-1?Q?K=F6nig?= , 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 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=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 6.6.15-amd64 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. - 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. Cheers, Sima -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch