From patchwork Sat Mar 18 00:54:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9631935 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 83C8360249 for ; Sat, 18 Mar 2017 01:44:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FBD728473 for ; Sat, 18 Mar 2017 01:44:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64452284EE; Sat, 18 Mar 2017 01:44:42 +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 B543D28473 for ; Sat, 18 Mar 2017 01:44:41 +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=5Rc5ywARnzrtNoqTXpO5KK3A1x7YLBp+ZrVfeL6oJ3U=; b=EgwsqnRFi0LgFrNGMID30+dB+l PBCU7K9m8M5FmyHb0y6GWIttBR6/kW2NUBKiyY9Zm8TaNN5Y8UcWbb0aWfka/Ep/ZLlqBSK3z3SgB 2+wBITqZVpOlKP4+0429hSjQm2c+O5Fk+XIQ1USIeGhvLhM67aObfWzsrWOCZOlDxhhWZ9INkT1jY Z+ggA1Kx9bcV0CTFHQKulkQgSmbRZl4We8DBW6MbBBVw4FdSJrVbg7y0GvF4DdNaCqbFzIOD5JuO0 lUx9rqqbbmp7kog5xxfgRq1VI55rq7GDEJe9k6WL6RlLg0g2l1wlw+iOz2g7qWFEWgzRzSVEYirap WZwxhTMg==; 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 1cp3Q8-00039k-Rd; Sat, 18 Mar 2017 01:44:40 +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-BV for linux-arm-kernel@bombadil.infradead.org; Sat, 18 Mar 2017 01:44:04 +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=3jXgssG47WzXW1ENWtla/YtjZr+Vs2u42oQ46oEZQcA=; b=HmenXtTS8yeLIHUlyP394OcAQ lpm1MKf40r+5IBti0xYyw+fuTt61HSQn/gaduGWF9QBJs1zu85KbfbBasmUo2TVn/ImRRwjVZE2K1 6BnkCSsqudNAhXJ9ZjQwG775GWzyg2c7Rn8RGu9kY3/C4+XbDC3GCZj0hS/QzRhLqrz3S5K/Y6u/t nyAmhYegR04q41Nb0L7nHNn6mV1rJVVaoD+YeVdBo9lJcxcPJO13yue/CdhOxaXcMkYRql0SoFpuC jomD+xH3FeLv5q5LUzwyrwj7iqDLAOXUantM8bkz++kLQ+lju81RGkD+9xbbiDCupHnWlynSABQqu WtuSa89OA==; Received: from mail-qt0-f174.google.com ([209.85.216.174]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cp2fC-00031h-MV for linux-arm-kernel@lists.infradead.org; Sat, 18 Mar 2017 00:56:12 +0000 Received: by mail-qt0-f174.google.com with SMTP id n21so75244309qta.1 for ; Fri, 17 Mar 2017 17:55:50 -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=3jXgssG47WzXW1ENWtla/YtjZr+Vs2u42oQ46oEZQcA=; b=jNEJDqqVbyrg7j8RRYvjJx9jhfFeUD1G0WloAyd6LU9Mp9cqnDR6eRE7O3GqnKrtSc B+83l6P5YywKHFC8T0hJlxWDRZ3dnEnv/aJ9MQuKw0pS1mZuqct0WrxMeITU3hfRaKI0 UxOWpK8z55h7kmTHMCneOGWe9eYXeiTeA90RoqrsqR00rybqYKsyYEvaz0JpIapO6wJV ixRrorfa4IDdYoYNamR6krcg0bDqu4GvMfmko6RZcHIxan/B5LbE6qoSQlnNtztp6+1l UGqW8WjjbPU8oky1rxxw+ZWuqBSHYGiNgJPrZe40zkmwUGo/fgkuLCk27XQ2sOabyCV8 c6Tg== X-Gm-Message-State: AFeK/H3nbV6l8GEY+YYUcORiBZbe6w+A33jOCDGuZ+Vu1SsqhRjZ7HSRpS3sP/MZy86lLjIt X-Received: by 10.200.50.112 with SMTP id y45mr15976143qta.75.1489798549387; Fri, 17 Mar 2017 17:55:49 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Mar 2017 17:55:48 -0700 (PDT) From: Laura Abbott To: Subject: [RFC PATCHv2 15/21] staging: android: ion: Break the ABI in the name of forward progress Date: Fri, 17 Mar 2017 17:54:47 -0700 Message-Id: <1489798493-16600-16-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_205610_807855_258F4BF8 X-CRM114-Status: GOOD ( 19.75 ) 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 To: Sumit Semwal To: Riley Andrews Cc: romlem@google.com To: arve@android.com To: Riley Andrews Cc: devel@driverdev.osuosl.org Cc: linux-kernel@vger.kernel.org Cc: linaro-mm-sig@lists.linaro.org Cc: Greg Kroah-Hartman Cc: linux-arm-kernel@lists.infradead.org Cc: linux-media@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: Brian Starkey Cc: Daniel Vetter Cc: Mark Brown Cc: Benjamin Gaignard Cc: linux-mm@kvack.org Cc: Laurent Pinchart Several of the Ion ioctls were designed in such a way that they necessitate compat ioctls. We're breaking a bunch of other ABIs and cleaning stuff up anyway so let's follow the ioctl guidelines and clean things up while everyone is busy converting things over anyway. As part of this, also remove the useless alignment field from the allocation structure. Signed-off-by: Laura Abbott --- drivers/staging/android/ion/Makefile | 3 - drivers/staging/android/ion/compat_ion.c | 152 ------------------------------- drivers/staging/android/ion/compat_ion.h | 29 ------ drivers/staging/android/ion/ion-ioctl.c | 1 - drivers/staging/android/ion/ion.c | 5 +- drivers/staging/android/uapi/ion.h | 19 ++-- 6 files changed, 11 insertions(+), 198 deletions(-) delete mode 100644 drivers/staging/android/ion/compat_ion.c delete mode 100644 drivers/staging/android/ion/compat_ion.h diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile index 66d0c4a..a892afa 100644 --- a/drivers/staging/android/ion/Makefile +++ b/drivers/staging/android/ion/Makefile @@ -2,6 +2,3 @@ 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 obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o -ifdef CONFIG_COMPAT -obj-$(CONFIG_ION) += compat_ion.o -endif diff --git a/drivers/staging/android/ion/compat_ion.c b/drivers/staging/android/ion/compat_ion.c deleted file mode 100644 index 5037ddd..0000000 --- a/drivers/staging/android/ion/compat_ion.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * drivers/staging/android/ion/compat_ion.c - * - * 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. - * - */ - -#include -#include -#include - -#include "ion.h" -#include "compat_ion.h" - -/* See drivers/staging/android/uapi/ion.h for the definition of these structs */ -struct compat_ion_allocation_data { - compat_size_t len; - compat_size_t align; - compat_uint_t heap_id_mask; - compat_uint_t flags; - compat_int_t handle; -}; - -struct compat_ion_handle_data { - compat_int_t handle; -}; - -#define COMPAT_ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ - struct compat_ion_allocation_data) -#define COMPAT_ION_IOC_FREE _IOWR(ION_IOC_MAGIC, 1, \ - struct compat_ion_handle_data) - -static int compat_get_ion_allocation_data( - struct compat_ion_allocation_data __user *data32, - struct ion_allocation_data __user *data) -{ - compat_size_t s; - compat_uint_t u; - compat_int_t i; - int err; - - err = get_user(s, &data32->len); - err |= put_user(s, &data->len); - err |= get_user(s, &data32->align); - err |= put_user(s, &data->align); - err |= get_user(u, &data32->heap_id_mask); - err |= put_user(u, &data->heap_id_mask); - err |= get_user(u, &data32->flags); - err |= put_user(u, &data->flags); - err |= get_user(i, &data32->handle); - err |= put_user(i, &data->handle); - - return err; -} - -static int compat_get_ion_handle_data( - struct compat_ion_handle_data __user *data32, - struct ion_handle_data __user *data) -{ - compat_int_t i; - int err; - - err = get_user(i, &data32->handle); - err |= put_user(i, &data->handle); - - return err; -} - -static int compat_put_ion_allocation_data( - struct compat_ion_allocation_data __user *data32, - struct ion_allocation_data __user *data) -{ - compat_size_t s; - compat_uint_t u; - compat_int_t i; - int err; - - err = get_user(s, &data->len); - err |= put_user(s, &data32->len); - err |= get_user(s, &data->align); - err |= put_user(s, &data32->align); - err |= get_user(u, &data->heap_id_mask); - err |= put_user(u, &data32->heap_id_mask); - err |= get_user(u, &data->flags); - err |= put_user(u, &data32->flags); - err |= get_user(i, &data->handle); - err |= put_user(i, &data32->handle); - - return err; -} - -long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - long ret; - - if (!filp->f_op->unlocked_ioctl) - return -ENOTTY; - - switch (cmd) { - case COMPAT_ION_IOC_ALLOC: - { - struct compat_ion_allocation_data __user *data32; - struct ion_allocation_data __user *data; - int err; - - data32 = compat_ptr(arg); - data = compat_alloc_user_space(sizeof(*data)); - if (!data) - return -EFAULT; - - err = compat_get_ion_allocation_data(data32, data); - if (err) - return err; - ret = filp->f_op->unlocked_ioctl(filp, ION_IOC_ALLOC, - (unsigned long)data); - err = compat_put_ion_allocation_data(data32, data); - return ret ? ret : err; - } - case COMPAT_ION_IOC_FREE: - { - struct compat_ion_handle_data __user *data32; - struct ion_handle_data __user *data; - int err; - - data32 = compat_ptr(arg); - data = compat_alloc_user_space(sizeof(*data)); - if (!data) - return -EFAULT; - - err = compat_get_ion_handle_data(data32, data); - if (err) - return err; - - return filp->f_op->unlocked_ioctl(filp, ION_IOC_FREE, - (unsigned long)data); - } - case ION_IOC_SHARE: - return filp->f_op->unlocked_ioctl(filp, cmd, - (unsigned long)compat_ptr(arg)); - default: - return -ENOIOCTLCMD; - } -} diff --git a/drivers/staging/android/ion/compat_ion.h b/drivers/staging/android/ion/compat_ion.h deleted file mode 100644 index 9da8f91..0000000 --- a/drivers/staging/android/ion/compat_ion.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * drivers/staging/android/ion/compat_ion.h - * - * 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. - * - */ - -#ifndef _LINUX_COMPAT_ION_H -#define _LINUX_COMPAT_ION_H - -#if IS_ENABLED(CONFIG_COMPAT) - -long compat_ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); - -#else - -#define compat_ion_ioctl NULL - -#endif /* CONFIG_COMPAT */ -#endif /* _LINUX_COMPAT_ION_H */ diff --git a/drivers/staging/android/ion/ion-ioctl.c b/drivers/staging/android/ion/ion-ioctl.c index a361724..91b5c2b 100644 --- a/drivers/staging/android/ion/ion-ioctl.c +++ b/drivers/staging/android/ion/ion-ioctl.c @@ -20,7 +20,6 @@ #include "ion.h" #include "ion_priv.h" -#include "compat_ion.h" union ion_ioctl_arg { struct ion_fd_data fd; diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 65638f5..fbab1e3 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -40,7 +40,6 @@ #include "ion.h" #include "ion_priv.h" -#include "compat_ion.h" bool ion_buffer_cached(struct ion_buffer *buffer) { @@ -1065,7 +1064,9 @@ static const struct file_operations ion_fops = { .open = ion_open, .release = ion_release, .unlocked_ioctl = ion_ioctl, - .compat_ioctl = compat_ion_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = ion_ioctl, +#endif }; static size_t ion_debug_heap_total(struct ion_client *client, diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h index abd72fd..bba1c47 100644 --- a/drivers/staging/android/uapi/ion.h +++ b/drivers/staging/android/uapi/ion.h @@ -20,8 +20,6 @@ #include #include -typedef int ion_user_handle_t; - /** * enum ion_heap_types - list of all possible types of heaps * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc @@ -76,7 +74,6 @@ enum ion_heap_type { /** * struct ion_allocation_data - metadata passed from userspace for allocations * @len: size of the allocation - * @align: required alignment of the allocation * @heap_id_mask: mask of heap ids to allocate from * @flags: flags passed to heap * @handle: pointer that will be populated with a cookie to use to @@ -85,11 +82,11 @@ enum ion_heap_type { * Provided by userspace as an argument to the ioctl */ struct ion_allocation_data { - size_t len; - size_t align; - unsigned int heap_id_mask; - unsigned int flags; - ion_user_handle_t handle; + __u64 len; + __u32 heap_id_mask; + __u32 flags; + __u32 handle; + __u32 unused; }; /** @@ -103,8 +100,8 @@ struct ion_allocation_data { * provides the file descriptor and the kernel returns the handle. */ struct ion_fd_data { - ion_user_handle_t handle; - int fd; + __u32 handle; + __u32 fd; }; /** @@ -112,7 +109,7 @@ struct ion_fd_data { * @handle: a handle */ struct ion_handle_data { - ion_user_handle_t handle; + __u32 handle; }; #define MAX_HEAP_NAME 32