Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 50F9EC282DE for ; Mon, 10 Mar 2025 14:30:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AEAA110E29A; Mon, 10 Mar 2025 14:30:38 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="iiME8SE/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="eoAKWdWE"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="iiME8SE/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="eoAKWdWE"; dkim-atps=neutral Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id E00B210E29A for ; Mon, 10 Mar 2025 14:30:37 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5ABB51F38C; Mon, 10 Mar 2025 14:30:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741617036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=9OuaAaoMQkTqb8w26X7f5KRFBs9coRKL9547fpG0jas=; b=iiME8SE/ImHZiLbnCsgACRB8S1C/xpTJ1RXPjBFm1oEbH/rZVAgzfnj6MVKj7hpXFtAXcY dst8mFNpARYPgNhdC3i4jorP+vcZyjgO2va+bLFxwp6ilenvLfRr9ABy9LC4K/T0Cbndbj 4nNWjGB22vaE3iI7IEyhePb67JTdAog= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741617036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=9OuaAaoMQkTqb8w26X7f5KRFBs9coRKL9547fpG0jas=; b=eoAKWdWE9oi40V2V4cUfXZzbKkJRD4zulGjLIgBuCICqwvsFpgUmfkdvmrAlAv3KDKkbAy fIFYkNXdpipxM1BQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="iiME8SE/"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=eoAKWdWE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741617036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=9OuaAaoMQkTqb8w26X7f5KRFBs9coRKL9547fpG0jas=; b=iiME8SE/ImHZiLbnCsgACRB8S1C/xpTJ1RXPjBFm1oEbH/rZVAgzfnj6MVKj7hpXFtAXcY dst8mFNpARYPgNhdC3i4jorP+vcZyjgO2va+bLFxwp6ilenvLfRr9ABy9LC4K/T0Cbndbj 4nNWjGB22vaE3iI7IEyhePb67JTdAog= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741617036; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=9OuaAaoMQkTqb8w26X7f5KRFBs9coRKL9547fpG0jas=; b=eoAKWdWE9oi40V2V4cUfXZzbKkJRD4zulGjLIgBuCICqwvsFpgUmfkdvmrAlAv3KDKkbAy fIFYkNXdpipxM1BQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id ECF44139E7; Mon, 10 Mar 2025 14:30:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id J2KGOIv3zmfQOAAAD6G6ig (envelope-from ); Mon, 10 Mar 2025 14:30:35 +0000 Message-ID: <775a8644-da28-4f1f-ab8e-d36502c9a2cb@suse.de> Date: Mon, 10 Mar 2025 15:30:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 0/5] drm: Provide a dedicated DMA device for PRIME import To: =?UTF-8?Q?Christian_K=C3=B6nig?= , Simona Vetter Cc: simona@ffwll.ch, javierm@redhat.com, airlied@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, hdegoede@redhat.com, airlied@redhat.com, sean@poorly.run, sumit.semwal@linaro.org, admin@kodeit.net, gargaditya08@live.com, jani.nikula@intel.com, dri-devel@lists.freedesktop.org References: <20250307080836.42848-1-tzimmermann@suse.de> <864f2d0e-083e-480f-b15a-263ac5f11360@suse.de> Content-Language: en-US From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= xsBNBFs50uABCADEHPidWt974CaxBVbrIBwqcq/WURinJ3+2WlIrKWspiP83vfZKaXhFYsdg XH47fD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0zbehDda8lv hFXodNFMAgTLJlLuDYOGLK2AwbrS3Sp0AEbkpdJBb44qVlGm5bApZouHeJ/+n+7r12+lqdsA EQEAAcLAdgQYAQgAIAIbDBYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJftOH6AAoJEGgNwR1T C3ojVSkIALpAPkIJPQoURPb1VWjh34l0HlglmYHvZszJWTXYwavHR8+k6Baa6H7ufXNQtThR yIxJrQLW6rV5lm7TjhffEhxVCn37+cg0zZ3j7zIsSS0rx/aMwi6VhFJA5hfn3T0TtrijKP4A SAQO9xD1Zk9/61JWk8OysuIh7MXkl0fxbRKWE93XeQBhIJHQfnc+YBLprdnxR446Sh8Wn/2D Ya8cavuWf2zrB6cZurs048xe0UbSW5AOSo4V9M0jzYI4nZqTmPxYyXbm30Kvmz0rYVRaitYJ 4kyYYMhuULvrJDMjZRvaNe52tkKAvMevcGdt38H4KSVXAylqyQOW5zvPc4/sq9c= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 5ABB51F38C X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com,live.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; ARC_NA(0.00)[]; RCPT_COUNT_TWELVE(0.00)[15]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_CC(0.00)[ffwll.ch,redhat.com,gmail.com,linux.intel.com,kernel.org,poorly.run,linaro.org,kodeit.net,live.com,intel.com,lists.freedesktop.org]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, suse.de:mid, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Am 10.03.25 um 14:56 schrieb Christian König: > Am 10.03.25 um 10:50 schrieb Thomas Zimmermann: >> Hi >> >> Am 07.03.25 um 14:32 schrieb Simona Vetter: >>> On Fri, Mar 07, 2025 at 09:03:58AM +0100, Thomas Zimmermann wrote: >>>> Importing dma-bufs via PRIME requires a DMA-capable hardware device. >>>> This is not the case for USB, where DMA is performed entirely by the >>>> USB controller instead of the USB devices. >>>> >>>> Drivers for USB-based hardware maintain their own workarounds for this >>>> problem. The original idea to resolve this was to provide different >>>> PRIME helpers for such devices, but the dma-buf code internally assumes >>>> DMA functionality as well. So that ideas is not realistic. >>> So dma-buf without dma is doable, but you have to avoid dma_buf_attach. >>> And that is a lot of surgery in the current prime helpers, since those >>> assume that an attachment always exists. But dma-buf itself is entirely >>> fine with cpu-only access through either userspace mmap or kernel vmap. >> Right. That's roughly how far I got in this direction. The field import_attach, set up by dma_buf_attach(), is currently used throughout the DRM code and drivers. Hence this series and the other one that replaced some of the uses of import_attach. Once this has all been resolved, there will be a few users of the field left, which might be uncritical. > Mhm, if I remember correctly the DMA subsystem used to use the DMA mask and other parameters of the parent device when a specific device couldn't do DMA by itself. This went away (for USB at least) with commit 6eb0233ec2d0 ("usb: don't inherity DMA properties for USB devices"). Buffer sharing with USB graphics devices failed and we worked around it in 659ab7a49cbe ("drm: Use USB controller's DMA mask when importing dmabufs"). Best regards Thomas > > I do remember a lot of discussion about that for the DMA-buf tee driver. > > Going to read up on that once more. Could be that this patch here is not really necessary. > > Regards, > Christian. > >> Best regards >> Thomas >> >>> I think as an interim step this is still good, since it makes the current >>> hacks easier to find because at least it's all common now. >>> -Sima >>> >>>> Let's instead turn the current workaround into a feature. Patch 1 adds a >>>> dma_dev field to struct drm_device and makes the PRIME code use it. Patches >>>> 2 to 5 replace related driver code. >>>> >>>> It will also be useful in other code. The exynos and mediatek drivers >>>> already maintain a dedicated DMA device for non-PRIME code. They could >>>> likely use dma_dev as well. GEM-DMA helpers currently allocate DMA >>>> memory with the regular parent device. They should support the dma_dev >>>> settings as well. >>>> >>>> Tested with udl. >>>> >>>> v2: >>>> - maintain reference on dma_dev (Jani) >>>> - improve docs (Maxime) >>>> - update appletbdrm >>>> >>>> Thomas Zimmermann (5): >>>>    drm/prime: Support dedicated DMA device for dma-buf imports >>>>    drm/appletbdrm: Set struct drm_device.dma_dev >>>>    drm/gm12u320: Set struct drm_device.dma_dev >>>>    drm/gud: Set struct drm_device.dma_dev >>>>    drm/udl: Set struct drm_device.dma_dev >>>> >>>>   drivers/gpu/drm/drm_drv.c          | 21 ++++++++++++++ >>>>   drivers/gpu/drm/drm_prime.c        |  2 +- >>>>   drivers/gpu/drm/gud/gud_drv.c      | 33 ++++++--------------- >>>>   drivers/gpu/drm/gud/gud_internal.h |  1 - >>>>   drivers/gpu/drm/tiny/appletbdrm.c  | 27 +++++++----------- >>>>   drivers/gpu/drm/tiny/gm12u320.c    | 46 +++++++++--------------------- >>>>   drivers/gpu/drm/udl/udl_drv.c      | 17 ----------- >>>>   drivers/gpu/drm/udl/udl_drv.h      |  1 - >>>>   drivers/gpu/drm/udl/udl_main.c     | 14 ++++----- >>>>   include/drm/drm_device.h           | 41 ++++++++++++++++++++++++++ >>>>   10 files changed, 102 insertions(+), 101 deletions(-) >>>> >>>> -- >>>> 2.48.1 >>>> -- -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)