From patchwork Fri Jan 10 03:40:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 23072 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E11B20555 for ; Fri, 10 Jan 2014 03:41:09 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id f11sf6631703qae.3 for ; Thu, 09 Jan 2014 19:41:08 -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=DOrCTN3sDT5QDt03soJTosk6me7LwFezQZ5N0FqXjCRyNNQErXZ9l7pzq4TaMNUNju zo4CyWn99ZwoYgfEYrgI3qnS9ED6CFHhBY2ZEGmVAlOVuZ1UjG0ERh6LChtD4Gka4kDC TPuidr7KMo+sQHyoLNAXyWEbj8VOiZT0jaVN0NTbyDXQcqNa5Lm2yz/JNaT5vtCUBHYq tqe2L9o1G3KsEro0q7sAdwOAEwJvkxaGynIc67Lj7OgtNy59F4IP8OT98TF+jzZMDFl8 VtVq6s+LF8vqkvtlsocTQzRbziaGYVgPj1jsJEBMMcmKmBOONtmJ1JR3TGpe/E6FFEqU zbCg== X-Gm-Message-State: ALoCoQmedUfdl6Gu+FQjBY9sDkLStf6u5TFVEc/ecI9KBHm9Yv68FxZjM0RJbHuZkHP5RqB2AL/z X-Received: by 10.236.121.195 with SMTP id r43mr2204426yhh.44.1389325268379; Thu, 09 Jan 2014 19:41:08 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.94.240 with SMTP id df16ls1260969qeb.82.gmail; Thu, 09 Jan 2014 19:41:08 -0800 (PST) X-Received: by 10.52.99.199 with SMTP id es7mr13061vdb.50.1389325268161; Thu, 09 Jan 2014 19:41:08 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id cz20si3949664veb.129.2014.01.09.19.41.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 19:41:08 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so3126858veb.35 for ; Thu, 09 Jan 2014 19:41:08 -0800 (PST) X-Received: by 10.52.166.6 with SMTP id zc6mr5012401vdb.10.1389325267158; Thu, 09 Jan 2014 19:41:07 -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 ey3csp57368ved; Thu, 9 Jan 2014 19:41:06 -0800 (PST) X-Received: by 10.66.182.199 with SMTP id eg7mr8089566pac.135.1389325266280; Thu, 09 Jan 2014 19:41:06 -0800 (PST) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id a6si5705225pao.186.2014.01.09.19.41.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 19:41:06 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id y13so1488380pdi.24 for ; Thu, 09 Jan 2014 19:41:05 -0800 (PST) X-Received: by 10.66.49.74 with SMTP id s10mr8284884pan.0.1389325265873; Thu, 09 Jan 2014 19:41:05 -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 lh13sm17308379pab.4.2014.01.09.19.41.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 19:41:05 -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 19:40:55 -0800 Message-Id: <1389325255-31534-3-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389325255-31534-1-git-send-email-john.stultz@linaro.org> References: <1389325255-31534-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.128.176 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; }