Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp631066pxa; Fri, 14 Aug 2020 13:26:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqhycjAML/ln/iQobHOWZdC4//lkYMJeIfmDQ5TSe4x6ccyjdWC7TwR/U18slEZcI63O7g X-Received: by 2002:a05:6402:1d32:: with SMTP id dh18mr3989348edb.14.1597436798092; Fri, 14 Aug 2020 13:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597436798; cv=none; d=google.com; s=arc-20160816; b=aS+1yZuXZGmy18k+b/uXBhAEgv9jByU/5ksvjirPjTBwD087n+MQhz4zownvvH15pW hik3EMMYoR98KrfttUO/rx2wiUJEJWixHenj0SY8LhW10OcG/RBsOpvTnAsNdAU3tKDN u2oauNLMwkwD5+3A8crfNTUMSnPT9pYCLe2Hs3oHHzNueoqhqf9vU1v2dNIdxcSugwJw nnzsEMBsL8lm5g7LD1LfBHo/r9pec79/P0G6jRI0JRRfpiIaAE/n8sWuC5YAe003RwBq PHtby3Ala6nZOA2/PGXZLrhdQVm2+jRn4t94UHsUgpAb/s4CBMor0ujz5954Tgx5aXL2 ovhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/HUkdNM84ljYVpfdQwsu/yQY6q4YRBxXm3BX9/rPigE=; b=HbYDvCNab4Qqp9GKY618X3FLWEKScsmjUClp25oQKe1FrjJX+X41oSg/VYNPvSRU9C ZAufvDpFtNDrKYK6g9yEfI3RuMfkLv5MVFWA795NMTAdtK1ZjJ+k+HAohxP0nYWhQAPf cKs26xSPUjzlKrT8xgL2l1T3Lp4AXEG0l7Lhc7O4TwyoLGpgnL7ZMyAYbvyvR3Ld0MrP 3q43uy4jA/CZG+MDtpxwgtFg5yDMs9dfp4+j5Z4U1U/QZQTyEgD8AEaDG2QLCq5be970 y+YScctA2AIJVHATFTrkBDhH/d/bmJGT+DYZ0Thcb7MpEdexllt2VXC8H5cuD8kUPUdy yJgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GAvytVLo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di7si6198039edb.220.2020.08.14.13.26.15; Fri, 14 Aug 2020 13:26:38 -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; dkim=pass header.i=@linaro.org header.s=google header.b=GAvytVLo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728112AbgHNT5f (ORCPT + 99 others); Fri, 14 Aug 2020 15:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726297AbgHNT5e (ORCPT ); Fri, 14 Aug 2020 15:57:34 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8969C061385 for ; Fri, 14 Aug 2020 12:57:34 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id t7so8530116otp.0 for ; Fri, 14 Aug 2020 12:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=/HUkdNM84ljYVpfdQwsu/yQY6q4YRBxXm3BX9/rPigE=; b=GAvytVLoP1qHrSPjrY7AvPriL14EDS2LCXNorZdppdkMv6K/LZxo1h/EuzLi3SXVNi M6CS7DnFvAbtqX+J63O3C1V6T9+yKxrKLzx/qaF9zojFvtZ8gB2P5UK68H33Hph3w1cP dr0yOx7Q3ZzaJoXZYJrk8JcCCA9mJ1SGOKUITcQlZtslndFbmIqY5xDddbNqu0KwQmHn g7lYfVLtQMLwcrAPGlizolRKf6l8oAHACQ+K7IqCHagXujF9UeIYMDCY+YvAWGTADUPH YDzE5+swXhEtYXl2xOwaJ2MLIJ1aXEFutNfWQSZTIwGLAoDuMWsi8fyNc7BLEg2HknkV xG9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=/HUkdNM84ljYVpfdQwsu/yQY6q4YRBxXm3BX9/rPigE=; b=Btv8WeHlV49f35LAUZfBQID+L4YJQQdMrpK1vfwXsLT2yK5Wn2/GF5yMcGE9PdCNv2 374IoQYdXBRJrQ1Pn/nx3UakkLuED06uC6iFuqwtBMu55AW9fDzZJNGDm+hGVKvq6Xik fGVT6K2KXoHkhCd1SFKKDb2KWKTX4HvUgn9y68iDX0FcZj+r1XmLq3Brb7OhtWZXlWQ0 0GmX3eVOtjxb3xfpNFjwxAIa5VCdxwHUiGwfjJ9+lorWIFT3RZbZ+6eAWUMtd1TPoCeT LFbXbVmZzptVTtTkAsdotBdCPREOPn3EYXqYzBTDJGTF1G0taF8krWR3+tguhPG076Fp 0yXA== X-Gm-Message-State: AOAM533zSAtoz655RcMEAiU1v5ZCzsPRqt1TGADDwNih/XntSrcj7qr4 yWizJv3SOdev4+QUwhbGHi9hTjfLOzHDMwAtAqgR/A== X-Received: by 2002:a05:6830:3196:: with SMTP id p22mr3306479ots.102.1597435054060; Fri, 14 Aug 2020 12:57:34 -0700 (PDT) MIME-Version: 1.0 References: <20200814062458.53049-1-john.stultz@linaro.org> <20200814062458.53049-2-john.stultz@linaro.org> <20200814091713.GO2352366@phenom.ffwll.local> In-Reply-To: <20200814091713.GO2352366@phenom.ffwll.local> From: John Stultz Date: Fri, 14 Aug 2020 12:57:22 -0700 Message-ID: Subject: Re: [RFC][PATCH v2 2/2] dma-heap: Add a system-uncached heap To: John Stultz , lkml , dri-devel , Liam Mark , "Andrew F . Davis" , Laura Abbott , Hridya Valsaraju , Robin Murphy , linux-media@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 14, 2020 at 2:17 AM Daniel Vetter wrote: > > On Fri, Aug 14, 2020 at 06:24:58AM +0000, John Stultz wrote: > > This adds a heap that allocates non-contiguous buffers that are > > marked as writecombined, so they are not cached by the CPU. > > > > This is useful, as most graphics buffers are usually not touched > > by the CPU or only written into once by the CPU. So when mapping > > the buffer over and over between devices, we can skip the CPU > > syncing, which saves a lot of cache management overhead, greatly > > improving performance. > > > > For folk using ION, there was a ION_FLAG_CACHED flag, which > > signaled if the returned buffer should be CPU cacheable or not. > > With DMA-BUF heaps, we have no such flag, and by default the > > current heaps (system and cma) produce CPU cachable buffers. > > So for folks transitioning from ION to DMA-BUF Heaps, this fills > > in some of that missing functionality. > > > > This does have a few "ugly" bits that were required to get > > the buffer properly flushed out initially which I'd like to > > improve. So feedback would be very welcome! > > > > Many thanks to Liam Mark for his help to get this working. > > > > Cc: Sumit Semwal > > Cc: Andrew F. Davis > > Cc: Benjamin Gaignard > > Cc: Liam Mark > > Cc: Laura Abbott > > Cc: Brian Starkey > > Cc: Hridya Valsaraju > > Cc: Robin Murphy > > Cc: linux-media@vger.kernel.org > > Cc: dri-devel@lists.freedesktop.org > > Signed-off-by: John Stultz > > --- > > v2: > > * Fix build issue on sh reported-by: kernel test robot > > * Rework to use for_each_sgtable_sg(), dma_map_sgtable(), and > > for_each_sg_page() along with numerous other cleanups suggested > > by Robin Murphy > > Mildly annoying me, but where's the userspace for this? Do we have a > gralloc somewhere that works with open driver stacks and uses this? So this is still early RFC, but I've added support to the HiKey960 gralloc, and have pending patches (following DRM rules) I pushed here: https://android-review.googlesource.com/c/device/linaro/hikey/+/1399519 And avoiding the cache syncing overhead improves performance nicely on that board. There is also work in progress to change the codec2 implementation in AOSP (which uses ion directly), to move over to DMA BUF heaps and as it used the !ION_FLAG_CACHED case there this heap would be useful to match ION's functionality. The latest patches for that are here: https://android-review.googlesource.com/c/platform/frameworks/av/+/1360640 (though I'm expecting a deeper rework on those) thanks -john