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: kernel test robot via dri-devel X-Patchwork-Id: 10816601 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAD326C2 for ; Sat, 16 Feb 2019 20:13:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4162AB54 for ; Sat, 16 Feb 2019 20:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF3452AB6F; Sat, 16 Feb 2019 20:13:38 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51D702AB54 for ; Sat, 16 Feb 2019 20:13:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD4B56E4A0; Sat, 16 Feb 2019 20:11:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 37A516EB2C for ; Fri, 15 Feb 2019 20:24:22 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id q206so5318070pgq.4 for ; Fri, 15 Feb 2019 12:24:22 -0800 (PST) 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=NstagziuRRYEpeCiFB9okuFWqgUrbQJBKQNCp/M7wTLcuN8cqqEf9hAvDwB5JgTwHQ uu6Zc/GNE03V7sOo6urgVQyAS6sGvUci3d74mFJj1Ny89FRBbjXfWZ5XCKCxjrbVROYg Gc6DC+9Ch1vfR4V5yA4txVq6thVa8MBhqGLO3SEa0R5Aim9ixbWmTnGWT/a1GFVsNbIT rFz9Mqq04AZahrAZPSiTMpz3IibyY5A4yWZuF/xnBb0eBYeq4emulRWwHXdRdYWN4ql0 Uf4LeNGUA67Oh6iScQbnqV8BCHm4+uonYhY5MoJLR46XscquD7ZOBQ9CSHc0hzKQEKq8 Xz/g== X-Gm-Message-State: AHQUAuaDtow0W6jWPxqGJDVGhdvySXcQHSLDps7tuf+WqErO1wRfXDYQ FGQxw00XV6E/v3Q3cRqWU2JwJg== 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) 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) To: Laura Abbott 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> X-Mailman-Original-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-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: John Stultz via dri-devel From: kernel test robot via dri-devel Reply-To: John Stultz Cc: Alistair Strachan , Liam Mark , "Andrew F . Davis" , dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);