Received: by 2002:ac0:a874:0:0:0:0:0 with SMTP id c49csp259130ima; Fri, 15 Mar 2019 02:08:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwc9YrTseeZHb73MAjXSQ/H/3doJqAy2m1PxStsfKN7Nr7j1tWb2g6jAv/1e2t9exj32FnY X-Received: by 2002:aa7:8459:: with SMTP id r25mr3014124pfn.65.1552640909583; Fri, 15 Mar 2019 02:08:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552640909; cv=none; d=google.com; s=arc-20160816; b=MTEfbu/EJUYSGPLCC1CUEhNViojlk/xbnes8GuDVBy2JLTIeMSzWdWAqA4Cr7Hbu+v WxpjOoZiWovPJxx+6uHHUe3GXPU6jh/Gl1zvNPZW/x3I7A3nK3MAbtgGDuMGGwYZMJFJ pEscResyhCWz0XjQcu9s2Z4ljvw4rIgq259RC92+LeJfFZA7ohIxp8qWfVSjPgDJrYQ1 Wqz/2dhqkrUsbf+Jq+gUYWnaPYkliJDkb8Oa8djKj5rNfoI++X6Z7R7AEe3v+HGoUp+c YZyyB/aXCq9rMZCaOvJHnziuJYPH693ht8t6bRZIGfKkoxk8x5wfHnkaC7NpGg3WJGXj fGcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=dhnvin1A+/DeqhKqw1M209Ghaxo83lMkAF87K2TEozs=; b=rRdjSePDPJslpQeoIczgRB57QgUD5vtKwSZxvhdtkUNidkZxjNOKfO045I29vn/JjP uiktl1MdkKirLg+8n500saFiHxWDRApFA2ojIdUEmpiP0Ah022OQugnH/ecHUmOgcF1C wr0vFv2kX5NNU82J62lhMNCP0K42AEAqNb+4ssDUtJrZ2EmzJ+3ntufJH3Umy/z9jJN8 xALCXoY7Brh8bbCvIkar/rhYPDxChpG0aOz7AYl6L1v9R12jx1qCJkA+2kiJA0Hj9C4N B0Oi0Aha1W064hq/zxNhmzoguWDpJP/l5DdqGOT0FdZX1tAb191aOXa3mxD1U4u42N8K Lvew== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=D2sYvTvA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p10si1256254plk.413.2019.03.15.02.08.15; Fri, 15 Mar 2019 02:08:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=D2sYvTvA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728747AbfCOJHQ (ORCPT + 99 others); Fri, 15 Mar 2019 05:07:16 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:34934 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728658AbfCOJGu (ORCPT ); Fri, 15 Mar 2019 05:06:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=dhnvin1A+/DeqhKqw1M209Ghaxo83lMkAF87K2TEozs=; b=D2sYvTvAumK+FL7XrQVQgorza 4cMnFHz2EAvIXuIzRbGbVloAQMtw+9/UzmPIJPqu6AXGHCA+TEsrlSyISslUYYHSbkRc1hdpuksJT j7m0I8BHNdfzii7yIWOdHu7p3SA10ZOJmQK21RMKm5tTiytHg34gSkJ/B9X4VdfvlYYjJfp34vS7X 9w6ZbqIdvKa2+yQB9tYTM4z4ap62L99exHTylNrUwG4MBI4vMq53wdDkvzsDYYle1ekq+LuZoZ8st R55qkSc3KCnSRjaJ7PYkUFL1SQRnLpUzlOrM2Q7xaRqKrrBwtkKki42QGTsYOD7RX8BLO7JmMlxG4 l2C8fzGLA==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1h4inh-0008Du-NK; Fri, 15 Mar 2019 09:06:49 +0000 Date: Fri, 15 Mar 2019 02:06:49 -0700 From: Christoph Hellwig To: John Stultz Cc: lkml , Laura Abbott , Benjamin Gaignard , Greg KH , Sumit Semwal , Liam Mark , Brian Starkey , "Andrew F . Davis" , Chenbo Feng , Alistair Strachan , dri-devel@lists.freedesktop.org Subject: Re: [RFC][PATCH 3/5 v2] dma-buf: heaps: Add system heap to dmabuf heaps Message-ID: <20190315090649.GD4470@infradead.org> References: <1551819273-640-1-git-send-email-john.stultz@linaro.org> <1551819273-640-4-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551819273-640-4-git-send-email-john.stultz@linaro.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > + i = sg_alloc_table(table, npages, GFP_KERNEL); > + if (i) > + goto err1; > + for_each_sg(table->sgl, sg, table->nents, i) { > + struct page *page; > + > + page = alloc_page(GFP_KERNEL); > + if (!page) > + goto err2; > + sg_set_page(sg, page, PAGE_SIZE, 0); > + } Given that one if not the primary intent here is to DMA map the memory this is a bad idea, as it might require bounce buffering. What we really want here is something like this: http://git.infradead.org/users/hch/misc.git/shortlog/refs/heads/dma-noncoherent-allocator.3 And I wonder if the S/G building should also move into common code instead of being duplicated everywhere. > +static int system_heap_create(void) > +{ > + struct system_heap *sys_heap; > + > + sys_heap = kzalloc(sizeof(*sys_heap), GFP_KERNEL); > + if (!sys_heap) > + return -ENOMEM; > + sys_heap->heap.name = "system_heap"; > + sys_heap->heap.ops = &system_heap_ops; > + > + dma_heap_add(&sys_heap->heap); Why is this dynamically allocated?