Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5561161pxb; Tue, 16 Feb 2021 01:27:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzByNFv755HAE6H21oJRphuKTeB44bKJTn2QP+xBpRfclsEATdX7HSWGYQrwmRlQma+V0eN X-Received: by 2002:a17:906:f148:: with SMTP id gw8mr5870438ejb.313.1613467647717; Tue, 16 Feb 2021 01:27:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613467647; cv=none; d=google.com; s=arc-20160816; b=UkaHN5vMkpxKXtBbLfFuuvvxoNrD5ljSWZvp0UatU8r18HBitRAiZcxw+5EgvK2hIa +LMqDgpdB5xA+h/TnUQ5+UfSby9vnMhvFH1esVaWaqjdmOH1Xjl5GV7wm6F9xbsfJPg9 hDtDQBA/UPkdBZ77msOoc4qzFY+HK6keEfVxiLF6qHMuLrM7/KEFFTddUloVZ+p/AUv0 dQVHJr8PRPoNvzPz5bLaN7oPfgBtagbzdDeEgGptNwyDCptVWft27SH/fjfaE9ix77cU HZ5QbRWJHfPeElrFx5+lbkKLhzqMJ6SUFl4lkTUj5/39dRvMnkF+DOr6ZEOR+/tfe3bA Gyig== 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-transfer-encoding :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=Exh3jg3n/TtKnZWGfFfDIiOa1Lq+MYGlC1ET8Iputzc=; b=DgiWZ/+PGyb948OYIkEvZ8MTrgLZ1A8qBzLWd3HGrVT9vzdYAeE5Ucw/uAf8fYLnRX Ix6+mrFIr9UfaHmh9XnZ8iaPWFsLMuEMX3Mu7wsQhoKtwTLB8p13iYW39aBj31SrJemO HjbvRMQz6YtP2TIW9zD17zvU8unZFh7j10gUrORinU7kxrC2aHaZnF/zGOLAzLxGDZ+M 6a+pzgc6YagHkJyjSFbew1wI7XMj3E5/331rbgNvAp8gYdwLpO/1WeD43VeBU5gEu2QD G3iekA+esuvu+ahywxcam2vcLkEAYLbpg3wRAk91DdzZeKwouy1aZ1ytOWJMhGoJXXWe TXvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=FChGD3Ii; 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 lz18si1069122ejb.576.2021.02.16.01.27.04; Tue, 16 Feb 2021 01:27:27 -0800 (PST) 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; dkim=pass header.i=@ffwll.ch header.s=google header.b=FChGD3Ii; 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 S229928AbhBPJ0N (ORCPT + 99 others); Tue, 16 Feb 2021 04:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbhBPJ0I (ORCPT ); Tue, 16 Feb 2021 04:26:08 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20909C061756 for ; Tue, 16 Feb 2021 01:25:28 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id o24so13711698wmh.5 for ; Tue, 16 Feb 2021 01:25:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Exh3jg3n/TtKnZWGfFfDIiOa1Lq+MYGlC1ET8Iputzc=; b=FChGD3IiT+eQbJpCR9t7O50n/LmrueYQUvA0eedPnhjL5FwTbBAttUChubzubHzzE+ TeFuh3DkLKYTv67VzE91ha47D+tgaEiPVy7rJ8lWsQfLHaZRVt0jwRWzxCBbPr4HwnVv asszquvZj2WmDxHU3OWs1baFcapv1QK36SGy0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to; bh=Exh3jg3n/TtKnZWGfFfDIiOa1Lq+MYGlC1ET8Iputzc=; b=UiEvQGocy+gDutekLoRPI4mekgDLkNiJDbw6cAw/46qSiBZJwUpBmm04Ipc4dK9pkb PYg9csPvBlvORGvErFQ/7ssseLtXtzebmWWQB/npUmPbDhh5LfSCA23O9K6nXZ89JxYw UdI6Bwn67TdX/nvLgyRIZc0TJkspzcQt5Dzi5V69wW66QgeXEFnEgVW1XB17/0Bwb3vi xwL78C1qZjzIKpWNL/hg3CjjmbiTWKvtGQNLjZ3OSdvNcDL8f+fhJwzdhDY+uwLVuPPH 3gfBfOMuQMiB3kUxlFkj3b5E2xx22PaLcxp+EeCrLw+2+oy3fyd1j5uxZ7R5CQhQHyDU fuFQ== X-Gm-Message-State: AOAM532UEO0VKIOKLH0knJTwTUKBjVYBBH5sLZzRQjPzLUqKDqjqFNGA //SdkIpnOaarRGufBlRXQ0zEW3BFl5Fq82JC X-Received: by 2002:a7b:c010:: with SMTP id c16mr2501284wmb.134.1613467526735; Tue, 16 Feb 2021 01:25:26 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id k11sm26838869wrv.51.2021.02.16.01.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 01:25:26 -0800 (PST) Date: Tue, 16 Feb 2021 10:25:24 +0100 From: Daniel Vetter To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: linux-media , dri-devel , linaro-mm-sig@lists.linaro.org, lkml , Sumit Semwal , Daniel Vetter , "Sharma, Shashank" Subject: Re: DMA-buf and uncached system memory Message-ID: Mail-Followup-To: Christian =?iso-8859-1?Q?K=F6nig?= , linux-media , dri-devel , linaro-mm-sig@lists.linaro.org, lkml , Sumit Semwal , "Sharma, Shashank" References: <91ff0bbb-ea3a-2663-3453-dea96ccd6dd8@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <91ff0bbb-ea3a-2663-3453-dea96ccd6dd8@amd.com> X-Operating-System: Linux phenom 5.7.0-1-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 15, 2021 at 09:58:08AM +0100, Christian K?nig wrote: > Hi guys, > > we are currently working an Freesync and direct scan out from system memory > on AMD APUs in A+A laptops. > > On problem we stumbled over is that our display hardware needs to scan out > from uncached system memory and we currently don't have a way to communicate > that through DMA-buf. > > For our specific use case at hand we are going to implement something driver > specific, but the question is should we have something more generic for > this? > > After all the system memory access pattern is a PCIe extension and as such > something generic. Yes it's a problem, and it's a complete mess. So the defacto rules are: 1. importer has to do coherent transactions to snoop cpu caches. This way both modes work: - if the buffer is cached, we're fine - if the buffer is not cached, but the exporter has flushed all the caches, you're mostly just wasting time on inefficient bus cycles. Also this doesn't work if your CPU doesn't just drop clean cachelines. Like I thing some ARM are prone to do, not idea about AMD, Intel is guaranteed to drop them which is why the uncached scanout for integrated Intel + amd discrete "works". 2. exporters picks the mode freely, and can even change it at runtime (i915 does this, since we don't have an "allocate for scanout" flag wired through consistently). This doesn't work on arm, there the rule is "all devices in the same system must use the same mode". 3. This should be solved at the dma-buf layer, but the dma-api refuses to tell you this information (at least for dma_alloc_coherent). And I'm not going to deal with the bikeshed that would bring into my inbox. Or at least there's always been screaming that drivers shouldn't peek behind the abstraction. So I think if AMD also guarantees to drop clean cachelines just do the same thing we do right now for intel integrated + discrete amd, but in reserve. It's fragile, but it does work. What we imo shouldn't do is driver private interfaces here, that's just going to make the problem worse long term. Or at least driver-private interfaces that spawn across drivers behind dma-buf, because imo this is really a problem that dma-buf should solve. If you do want to solve this at the dma-buf level I can try and point you at the respective i915 and amdgpu code that makes the magic work - I've had to fix it a few times in the past. I'm not sure whether we'd need to pass the dynamic nature through though, i.e. whether we want to be able to scan out imported dma-buf and hence request they be used in uncached mode. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch