From patchwork Wed Jun 12 19:58:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 17859 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A161023903 for ; Wed, 12 Jun 2013 19:58:54 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id hu16sf1106359qab.0 for ; Wed, 12 Jun 2013 12:58:54 -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=Jz159VhuYAVe2dR1Wxs/mg3PHEYrbhpMpZIeq4oJUzQ=; b=PZp0jq8+dUr5MBRiPkLIeA9Hhxf0ddo2dBrFYglu20wDIfMj89P5TSOqMzPXLqhDWc nImOOXmTlgXm/9ajDiaDRFQ3TpncsKzFwflqi4UUz0a0DPOhenvipO3qA8rr5CPSvQ+3 qN5tbGncsDyPqpZXL3Qhu6uvnGnWtngtTpyChTZESBHMY9wlOAv4DBmFz7t0xKp7Fde7 mdm3k8DZsyXyX6OeZNfNM+zzJbvfAU7j9950b7Nou6weza9v9CEeGAyxASFVpZprs8qJ 8kalMNThqvMtIzyhWs1VGgHOAzVSAje+sDZRy2UfQpQuR+aPWZcSamr2TSjtcbEXo5Yx suVA== X-Received: by 10.236.230.72 with SMTP id i68mr12083578yhq.23.1371067134145; Wed, 12 Jun 2013 12:58:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.60.163 with SMTP id i3ls1459392qer.49.gmail; Wed, 12 Jun 2013 12:58:53 -0700 (PDT) X-Received: by 10.58.118.70 with SMTP id kk6mr3620712veb.1.1371067133902; Wed, 12 Jun 2013 12:58:53 -0700 (PDT) Received: from mail-ve0-x22c.google.com (mail-ve0-x22c.google.com [2607:f8b0:400c:c01::22c]) by mx.google.com with ESMTPS id bs2si9222196veb.5.2013.06.12.12.58.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 12:58:53 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22c 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:c01::22c; Received: by mail-ve0-f172.google.com with SMTP id jz10so7084957veb.17 for ; Wed, 12 Jun 2013 12:58:53 -0700 (PDT) X-Received: by 10.220.192.138 with SMTP id dq10mr10398944vcb.23.1371067133750; Wed, 12 Jun 2013 12:58:53 -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.58.191.99 with SMTP id gx3csp157498vec; Wed, 12 Jun 2013 12:58:53 -0700 (PDT) X-Received: by 10.68.217.197 with SMTP id pa5mr21267567pbc.127.1371067132767; Wed, 12 Jun 2013 12:58:52 -0700 (PDT) Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com [2607:f8b0:400e:c03::234]) by mx.google.com with ESMTPS id sb1si10228911pbb.112.2013.06.12.12.58.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 12:58:52 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c03::234 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=2607:f8b0:400e:c03::234; Received: by mail-pa0-f52.google.com with SMTP id kq13so4176538pab.11 for ; Wed, 12 Jun 2013 12:58:52 -0700 (PDT) X-Received: by 10.66.221.101 with SMTP id qd5mr25440695pac.174.1371067132361; Wed, 12 Jun 2013 12:58:52 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id vv6sm26056524pab.6.2013.06.12.12.58.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 12 Jun 2013 12:58:51 -0700 (PDT) From: John Stultz To: Rebecca Schultz Zavin Cc: John Stultz , Serban Constantinescu , Arnd Bergmann , Jesse Barker Subject: [PATCH 2/4] ion: Remove the kernel mapping functions [squish me!] Date: Wed, 12 Jun 2013 12:58:24 -0700 Message-Id: <1371067106-19129-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1371067106-19129-1-git-send-email-john.stultz@linaro.org> References: <1371067106-19129-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQmwV66aV1kQ/QMRneRuJm3LaxYmSo0kKSfrIj21gD7PrWTE1tAdEHwT8lgGfbFqoOb/+3PU X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22c 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. Cc: Rebecca Schultz Zavin Cc: Serban Constantinescu Cc: Arnd Bergmann Cc: Jesse Barker Signed-off-by: John Stultz --- drivers/gpu/ion/ion.c | 99 +-------------------------------------- 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(+), 160 deletions(-) diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 6c5c585..6711b55 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -565,81 +565,6 @@ 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; -} - -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; @@ -952,34 +877,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 b981144..64e7bed 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 e324dab..ebad6ea 100644 --- a/drivers/gpu/ion/ion_system_heap.c +++ b/drivers/gpu/ion/ion_system_heap.c @@ -250,8 +250,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, }; @@ -395,8 +393,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 29f6654..cc5010e 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