From patchwork Fri Jan 10 05:08:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 23079 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 632B0202E2 for ; Fri, 10 Jan 2014 05:09:01 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id jw12sf6988535veb.3 for ; Thu, 09 Jan 2014 21:09:00 -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=p7rSPU2AgVRjCxjiJtEv/Aaenumy6i4429RWXuO47SU=; b=j1z3mysOus9i4iKuQlKuJisPvtZuEgSekumwgai11H0e7qLVesfswf24zLrwdQsro1 lD+bokvuZxvCiG1BRE4i4t8FELT+g973QW2b1CyN79v9LyWj8rfn7mgKpIEWm6yukesh mKHMAl6KfeiMPDTHeSRIA5bGmXSO/hNMZs0eCPsuYwHgAYX0OMhnYFYSlOmLqhBHLr+h U4q8plodJOUbBBSbGUDqcIDA1sODrxjbP8m8NXw2BPZ6WvSwBNdLXeAoiC+920f3TZgg YbWZUB5JKeM9rD41//+5r4RpMjbRGwmKI0P+HzDPRaeeBIvU3OWtiBfS7lgalZHXBelB 4/vQ== X-Gm-Message-State: ALoCoQlCtXFnoOi5Goed9HQJF4Hg/jJCpoK7GSChWRCDrTs7JKc67et8erkkJfrFOZnWwizyFSEd X-Received: by 10.236.20.114 with SMTP id o78mr2449140yho.8.1389330540486; Thu, 09 Jan 2014 21:09:00 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.41.66 with SMTP id d2ls1365484qel.10.gmail; Thu, 09 Jan 2014 21:09:00 -0800 (PST) X-Received: by 10.52.164.203 with SMTP id ys11mr5150247vdb.37.1389330540399; Thu, 09 Jan 2014 21:09:00 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id tc7si4117264vdc.48.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.128.178 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.178; Received: by mail-ve0-f178.google.com with SMTP id c14so3183925vea.9 for ; Thu, 09 Jan 2014 21:09:00 -0800 (PST) X-Received: by 10.58.255.233 with SMTP id at9mr6311832ved.20.1389330540192; Thu, 09 Jan 2014 21:09:00 -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 ey3csp61085ved; Thu, 9 Jan 2014 21:08:59 -0800 (PST) X-Received: by 10.66.186.174 with SMTP id fl14mr8662633pac.108.1389330539203; Thu, 09 Jan 2014 21:08:59 -0800 (PST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx.google.com with ESMTPS id qy2si5932927pbb.52.2014.01.09.21.08.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 21:08:59 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.54 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.54; Received: by mail-pa0-f54.google.com with SMTP id kl14so4248199pab.13 for ; Thu, 09 Jan 2014 21:08:58 -0800 (PST) X-Received: by 10.68.225.9 with SMTP id rg9mr8747760pbc.122.1389330538749; Thu, 09 Jan 2014 21:08:58 -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.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 09 Jan 2014 21:08:57 -0800 (PST) From: John Stultz To: LKML Cc: John Stultz , Colin Cross , Greg KH , Jesse Barker , Android Kernel Team Subject: [PATCH 1/2] ion: Add dummy driver for testing Date: Thu, 9 Jan 2014 21:08:37 -0800 Message-Id: <1389330518-31919-2-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.128.178 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: , Provide a basic dummy driver to register the ion device and to install basic SYSTEM and SYSTEM_CONTIG heaps. This allows for basic testing with ION without having access to drivers or systems that have been enabled to use ION. Cc: Colin Cross Cc: Greg KH Cc: Jesse Barker Cc: Android Kernel Team Signed-off-by: John Stultz --- drivers/staging/android/ion/Kconfig | 10 +++ drivers/staging/android/ion/Makefile | 3 + drivers/staging/android/ion/ion_dummy_driver.c | 93 ++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 drivers/staging/android/ion/ion_dummy_driver.c diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index a9a64ea..0f8fec1 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -17,6 +17,16 @@ config ION_TEST Choose this option to create a device that can be used to test the kernel and device side ION functions. +config ION_DUMMY + bool "Dummy Ion driver" + depends on ION + help + Provides a dummy ION driver that registers the + /dev/ion device and some basic heaps. This can + be used for testing the ION infrastructure if + one doesn't have access to hardware drivers that + use ION. + config ION_TEGRA tristate "Ion for Tegra" depends on ARCH_TEGRA && ION diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile index 75039b9..b56fd2b 100644 --- a/drivers/staging/android/ion/Makefile +++ b/drivers/staging/android/ion/Makefile @@ -4,4 +4,7 @@ obj-$(CONFIG_ION_TEST) += ion_test.o ifdef CONFIG_COMPAT obj-$(CONFIG_ION) += compat_ion.o endif + +obj-$(CONFIG_ION_DUMMY) += ion_dummy_driver.o obj-$(CONFIG_ION_TEGRA) += tegra/ + diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c new file mode 100644 index 0000000..6749d29 --- /dev/null +++ b/drivers/staging/android/ion/ion_dummy_driver.c @@ -0,0 +1,93 @@ +/* + * drivers/gpu/ion/ion_dummy_driver.c + * + * Copyright (C) 2013 Linaro, Inc + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include +#include +#include +#include +#include +#include +#include "ion.h" +#include "ion_priv.h" + +struct ion_device *idev; +struct ion_heap **heaps; + +struct ion_platform_heap dummy_heaps[] = { + { + .id = ION_HEAP_TYPE_SYSTEM, + .type = ION_HEAP_TYPE_SYSTEM, + .name = "system", + }, + { + .id = ION_HEAP_TYPE_SYSTEM_CONTIG, + .type = ION_HEAP_TYPE_SYSTEM_CONTIG, + .name = "system contig", + }, +}; + +struct ion_platform_data dummy_ion_pdata = { + .nr = 2, + .heaps = dummy_heaps, +}; + +static int __init ion_dummy_init(void) +{ + int i, err; + + idev = ion_device_create(NULL); + heaps = kzalloc(sizeof(struct ion_heap *) * dummy_ion_pdata.nr, + GFP_KERNEL); + if (!heaps) + return PTR_ERR(heaps); + + for (i = 0; i < dummy_ion_pdata.nr; i++) { + struct ion_platform_heap *heap_data = &dummy_ion_pdata.heaps[i]; + + heaps[i] = ion_heap_create(heap_data); + if (IS_ERR_OR_NULL(heaps[i])) { + err = PTR_ERR(heaps[i]); + goto err; + } + ion_device_add_heap(idev, heaps[i]); + } + return 0; +err: + for (i = 0; i < dummy_ion_pdata.nr; i++) { + if (heaps[i]) + ion_heap_destroy(heaps[i]); + } + kfree(heaps); + + return err; +} + +static void __exit ion_dummy_exit(void) +{ + int i; + + ion_device_destroy(idev); + + for (i = 0; i < dummy_ion_pdata.nr; i++) + ion_heap_destroy(heaps[i]); + kfree(heaps); + + return; +} + +module_init(ion_dummy_init); +module_exit(ion_dummy_exit); +