From patchwork Sat Mar 18 00:54:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9631937 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 325A660249 for ; Sat, 18 Mar 2017 01:45:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CBE8284E9 for ; Sat, 18 Mar 2017 01:45:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D6BF28473; Sat, 18 Mar 2017 01:45:02 +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 8AB9A28473 for ; Sat, 18 Mar 2017 01:45:00 +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=FECSzwPsVJS50pTLDhd9L1YlGDE5WgjZBTzFgX6ReLM=; b=P+22lqcsAOpxmKG9cDVRyElhW1 6NmgaKorZypWueuT7nw2LuyqwWzmS097XF15VfLPVJid7wLf1NVM/2MzvSH5EEt8WjliNJmbl4oJP YxC4XsczNjYgAK95JTHcJdhaGeC1yGWF3KoW/WUpSlKJ8SyWVVDGoTrFEaKC2iNjNuuAYQ/i/PeLf RYHiQ48uYndmLuaVKeh6L5upaqYevnyCOdFXJtX7s6LSxdktlO3JsgxHr31YivGJY7G0MwY7VliUp s6FiYn5++MPBoqem3FTdpSWAa/tL6U4kLbPb3sR0TI4OZ3QUPLuFkwSF3zT+QE15tVqcyGuyVNppY pZqPB2Zw==; 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 1cp3QK-0003Pi-UJ; Sat, 18 Mar 2017 01:44:52 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cp3PY-0002Pv-Um for linux-arm-kernel@bombadil.infradead.org; Sat, 18 Mar 2017 01:44:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=f0tpTl8QAWOCaJNcfzufTkrRLhHSUBEUAgy/oTW22AU=; b=h58KDQS6CfR96e/iUZcyszy7t 9NOOhZROmC/OiE0rfHySMB0E+1LfJ8T5L0kq+M2pye7LoVf9izkc7HPn7PQgPopTHiL8Yo9nkOrnJ CprVfCkqU/pLlTvXnSbj3h0CGAN8F33VpQ5YyhUncNHcatcnN1v0QUGbVIp/lGYezqTdUwWrqwwuN H6NFdLj8Ue7AZOkczbiNy0947dWJtDcDE7ckX/1n+B9tr3eYvWOLHhED9rxfcSrWG5wX0761VOsN+ gKKTvsozZAwGyyu7o4+Q0sx+7WocGJJTYFTY+nsEdnB5t3aVCw4Lpd5laidaUYT4jMAa434PCqHUQ fG2JTpo/Q==; Received: from mail-qk0-f176.google.com ([209.85.220.176]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cp2f7-00031Q-Ix for linux-arm-kernel@lists.infradead.org; Sat, 18 Mar 2017 00:56:08 +0000 Received: by mail-qk0-f176.google.com with SMTP id 1so77274761qkl.3 for ; Fri, 17 Mar 2017 17:55:41 -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=f0tpTl8QAWOCaJNcfzufTkrRLhHSUBEUAgy/oTW22AU=; b=k8wSEEBmKmOFvzHB5SAIdh6XpfuVJAVTjQIzXFvs42YmHd7pyGxzGEmZgPjwwW0joC vHOFuZqAMQZExUCFm+TWJcos/9vv8/Ci764I39VPs+PvEub5jYaYVspoPBm/ag9htxbG qEJjugwwJarO9P/vlNYZs2LJ6v8b36KPSKW8qQ/3F2n+59OrLTxoKMy8FpMXt/CecP4v c3W0tzRxYHtpp3ANfbzMKFSGucrjtdNnxEQXfxN0JcJHwfQ/cGY82q0/CMui4uVFauHl bs2rqSDTvLwJKcPYC9pHWqVAeVtwJSwsMYEhGy1pTmDfzMpVqezMr+LgWbqoYBXy2e8B oHUA== X-Gm-Message-State: AFeK/H1anbwAFa5ps61nDaZrxFhB5WBM3d2jb4h7m9U/urmaehoJZVvmUGsiIlz3vv4pMnEZ X-Received: by 10.233.220.130 with SMTP id q124mr3705110qkf.27.1489798539859; Fri, 17 Mar 2017 17:55:39 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2017 17:55:38 -0700 (PDT) From: Laura Abbott To: Sumit Semwal , Riley Andrews , arve@android.com Subject: [RFC PATCHv2 12/21] staging: android: ion: Remove old platform support Date: Fri, 17 Mar 2017 17:54:44 -0700 Message-Id: <1489798493-16600-13-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_205605_727421_7ECD4F71 X-CRM114-Status: GOOD ( 24.43 ) 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 Device specific platform support has been haphazard for Ion. There have been several independent attempts and there are still objections to what bindings exist right now. Just remove everything for a fresh start. Signed-off-by: Laura Abbott --- drivers/staging/android/ion/Kconfig | 42 --- drivers/staging/android/ion/Makefile | 7 - drivers/staging/android/ion/hisilicon/Kconfig | 5 - drivers/staging/android/ion/hisilicon/Makefile | 1 - drivers/staging/android/ion/hisilicon/hi6220_ion.c | 113 -------- drivers/staging/android/ion/ion_dummy_driver.c | 156 ----------- drivers/staging/android/ion/ion_of.c | 184 ------------- drivers/staging/android/ion/ion_of.h | 37 --- drivers/staging/android/ion/ion_test.c | 305 --------------------- drivers/staging/android/ion/tegra/Makefile | 1 - drivers/staging/android/ion/tegra/tegra_ion.c | 80 ------ drivers/staging/android/uapi/ion_test.h | 69 ----- 12 files changed, 1000 deletions(-) delete mode 100644 drivers/staging/android/ion/hisilicon/Kconfig delete mode 100644 drivers/staging/android/ion/hisilicon/Makefile delete mode 100644 drivers/staging/android/ion/hisilicon/hi6220_ion.c delete mode 100644 drivers/staging/android/ion/ion_dummy_driver.c delete mode 100644 drivers/staging/android/ion/ion_of.c delete mode 100644 drivers/staging/android/ion/ion_of.h delete mode 100644 drivers/staging/android/ion/ion_test.c delete mode 100644 drivers/staging/android/ion/tegra/Makefile delete mode 100644 drivers/staging/android/ion/tegra/tegra_ion.c delete mode 100644 drivers/staging/android/uapi/ion_test.h diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index c8fb413..206c4de 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -10,45 +10,3 @@ menuconfig ION If you're not using Android its probably safe to say N here. -config ION_TEST - tristate "Ion Test Device" - depends on ION - help - 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 - help - Choose this option if you wish to use ion on an nVidia Tegra. - -config ION_HISI - tristate "Ion for Hisilicon" - depends on ARCH_HISI && ION - select ION_OF - help - Choose this option if you wish to use ion on Hisilicon Platform. - -source "drivers/staging/android/ion/hisilicon/Kconfig" - -config ION_OF - bool "Devicetree support for Ion" - depends on ION && OF_ADDRESS - help - Provides base support for defining Ion heaps in devicetree - and setting them up. Also includes functions for platforms - to parse the devicetree and expand for their own custom - extensions - - If using Ion and devicetree, you should say Y here diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile index 5d630a0..26672a0 100644 --- a/drivers/staging/android/ion/Makefile +++ b/drivers/staging/android/ion/Makefile @@ -1,13 +1,6 @@ obj-$(CONFIG_ION) += ion.o ion-ioctl.o ion_heap.o \ ion_page_pool.o ion_system_heap.o \ ion_carveout_heap.o ion_chunk_heap.o ion_cma_heap.o -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/ -obj-$(CONFIG_ION_HISI) += hisilicon/ -obj-$(CONFIG_ION_OF) += ion_of.o - diff --git a/drivers/staging/android/ion/hisilicon/Kconfig b/drivers/staging/android/ion/hisilicon/Kconfig deleted file mode 100644 index 2b4bd07..0000000 --- a/drivers/staging/android/ion/hisilicon/Kconfig +++ /dev/null @@ -1,5 +0,0 @@ -config HI6220_ION - bool "Hi6220 ION Driver" - depends on ARCH_HISI && ION - help - Build the Hisilicon Hi6220 ion driver. diff --git a/drivers/staging/android/ion/hisilicon/Makefile b/drivers/staging/android/ion/hisilicon/Makefile deleted file mode 100644 index 2a89414..0000000 --- a/drivers/staging/android/ion/hisilicon/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_HI6220_ION) += hi6220_ion.o diff --git a/drivers/staging/android/ion/hisilicon/hi6220_ion.c b/drivers/staging/android/ion/hisilicon/hi6220_ion.c deleted file mode 100644 index 0de7897..0000000 --- a/drivers/staging/android/ion/hisilicon/hi6220_ion.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Hisilicon Hi6220 ION Driver - * - * Copyright (c) 2015 Hisilicon Limited. - * - * Author: Chen Feng - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#define pr_fmt(fmt) "Ion: " fmt - -#include -#include -#include -#include -#include -#include "../ion_priv.h" -#include "../ion.h" -#include "../ion_of.h" - -struct hisi_ion_dev { - struct ion_heap **heaps; - struct ion_device *idev; - struct ion_platform_data *data; -}; - -static struct ion_of_heap hisi_heaps[] = { - PLATFORM_HEAP("hisilicon,sys_user", 0, - ION_HEAP_TYPE_SYSTEM, "sys_user"), - PLATFORM_HEAP("hisilicon,sys_contig", 1, - ION_HEAP_TYPE_SYSTEM_CONTIG, "sys_contig"), - PLATFORM_HEAP("hisilicon,cma", ION_HEAP_TYPE_DMA, ION_HEAP_TYPE_DMA, - "cma"), - {} -}; - -static int hi6220_ion_probe(struct platform_device *pdev) -{ - struct hisi_ion_dev *ipdev; - int i; - - ipdev = devm_kzalloc(&pdev->dev, sizeof(*ipdev), GFP_KERNEL); - if (!ipdev) - return -ENOMEM; - - platform_set_drvdata(pdev, ipdev); - - ipdev->idev = ion_device_create(NULL); - if (IS_ERR(ipdev->idev)) - return PTR_ERR(ipdev->idev); - - ipdev->data = ion_parse_dt(pdev, hisi_heaps); - if (IS_ERR(ipdev->data)) - return PTR_ERR(ipdev->data); - - ipdev->heaps = devm_kzalloc(&pdev->dev, - sizeof(struct ion_heap) * ipdev->data->nr, - GFP_KERNEL); - if (!ipdev->heaps) { - ion_destroy_platform_data(ipdev->data); - return -ENOMEM; - } - - for (i = 0; i < ipdev->data->nr; i++) { - ipdev->heaps[i] = ion_heap_create(&ipdev->data->heaps[i]); - if (!ipdev->heaps) { - ion_destroy_platform_data(ipdev->data); - return -ENOMEM; - } - ion_device_add_heap(ipdev->idev, ipdev->heaps[i]); - } - return 0; -} - -static int hi6220_ion_remove(struct platform_device *pdev) -{ - struct hisi_ion_dev *ipdev; - int i; - - ipdev = platform_get_drvdata(pdev); - - for (i = 0; i < ipdev->data->nr; i++) - ion_heap_destroy(ipdev->heaps[i]); - - ion_destroy_platform_data(ipdev->data); - ion_device_destroy(ipdev->idev); - - return 0; -} - -static const struct of_device_id hi6220_ion_match_table[] = { - {.compatible = "hisilicon,hi6220-ion"}, - {}, -}; - -static struct platform_driver hi6220_ion_driver = { - .probe = hi6220_ion_probe, - .remove = hi6220_ion_remove, - .driver = { - .name = "ion-hi6220", - .of_match_table = hi6220_ion_match_table, - }, -}; - -static int __init hi6220_ion_init(void) -{ - return platform_driver_register(&hi6220_ion_driver); -} - -subsys_initcall(hi6220_ion_init); diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c deleted file mode 100644 index cf5c010..0000000 --- a/drivers/staging/android/ion/ion_dummy_driver.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 -#include -#include "ion.h" -#include "ion_priv.h" - -static struct ion_device *idev; -static struct ion_heap **heaps; - -static void *carveout_ptr; -static void *chunk_ptr; - -static 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", - }, - { - .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), - }, -}; - -static const struct ion_platform_data dummy_ion_pdata = { - .nr = ARRAY_SIZE(dummy_heaps), - .heaps = dummy_heaps, -}; - -static int __init ion_dummy_init(void) -{ - int i, err; - - idev = ion_device_create(NULL); - if (IS_ERR(idev)) - return PTR_ERR(idev); - heaps = kcalloc(dummy_ion_pdata.nr, sizeof(struct ion_heap *), - GFP_KERNEL); - if (!heaps) - return -ENOMEM; - - - /* 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]); - goto err; - } - ion_device_add_heap(idev, heaps[i]); - } - return 0; -err: - for (i = 0; i < dummy_ion_pdata.nr; ++i) - 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 err; -} -device_initcall(ion_dummy_init); - -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); - - 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; - } -} -__exitcall(ion_dummy_exit); diff --git a/drivers/staging/android/ion/ion_of.c b/drivers/staging/android/ion/ion_of.c deleted file mode 100644 index 7791c70..0000000 --- a/drivers/staging/android/ion/ion_of.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Based on work from: - * Andrew Andrianov - * Google - * The Linux Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ion.h" -#include "ion_priv.h" -#include "ion_of.h" - -static int ion_parse_dt_heap_common(struct device_node *heap_node, - struct ion_platform_heap *heap, - struct ion_of_heap *compatible) -{ - int i; - - for (i = 0; compatible[i].name; i++) { - if (of_device_is_compatible(heap_node, compatible[i].compat)) - break; - } - - if (!compatible[i].name) - return -ENODEV; - - heap->id = compatible[i].heap_id; - heap->type = compatible[i].type; - heap->name = compatible[i].name; - heap->align = compatible[i].align; - - /* Some kind of callback function pointer? */ - - pr_info("%s: id %d type %d name %s align %lx\n", __func__, - heap->id, heap->type, heap->name, heap->align); - return 0; -} - -static int ion_setup_heap_common(struct platform_device *parent, - struct device_node *heap_node, - struct ion_platform_heap *heap) -{ - int ret = 0; - - switch (heap->type) { - case ION_HEAP_TYPE_CARVEOUT: - case ION_HEAP_TYPE_CHUNK: - if (heap->base && heap->size) - return 0; - - ret = of_reserved_mem_device_init(heap->priv); - break; - default: - break; - } - - return ret; -} - -struct ion_platform_data *ion_parse_dt(struct platform_device *pdev, - struct ion_of_heap *compatible) -{ - int num_heaps, ret; - const struct device_node *dt_node = pdev->dev.of_node; - struct device_node *node; - struct ion_platform_heap *heaps; - struct ion_platform_data *data; - int i = 0; - - num_heaps = of_get_available_child_count(dt_node); - - if (!num_heaps) - return ERR_PTR(-EINVAL); - - heaps = devm_kzalloc(&pdev->dev, - sizeof(struct ion_platform_heap) * num_heaps, - GFP_KERNEL); - if (!heaps) - return ERR_PTR(-ENOMEM); - - data = devm_kzalloc(&pdev->dev, sizeof(struct ion_platform_data), - GFP_KERNEL); - if (!data) - return ERR_PTR(-ENOMEM); - - for_each_available_child_of_node(dt_node, node) { - struct platform_device *heap_pdev; - - ret = ion_parse_dt_heap_common(node, &heaps[i], compatible); - if (ret) - return ERR_PTR(ret); - - heap_pdev = of_platform_device_create(node, heaps[i].name, - &pdev->dev); - if (!heap_pdev) - return ERR_PTR(-ENOMEM); - heap_pdev->dev.platform_data = &heaps[i]; - - heaps[i].priv = &heap_pdev->dev; - - ret = ion_setup_heap_common(pdev, node, &heaps[i]); - if (ret) - goto out_err; - i++; - } - - data->heaps = heaps; - data->nr = num_heaps; - return data; - -out_err: - for ( ; i >= 0; i--) - if (heaps[i].priv) - of_device_unregister(to_platform_device(heaps[i].priv)); - - return ERR_PTR(ret); -} - -void ion_destroy_platform_data(struct ion_platform_data *data) -{ - int i; - - for (i = 0; i < data->nr; i++) - if (data->heaps[i].priv) - of_device_unregister(to_platform_device( - data->heaps[i].priv)); -} - -#ifdef CONFIG_OF_RESERVED_MEM -#include -#include -#include - -static int rmem_ion_device_init(struct reserved_mem *rmem, struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct ion_platform_heap *heap = pdev->dev.platform_data; - - heap->base = rmem->base; - heap->base = rmem->size; - pr_debug("%s: heap %s base %pa size %pa dev %p\n", __func__, - heap->name, &rmem->base, &rmem->size, dev); - return 0; -} - -static void rmem_ion_device_release(struct reserved_mem *rmem, - struct device *dev) -{ -} - -static const struct reserved_mem_ops rmem_dma_ops = { - .device_init = rmem_ion_device_init, - .device_release = rmem_ion_device_release, -}; - -static int __init rmem_ion_setup(struct reserved_mem *rmem) -{ - phys_addr_t size = rmem->size; - - size = size / 1024; - - pr_info("Ion memory setup at %pa size %pa MiB\n", - &rmem->base, &size); - rmem->ops = &rmem_dma_ops; - return 0; -} - -RESERVEDMEM_OF_DECLARE(ion, "ion-region", rmem_ion_setup); -#endif diff --git a/drivers/staging/android/ion/ion_of.h b/drivers/staging/android/ion/ion_of.h deleted file mode 100644 index 8241a17..0000000 --- a/drivers/staging/android/ion/ion_of.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Based on work from: - * Andrew Andrianov - * Google - * The Linux Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef _ION_OF_H -#define _ION_OF_H - -struct ion_of_heap { - const char *compat; - int heap_id; - int type; - const char *name; - int align; -}; - -#define PLATFORM_HEAP(_compat, _id, _type, _name) \ -{ \ - .compat = _compat, \ - .heap_id = _id, \ - .type = _type, \ - .name = _name, \ - .align = PAGE_SIZE, \ -} - -struct ion_platform_data *ion_parse_dt(struct platform_device *pdev, - struct ion_of_heap *compatible); - -void ion_destroy_platform_data(struct ion_platform_data *data); - -#endif diff --git a/drivers/staging/android/ion/ion_test.c b/drivers/staging/android/ion/ion_test.c deleted file mode 100644 index 5abf8320..0000000 --- a/drivers/staging/android/ion/ion_test.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * - * Copyright (C) 2013 Google, 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. - * - */ - -#define pr_fmt(fmt) "ion-test: " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ion.h" -#include "../uapi/ion_test.h" - -#define u64_to_uptr(x) ((void __user *)(unsigned long)(x)) - -struct ion_test_device { - struct miscdevice misc; -}; - -struct ion_test_data { - struct dma_buf *dma_buf; - struct device *dev; -}; - -static int ion_handle_test_dma(struct device *dev, struct dma_buf *dma_buf, - void __user *ptr, size_t offset, size_t size, - bool write) -{ - int ret = 0; - struct dma_buf_attachment *attach; - struct sg_table *table; - pgprot_t pgprot = pgprot_writecombine(PAGE_KERNEL); - enum dma_data_direction dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; - struct sg_page_iter sg_iter; - unsigned long offset_page; - - attach = dma_buf_attach(dma_buf, dev); - if (IS_ERR(attach)) - return PTR_ERR(attach); - - table = dma_buf_map_attachment(attach, dir); - if (IS_ERR(table)) - return PTR_ERR(table); - - offset_page = offset >> PAGE_SHIFT; - offset %= PAGE_SIZE; - - for_each_sg_page(table->sgl, &sg_iter, table->nents, offset_page) { - struct page *page = sg_page_iter_page(&sg_iter); - void *vaddr = vmap(&page, 1, VM_MAP, pgprot); - size_t to_copy = PAGE_SIZE - offset; - - to_copy = min(to_copy, size); - if (!vaddr) { - ret = -ENOMEM; - goto err; - } - - if (write) - ret = copy_from_user(vaddr + offset, ptr, to_copy); - else - ret = copy_to_user(ptr, vaddr + offset, to_copy); - - vunmap(vaddr); - if (ret) { - ret = -EFAULT; - goto err; - } - size -= to_copy; - if (!size) - break; - ptr += to_copy; - offset = 0; - } - -err: - dma_buf_unmap_attachment(attach, table, dir); - dma_buf_detach(dma_buf, attach); - return ret; -} - -static int ion_handle_test_kernel(struct dma_buf *dma_buf, void __user *ptr, - size_t offset, size_t size, bool write) -{ - int ret; - unsigned long page_offset = offset >> PAGE_SHIFT; - size_t copy_offset = offset % PAGE_SIZE; - size_t copy_size = size; - enum dma_data_direction dir = write ? DMA_FROM_DEVICE : DMA_TO_DEVICE; - - if (offset > dma_buf->size || size > dma_buf->size - offset) - return -EINVAL; - - ret = dma_buf_begin_cpu_access(dma_buf, dir); - if (ret) - return ret; - - while (copy_size > 0) { - size_t to_copy; - void *vaddr = dma_buf_kmap(dma_buf, page_offset); - - if (!vaddr) - goto err; - - to_copy = min_t(size_t, PAGE_SIZE - copy_offset, copy_size); - - if (write) - ret = copy_from_user(vaddr + copy_offset, ptr, to_copy); - else - ret = copy_to_user(ptr, vaddr + copy_offset, to_copy); - - dma_buf_kunmap(dma_buf, page_offset, vaddr); - if (ret) { - ret = -EFAULT; - goto err; - } - - copy_size -= to_copy; - ptr += to_copy; - page_offset++; - copy_offset = 0; - } -err: - dma_buf_end_cpu_access(dma_buf, dir); - return ret; -} - -static long ion_test_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) -{ - struct ion_test_data *test_data = filp->private_data; - int ret = 0; - - union { - struct ion_test_rw_data test_rw; - } data; - - if (_IOC_SIZE(cmd) > sizeof(data)) - return -EINVAL; - - if (_IOC_DIR(cmd) & _IOC_WRITE) - if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd))) - return -EFAULT; - - switch (cmd) { - case ION_IOC_TEST_SET_FD: - { - struct dma_buf *dma_buf = NULL; - int fd = arg; - - if (fd >= 0) { - dma_buf = dma_buf_get((int)arg); - if (IS_ERR(dma_buf)) - return PTR_ERR(dma_buf); - } - if (test_data->dma_buf) - dma_buf_put(test_data->dma_buf); - test_data->dma_buf = dma_buf; - break; - } - case ION_IOC_TEST_DMA_MAPPING: - { - ret = ion_handle_test_dma(test_data->dev, test_data->dma_buf, - u64_to_uptr(data.test_rw.ptr), - data.test_rw.offset, - data.test_rw.size, - data.test_rw.write); - break; - } - case ION_IOC_TEST_KERNEL_MAPPING: - { - ret = ion_handle_test_kernel(test_data->dma_buf, - u64_to_uptr(data.test_rw.ptr), - data.test_rw.offset, - data.test_rw.size, - data.test_rw.write); - break; - } - default: - return -ENOTTY; - } - - if (_IOC_DIR(cmd) & _IOC_READ) { - if (copy_to_user((void __user *)arg, &data, sizeof(data))) - return -EFAULT; - } - return ret; -} - -static int ion_test_open(struct inode *inode, struct file *file) -{ - struct ion_test_data *data; - struct miscdevice *miscdev = file->private_data; - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - data->dev = miscdev->parent; - - file->private_data = data; - - return 0; -} - -static int ion_test_release(struct inode *inode, struct file *file) -{ - struct ion_test_data *data = file->private_data; - - kfree(data); - - return 0; -} - -static const struct file_operations ion_test_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = ion_test_ioctl, - .compat_ioctl = ion_test_ioctl, - .open = ion_test_open, - .release = ion_test_release, -}; - -static int __init ion_test_probe(struct platform_device *pdev) -{ - int ret; - struct ion_test_device *testdev; - - testdev = devm_kzalloc(&pdev->dev, sizeof(struct ion_test_device), - GFP_KERNEL); - if (!testdev) - return -ENOMEM; - - testdev->misc.minor = MISC_DYNAMIC_MINOR; - testdev->misc.name = "ion-test"; - testdev->misc.fops = &ion_test_fops; - testdev->misc.parent = &pdev->dev; - ret = misc_register(&testdev->misc); - if (ret) { - pr_err("failed to register misc device.\n"); - return ret; - } - - platform_set_drvdata(pdev, testdev); - - return 0; -} - -static int ion_test_remove(struct platform_device *pdev) -{ - struct ion_test_device *testdev; - - testdev = platform_get_drvdata(pdev); - if (!testdev) - return -ENODATA; - - misc_deregister(&testdev->misc); - return 0; -} - -static struct platform_device *ion_test_pdev; -static struct platform_driver ion_test_platform_driver = { - .remove = ion_test_remove, - .driver = { - .name = "ion-test", - }, -}; - -static int __init ion_test_init(void) -{ - ion_test_pdev = platform_device_register_simple("ion-test", - -1, NULL, 0); - if (IS_ERR(ion_test_pdev)) - return PTR_ERR(ion_test_pdev); - - return platform_driver_probe(&ion_test_platform_driver, ion_test_probe); -} - -static void __exit ion_test_exit(void) -{ - platform_driver_unregister(&ion_test_platform_driver); - platform_device_unregister(ion_test_pdev); -} - -module_init(ion_test_init); -module_exit(ion_test_exit); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/android/ion/tegra/Makefile b/drivers/staging/android/ion/tegra/Makefile deleted file mode 100644 index 808f1f5..0000000 --- a/drivers/staging/android/ion/tegra/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-$(CONFIG_ION_TEGRA) += tegra_ion.o diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c deleted file mode 100644 index 49e55e5..0000000 --- a/drivers/staging/android/ion/tegra/tegra_ion.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * drivers/gpu/tegra/tegra_ion.c - * - * Copyright (C) 2011 Google, 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 "../ion.h" -#include "../ion_priv.h" - -static struct ion_device *idev; -static int num_heaps; -static struct ion_heap **heaps; - -static int tegra_ion_probe(struct platform_device *pdev) -{ - struct ion_platform_data *pdata = pdev->dev.platform_data; - int err; - int i; - - num_heaps = pdata->nr; - - heaps = devm_kcalloc(&pdev->dev, pdata->nr, - sizeof(struct ion_heap *), GFP_KERNEL); - - idev = ion_device_create(NULL); - if (IS_ERR(idev)) - return PTR_ERR(idev); - - /* create the heaps as specified in the board file */ - for (i = 0; i < num_heaps; i++) { - struct ion_platform_heap *heap_data = &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]); - } - platform_set_drvdata(pdev, idev); - return 0; -err: - for (i = 0; i < num_heaps; ++i) - ion_heap_destroy(heaps[i]); - return err; -} - -static int tegra_ion_remove(struct platform_device *pdev) -{ - struct ion_device *idev = platform_get_drvdata(pdev); - int i; - - ion_device_destroy(idev); - for (i = 0; i < num_heaps; i++) - ion_heap_destroy(heaps[i]); - return 0; -} - -static struct platform_driver ion_driver = { - .probe = tegra_ion_probe, - .remove = tegra_ion_remove, - .driver = { .name = "ion-tegra" } -}; - -module_platform_driver(ion_driver); - diff --git a/drivers/staging/android/uapi/ion_test.h b/drivers/staging/android/uapi/ion_test.h deleted file mode 100644 index 480242e..0000000 --- a/drivers/staging/android/uapi/ion_test.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * drivers/staging/android/uapi/ion.h - * - * Copyright (C) 2011 Google, 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. - * - */ - -#ifndef _UAPI_LINUX_ION_TEST_H -#define _UAPI_LINUX_ION_TEST_H - -#include -#include - -/** - * struct ion_test_rw_data - metadata passed to the kernel to read handle - * @ptr: a pointer to an area at least as large as size - * @offset: offset into the ion buffer to start reading - * @size: size to read or write - * @write: 1 to write, 0 to read - */ -struct ion_test_rw_data { - __u64 ptr; - __u64 offset; - __u64 size; - int write; - int __padding; -}; - -#define ION_IOC_MAGIC 'I' - -/** - * DOC: ION_IOC_TEST_SET_DMA_BUF - attach a dma buf to the test driver - * - * Attaches a dma buf fd to the test driver. Passing a second fd or -1 will - * release the first fd. - */ -#define ION_IOC_TEST_SET_FD \ - _IO(ION_IOC_MAGIC, 0xf0) - -/** - * DOC: ION_IOC_TEST_DMA_MAPPING - read or write memory from a handle as DMA - * - * Reads or writes the memory from a handle using an uncached mapping. Can be - * used by unit tests to emulate a DMA engine as close as possible. Only - * expected to be used for debugging and testing, may not always be available. - */ -#define ION_IOC_TEST_DMA_MAPPING \ - _IOW(ION_IOC_MAGIC, 0xf1, struct ion_test_rw_data) - -/** - * DOC: ION_IOC_TEST_KERNEL_MAPPING - read or write memory from a handle - * - * Reads or writes the memory from a handle using a kernel mapping. Can be - * used by unit tests to test heap map_kernel functions. Only expected to be - * used for debugging and testing, may not always be available. - */ -#define ION_IOC_TEST_KERNEL_MAPPING \ - _IOW(ION_IOC_MAGIC, 0xf2, struct ion_test_rw_data) - -#endif /* _UAPI_LINUX_ION_H */