From patchwork Sat May 25 00:19:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 17209 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f198.google.com (mail-vc0-f198.google.com [209.85.220.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C4873238FC for ; Sat, 25 May 2013 00:21:14 +0000 (UTC) Received: by mail-vc0-f198.google.com with SMTP id gd11sf6276428vcb.9 for ; Fri, 24 May 2013 17:20:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=zCCCCjs8As+uRmcfXDjzUVlGOTRkLoxZrBAKRysY4M8=; b=MwTbt3Y81CsS4vf1G1BOtHePIc3mDSnsh0OUDb0wobOEJlILJil2YyE7fGtSThXktE Dvkq2qQDz+uK2z90Qxg0CFZtDmyVdcYvwuFq1MMY8J6WqEDILBwwdNlK7S1OYkx9ZJSo Fyb5jyazf+KYSaoXnbSR7gARVo/o4mf88TKaZuU/QLEKcVJgQH/MupR30ekTpRyYNW6L FuZMgWehDdQ4FiG3+SwVLoFQp3Jay95bDB5Y8+FxPSw6DepDFzBh6X6euvWi2E7RZ/eU SIzIdnX1NMDGNy0lcHRPbVUt0nl+eACxYBc388GUjcmVtVxsj9Kh9RzMHprblRYXO7i/ Hqrw== X-Received: by 10.224.36.66 with SMTP id s2mr9632643qad.6.1369441216333; Fri, 24 May 2013 17:20:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.13.199 with SMTP id j7ls2095782qec.61.gmail; Fri, 24 May 2013 17:20:16 -0700 (PDT) X-Received: by 10.58.221.134 with SMTP id qe6mr10142731vec.2.1369441216203; Fri, 24 May 2013 17:20:16 -0700 (PDT) Received: from mail-vb0-x230.google.com (mail-vb0-x230.google.com [2607:f8b0:400c:c02::230]) by mx.google.com with ESMTPS id un20si10906436veb.29.2013.05.24.17.20.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 May 2013 17:20:16 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::230; Received: by mail-vb0-f48.google.com with SMTP id w8so2553305vbf.7 for ; Fri, 24 May 2013 17:20:16 -0700 (PDT) X-Received: by 10.220.112.16 with SMTP id u16mr10193786vcp.40.1369441215998; Fri, 24 May 2013 17:20:15 -0700 (PDT) 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.126.138 with SMTP id c10csp123662vcs; Fri, 24 May 2013 17:20:15 -0700 (PDT) X-Received: by 10.68.184.100 with SMTP id et4mr19715008pbc.48.1369441215061; Fri, 24 May 2013 17:20:15 -0700 (PDT) Received: from mail-pa0-f47.google.com (mail-pa0-f47.google.com [209.85.220.47]) by mx.google.com with ESMTPS id av8si13969743pbd.69.2013.05.24.17.20.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 May 2013 17:20:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.47 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.47; Received: by mail-pa0-f47.google.com with SMTP id kl12so1431302pab.34 for ; Fri, 24 May 2013 17:20:14 -0700 (PDT) X-Received: by 10.68.230.40 with SMTP id sv8mr19848020pbc.30.1369441214670; Fri, 24 May 2013 17:20:14 -0700 (PDT) Received: from localhost.localdomain (c-24-21-54-107.hsd1.or.comcast.net. [24.21.54.107]) by mx.google.com with ESMTPSA id 3sm18032243pbj.46.2013.05.24.17.20.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 24 May 2013 17:20:13 -0700 (PDT) From: John Stultz To: Jesse Barker Cc: John Stultz , Arnd Bergmann , Serban Constantinescu Subject: [PATCH 2/4] ion: Remove the kernel mapping functions [squish me!] Date: Fri, 24 May 2013 17:19:43 -0700 Message-Id: <1369441185-3434-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1369441185-3434-1-git-send-email-john.stultz@linaro.org> References: <1369441185-3434-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQkeG6h2hDxDHHU/M1duXb2CkCUdR58rCbH+Mxk6jSiQKQNI/7/iLH861lXXoW2y1+AagnoY X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::230 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: , This patch removes the kernel mapping functions per discussions with Rebecca. No clue if this is right. There's some dmabuf interfaces that may no longer work. Maybe that's ok? No clue. This will be squished down into the previous patch once folks agree its the right way to go. Cc: Jesse Barker Cc: Arnd Bergmann Cc: Serban Constantinescu Signed-off-by: John Stultz --- drivers/gpu/ion/ion.c | 102 +------------------------------------- drivers/gpu/ion/ion_heap.c | 40 --------------- drivers/gpu/ion/ion_priv.h | 2 - drivers/gpu/ion/ion_system_heap.c | 4 -- include/linux/ion.h | 17 ------- 5 files changed, 2 insertions(+), 163 deletions(-) diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index a8ae679..9e7e291 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -232,8 +232,6 @@ err2: static void _ion_buffer_destroy(struct ion_buffer *buffer) { - if (WARN_ON(buffer->kmap_cnt > 0)) - buffer->heap->ops->unmap_kernel(buffer->heap, buffer); buffer->heap->ops->unmap_dma(buffer->heap, buffer); buffer->heap->ops->free(buffer); if (buffer->flags & ION_FLAG_CACHED) @@ -513,43 +511,10 @@ int ion_phys(struct ion_client *client, struct ion_handle *handle, } EXPORT_SYMBOL(ion_phys); -static void *ion_buffer_kmap_get(struct ion_buffer *buffer) -{ - void *vaddr; - - if (buffer->kmap_cnt) { - buffer->kmap_cnt++; - return buffer->vaddr; - } - vaddr = buffer->heap->ops->map_kernel(buffer->heap, buffer); - if (IS_ERR_OR_NULL(vaddr)) - return vaddr; - buffer->vaddr = vaddr; - buffer->kmap_cnt++; - return vaddr; -} - -static void *ion_handle_kmap_get(struct ion_handle *handle) -{ - struct ion_buffer *buffer = handle->buffer; - void *vaddr; - - if (handle->kmap_cnt) { - handle->kmap_cnt++; - return buffer->vaddr; - } - vaddr = ion_buffer_kmap_get(buffer); - if (IS_ERR_OR_NULL(vaddr)) - return vaddr; - handle->kmap_cnt++; - return vaddr; -} - static void ion_buffer_kmap_put(struct ion_buffer *buffer) { buffer->kmap_cnt--; if (!buffer->kmap_cnt) { - buffer->heap->ops->unmap_kernel(buffer->heap, buffer); buffer->vaddr = NULL; } } @@ -563,49 +528,6 @@ static void ion_handle_kmap_put(struct ion_handle *handle) ion_buffer_kmap_put(buffer); } -void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle) -{ - struct ion_buffer *buffer; - void *vaddr; - - mutex_lock(&client->lock); - if (!ion_handle_validate(client, handle)) { - pr_err("%s: invalid handle passed to map_kernel.\n", - __func__); - mutex_unlock(&client->lock); - return ERR_PTR(-EINVAL); - } - - buffer = handle->buffer; - - if (!handle->buffer->heap->ops->map_kernel) { - pr_err("%s: map_kernel is not implemented by this heap.\n", - __func__); - mutex_unlock(&client->lock); - return ERR_PTR(-ENODEV); - } - - mutex_lock(&buffer->lock); - vaddr = ion_handle_kmap_get(handle); - mutex_unlock(&buffer->lock); - mutex_unlock(&client->lock); - return vaddr; -} -EXPORT_SYMBOL(ion_map_kernel); - -void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle) -{ - struct ion_buffer *buffer; - - mutex_lock(&client->lock); - buffer = handle->buffer; - mutex_lock(&buffer->lock); - ion_handle_kmap_put(handle); - mutex_unlock(&buffer->lock); - mutex_unlock(&client->lock); -} -EXPORT_SYMBOL(ion_unmap_kernel); - static int ion_debug_client_show(struct seq_file *s, void *unused) { struct ion_client *client = s->private; @@ -932,34 +854,14 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len, enum dma_data_direction direction) { - struct ion_buffer *buffer = dmabuf->priv; - void *vaddr; - - if (!buffer->heap->ops->map_kernel) { - pr_err("%s: map kernel is not implemented by this heap.\n", - __func__); - return -ENODEV; - } - - mutex_lock(&buffer->lock); - vaddr = ion_buffer_kmap_get(buffer); - mutex_unlock(&buffer->lock); - if (IS_ERR(vaddr)) - return PTR_ERR(vaddr); - if (!vaddr) - return -ENOMEM; - return 0; + return -ENODEV; } static void ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf, size_t start, size_t len, enum dma_data_direction direction) { - struct ion_buffer *buffer = dmabuf->priv; - - mutex_lock(&buffer->lock); - ion_buffer_kmap_put(buffer); - mutex_unlock(&buffer->lock); + return; } struct dma_buf_ops dma_buf_ops = { diff --git a/drivers/gpu/ion/ion_heap.c b/drivers/gpu/ion/ion_heap.c index cf30b8a..0f2e7bb 100644 --- a/drivers/gpu/ion/ion_heap.c +++ b/drivers/gpu/ion/ion_heap.c @@ -21,46 +21,6 @@ #include #include "ion_priv.h" -void *ion_heap_map_kernel(struct ion_heap *heap, - struct ion_buffer *buffer) -{ - struct scatterlist *sg; - int i, j; - void *vaddr; - pgprot_t pgprot; - struct sg_table *table = buffer->sg_table; - int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; - struct page **pages = vmalloc(sizeof(struct page *) * npages); - struct page **tmp = pages; - - if (!pages) - return 0; - - if (buffer->flags & ION_FLAG_CACHED) - pgprot = PAGE_KERNEL; - else - pgprot = pgprot_writecombine(PAGE_KERNEL); - - for_each_sg(table->sgl, sg, table->nents, i) { - int npages_this_entry = PAGE_ALIGN(sg_dma_len(sg)) / PAGE_SIZE; - struct page *page = sg_page(sg); - BUG_ON(i >= npages); - for (j = 0; j < npages_this_entry; j++) { - *(tmp++) = page++; - } - } - vaddr = vmap(pages, npages, VM_MAP, pgprot); - vfree(pages); - - return vaddr; -} - -void ion_heap_unmap_kernel(struct ion_heap *heap, - struct ion_buffer *buffer) -{ - vunmap(buffer->vaddr); -} - int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, struct vm_area_struct *vma) { diff --git a/drivers/gpu/ion/ion_priv.h b/drivers/gpu/ion/ion_priv.h index 2146a65..e973040 100644 --- a/drivers/gpu/ion/ion_priv.h +++ b/drivers/gpu/ion/ion_priv.h @@ -104,8 +104,6 @@ struct ion_heap_ops { struct sg_table *(*map_dma) (struct ion_heap *heap, struct ion_buffer *buffer); void (*unmap_dma) (struct ion_heap *heap, struct ion_buffer *buffer); - void * (*map_kernel) (struct ion_heap *heap, struct ion_buffer *buffer); - void (*unmap_kernel) (struct ion_heap *heap, struct ion_buffer *buffer); int (*map_user) (struct ion_heap *mapper, struct ion_buffer *buffer, struct vm_area_struct *vma); }; diff --git a/drivers/gpu/ion/ion_system_heap.c b/drivers/gpu/ion/ion_system_heap.c index 7e5aca3..2235b0e 100644 --- a/drivers/gpu/ion/ion_system_heap.c +++ b/drivers/gpu/ion/ion_system_heap.c @@ -249,8 +249,6 @@ static struct ion_heap_ops system_heap_ops = { .free = ion_system_heap_free, .map_dma = ion_system_heap_map_dma, .unmap_dma = ion_system_heap_unmap_dma, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, .map_user = ion_heap_map_user, }; @@ -394,8 +392,6 @@ static struct ion_heap_ops kmalloc_ops = { .phys = ion_system_contig_heap_phys, .map_dma = ion_system_contig_heap_map_dma, .unmap_dma = ion_system_contig_heap_unmap_dma, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, .map_user = ion_system_contig_heap_map_user, }; diff --git a/include/linux/ion.h b/include/linux/ion.h index db46b19..a4adac4 100644 --- a/include/linux/ion.h +++ b/include/linux/ion.h @@ -189,23 +189,6 @@ struct sg_table *ion_sg_table(struct ion_client *client, struct ion_handle *handle); /** - * ion_map_kernel - create mapping for the given handle - * @client: the client - * @handle: handle to map - * - * Map the given handle into the kernel and return a kernel address that - * can be used to access this address. - */ -void *ion_map_kernel(struct ion_client *client, struct ion_handle *handle); - -/** - * ion_unmap_kernel() - destroy a kernel mapping for a handle - * @client: the client - * @handle: handle to unmap - */ -void ion_unmap_kernel(struct ion_client *client, struct ion_handle *handle); - -/** * ion_share_dma_buf() - share buffer as dma-buf * @client: the client * @handle: the handle