From patchwork Fri Jul 17 11:01:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Jon Medhurst \(Tixy\)" X-Patchwork-Id: 51229 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 65A5822A8D for ; Fri, 17 Jul 2015 11:01:42 +0000 (UTC) Received: by lbvb1 with SMTP id b1sf24667663lbv.3 for ; Fri, 17 Jul 2015 04:01:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:message-id:subject:from:to:cc:date :content-type:mime-version:content-transfer-encoding:sender :precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=WgoHxfoNYG4RxdmMfv1VYgo6KaVFNTjqEjiwwFqEKFE=; b=E5iKxj9cKwcGFzkrvyrUO5sKqFtMZcD2MM8uX+p0qFci4j/XuyUQmCQ6wE2rOVmadQ aj27laY65OP3zUIkprKRxzpjKH/h9jw1ufguem2YLSlHFriJtaD42OBiAguZ62u6vqDg WMXyN65VEaWnvizWDqcJ4N0ZIRqwbvMdFsV2NLOx/n6mf6BXfd9atRF6w3q2opdeyuyL pelb2wrJZU9CpLj8y/A/L3X/o/3D2HFq7xUi79u+Aw0Mv8OEZwlaCjEUDVKFNqU3Ho+/ xtGJV8iqTa3LEQvRSYWcKD82QKZMj9UmP2nuoSm5zbBnQL4sbxpzPfh+7QGKO8ZqE+/k wQlA== X-Gm-Message-State: ALoCoQm/olfS907pF0moWDz2rI2D09eEPkADtBEY7YMzu+2whK72RTPdWe0dgyjNu1XT1iit85P7 X-Received: by 10.112.54.166 with SMTP id k6mr7316762lbp.0.1437130901105; Fri, 17 Jul 2015 04:01:41 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.6 with SMTP id o6ls463336lah.56.gmail; Fri, 17 Jul 2015 04:01:40 -0700 (PDT) X-Received: by 10.112.157.36 with SMTP id wj4mr13980193lbb.115.1437130900859; Fri, 17 Jul 2015 04:01:40 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id b10si9603014laf.38.2015.07.17.04.01.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jul 2015 04:01:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lblf12 with SMTP id f12so59163657lbl.2 for ; Fri, 17 Jul 2015 04:01:40 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr13837381lbc.72.1437130900418; Fri, 17 Jul 2015 04:01:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp838098lbb; Fri, 17 Jul 2015 04:01:39 -0700 (PDT) X-Received: by 10.70.138.70 with SMTP id qo6mr28039942pdb.163.1437130898569; Fri, 17 Jul 2015 04:01:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si18180364pdc.102.2015.07.17.04.01.37; Fri, 17 Jul 2015 04:01:38 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757985AbbGQLBg (ORCPT + 28 others); Fri, 17 Jul 2015 07:01:36 -0400 Received: from smarthost01c.mail.zen.net.uk ([212.23.1.5]:47260 "EHLO smarthost01c.mail.zen.net.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757850AbbGQLBe (ORCPT ); Fri, 17 Jul 2015 07:01:34 -0400 Received: from [82.69.122.217] (helo=linaro1) by smarthost01c.mail.zen.net.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZG3OU-0006m7-OI; Fri, 17 Jul 2015 11:01:30 +0000 Message-ID: <1437130889.3221.53.camel@linaro.org> Subject: [PATCH] staging: ion: ion_cma_heap: Don't directly use dma_common_get_sgtable From: "Jon Medhurst (Tixy)" To: Greg Kroah-Hartman , Arve =?ISO-8859-1?Q?Hj=F8nnev=E5g?= , Riley Andrews Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, Zeng Tao , Laura Abbott , Robin Murphy Date: Fri, 17 Jul 2015 12:01:29 +0100 X-Mailer: Evolution 3.12.9-1+b1 Mime-Version: 1.0 X-Originating-smarthost01c-IP: [82.69.122.217] Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tixy@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Use dma_get_sgtable rather than dma_common_get_sgtable so a device's dma_ops aren't bypassed. This is essential in situations where a device uses an IOMMU and the physical memory is not contiguous (as the common function assumes). Signed-off-by: Jon Medhurst --- This also begs the question as to what happens if the memory region _is_ contiguous but is in highmem or an ioremapped region. Should a device always provide dma_ops for that case? Because I believe the current implementation of dma_common_get_sgtable won't work for those as it uses virt_to_page. I see that this point has been raised before [1] by Zeng Tao, and I myself have been given a different fix to apply to a Linaro kernel tree. However, both solutions looked wrong to me as they treat a dma_addr_t as a physical address, so should at least be using dma_to_phys. So, should we fix dma_common_get_sgtable or mandate that the device has dma_ops? The latter seems to be implied by the commit message which introduced the function: This patch provides a generic implementation based on virt_to_page() call. Architectures which require more sophisticated translation might provide their own get_sgtable() methods. Note, I don't have a system where any of this code is used to test things, and have never looked at this area before yesterday, so I may have misunderstood what’s going on in the code. [1] https://lkml.org/lkml/2014/12/1/584 drivers/staging/android/ion/ion_cma_heap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index f4211f1..86b91fd 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -73,8 +73,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (!info->table) goto free_mem; - if (dma_common_get_sgtable - (dev, info->table, info->cpu_addr, info->handle, len)) + if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle, len)) goto free_table; /* keep this for memory release */ buffer->priv_virt = info;