Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1445592pxb; Thu, 28 Jan 2021 17:27:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOGFQrbuF2wTdIvEHEc6BpVPEFhijDQwxnFWGTLYdfaHx4tTM1sVDqHqAfqPIU3KXLe0jp X-Received: by 2002:a17:906:3101:: with SMTP id 1mr2280884ejx.115.1611883678368; Thu, 28 Jan 2021 17:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611883678; cv=none; d=google.com; s=arc-20160816; b=Pzln3glFePFh+Dv+HTY8bbsgOMnjf7uYfciqwTsylkzgR/JlsfiNcQKjbjM09+B6ZB BYsEhrkchKyOdWDYsJBfNpl0ibhH/Y+giIr7kHzk49isRCknwjyik/vdOYB1bRRtzIjT luSK2cSl/tg+qavEyxrA5IoegDtUn9EYajtelRPugQGyGO6pWEVKm7kcmXhn5cCmRx38 YOGY5jqB1/QljAMdPmunm7VDiTR2ayNMCbVkqkjizvRypS/68Egr6QUDEtWSsCLlDIr9 hHxP4EMCoNsky6VPlQDJUyNs/xsDz0zVfKnh8NIXJvzExHhn2OTXtrJtLd5OYZFPx/QH TWMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sjkb6yXWtZ9Sxv1/gNdqQbGBoN1+dPLaicMA2ZT6rNM=; b=Apew6tg55iU1UjyZ6hwY70GzTd0OVlT64biRMjwJ3CGqO1NVTwYVKxjXxU5u3iQCr8 TlYvLLkMs9ymjKKWJCsVjGNor8Zud6gWPYb3JORquShME7u17HzG79RPWrt5XnnvPWdZ gw2OjSgFPZIMt2h18FhbR5ZEGTUjFmIUnlK/LKPzoaWH7mkTLkJsbE3h3J2u3nwkMKKP 43CurAuxa+xSwc6S7qbdDMv53d7wpSyAxOHFhZn6DiE4f+CGM5U1ErwtLg4Qjn9KVUpG Ca9956IfJcwGvXxJRoXL1pEfxR5KngLR76+rvJPAX3igLBFCrYOlBqW2xZ1uWvvKSzTa Ajhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=iCLYU3fu; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm10si4203022edb.372.2021.01.28.17.27.34; Thu, 28 Jan 2021 17:27:58 -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=@google.com header.s=20161025 header.b=iCLYU3fu; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231687AbhA2BYG (ORCPT + 99 others); Thu, 28 Jan 2021 20:24:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231601AbhA2BYF (ORCPT ); Thu, 28 Jan 2021 20:24:05 -0500 Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A4CAC061574 for ; Thu, 28 Jan 2021 17:23:25 -0800 (PST) Received: by mail-vs1-xe2f.google.com with SMTP id b5so4087910vsh.3 for ; Thu, 28 Jan 2021 17:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sjkb6yXWtZ9Sxv1/gNdqQbGBoN1+dPLaicMA2ZT6rNM=; b=iCLYU3fuPsvJZltkAom5unfVux3qbx/84SoQSmqh5RtsiImcrCdGMT31C6+1ENMBLS 0+LRiLAsmRhmOFQ5Q3GHbyu5aZ74aQkQRyaA63MegeLEXfmWLspArV+SQzI3/B/1cGxJ 1rQ42u/3utf0mvm4yEsRiVY+BSTy3WgKy9UUCY1jQR27gxY3lKBZJ2MjQvlH/Y3jc8R5 O3KBn5Wfuxbpq3cWKoGssSVuk/IPGSipcB70yiVvVwUkdP1OYGYUTRRJlSo87uQH/33A B+txLKIct1lZEOxXRo12HH2AlAlcCOCVY8UJXBD8D02HEcysxUof5gYWcOYymjgwUMGv a2ew== 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:cc; bh=sjkb6yXWtZ9Sxv1/gNdqQbGBoN1+dPLaicMA2ZT6rNM=; b=tWiGXtHOJuuOcfgtfJlw48UdSe5TMpIqNWffrDTXGZ5cySFgXViJ1spVl5qkahB5z+ tTt4CIvoFXtXwfvCAWSQ0QjazGicZYylM5PtCuA3u5goI7DM3C1B2Mb7uPJMCE+dqE9F 0MjgWDQ+TLKKP0GZDgO1O9qJblCl9jBjNRgAPdVFdZmJDtf5yLP7+YaO+qMrM8d7secb EPA8+dbQqoszBMUKgkQtqg9WA8mbv2boEFcXiYsdTc4/6mqdHP5HvPeRqlpcutXb79HY eH+oCa47wEo2cnXu8mquz2hf4JxHgARYD3jZ5dkxY2djZInXYDMbd4CRAAysuv4DjBuj WpAQ== X-Gm-Message-State: AOAM530Zf1AdTO3AbE+4uK6OItEWQMkvuxYlzi6RnX46ItPQyP+Xe3pZ 1aodggbPOvwkqbHkDvsIQ6ZXpHqykaKxTi91E4P+SQ== X-Received: by 2002:a67:f810:: with SMTP id l16mr1395266vso.41.1611883403850; Thu, 28 Jan 2021 17:23:23 -0800 (PST) MIME-Version: 1.0 References: <20201003040257.62768-1-john.stultz@linaro.org> <20201003040257.62768-8-john.stultz@linaro.org> <20201008115101.4qi6wh3hhkb6krg5@DESKTOP-E1NTVVP.localdomain> In-Reply-To: From: Daniel Mentz Date: Thu, 28 Jan 2021 17:23:12 -0800 Message-ID: Subject: Re: [PATCH v3 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap To: John Stultz Cc: Brian Starkey , lkml , Sumit Semwal , Liam Mark , Laura Abbott , Hridya Valsaraju , Suren Baghdasaryan , Sandeep Patil , Chris Goldsworthy , =?UTF-8?Q?=C3=98rjan_Eide?= , Robin Murphy , Ezequiel Garcia , Simon Ser , James Jones , linux-media , dri-devel , nd Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 16, 2020 at 12:04 PM John Stultz wrote: > > On Thu, Oct 8, 2020 at 4:51 AM Brian Starkey wrote: > > On Sat, Oct 03, 2020 at 04:02:57AM +0000, John Stultz wrote: > > > @@ -393,6 +424,16 @@ static int system_heap_allocate(struct dma_heap *heap, > > > /* just return, as put will call release and that will free */ > > > return ret; > > > } > > > + > > > + /* > > > + * For uncached buffers, we need to initially flush cpu cache, since > > > + * the __GFP_ZERO on the allocation means the zeroing was done by the > > > + * cpu and thus it is likely cached. Map (and implicitly flush) it out > > > + * now so we don't get corruption later on. > > > + */ > > > + if (buffer->uncached) > > > + dma_map_sgtable(dma_heap_get_dev(heap), table, DMA_BIDIRECTIONAL, 0); > > > > Do we have to keep this mapping around for the entire lifetime of the > > buffer? > > Yea, I guess we can just map and unmap it right there. It will look a > little absurd, but that sort of aligns with your next point. > > > Also, this problem (and solution) keeps lingering around. It really > > feels like there should be a better way to solve "clean the linear > > mapping all the way to DRAM", but I don't know what that should be. > > Yea, something better here would be nice... In ION, we had a little helper function named ion_buffer_prep_noncached that called arch_dma_prep_coherent() on all sg entries like so for_each_sg(table->sgl, sg, table->orig_nents, i) arch_dma_prep_coherent(sg_page(sg), sg->length); Would that help?