From patchwork Fri Dec 13 22:23:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22377 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5EE3823FBA for ; Fri, 13 Dec 2013 22:26:26 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id f12sf300679vbg.8 for ; Fri, 13 Dec 2013 14:26:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=S/VY3UnOZRSI79WaCoJNqjIXGdn13u6LxMedXXKQoMI=; b=adTytXLgF+LVyDB5p46slCn1AIUnHj0aX6C61WH+kPBvlr3FbERI0CjcEL0hvwFmGh WfWHTimNyHFIIdWuYGXl5XI7OOCwe0ir5Bjtra1dBEmddJVCqrSWzobL7IYk1rni9HYA BPWzsA5hzoneUQ+2Wi0H7X2x8C0ZQ2u8oCysYiUxLQwNQ5ud+DIbw3LQyeJdVKNoJh3y XUzhY4mcb35oRsZjJJeEHiumRceGihfxN2eaK5O2ZGLzSJMhC9JB2Fm+ZIz+OPAlQEVc PqhDvoOpDny5sRKdzczIthGv0f5m2HA/9kNe5lZTLbiqY1m0Nj63EctiiPBuWiPhoRpP 9dzA== X-Gm-Message-State: ALoCoQnvfRPjnX+mRjJyroHztBi2BkY8ekWGcfJb1NpEIQjSs1y6EjbraXo42iktuNAW0O4Y04b1 X-Received: by 10.236.147.18 with SMTP id s18mr1726213yhj.28.1386973586175; Fri, 13 Dec 2013 14:26:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.201 with SMTP id ec9ls1221898qeb.60.gmail; Fri, 13 Dec 2013 14:26:25 -0800 (PST) X-Received: by 10.58.246.136 with SMTP id xw8mr2164252vec.41.1386973585960; Fri, 13 Dec 2013 14:26:25 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id tj7si1188312vdc.111.2013.12.13.14.26.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 14:26:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so1851398veb.32 for ; Fri, 13 Dec 2013 14:26:25 -0800 (PST) X-Received: by 10.220.124.68 with SMTP id t4mr2223730vcr.52.1386973585865; Fri, 13 Dec 2013 14:26:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp73460vcz; Fri, 13 Dec 2013 14:26:25 -0800 (PST) X-Received: by 10.68.220.72 with SMTP id pu8mr5911368pbc.83.1386973585025; Fri, 13 Dec 2013 14:26:25 -0800 (PST) Received: from mail-pd0-f175.google.com (mail-pd0-f175.google.com [209.85.192.175]) by mx.google.com with ESMTPS id j8si917318pad.207.2013.12.13.14.26.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 14:26:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.175 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.175; Received: by mail-pd0-f175.google.com with SMTP id w10so3020169pde.34 for ; Fri, 13 Dec 2013 14:26:24 -0800 (PST) X-Received: by 10.66.121.164 with SMTP id ll4mr6200798pab.48.1386973584644; Fri, 13 Dec 2013 14:26:24 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id qz9sm7457908pbc.3.2013.12.13.14.26.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 14:26:23 -0800 (PST) From: John Stultz To: LKML Cc: Greg KH , Android Kernel Team , Sumit Semwal , Jesse Barker , Colin Cross , Rebecca Schultz Zavin , John Stultz Subject: [PATCH 012/115] gpu: ion: Set the dma_address of the sg list at alloc time Date: Fri, 13 Dec 2013 14:23:46 -0800 Message-Id: <1386973529-4884-13-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1386973529-4884-1-git-send-email-john.stultz@linaro.org> References: <1386973529-4884-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Rebecca Schultz Zavin This patch sets the dma_address field of the sglist representing an allocation at allocation time. This technically breaks the dma api which states that these addresses should be set when a particular device takes ownership of a buffer via the dma_map apis. In the case of our systems the only dma address space is physical addresses. Additionally, we can not afford the overhead of calling dma_map_sg from this location as it implies a cache invalidate that is not necessary if the memory was previously mapped cached. Instead, the expectation is that memory being returned from the heaps is ready for dma in that if any cached mappings of that memory exist they have been invalidated. Signed-off-by: Rebecca Schultz Zavin [jstultz: modified patch to apply to staging directory] Signed-off-by: John Stultz --- drivers/staging/android/ion/ion.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 552a86a..ddfe49a 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -136,7 +136,8 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, { struct ion_buffer *buffer; struct sg_table *table; - int ret; + struct scatterlist *sg; + int i, ret; buffer = kzalloc(sizeof(struct ion_buffer), GFP_KERNEL); if (!buffer) @@ -163,6 +164,16 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, buffer->sg_table = table; mutex_init(&buffer->lock); + /* this will set up dma addresses for the sglist -- it is not + technically correct as per the dma api -- a specific + device isn't really taking ownership here. However, in practice on + our systems the only dma_address space is physical addresses. + Additionally, we can't afford the overhead of invalidating every + allocation via dma_map_sg. The implicit contract here is that + memory comming from the heaps is ready for dma, ie if it has a + cached mapping that mapping has been invalidated */ + for_each_sg(buffer->sg_table->sgl, sg, buffer->sg_table->nents, i) + sg_dma_address(sg) = sg_phys(sg); ion_buffer_add(dev, buffer); return buffer; }