From patchwork Mon Nov 6 15:59:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 118069 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2919894qgn; Mon, 6 Nov 2017 08:00:04 -0800 (PST) X-Google-Smtp-Source: ABhQp+Qsy9xO/Ho1xOVn3B8q19ugKS3Lb0OLdpB9px3iqkbpVG4JsWoDKW/r55tYpOqTDWRV0TDA X-Received: by 10.98.222.2 with SMTP id h2mr17124589pfg.165.1509984003916; Mon, 06 Nov 2017 08:00:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509984003; cv=none; d=google.com; s=arc-20160816; b=xhGnYrJ2Vpzod9yxKQZ4yfMsztZ750rsTktZvvhjQ0ujImbIpT3YpAJ/48dTVsKQkl cgW51A6zw/yrd07t31kX/Cc+GxDf7gmyXo8oW4xSJ8n7vO4Dn7uBQuNVS8mEPxT8PwOY XlwM7J5hMSfYiBzhcui/qrTeHp197Ut6wAmnYH8aTgkgklPPJVde06a3shjFFzNxoBFL NMFxyo+ijDxZukYZx5AQLR/yFCXQ4UK6BlEIgZ73cPx8cheNhJZEzIa5t0M/vI5eSDJ6 IliMC/RMQxvU/LwwSA3BXVIRdw6HRTAcBOzblFoZxqbdjeTuG+bBlohNtZt+bw1Z4k7t EMlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=hBJkzWPlFFGJ5jRSpPqRPZgc83igYBHIG6hI9FfmDek=; b=L0dU8kx23K+b6cv47M3UItMa9uZoYQ8nQQhlLamp6zrdgw5RoGdnEcefPfwtW+CQYa FjLHI92QsALICIS/PtqQ0SRYtQBu4C122tQJMVe6EDEKlS10cKMik3K7MnmlnB5VrlTE UXBQvqs7l4M3/sKJ5S4/zUK+vYNEwP7sS+cnDeelEVpl1ncEf0EFW22tyvGJUv9q9UME E0I9ICxDb4oBL9UAUSra8/lfiYwMu+kNAodDyoTsyG7YCy3x08EIZ7/Sg82iX+3sYqlR vgtypGAJ9lQFC5T+MDSTlRg1FU5yS2RZW69Y0Rvb57s7u5EtBXfjoELwgmlyrtJZD+BK ZZtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBb3evYt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21si12654483pfa.266.2017.11.06.08.00.03; Mon, 06 Nov 2017 08:00:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBb3evYt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754040AbdKFQAA (ORCPT + 26 others); Mon, 6 Nov 2017 11:00:00 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:54625 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754021AbdKFP75 (ORCPT ); Mon, 6 Nov 2017 10:59:57 -0500 Received: by mail-wr0-f195.google.com with SMTP id g10so1535403wrg.11 for ; Mon, 06 Nov 2017 07:59:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hBJkzWPlFFGJ5jRSpPqRPZgc83igYBHIG6hI9FfmDek=; b=WBb3evYtBpfkVEZRG6gKGND6W9t876MB6ePpNPmduyYSZ0tWq+fdM1wK2wfjk453Me k26+84n7ha57wyl/R4YpzXK78W6RAV1iWKweIJEjKpBhondgwd+Dv+IzksZaMpgEBMQj ZCcvIo2MJT5Ut3cQCcCzE/o73xoQRtLrwV/sc= 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=hBJkzWPlFFGJ5jRSpPqRPZgc83igYBHIG6hI9FfmDek=; b=hxzCVtqUzcG/RMa+QZrD4PAiBzTTjzSHE7AfJGf53oqUIB9bgSO/qVHVPBEhEFgCC4 pUM4zAgLAAvZhKy+DS7dufI/M6UI5bWdWv1VaTJqnD7MwAysoG5Pj5xAnlLEB/kwR/ie 5MzlqrZp2DXp6JvgUJFejFKV9Ng4FxTjvjbyt/V84Wl71DM/jb2L9GUkglRg6MdyIZC2 tmX83gtCL3eZDfQD3bnE1Uy2OncswitEVYsnr6W4RIF2UTEH3WfPcQwoIi6Ail5/Qw7P khIc4z3zcoNZtm6jNa0I1+s+z3SXkGL2X7e2AzN4xyQ124V7Bea9F9klDQNXKt6d46ct uk1g== X-Gm-Message-State: AJaThX65qpVZlHT/KwB1WfuGQEn89bhem8u6ss01bm9ilEqZdvNk9heB bqF5KloVQSH1N/M+fAwFNZm2tw== X-Received: by 10.223.151.211 with SMTP id t19mr5340367wrb.2.1509983996489; Mon, 06 Nov 2017 07:59:56 -0800 (PST) Received: from lmecxl0911.lme.st.com ([80.215.204.172]) by smtp.gmail.com with ESMTPSA id x63sm9601003wma.39.2017.11.06.07.59.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 07:59:55 -0800 (PST) From: Benjamin Gaignard To: labbott@redhat.com, sumit.semwal@linaro.org, gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, broonie@kernel.org, dan.carpenter@oracle.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org, Benjamin Gaignard Subject: [PATCH v6 1/2] staging: ion: reorder include Date: Mon, 6 Nov 2017 16:59:44 +0100 Message-Id: <1509983985-20950-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509983985-20950-1-git-send-email-benjamin.gaignard@linaro.org> References: <1509983985-20950-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Put include in alphabetic order Signed-off-by: Benjamin Gaignard --- drivers/staging/android/ion/ion.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.7.4 Acked-by: Laura Abbott diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index a7d9b0e..fda9756 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -15,28 +15,28 @@ * */ +#include +#include #include +#include #include +#include #include #include #include -#include +#include #include #include #include #include -#include #include #include #include -#include +#include #include +#include #include #include -#include -#include -#include -#include #include "ion.h" From patchwork Mon Nov 6 15:59:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 118070 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2919982qgn; Mon, 6 Nov 2017 08:00:09 -0800 (PST) X-Google-Smtp-Source: ABhQp+SJ561h/NXQ3iyxDwA4NjkEkJxm8FGkHz7Pr3ToFcXO16zkXSC8dM9UO/kvaHt4ghgVbgM5 X-Received: by 10.159.252.198 with SMTP id o6mr14854084pls.390.1509984009027; Mon, 06 Nov 2017 08:00:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509984009; cv=none; d=google.com; s=arc-20160816; b=g5279A5a1ZQER7MZCmw/DzW/ddNKC34z+Iud+pgzTsYprlyvGZFUklwfChVaSxMPwY +oGws56M7YaAkBSuxVNNW7fuEhs3eP6qJdYfiKdlB6vv3ZrKfpmWRF0xzImq/PB5OiCK X79uQ1fc9M8l3YuK6AI8ysF0qAKKTouTkaXeqq38QTez69iaaB5bcD1WnFtBxfMHYpgF Irvujp1CzG19AH8odV8/2VWYaOajNfhTRThnmm2sNOcRgGUV/USYAqj9fK2nnnCEBybt IO8mwcETy1weKS7/IjttYWuJmDUHE/qcIGK9H6YCOWb16KbTbq1aXJvdB2rnwkkW+OSf MRNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=82wSscWDk5v9abSbkwSg1Ujf04lUUcRbwpz35s3Sk/A=; b=LTGTJTZ9VPffLrpiymFNBME6ESrvwTRg57dR4EEu2Gkapi6wK0BnSuz4hlJi/Gkgg9 AhbvObFpSAGWs+M4VpOyy1FZXPcba0te43e5z4GjhK8QbKrPZRrVMYyY7D6Gilqwg18a zrQYr/V2D33Kwkz3wz/l+l2GdKdLLNBIDg/hOBAO5m006N5Haf1mcSUT1RXSzPSQekmf Bg0p1f9bwt778sKwg4dU9xKfbLFMOD636RAyFFiyZTdDrwjsUMc4hyR9YL9eCAC5iQio OO1iz4/O6XB88VRh9hR7KSBrUSJUASVHEoxv6pmymE7crWMXbWBW2xh+kHWTyRWDfa2Z vB8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QYADl11A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20si10939840plr.659.2017.11.06.08.00.08; Mon, 06 Nov 2017 08:00:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QYADl11A; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754055AbdKFQAF (ORCPT + 26 others); Mon, 6 Nov 2017 11:00:05 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44626 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754035AbdKFQAB (ORCPT ); Mon, 6 Nov 2017 11:00:01 -0500 Received: by mail-wr0-f194.google.com with SMTP id u97so1598000wrc.1 for ; Mon, 06 Nov 2017 08:00:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=82wSscWDk5v9abSbkwSg1Ujf04lUUcRbwpz35s3Sk/A=; b=QYADl11AsOcJ9mcoLYTU9gnGl6vHXkttg+UIxHBTUYZ4RA7ORw7I4EEVaRcBF7dUDz 8DvxLUfdk5M8sxbzF8rdJBm0i6U0816UsXiWZu1alNj6lAEsJubrJjkxmeRSsZlMAUFB LVwzU1JZAjfRocPsA1Hjm9ZwpNcOKdok2wFso= 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=82wSscWDk5v9abSbkwSg1Ujf04lUUcRbwpz35s3Sk/A=; b=kEAbrRHxKyIwIC/eO33iUhjKWT3At3FDgNLcjjNDRnT+Yvc+4B/oef6nhukOZSgAed HLHP34jKbSRGJJ5Yey97bbVRqNHHdk9l6qzGLXR9ZfUAXJQbtY0M2eeZVicHG/J8whjp QTi6Qe6IqKBEfcZ4xyweW6jt0l5NdCROlBkjJHX5uFh7hh3QuZTk/PZxs7fhtouYhZOM ApmyK2/3PEmOd8NUdrvzLcrq/BzQRKHV/wbcwywHk4n0ha07LhDGX861ji/4OW9ONLe3 3LVsTa86/Vn2hSD6soCgzcxtShvZrUaL5IPZ1ANy5f02ppU2XivnNSby3UQiOFyxIa5f Or6g== X-Gm-Message-State: AMCzsaU0kd4bvStmp0JBgFVj/agSWom8UDuLAj0eYogrSc1m7PM9ahuh ug4+Yk3I11vrDc95BAu+C7jJI0zgLJCkDw== X-Received: by 10.223.183.7 with SMTP id l7mr12268827wre.139.1509983999641; Mon, 06 Nov 2017 07:59:59 -0800 (PST) Received: from lmecxl0911.lme.st.com ([80.215.204.172]) by smtp.gmail.com with ESMTPSA id x63sm9601003wma.39.2017.11.06.07.59.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 07:59:58 -0800 (PST) From: Benjamin Gaignard To: labbott@redhat.com, sumit.semwal@linaro.org, gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, broonie@kernel.org, dan.carpenter@oracle.com Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-api@vger.kernel.org, Benjamin Gaignard Subject: [PATCH v6 2/2] staging: ion: create one device entry per heap Date: Mon, 6 Nov 2017 16:59:45 +0100 Message-Id: <1509983985-20950-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509983985-20950-1-git-send-email-benjamin.gaignard@linaro.org> References: <1509983985-20950-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead a getting only one common device "/dev/ion" for all the heaps this patch allow to create one device entry ("/dev/ionX") per heap. Getting an entry per heap could allow to set security rules per heap and global ones for all heaps. Allocation requests will be only allowed if the mask_id match with device minor. Query request could be done on any of the devices. Signed-off-by: Benjamin Gaignard --- drivers/staging/android/TODO | 1 - drivers/staging/android/ion/Kconfig | 7 ++++ drivers/staging/android/ion/ion-ioctl.c | 18 ++++++++-- drivers/staging/android/ion/ion.c | 62 +++++++++++++++++++++++++++++---- drivers/staging/android/ion/ion.h | 15 ++++++-- 5 files changed, 91 insertions(+), 12 deletions(-) -- 2.7.4 Acked-by: Laura Abbott diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO index 687e0ea..8a11931 100644 --- a/drivers/staging/android/TODO +++ b/drivers/staging/android/TODO @@ -8,7 +8,6 @@ TODO: ion/ - Add dt-bindings for remaining heaps (chunk and carveout heaps). This would involve putting appropriate bindings in a memory node for Ion to find. - - Split /dev/ion up into multiple nodes (e.g. /dev/ion/heap0) - Better test framework (integration with VGEM was suggested) Please send patches to Greg Kroah-Hartman and Cc: diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index a517b2d..cb4666e 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -10,6 +10,13 @@ menuconfig ION If you're not using Android its probably safe to say N here. +config ION_LEGACY_DEVICE_API + bool "Keep using Ion legacy misc device API" + depends on ION + help + Choose this option to keep using Ion legacy misc device API + i.e. /dev/ion + config ION_SYSTEM_HEAP bool "Ion system heap" depends on ION diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c index e26b786..bb5c77b 100644 --- a/drivers/staging/android/ion/ion-ioctl.c +++ b/drivers/staging/android/ion/ion-ioctl.c @@ -25,7 +25,8 @@ union ion_ioctl_arg { struct ion_heap_query query; }; -static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) +static int validate_ioctl_arg(struct file *filp, + unsigned int cmd, union ion_ioctl_arg *arg) { switch (cmd) { case ION_IOC_HEAP_QUERY: @@ -34,6 +35,19 @@ static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) arg->query.reserved2 ) return -EINVAL; break; + + case ION_IOC_ALLOC: + { + int mask = 1 << iminor(filp->f_inode); + +#ifdef CONFIG_ION_LEGACY_DEVICE_API + if (imajor(filp->f_inode) == MISC_MAJOR) + return 0; +#endif + if (!(arg->allocation.heap_id_mask & mask)) + return -EINVAL; + break; + } default: break; } @@ -69,7 +83,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd))) return -EFAULT; - ret = validate_ioctl_arg(cmd, &data); + ret = validate_ioctl_arg(filp, cmd, &data); if (WARN_ON_ONCE(ret)) return ret; diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index fda9756..2c2568b 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -40,6 +40,9 @@ #include "ion.h" +#define ION_DEV_MAX 32 +#define ION_NAME "ion" + static struct ion_device *internal_dev; static int heap_id; @@ -535,15 +538,38 @@ static int debug_shrink_get(void *data, u64 *val) DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get, debug_shrink_set, "%llu\n"); -void ion_device_add_heap(struct ion_heap *heap) +static struct device ion_bus = { + .init_name = ION_NAME, +}; + +static struct bus_type ion_bus_type = { + .name = ION_NAME, +}; + +int ion_device_add_heap(struct ion_heap *heap) { struct dentry *debug_file; struct ion_device *dev = internal_dev; + int ret = 0; if (!heap->ops->allocate || !heap->ops->free) pr_err("%s: can not add heap with invalid ops struct.\n", __func__); + if (heap_id >= ION_DEV_MAX) + return -EBUSY; + + heap->ddev.parent = &ion_bus; + heap->ddev.bus = &ion_bus_type; + heap->ddev.devt = MKDEV(MAJOR(internal_dev->devt), heap_id); + dev_set_name(&heap->ddev, ION_NAME"%d", heap_id); + device_initialize(&heap->ddev); + cdev_init(&heap->chrdev, &ion_fops); + heap->chrdev.owner = THIS_MODULE; + ret = cdev_device_add(&heap->chrdev, &heap->ddev); + if (ret < 0) + return ret; + spin_lock_init(&heap->free_lock); heap->free_list_size = 0; @@ -581,6 +607,8 @@ void ion_device_add_heap(struct ion_heap *heap) dev->heap_cnt++; up_write(&dev->lock); + + return ret; } EXPORT_SYMBOL(ion_device_add_heap); @@ -593,8 +621,9 @@ static int ion_device_create(void) if (!idev) return -ENOMEM; +#ifdef CONFIG_ION_LEGACY_DEVICE_API idev->dev.minor = MISC_DYNAMIC_MINOR; - idev->dev.name = "ion"; + idev->dev.name = ION_NAME; idev->dev.fops = &ion_fops; idev->dev.parent = NULL; ret = misc_register(&idev->dev); @@ -603,19 +632,38 @@ static int ion_device_create(void) kfree(idev); return ret; } +#endif - idev->debug_root = debugfs_create_dir("ion", NULL); - if (!idev->debug_root) { + ret = device_register(&ion_bus); + if (ret) + goto clean_misc; + + ret = bus_register(&ion_bus_type); + if (ret) + goto clean_device; + + ret = alloc_chrdev_region(&idev->devt, 0, ION_DEV_MAX, ION_NAME); + if (ret) + goto clean_device; + + idev->debug_root = debugfs_create_dir(ION_NAME, NULL); + if (!idev->debug_root) pr_err("ion: failed to create debugfs root directory.\n"); - goto debugfs_done; - } -debugfs_done: idev->buffers = RB_ROOT; mutex_init(&idev->buffer_lock); init_rwsem(&idev->lock); plist_head_init(&idev->heaps); internal_dev = idev; return 0; + +clean_device: + device_unregister(&ion_bus); +clean_misc: +#ifdef CONFIG_ION_LEGACY_DEVICE_API + misc_deregister(&idev->dev); +#endif + kfree(idev); + return ret; } subsys_initcall(ion_device_create); diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index f5f9cd6..4869e96 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -17,16 +17,19 @@ #ifndef _ION_H #define _ION_H +#include #include #include #include +#ifdef CONFIG_ION_LEGACY_DEVICE_API +#include +#endif #include #include #include #include #include #include -#include #include "../uapi/ion.h" @@ -92,12 +95,16 @@ void ion_buffer_destroy(struct ion_buffer *buffer); /** * struct ion_device - the metadata of the ion device node * @dev: the actual misc device + * @devt: Ion device * @buffers: an rb tree of all the existing buffers * @buffer_lock: lock protecting the tree of buffers * @lock: rwsem protecting the tree of heaps and clients */ struct ion_device { +#ifdef CONFIG_ION_LEGACY_DEVICE_API struct miscdevice dev; +#endif + dev_t devt; struct rb_root buffers; struct mutex buffer_lock; struct rw_semaphore lock; @@ -153,6 +160,8 @@ struct ion_heap_ops { * struct ion_heap - represents a heap in the system * @node: rb node to put the heap on the device's tree of heaps * @dev: back pointer to the ion_device + * @ddev: device structure + * @chrdev: associated character device * @type: type of heap * @ops: ops struct as above * @flags: flags @@ -177,6 +186,8 @@ struct ion_heap_ops { struct ion_heap { struct plist_node node; struct ion_device *dev; + struct device ddev; + struct cdev chrdev; enum ion_heap_type type; struct ion_heap_ops *ops; unsigned long flags; @@ -213,7 +224,7 @@ bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer); * ion_device_add_heap - adds a heap to the ion device * @heap: the heap to add */ -void ion_device_add_heap(struct ion_heap *heap); +int ion_device_add_heap(struct ion_heap *heap); /** * some helpers for common operations on buffers using the sg_table