From patchwork Sat Mar 18 00:54:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9631839 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 7FA7460249 for ; Sat, 18 Mar 2017 00:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7170C283FB for ; Sat, 18 Mar 2017 00:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65D72284A5; Sat, 18 Mar 2017 00:56:56 +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=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72377283FB for ; Sat, 18 Mar 2017 00:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=wuqwg0oxdkrCK8tWc13zxa2tmnA4vyAKsxBcC2DaX74=; b=rgfYcNNKJ0tXPgFw4ranSg9pbd Ok/nbG248o8Or0JGMH6rjXv74cYLBl8FhF7L+28q+U9BFYgmtTfam5rWcCsI6tNq09nygb3zflJ6Q ktLHsyfsUQcIvk1UOv2mK7hiWLRO7pL1UmWVrLsEAaNYyKHxk40A//BuH0ay8LVryLtZG8BBjlgdF CtUPIgUJg+iAyN/mVhE39I91YsYS88F6HBxrv8G4x0LrhLr5DV2IdDft1p/xLy4nFGlMg08EMgIVy 8U5hEtNScc1J9a310NuEhdW+/38UN4hAVxF3fY1B3ZNi8nGkdI9ci686A8aVlNMngjgsZL8yOICnI 1YzRxZIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cp2fu-0004wC-VJ; Sat, 18 Mar 2017 00:56:54 +0000 Received: from mail-qk0-f179.google.com ([209.85.220.179]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cp2ec-0003Pz-IE for linux-arm-kernel@lists.infradead.org; Sat, 18 Mar 2017 00:55:39 +0000 Received: by mail-qk0-f179.google.com with SMTP id p64so77328572qke.1 for ; Fri, 17 Mar 2017 17:55:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AAvGlexdB0Dy1P3EMDeu0+ZWlJ6T2doDRN1898FUKSs=; b=b9RUFgB+siMXEPs5YPb651uUFN3KUYekMo0K1F4KUurzCSbTL6bD5xWfCPaLtQ4WuI KMgqxc1r0p2dM7FSCL268yZFu0bMB7r77t5TOxzdnSfh4Hz0GppWBrVJFvu3ICAz4dnG Hw4jWK87RPYv9tn1lr39OKbWJ6NzRk6gYTz5MPyEKjLMYePzItxlQJjFpiGtAH522t6s EbwmBmtA991pPHP3P9bPI5ijeBZ07bLJ2MxEtUpb1D2479oDe7Zk2mFxDSPq+/1e2fOQ d4YK3h0OpkPq0UN2k4/TRj2vcXy3ILXqDwar2gJ4/SLh7qvFEfiaW1IxWCeMLenvHu7C YLRw== X-Gm-Message-State: AFeK/H2QgheD2jJnugI/VGDtj3so1BbplaBmM5fFtemLxQ/2rc9cN80XtUWXSAZpOsQv53Gg X-Received: by 10.55.197.135 with SMTP id k7mr14879932qkl.238.1489798512963; Fri, 17 Mar 2017 17:55:12 -0700 (PDT) Received: from labbott-redhat-machine.redhat.com ([2601:602:9802:a8dc:1722:8a6b:a66c:79eb]) by smtp.gmail.com with ESMTPSA id e55sm7118568qte.52.2017.03.17.17.55.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2017 17:55:11 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , Riley Andrews , arve@android.com Subject: [RFC PATCHv2 04/21] staging: android: ion: Remove alignment from allocation field Date: Fri, 17 Mar 2017 17:54:36 -0700 Message-Id: <1489798493-16600-5-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1489798493-16600-1-git-send-email-labbott@redhat.com> References: <1489798493-16600-1-git-send-email-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170317_175534_994527_1BBD9BD4 X-CRM114-Status: GOOD ( 17.48 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, romlem@google.com, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-mm@kvack.org, Mark Brown , Laurent Pinchart , Benjamin Gaignard , Daniel Vetter , Laura Abbott , Brian Starkey , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.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 align field was supposed to be used to specify the alignment of the allocation. Nobody actually does anything with it except to check if the alignment specified is out of bounds. Since this has no effect on the actual allocation, just remove it. Signed-off-by: Laura Abbott --- drivers/staging/android/ion/ion-ioctl.c | 1 - drivers/staging/android/ion/ion.c | 14 ++++++-------- drivers/staging/android/ion/ion.h | 5 +---- drivers/staging/android/ion/ion_carveout_heap.c | 10 +++------- drivers/staging/android/ion/ion_chunk_heap.c | 9 +++------ drivers/staging/android/ion/ion_cma_heap.c | 5 +---- drivers/staging/android/ion/ion_priv.h | 2 +- drivers/staging/android/ion/ion_system_heap.c | 9 +-------- 8 files changed, 16 insertions(+), 39 deletions(-) diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c index 9ff815a..5b2e93f 100644 --- a/drivers/staging/android/ion/ion-ioctl.c +++ b/drivers/staging/android/ion/ion-ioctl.c @@ -95,7 +95,6 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) struct ion_handle *handle; handle = ion_alloc(client, data.allocation.len, - data.allocation.align, data.allocation.heap_id_mask, data.allocation.flags); if (IS_ERR(handle)) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index f45115f..c2adfe1 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -103,7 +103,6 @@ static void ion_buffer_add(struct ion_device *dev, static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, struct ion_device *dev, unsigned long len, - unsigned long align, unsigned long flags) { struct ion_buffer *buffer; @@ -119,15 +118,14 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, buffer->flags = flags; kref_init(&buffer->ref); - ret = heap->ops->allocate(heap, buffer, len, align, flags); + ret = heap->ops->allocate(heap, buffer, len, flags); if (ret) { if (!(heap->flags & ION_HEAP_FLAG_DEFER_FREE)) goto err2; ion_heap_freelist_drain(heap, 0); - ret = heap->ops->allocate(heap, buffer, len, align, - flags); + ret = heap->ops->allocate(heap, buffer, len, flags); if (ret) goto err2; } @@ -401,7 +399,7 @@ static int ion_handle_add(struct ion_client *client, struct ion_handle *handle) } struct ion_handle *ion_alloc(struct ion_client *client, size_t len, - size_t align, unsigned int heap_id_mask, + unsigned int heap_id_mask, unsigned int flags) { struct ion_handle *handle; @@ -410,8 +408,8 @@ struct ion_handle *ion_alloc(struct ion_client *client, size_t len, struct ion_heap *heap; int ret; - pr_debug("%s: len %zu align %zu heap_id_mask %u flags %x\n", __func__, - len, align, heap_id_mask, flags); + pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__, + len, heap_id_mask, flags); /* * traverse the list of heaps available in this system in priority * order. If the heap type is supported by the client, and matches the @@ -428,7 +426,7 @@ struct ion_handle *ion_alloc(struct ion_client *client, size_t len, /* if the caller didn't specify this heap id */ if (!((1 << heap->id) & heap_id_mask)) continue; - buffer = ion_buffer_create(heap, dev, len, align, flags); + buffer = ion_buffer_create(heap, dev, len, flags); if (!IS_ERR(buffer)) break; } diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 93dafb4..3b4bff5 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -45,7 +45,6 @@ struct ion_buffer; * @name: used for debug purposes * @base: base address of heap in physical memory if applicable * @size: size of the heap in bytes if applicable - * @align: required alignment in physical memory if applicable * @priv: private info passed from the board file * * Provided by the board file. @@ -93,8 +92,6 @@ void ion_client_destroy(struct ion_client *client); * ion_alloc - allocate ion memory * @client: the client * @len: size of the allocation - * @align: requested allocation alignment, lots of hardware blocks - * have alignment requirements of some kind * @heap_id_mask: mask of heaps to allocate from, if multiple bits are set * heaps will be tried in order from highest to lowest * id @@ -106,7 +103,7 @@ void ion_client_destroy(struct ion_client *client); * an opaque handle to it. */ struct ion_handle *ion_alloc(struct ion_client *client, size_t len, - size_t align, unsigned int heap_id_mask, + unsigned int heap_id_mask, unsigned int flags); /** diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c index a8ea973..9bf8e98 100644 --- a/drivers/staging/android/ion/ion_carveout_heap.c +++ b/drivers/staging/android/ion/ion_carveout_heap.c @@ -34,8 +34,7 @@ struct ion_carveout_heap { }; static ion_phys_addr_t ion_carveout_allocate(struct ion_heap *heap, - unsigned long size, - unsigned long align) + unsigned long size) { struct ion_carveout_heap *carveout_heap = container_of(heap, struct ion_carveout_heap, heap); @@ -60,16 +59,13 @@ static void ion_carveout_free(struct ion_heap *heap, ion_phys_addr_t addr, static int ion_carveout_heap_allocate(struct ion_heap *heap, struct ion_buffer *buffer, - unsigned long size, unsigned long align, + unsigned long size, unsigned long flags) { struct sg_table *table; ion_phys_addr_t paddr; int ret; - if (align > PAGE_SIZE) - return -EINVAL; - table = kmalloc(sizeof(*table), GFP_KERNEL); if (!table) return -ENOMEM; @@ -77,7 +73,7 @@ static int ion_carveout_heap_allocate(struct ion_heap *heap, if (ret) goto err_free; - paddr = ion_carveout_allocate(heap, size, align); + paddr = ion_carveout_allocate(heap, size); if (paddr == ION_CARVEOUT_ALLOCATE_FAIL) { ret = -ENOMEM; goto err_free_table; diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c index 70495dc..8c41889 100644 --- a/drivers/staging/android/ion/ion_chunk_heap.c +++ b/drivers/staging/android/ion/ion_chunk_heap.c @@ -35,7 +35,7 @@ struct ion_chunk_heap { static int ion_chunk_heap_allocate(struct ion_heap *heap, struct ion_buffer *buffer, - unsigned long size, unsigned long align, + unsigned long size, unsigned long flags) { struct ion_chunk_heap *chunk_heap = @@ -46,9 +46,6 @@ static int ion_chunk_heap_allocate(struct ion_heap *heap, unsigned long num_chunks; unsigned long allocated_size; - if (align > chunk_heap->chunk_size) - return -EINVAL; - allocated_size = ALIGN(size, chunk_heap->chunk_size); num_chunks = allocated_size / chunk_heap->chunk_size; @@ -160,8 +157,8 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data) chunk_heap->heap.ops = &chunk_heap_ops; chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK; chunk_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE; - pr_debug("%s: base %lu size %zu align %ld\n", __func__, - chunk_heap->base, heap_data->size, heap_data->align); + pr_debug("%s: base %lu size %zu \n", __func__, + chunk_heap->base, heap_data->size); return &chunk_heap->heap; diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 6c40685..d562fd7 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -40,7 +40,7 @@ struct ion_cma_buffer_info { /* ION CMA heap operations functions */ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, - unsigned long len, unsigned long align, + unsigned long len, unsigned long flags) { struct ion_cma_heap *cma_heap = to_cma_heap(heap); @@ -52,9 +52,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (buffer->flags & ION_FLAG_CACHED) return -EINVAL; - if (align > PAGE_SIZE) - return -EINVAL; - info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index 46d3ff5..b09bc7c 100644 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -172,7 +172,7 @@ struct ion_handle { struct ion_heap_ops { int (*allocate)(struct ion_heap *heap, struct ion_buffer *buffer, unsigned long len, - unsigned long align, unsigned long flags); + unsigned long flags); void (*free)(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); diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 3ebbb75..6cb2fe7 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -129,7 +129,7 @@ static struct page *alloc_largest_available(struct ion_system_heap *heap, static int ion_system_heap_allocate(struct ion_heap *heap, struct ion_buffer *buffer, - unsigned long size, unsigned long align, + unsigned long size, unsigned long flags) { struct ion_system_heap *sys_heap = container_of(heap, @@ -143,9 +143,6 @@ static int ion_system_heap_allocate(struct ion_heap *heap, unsigned long size_remaining = PAGE_ALIGN(size); unsigned int max_order = orders[0]; - if (align > PAGE_SIZE) - return -EINVAL; - if (size / PAGE_SIZE > totalram_pages / 2) return -ENOMEM; @@ -372,7 +369,6 @@ void ion_system_heap_destroy(struct ion_heap *heap) static int ion_system_contig_heap_allocate(struct ion_heap *heap, struct ion_buffer *buffer, unsigned long len, - unsigned long align, unsigned long flags) { int order = get_order(len); @@ -381,9 +377,6 @@ static int ion_system_contig_heap_allocate(struct ion_heap *heap, unsigned long i; int ret; - if (align > (PAGE_SIZE << order)) - return -EINVAL; - page = alloc_pages(low_order_gfp_flags, order); if (!page) return -ENOMEM;