From patchwork Fri Jan 10 05:08:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 23080 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A6113202E2 for ; Fri, 10 Jan 2014 05:09:03 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id e14sf15750583iej.0 for ; Thu, 09 Jan 2014 21:09:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=NhA3LG3ixggBpu/htLL6aACv1uzJ6pBNyXEdpiWEj28=; b=cPK2H+aQRcDokb9AIgi+IUzcFMxO9SKlYdvsDqod8iUjA5Cwo7vA1jjW3dQ1IOImDo 0swBV8kg4tFTR3oerUbHcNC4zRNYe39b4TLotLfnpdvNiks2GN7QQuyQtToXqALgayC/ VDZQvyAT8nlfOLsg+jdCF4+j3FJb0Uhb7b2TDDNCn+Nf8t82lP35IKPVsT7pAtN/uVyb YKONCB4YipjotsQ9Db2DA631MQJUaNjRqosbwOpGGcv/Am8IkuhEFHApGLzXIjxIbESa wcuoHh0ZzqSdUTyunjHRA1x4vTdyfLCDxh3HK2Uk0/cy9LjkqpRtDVnZ+69IW4ScIdv8 hpXQ== X-Gm-Message-State: ALoCoQn2PPLaJ5WvbogZgmlKL4Z+CtuoGDtzpPoPx4ZEZOIrLXWXdv5n7oEHKvfijLQDHDS3Xfgt X-Received: by 10.182.109.200 with SMTP id hu8mr2866662obb.20.1389330542852; Thu, 09 Jan 2014 21:09:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.86.136 with SMTP id p8ls1346668qez.57.gmail; Thu, 09 Jan 2014 21:09:02 -0800 (PST) X-Received: by 10.52.229.39 with SMTP id sn7mr5113724vdc.2.1389330542712; Thu, 09 Jan 2014 21:09:02 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id vc3si1190438vdc.44.2014.01.09.21.09.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 21:09:02 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id x11so2871901vbb.36 for ; Thu, 09 Jan 2014 21:09:02 -0800 (PST) X-Received: by 10.58.58.74 with SMTP id o10mr5822753veq.33.1389330541659; Thu, 09 Jan 2014 21:09:01 -0800 (PST) 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.59.13.131 with SMTP id ey3csp61086ved; Thu, 9 Jan 2014 21:09:01 -0800 (PST) X-Received: by 10.66.142.132 with SMTP id rw4mr8809955pab.6.1389330540682; Thu, 09 Jan 2014 21:09:00 -0800 (PST) Received: from mail-pb0-f45.google.com (mail-pb0-f45.google.com [209.85.160.45]) by mx.google.com with ESMTPS id pi8si5930184pac.59.2014.01.09.21.09.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 21:09:00 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.45 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.160.45; Received: by mail-pb0-f45.google.com with SMTP id rp16so3972198pbb.4 for ; Thu, 09 Jan 2014 21:09:00 -0800 (PST) X-Received: by 10.68.133.6 with SMTP id oy6mr8434947pbb.153.1389330540278; Thu, 09 Jan 2014 21:09:00 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id bz4sm14061802pbb.12.2014.01.09.21.08.58 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 21:08:59 -0800 (PST) From: John Stultz To: LKML Cc: John Stultz , Colin Cross , Greg KH , Jesse Barker , Android Kernel Team Subject: [PATCH 2/2] ion: Add carveout and chunk heaps to dummy driver Date: Thu, 9 Jan 2014 21:08:38 -0800 Message-Id: <1389330518-31919-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389330518-31919-1-git-send-email-john.stultz@linaro.org> References: <1389330518-31919-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.49 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: , Add support to the dummy driver for basic carveout and chunk heaps. Since we're generating these heaps at module_init, and we want this driver to be generic enough to be tested on any arch, we don't have the ability to alloc bootmem, so both of these heaps are conventionally allocated using alloc_pages(), which limits us to 4M in size. Should look into using CMA for heap allocation eventually, but this provides enough to test the basic functionality of the heaps. Cc: Colin Cross Cc: Greg KH Cc: Jesse Barker Cc: Android Kernel Team Signed-off-by: John Stultz --- drivers/staging/android/ion/ion_dummy_driver.c | 67 +++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c index 6749d29..55b2002 100644 --- a/drivers/staging/android/ion/ion_dummy_driver.c +++ b/drivers/staging/android/ion/ion_dummy_driver.c @@ -26,6 +26,9 @@ struct ion_device *idev; struct ion_heap **heaps; +void *carveout_ptr; +void *chunk_ptr; + struct ion_platform_heap dummy_heaps[] = { { .id = ION_HEAP_TYPE_SYSTEM, @@ -37,10 +40,24 @@ struct ion_platform_heap dummy_heaps[] = { .type = ION_HEAP_TYPE_SYSTEM_CONTIG, .name = "system contig", }, + { + .id = ION_HEAP_TYPE_CARVEOUT, + .type = ION_HEAP_TYPE_CARVEOUT, + .name = "carveout", + .size = SZ_4M, + }, + { + .id = ION_HEAP_TYPE_CHUNK, + .type = ION_HEAP_TYPE_CHUNK, + .name = "chunk", + .size = SZ_4M, + .align = SZ_16K, + .priv = (void *)(SZ_16K), + }, }; struct ion_platform_data dummy_ion_pdata = { - .nr = 2, + .nr = 4, .heaps = dummy_heaps, }; @@ -54,9 +71,36 @@ static int __init ion_dummy_init(void) if (!heaps) return PTR_ERR(heaps); + + /* Allocate a dummy carveout heap */ + carveout_ptr = alloc_pages_exact( + dummy_heaps[ION_HEAP_TYPE_CARVEOUT].size, + GFP_KERNEL); + if (carveout_ptr) + dummy_heaps[ION_HEAP_TYPE_CARVEOUT].base = + virt_to_phys(carveout_ptr); + else + pr_err("ion_dummy: Could not allocate carveout\n"); + + /* Allocate a dummy chunk heap */ + chunk_ptr = alloc_pages_exact( + dummy_heaps[ION_HEAP_TYPE_CHUNK].size, + GFP_KERNEL); + if (chunk_ptr) + dummy_heaps[ION_HEAP_TYPE_CHUNK].base = virt_to_phys(chunk_ptr); + else + pr_err("ion_dummy: Could not allocate chunk\n"); + for (i = 0; i < dummy_ion_pdata.nr; i++) { struct ion_platform_heap *heap_data = &dummy_ion_pdata.heaps[i]; + if (heap_data->type == ION_HEAP_TYPE_CARVEOUT && + !heap_data->base) + continue; + + if (heap_data->type == ION_HEAP_TYPE_CHUNK && !heap_data->base) + continue; + heaps[i] = ion_heap_create(heap_data); if (IS_ERR_OR_NULL(heaps[i])) { err = PTR_ERR(heaps[i]); @@ -72,6 +116,16 @@ err: } kfree(heaps); + if (carveout_ptr) { + free_pages_exact(carveout_ptr, + dummy_heaps[ION_HEAP_TYPE_CARVEOUT].size); + carveout_ptr = NULL; + } + if (chunk_ptr) { + free_pages_exact(chunk_ptr, + dummy_heaps[ION_HEAP_TYPE_CHUNK].size); + chunk_ptr = NULL; + } return err; } @@ -85,6 +139,17 @@ static void __exit ion_dummy_exit(void) ion_heap_destroy(heaps[i]); kfree(heaps); + if (carveout_ptr) { + free_pages_exact(carveout_ptr, + dummy_heaps[ION_HEAP_TYPE_CARVEOUT].size); + carveout_ptr = NULL; + } + if (chunk_ptr) { + free_pages_exact(chunk_ptr, + dummy_heaps[ION_HEAP_TYPE_CHUNK].size); + chunk_ptr = NULL; + } + return; }