From patchwork Wed May 25 19:48:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9136143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 939F1607D3 for ; Wed, 25 May 2016 19:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8285128123 for ; Wed, 25 May 2016 19:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76559281FE; Wed, 25 May 2016 19:51:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3181928123 for ; Wed, 25 May 2016 19:51:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5ep6-0005VX-Vq; Wed, 25 May 2016 19:50:32 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b5ep4-0005Uq-Oz for linux-arm-kernel@bombadil.infradead.org; Wed, 25 May 2016 19:50:30 +0000 Received: from mail-qk0-f176.google.com ([209.85.220.176]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1b5ep3-0005Ku-GF for linux-arm-kernel@lists.infradead.org; Wed, 25 May 2016 19:50:29 +0000 Received: by mail-qk0-f176.google.com with SMTP id n63so42931158qkf.0 for ; Wed, 25 May 2016 12:50:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jJFIUi079RaU+Z9QKRZfw9ogE26QOI/3r1zt7Y04Cf8=; b=ijj20rnsU8QcR1IKUktMZ9izgEirBQC3zUsHOk3u48B7DhHa5AXqBmwviMzSNA0/nu /npkzc6ZaxTszPxqOJ0/pZh+nXkQekbiEKB0BCnrBMbWm/YJ10/PC/l/SCWVpbdeuhkG bj9/vJWKsb6+aqSf8PDZvZFmOn/1NiTzMcusqbmnaqqjgucvRdWGj1UDS2EeLIrnLscX DQmy5O58Ta7Elq9W0KdwZWPTcS6XHh2POZCepYIgp0XBosSqW9NVPuNabAnIiYfgw6Vv YNP9XjcPzLMmLACTLfaH7vpihcZdXd2XtBbdGW1r0gwgIUgIMHrx8mNrbdxu5gml+Lt9 zaFQ== X-Gm-Message-State: ALyK8tJXpyLKMmcwNGP+r8BH9VveVQNFtd3+BWLr25XzkGdvybpIJMB8bXMgrGTsG9M1zOMJ X-Received: by 10.55.112.69 with SMTP id l66mr5611343qkc.20.1464205702075; Wed, 25 May 2016 12:48:22 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9800:177f::337f]) by smtp.gmail.com with ESMTPSA id w48sm101110qgd.42.2016.05.25.12.48.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 May 2016 12:48:21 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , John Stultz , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Riley Andrews Subject: [RFC][PATCH 3/3] staging: ion: Add dma_map/dma_unmap calls to dma_buf calls Date: Wed, 25 May 2016 12:48:04 -0700 Message-Id: <1464205684-5587-4-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464205684-5587-1-git-send-email-labbott@redhat.com> References: <1464205684-5587-1-git-send-email-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160525_155029_574815_0F6294B4 X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Jon Medhurst , Android Kernel Team , Greg Kroah-Hartman , Daniel Vetter , Will Deacon , Russell King , linux-kernel@vger.kernel.org, linaro-mm-sig@lists.linaro.org, Rohit kumar , Bryan Huntsman , Jeremy Gebben , Eun Taik Lee , Catalin Marinas , Liviu Dudau , Laura Abbott , Mitchel Humpherys , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The .map_dma_buf/.unmap_dma_buf function calls are designed for buffer users to perform DMA accesses. Ion doesn't call into the lower DMA layer currently. This may leave mapping incomplete for devices with more complex topologies (e.g. IOMMUs). Add the appropriate dma_map calls to the dma_buf call backs. Signed-off-by: Laura Abbott --- drivers/staging/android/ion/ion.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 2096592..52dbea4 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -980,7 +980,18 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment, struct dma_buf *dmabuf = attachment->dmabuf; struct ion_buffer *buffer = dmabuf->priv; + /* Necessary but not sufficient: This is for userspace */ ion_buffer_sync_for_device(buffer, attachment->dev, direction); + + /* The rest of this is for the standard mappings */ + buffer->sg_table->nents = dma_map_sg(attachment->dev, + buffer->sg_table->sgl, + buffer->sg_table->orig_nents, + direction); + + if (!buffer->sg_table->nents) + return ERR_PTR(-EIO); + return buffer->sg_table; } @@ -988,6 +999,7 @@ static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment, struct sg_table *table, enum dma_data_direction direction) { + dma_unmap_sg(attachment->dev, table->sgl, table->nents, direction); } static int ion_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)