Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp673411pxb; Fri, 3 Sep 2021 10:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvbJ2HVWwYMm0VqCdC/ViF7+uHBl8Y2kJtUpjxtgQNf146Ch/GUZMd5apqPO3WB+jxk9cu X-Received: by 2002:a17:907:c10:: with SMTP id ga16mr42159ejc.174.1630690897044; Fri, 03 Sep 2021 10:41:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630690896; cv=none; d=google.com; s=arc-20160816; b=JsZzOgUZc1AA21TOiXAUfCHtit5gN2im+yzkEfiaB/PsQQdSukn5lWsO7WBW8no9o6 AXy4KREfrh9KA5QV7oihZtorhVwGUldT0F0ARZjvLIQGRQY9tziLQPLs9xbn4Gi9fwXY cyd0TtAoUFZAc9Ni1ZfSX/CtWj/OIEDS8rqO+NsOe99otLd6I3GfBHaNcM5hVm8JMeva gdml3g6v8o8wR+dIj/0lDcAJVvoJ5MfSZ4L2OsQ2ZAudr0TXVa2G5dQt0OFtN+xCGsoV k7wF8Utn9/ZfbmVg9Kjz3ZgieXX2xf4FZjiLDatDk8B8CUlSOwYKpWjJB0YDOXzZTdnT QR9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=PdmM1oDIRcFhT+KHTRIAX+OXttLZKYr4RU3yAH4tFU0=; b=sPAOEhqiYI5JwaOgS/f6E0ek30uHwbUQmsR6ZL7SWGW1qHkfy61qLOK3vDz0W6Tlw0 4AapuxLHcNE0OGeXxhbk6hR1dqtqIztdWzesm7Yi2+0tPRTwxHXMtooTO79KbM019YRv D1s0r/NSCLhjU5qHCPpAnKScoJkWpHf7e0wQR11w+q7sImXykkqMa1EQnnM/NC294oSy KFo9BN46VI52BIoP5bNqaSaFxpb0Zt4QFPa9YNZgLE2JxKxRDYTAc37Caf4QOHljE8qY c8T/LdkZwq6x2erZIDnfLSiJDosHZ2yWmztjsg+4kDKS4Wn0+tEa9QoLLEPC5zgMwKjG n4qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p5si787025ejj.74.2021.09.03.10.41.13; Fri, 03 Sep 2021 10:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235419AbhICQRy (ORCPT + 99 others); Fri, 3 Sep 2021 12:17:54 -0400 Received: from rosenzweig.io ([138.197.143.207]:45816 "EHLO rosenzweig.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbhICQRy (ORCPT ); Fri, 3 Sep 2021 12:17:54 -0400 Date: Fri, 3 Sep 2021 09:11:14 -0400 From: Alyssa Rosenzweig To: Robin Murphy Cc: Sven Peter , Sven Peter , Joerg Roedel , Will Deacon , Arnd Bergmann , Mohamed Mediouni , Alexander Graf , Hector Martin , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/8] iommu/dma: Disable get_sgtable for granule > PAGE_SIZE Message-ID: References: <20210828153642.19396-1-sven@svenpeter.dev> <20210828153642.19396-4-sven@svenpeter.dev> <74621c69-ef68-c12a-3770-319cb7a0db73@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74621c69-ef68-c12a-3770-319cb7a0db73@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > On the IOMMU API level you have much more information available about the actual > > hardware and can prepare the buffers in a way that makes both devices happy. > > That's why iommu_map_sgtable combined with iovad->granule aligned sgt entries > > can actually guarantee to map the entire list to a single contiguous IOVA block. > > Essentially there are two reasonable options, and doing pretend dma-buf > export/import between two devices effectively owned by the same driver is > neither of them. Handily, DRM happens to be exactly where all the precedent > is, too; unsurprisingly this is not a new concern. > > One is to go full IOMMU API, like rockchip or tegra, attaching the relevant > devices to your own unmanaged domain(s) and mapping pages exactly where you > choose. You still make dma_map/dma_unmap calls for the sake of cache > maintenance and other housekeeping on the underlying memory, but you ignore > the provided DMA addresses in favour of your own IOVAs when it comes to > programming the devices. I guess this is the way to go for DCP. > The lazier option if you can rely on all relevant devices having equal DMA > and IOMMU capabilities is to follow exynos, and herd the devices into a > common default domain. Instead of allocating you own domain, you grab the > current domain for one device (which will be its default domain) and > manually attach the other devices to that. Then you forget all about IOMMUs > but make sure to do all your regular DMA API calls using that first device, > and the DMA addresses which come back should be magically valid for the > other devices too. It was a bit of a cheeky hack TBH, but I'd still much > prefer more of that over any usage of get_sgtable outside of actual > dma-buf... It'd probably be *possible* to get away with this for DCP but it'd probably involve more hacks, since the DARTs are not 100% symmetric and there are some contraints on the different DARTs involved. It'd also be less desirable -- there is no reason for the display coprocessor to know the actual *contents* of the framebuffer, only the IOVA valid only for the actual display hardware. These are two devices in hardware with two independent DARTs, by modeling as such we reduce the amount we need to trust the coprocessor firmware blob. > Note that where multiple IOMMU instances are involved, the latter approach > does depend on the IOMMU driver being able to support sharing a single > domain across them; I think that might sort-of-work for DART already, but > may need a little more attention. I think this already works (for USB-C).