From patchwork Fri Feb 15 20:24:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 158549 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1112835jaa; Fri, 15 Feb 2019 12:24:22 -0800 (PST) X-Received: by 2002:a17:902:22f:: with SMTP id 44mr12005407plc.137.1550262262098; Fri, 15 Feb 2019 12:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550262262; cv=none; d=google.com; s=arc-20160816; b=cByWMHPRbku1e1Ryd4SqvXT9qgZwfRk9GNLE6Whg/ASOZ9czrqoE0x8heOaKMFPIkH /r5AjkQEYAiAZsTQcNMghcwEqnZIzHQHz6Wx2Z4LnXvhjsStwjgEwL72BVL0wdWCZT51 Yci2aUy5mZBvXSrCRtuz+nQCDO/vTebm5V534hkM2UwQKq8HmuKDDQ2o5fg2VhM3oPkK XsNxC2r0fPONVP3Da5lrBti82Rg5v2y32lbuKsfvcYqfUiOjkPkrS6OkTpNakK5nPiFA jdLm73zNbHMuEajP61ck2OlVP0FWont4YwUPHb+cyiz0WYNIPKf8dA5vIqMAgk4PhVxy p2Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q5G2GKGbywqAdnaJODcSwGYr0iOLzvSrGO5crfVUvyk=; b=EIEYB0nCPnN0a8Pdm+W7GGWJCW7HFkhWYY2W9xFHE942i4OADoGhryi3qK4HxF4t9y c89yD8/skY8r99OK3ggxu8AIuJexjNrL4I2UyYfaHgFyIdChcBty9CF7If00Uml4k4p4 pP3yIyzsFS56sCEfu3UUWtjesltC0J4QwQndxXTowpSFUKNXrQXTlFjhFDUl6o62udUJ FtuL277wBsfslqXN5kg5x3BxEDj6IHq8KVOAcJ2/TaJBdDK+6N+xzkr4Ae/6pjAkXRPU 24PT9PQqODtILDYxe1nqEc6jfXobWrSFXIyTASjmdp8ksJpXgZq5olWG2cWcQ1YRrFBI p52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QN4tdNTX; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id x13sor10619999pge.29.2019.02.15.12.24.22 for (Google Transport Security); Fri, 15 Feb 2019 12:24:22 -0800 (PST) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QN4tdNTX; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=Q5G2GKGbywqAdnaJODcSwGYr0iOLzvSrGO5crfVUvyk=; b=QN4tdNTXPKeyZUXD9Rd25oxEJMMZuwjVgauQFc4/FdPSUsI1l5NZfav2NtbcPzz7j0 eB7cF33o6naOZVbfaex4f8PsN0jvCYikdYtePTqjz0yO2Xp5OYpiBUPIayipPEdz406W nZw04FjZ4tfz0FtzRVXkdS5W7fnRxsm1lijeUfS6P0hMbRu61WACGw91ERljXkXPAryH 5MRoHsxRfyXYq42tjUV7zv5mnXLdDY+R7N7xQltppz9yOoaojY4zAWdkZnZzqy5jCwwm Qfr2n3aBrWXLggG6/XR7qNQIhkAKvK73AwX7bu71RnNMe1V8c5VW2CzfVDb1C974HWyJ LVpA== 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=Q5G2GKGbywqAdnaJODcSwGYr0iOLzvSrGO5crfVUvyk=; b=n00MnPciNSr1g/AeUsclXsqonkyzdpf+TcBuqxK5lTl5IIyoVh1jpPs1I/f0L1z3S8 UpiC7+c4/0ECVXUCk8UCHQa2aNTflq1TnKYEwY0yo0wV24mTt95KRR1WTxTTFtrqHFhk s4si9l8GvBz7Eupp85CVdV/qsCmnvAm69SkLADlfP14mzdxK7hxr4W5FETI/V2YDMbBv 3KUOQl3eZcHe7JaGtb81Vh2jTqtEd8bdY8IKQiwvdJWlxRtPSniq+8Gvle9Aeg5U1jtA c+FvMl47cV97zy5W43Y1bT/YQV/Uf/gywAG9jZHAE6rEWOO7KH1kGpQNR0KqQDZnHykb TR7Q== X-Gm-Message-State: AHQUAuZGYZU9Ot/HJ++ADvpTAAH0rZIXjT4wW7lZgzzWg7RlsF6r8CAj VE55UeSdTx9ICnSAsiyP8eeiFtuY X-Google-Smtp-Source: AHgI3IZ4x7fp44gShXXsEXVj8S70EIJVnisXDbNNmgEjjNVjSCGYBrGpt0dPYK9Wjo5lFYYA7PjeYA== X-Received: by 2002:a63:8b4b:: with SMTP id j72mr7040440pge.100.1550262261718; Fri, 15 Feb 2019 12:24:21 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id l2sm7593340pgn.52.2019.02.15.12.24.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Feb 2019 12:24:20 -0800 (PST) From: John Stultz To: Laura Abbott Cc: John Stultz , Sumit Semwal , Liam Mark , Brian Starkey , "Andrew F . Davis" , Alistair Strachan , dri-devel@lists.freedesktop.org Subject: [EARLY RFC][PATCH 4/4] ion: Make "legacy" /dev/ion support optional Date: Fri, 15 Feb 2019 12:24:12 -0800 Message-Id: <1550262252-15558-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550262252-15558-1-git-send-email-john.stultz@linaro.org> References: <1550262252-15558-1-git-send-email-john.stultz@linaro.org> Add a config option to make the "legacy" /dev/ion interface optional. Not yet clear if this will come out of staging or not, but to help with the transition. Cc: Laura Abbott Cc: Sumit Semwal Cc: Liam Mark Cc: Brian Starkey Cc: Andrew F. Davis Cc: Alistair Strachan Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/staging/android/ion/Kconfig | 7 ++++++ drivers/staging/android/ion/ion-ioctl.c | 2 ++ drivers/staging/android/ion/ion.c | 43 +++++++++++++++++++++------------ drivers/staging/android/ion/ion.h | 2 ++ 4 files changed, 39 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index 0fdda6f..7f5a0b2 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -42,3 +42,10 @@ config ION_CMA_HEAP Choose this option to enable CMA heaps with Ion. This heap is backed by the Contiguous Memory Allocator (CMA). If your system has these regions, you should say Y here. + +config ION_COMPAT_INTERFACE + bool "Legacy /dev/ion interface support" + depends on ION + help + Choose this option to enable the legacy /dev/ion interface which + provides compatibility with userspace designed for 4.12+ kernels diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c index 6db5969..427980c 100644 --- a/drivers/staging/android/ion/ion-ioctl.c +++ b/drivers/staging/android/ion/ion-ioctl.c @@ -43,6 +43,7 @@ static unsigned int ion_ioctl_dir(unsigned int cmd) } } +#ifdef CONFIG_ION_COMPAT_INTERFACE long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int ret = 0; @@ -102,6 +103,7 @@ long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } return ret; } +#endif long ion_heap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 1f7c893..9a73526 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -500,14 +500,6 @@ static const struct file_operations ion_heap_fops = { #endif }; -static const struct file_operations ion_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = ion_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = ion_ioctl, -#endif -}; - static int debug_shrink_set(void *data, u64 val) { struct ion_heap *heap = data; @@ -619,15 +611,19 @@ void ion_device_add_heap(struct ion_heap *heap) } EXPORT_SYMBOL(ion_device_add_heap); -static int ion_device_create(void) +#ifdef CONFIG_ION_COMPAT_INTERFACE +static const struct file_operations ion_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = ion_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ion_ioctl, +#endif +}; + +static int ion_create_legacy_interface(struct ion_device *idev) { - struct ion_device *idev; int ret; - idev = kzalloc(sizeof(*idev), GFP_KERNEL); - if (!idev) - return -ENOMEM; - idev->dev.minor = MISC_DYNAMIC_MINOR; idev->dev.name = "ion"; idev->dev.fops = &ion_fops; @@ -636,8 +632,25 @@ static int ion_device_create(void) if (ret) { pr_err("ion: failed to register misc device.\n"); kfree(idev); - return ret; } + return ret; +} +#else +#define ion_create_legacy_interface(x) 0 +#endif + +static int ion_device_create(void) +{ + struct ion_device *idev; + int ret; + + idev = kzalloc(sizeof(*idev), GFP_KERNEL); + if (!idev) + return -ENOMEM; + + ret = ion_create_legacy_interface(idev); + if (ret) + return ret; idev->debug_root = debugfs_create_dir("ion", NULL); idev->buffers = RB_ROOT; diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 7ed4a6a..a82178b 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -333,7 +333,9 @@ void ion_page_pool_free(struct ion_page_pool *pool, struct page *page); int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, int nr_to_scan); +#ifdef CONFIG_ION_COMPAT_INTERFACE long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); +#endif long ion_heap_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); int ion_query_heaps(struct ion_heap_query *query);