From patchwork Wed May 22 16:41:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10956347 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 0884E912 for ; Wed, 22 May 2019 16:42:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE52328C96 for ; Wed, 22 May 2019 16:42:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2CB628C85; Wed, 22 May 2019 16:42:49 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 7456928A51 for ; Wed, 22 May 2019 16:42:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A95BA89C0A; Wed, 22 May 2019 16:42:46 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9ACCC89BFD for ; Wed, 22 May 2019 16:42:44 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id s17so3087271wru.3 for ; Wed, 22 May 2019 09:42:44 -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:mime-version :content-transfer-encoding; bh=EiCXJBgmQQgvHjA9MJX6zXtOm5JUiCrk6V/+8qDrxZk=; b=NmiP7v/LmXCNEvK5g3Dc3+6Gmohdy4hE4EzGq57KIek6zYBRBmpTb8wHWKUnnlg2t+ cu3+Qq8GZMm10uGaL3d9GrTIB9lRPnp+Y7+vm/rNUAj+U/LEV8ww5kGeyYhQL7vTQqmt N2hblq3jPffd5/Sd8t+qBqexqkfcvJEFNlTuvqXQISrn6sjBW0nDbPvm+80PMS2v7uJR 09Qayz81o0hvn8syILU7pq6YEMGNx02qnio/4Dxqcf6CmIT1sDJFXOMLjS2L+pv78Ym3 1u/y4MKXOIoqhvs1XSyceqWF5ZmLIGjJQxFe14qW45gHrhChBJP23pKey86SoZPwPdsG ZYQA== X-Gm-Message-State: APjAAAXKIVYQ/R2RCF1LRMWQngoEZSyhF1U5hd4w6Z6u8RpL0VJ1JnWj 4j212i0cUkxNIL9UAS3PU+NulCk5 X-Google-Smtp-Source: APXvYqwmuJmBXVS+sNh7zySGrXTzRc79zy0KCVF6B0eeuSJbs1d2RpNguwyFSqi92qTB470E1aKixQ== X-Received: by 2002:a5d:4f0e:: with SMTP id c14mr40395703wru.91.1558543362833; Wed, 22 May 2019 09:42:42 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id l18sm24576684wrv.38.2019.05.22.09.42.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 09:42:42 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] vmwgfx: drop empty lastclose stub Date: Wed, 22 May 2019 17:41:15 +0100 Message-Id: <20190522164119.24139-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=EiCXJBgmQQgvHjA9MJX6zXtOm5JUiCrk6V/+8qDrxZk=; b=gnpg/6QLDSAPuzTRIaDVF+KpTNeqMgBNG6VMO8WH8vGRjBDQfaSR6b25rd3Gymo4M1 B7tl5EXpBuaHej0Fc3ujlNcMcB6eoFldKwwPw1iDhXdn9W3FUsVj1Gqs/I7QnZyI8XjT FjIoQ/XM9ySe245b0BO9jhPgF7WjdBInMoIf9F4Jl+sSADPekUCZFqoWZPDUOtbNoSwI cVNBOadIEGuwvZwbzgBVQqGJwq90WcC3IupfIOvgtvJuTSAZ43iFYR9Gzu1vW+4/Z0Ad TcZH28t1IO8dR2rvvdK7cuHQ5G2OQonAXmMLdlX2ODeGpAqJWnEeQRpvDETudxSyrU9+ v8PQ== 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: , Cc: Thomas Hellstrom , kernel@collabora.com, VMware Graphics Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Core DRM is safe when the callback is NULL. Cc: "VMware Graphics" Cc: Thomas Hellstrom Cc: Daniel Vetter Signed-off-by: Emil Velikov Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index be25ce9440ad..a38f06909fb6 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1200,10 +1200,6 @@ static long vmw_compat_ioctl(struct file *filp, unsigned int cmd, } #endif -static void vmw_lastclose(struct drm_device *dev) -{ -} - static void vmw_master_init(struct vmw_master *vmaster) { ttm_lock_init(&vmaster->lock); @@ -1568,7 +1564,6 @@ static struct drm_driver driver = { DRIVER_MODESET | DRIVER_PRIME | DRIVER_RENDER | DRIVER_ATOMIC, .load = vmw_driver_load, .unload = vmw_driver_unload, - .lastclose = vmw_lastclose, .get_vblank_counter = vmw_get_vblank_counter, .enable_vblank = vmw_enable_vblank, .disable_vblank = vmw_disable_vblank, From patchwork Wed May 22 16:41:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10956349 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 4AD141390 for ; Wed, 22 May 2019 16:42:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C6DA28C76 for ; Wed, 22 May 2019 16:42:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 309F728C9C; Wed, 22 May 2019 16:42:52 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 C788428C85 for ; Wed, 22 May 2019 16:42:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4064389C14; Wed, 22 May 2019 16:42:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B4CC89BFD for ; Wed, 22 May 2019 16:42:45 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id i3so2905777wml.4 for ; Wed, 22 May 2019 09:42:45 -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:mime-version:content-transfer-encoding; bh=9DKrzunIyydueP1ABArbsyU6wbPwjgNS2c0Kr6npnPM=; b=ANpm5zRzG3CsjTBcn7WbueFIuKt+brX8Aht04mfPJeTUA7AnKEdj393QIr7aaS+7Cn h080c0GWApsZn2trO/+Ez2x0QgLo3USP8oemRlMX90bb10LH7V4vz1RaQMJzQBCMMA4z b2SdhsFF48RmOQDvv8wgIbvsu+TL7AEdovuy96oMg4vit14/4hayX1XBFXpowC18gaWV yMTxEptyTBHREdR1qHqsf9rD6ufXJLSyzBmRoL9sQ6KjYxxxtTZpO0wsoVsvMjGsyYC/ m04vVbjxU5DRDRRhzn8XOLVoQfmiPKeReoNYTVngpnGq/2LbKkYUW9sEt3qDNcCXivfU CYFw== X-Gm-Message-State: APjAAAVS7MBDyAt7eTrfmTlvzBRGRJBhNpoCS1DxLZ+n9ZnEA8KCxzaL 4h6YTt+MNIXlLCLG/9E3mM7onQyG X-Google-Smtp-Source: APXvYqwV9jyQPgH+Ni5KCSKizkyNxbz2D0yFCaqOi32oy5VqFVjA7Kwax01ltoajKvOzqwKd6D3W7Q== X-Received: by 2002:a1c:2dd2:: with SMTP id t201mr8200833wmt.136.1558543363722; Wed, 22 May 2019 09:42:43 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id l18sm24576684wrv.38.2019.05.22.09.42.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 09:42:43 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm/vmgfx: kill off unused init_mutex Date: Wed, 22 May 2019 17:41:16 +0100 Message-Id: <20190522164119.24139-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522164119.24139-1-emil.l.velikov@gmail.com> References: <20190522164119.24139-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9DKrzunIyydueP1ABArbsyU6wbPwjgNS2c0Kr6npnPM=; b=Ug446RUhhuSVanuiILd+TW7vv9oc1fRcofmEvW3KjnmHcgRSyfUOJWJpHqRCqAtgk5 v2HoP6/qgvYxmD89yCXDJ1HWuiXCMvZ8CwH6tsb7lYBqils/cVkso6OcOqfGLYYdU/nc ni10whoByNa4iA8XFbNNS4HyrvpOYoZ4V7QDZz57kZY/g0NgRtA+C8rEpNDF/S6QMAR7 Yfsw8b95sNcMqXJGKMxzWyW7yuDXv3MEWNClkpKBMDYL39nxxbFQdXMbLssT3Ws7w7E7 0G97xCcqsSS7z2i9E60gfhGyKPEJz3uXa+cuLr+aq4ITl0no4fFrljYmhYYqXAscep+z bYUQ== 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: , Cc: Thomas Hellstrom , kernel@collabora.com, VMware Graphics Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov According to the docs - prevents firstopen/lastclose races. Yet never used in practise. Cc: "VMware Graphics" Cc: Thomas Hellstrom Cc: Daniel Vetter Signed-off-by: Emil Velikov Reviewed-by: Thomas Hellstrom --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 1 - drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 5 ----- 2 files changed, 6 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index a38f06909fb6..d3f108f7e52d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -664,7 +664,6 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) INIT_LIST_HEAD(&dev_priv->res_lru[i]); } - mutex_init(&dev_priv->init_mutex); init_waitqueue_head(&dev_priv->fence_queue); init_waitqueue_head(&dev_priv->fifo_queue); dev_priv->fence_queue_waiters = 0; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 96983c47fb40..9be2176cc260 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -484,11 +484,6 @@ struct vmw_private { spinlock_t resource_lock; struct idr res_idr[vmw_res_max]; - /* - * Block lastclose from racing with firstopen. - */ - - struct mutex init_mutex; /* * A resource manager for kernel-only surfaces and From patchwork Wed May 22 16:41:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10956353 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 002A0912 for ; Wed, 22 May 2019 16:42:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4E6B28C9B for ; Wed, 22 May 2019 16:42:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D912728CA6; Wed, 22 May 2019 16:42:56 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 249BA28C9B for ; Wed, 22 May 2019 16:42:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D766689C1A; Wed, 22 May 2019 16:42:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5DB0F89BFD for ; Wed, 22 May 2019 16:42:46 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id g12so3056052wro.8 for ; Wed, 22 May 2019 09:42:46 -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:mime-version:content-transfer-encoding; bh=RjoLA6QCk7auGxjMBGiiysypySk4DW/hctJNZ3oSXI0=; b=N144ORnmN0LEXj+AMdtTNxVVDk460gajclphO6gzzMK9VMqbv2rs/2grptBcZYta6z dJ/vjtcqNpLsl5EgRh2UpGumru+0iErLmxJgT4Q1Xw9yTHHMC5CWM0ajeAmy0KJcCg6N QTSdJNp175l/8eoAghXTrmLmj5U87214i8xrLxfOJ8vh9ciMXBMs9AkskfmOrJkTI0ww SxAPiYsQiSCYcYI/s2YhVBLm24Ow05Hpi87ENhwVjGGx92JjvTnQu/vjmS8lhRJFkoFy CQx/6ElIdT0ci/FeBACqyg/KAmLcqELhGeZ2j4/0B2E53pvFLdm/iiYeQDEvc5ZemdpU riYA== X-Gm-Message-State: APjAAAUeMB2pDOHwztRvXsX8AA0s782varzb6Tw+68ss4Bg9YYK/tajB 87PXrI8cR5SBiFXb9GQy++0fX3UI X-Google-Smtp-Source: APXvYqwRGEaxzw+AgXozh+1MoU8p4xOkOlHspOq2TqOzXMDhBx9qas8B5e8moKONzbvJdv8i3Mb9kw== X-Received: by 2002:adf:cd09:: with SMTP id w9mr18051735wrm.242.1558543364811; Wed, 22 May 2019 09:42:44 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id l18sm24576684wrv.38.2019.05.22.09.42.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 09:42:44 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm/vmwgfx: use core drm to extend/check vmw_execbuf_ioctl Date: Wed, 22 May 2019 17:41:17 +0100 Message-Id: <20190522164119.24139-3-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522164119.24139-1-emil.l.velikov@gmail.com> References: <20190522164119.24139-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RjoLA6QCk7auGxjMBGiiysypySk4DW/hctJNZ3oSXI0=; b=DZWg/pY2/onPFJW6zOYOffAOiGuotZJprG6hjr5uGWvwxqS9PWThkd8BhSsRUu05/N Y2PPcxzqdk9Ove5rbB/ynIJVx6vxulLdMFGB1TjfjODRmq7zzLYfHJx3A+CrGOaYGOU3 xnk3oiZ8kEuiuYfulbXp9n5jTxo27lGOSOuJ47JaD5ax4im839GvMvPPhFQNk8TWBHrr /+k7WqGUKNoTlAKsW1HZpEfDz3TpiV8xAvTHc6owEhUtHUxt0YAnDEK/pPaL42m/Xm77 d0w9qbFQvYAzc5/YNnXPBKJ71txhKq9tmGu80eZQvIYJjZsYbbM9QbK5VuNFh53JYIgQ ytvA== 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: , Cc: Thomas Hellstrom , kernel@collabora.com, VMware Graphics Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Currently vmw_execbuf_ioctl() open-codes the permission checking, size extending and copying that is already done in core drm. Kill all the duplication, adding a few comments for clarity. Cc: "VMware Graphics" Cc: Thomas Hellstrom Cc: Daniel Vetter Signed-off-by: Emil Velikov Tested-by: Thomas Hellstrom Reviewed-by: Thomas Hellstrom --- Thomas, VMware team, Please give this some testing on your end. I've only tested it against mesa-master. Thanks Emil --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 12 +----- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 52 +++++++++---------------- 3 files changed, 23 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index d3f108f7e52d..2cb6ae219e43 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -186,7 +186,7 @@ static const struct drm_ioctl_desc vmw_ioctls[] = { DRM_RENDER_ALLOW), VMW_IOCTL_DEF(VMW_REF_SURFACE, vmw_surface_reference_ioctl, DRM_AUTH | DRM_RENDER_ALLOW), - VMW_IOCTL_DEF(VMW_EXECBUF, NULL, DRM_AUTH | + VMW_IOCTL_DEF(VMW_EXECBUF, vmw_execbuf_ioctl, DRM_AUTH | DRM_RENDER_ALLOW), VMW_IOCTL_DEF(VMW_FENCE_WAIT, vmw_fence_obj_wait_ioctl, DRM_RENDER_ALLOW), @@ -1140,15 +1140,7 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd, &vmw_ioctls[nr - DRM_COMMAND_BASE]; if (nr == DRM_COMMAND_BASE + DRM_VMW_EXECBUF) { - ret = (long) drm_ioctl_permit(ioctl->flags, file_priv); - if (unlikely(ret != 0)) - return ret; - - if (unlikely((cmd & (IOC_IN | IOC_OUT)) != IOC_IN)) - goto out_io_encoding; - - return (long) vmw_execbuf_ioctl(dev, arg, file_priv, - _IOC_SIZE(cmd)); + return ioctl_func(filp, cmd, arg); } else if (nr == DRM_COMMAND_BASE + DRM_VMW_UPDATE_LAYOUT) { if (!drm_is_current_master(file_priv) && !capable(CAP_SYS_ADMIN)) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 9be2176cc260..f5bfac85f793 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -910,8 +910,8 @@ static inline struct page *vmw_piter_page(struct vmw_piter *viter) * Command submission - vmwgfx_execbuf.c */ -extern int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, - struct drm_file *file_priv, size_t size); +extern int vmw_execbuf_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv); extern int vmw_execbuf_process(struct drm_file *file_priv, struct vmw_private *dev_priv, void __user *user_commands, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 2ff7ba04d8c8..767e2b99618d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -3977,54 +3977,40 @@ void vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv) mutex_unlock(&dev_priv->cmdbuf_mutex); } -int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, - struct drm_file *file_priv, size_t size) +int vmw_execbuf_ioctl(struct drm_device *dev, void *data, + struct drm_file *file_priv) { struct vmw_private *dev_priv = vmw_priv(dev); - struct drm_vmw_execbuf_arg arg; + struct drm_vmw_execbuf_arg *arg = data; int ret; - static const size_t copy_offset[] = { - offsetof(struct drm_vmw_execbuf_arg, context_handle), - sizeof(struct drm_vmw_execbuf_arg)}; struct dma_fence *in_fence = NULL; - if (unlikely(size < copy_offset[0])) { - VMW_DEBUG_USER("Invalid command size, ioctl %d\n", - DRM_VMW_EXECBUF); - return -EINVAL; - } - - if (copy_from_user(&arg, (void __user *) data, copy_offset[0]) != 0) - return -EFAULT; - /* * Extend the ioctl argument while maintaining backwards compatibility: - * We take different code paths depending on the value of arg.version. + * We take different code paths depending on the value of arg->version. + * + * Note: The ioctl argument is extended and zeropadded by core DRM. */ - if (unlikely(arg.version > DRM_VMW_EXECBUF_VERSION || - arg.version == 0)) { + if (unlikely(arg->version > DRM_VMW_EXECBUF_VERSION || + arg->version == 0)) { VMW_DEBUG_USER("Incorrect execbuf version.\n"); return -EINVAL; } - if (arg.version > 1 && - copy_from_user(&arg.context_handle, - (void __user *) (data + copy_offset[0]), - copy_offset[arg.version - 1] - copy_offset[0]) != 0) - return -EFAULT; - - switch (arg.version) { + switch (arg->version) { case 1: - arg.context_handle = (uint32_t) -1; + /* For v1 core DRM have extended + zeropadded the data */ + arg->context_handle = (uint32_t) -1; break; case 2: default: + /* For v2 and later core DRM would have correctly copied it */ break; } /* If imported a fence FD from elsewhere, then wait on it */ - if (arg.flags & DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD) { - in_fence = sync_file_get_fence(arg.imported_fence_fd); + if (arg->flags & DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD) { + in_fence = sync_file_get_fence(arg->imported_fence_fd); if (!in_fence) { VMW_DEBUG_USER("Cannot get imported fence\n"); @@ -4041,11 +4027,11 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned long data, return ret; ret = vmw_execbuf_process(file_priv, dev_priv, - (void __user *)(unsigned long)arg.commands, - NULL, arg.command_size, arg.throttle_us, - arg.context_handle, - (void __user *)(unsigned long)arg.fence_rep, - NULL, arg.flags); + (void __user *)(unsigned long)arg->commands, + NULL, arg->command_size, arg->throttle_us, + arg->context_handle, + (void __user *)(unsigned long)arg->fence_rep, + NULL, arg->flags); ttm_read_unlock(&dev_priv->reservation_sem); if (unlikely(ret != 0)) From patchwork Wed May 22 16:41:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10956355 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 A9E98912 for ; Wed, 22 May 2019 16:42:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ABB028CA4 for ; Wed, 22 May 2019 16:42:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F36620008; Wed, 22 May 2019 16:42:58 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 4E40E28CA6 for ; Wed, 22 May 2019 16:42:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E1D4189C2C; Wed, 22 May 2019 16:42:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 388C589BFD for ; Wed, 22 May 2019 16:42:47 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id s17so3087459wru.3 for ; Wed, 22 May 2019 09:42:47 -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:mime-version:content-transfer-encoding; bh=w/diVRkSY3GbsqvZKDkKB9JH05Fjty08jM7SF5zvRbk=; b=D5d6Ic13TYGs13wzcmHBg0+2SJ6bT0LcazOUBYPT+DmspTNba9rBkGdbVu8HDePDsA PieNU805086FfzZw8sNxeJpltczmrO26vtoWea72Gs1+wobT/PrrhR5PH4PXqGjxD1eP EZNNJwCaJ/PQ9eSt/WNqXWVW8j4X+egsGYPJpQD/9ciuuZ8ByvWFPjnehh8oYuV2lwyQ RHXqMSNS3gsuen3dioeUBfI1ZHHGd3/lU84s91SnMDINUMdobsusGuzznukblCA5xAT4 M819ke52tIlbrIeGVQRjfvrMwqFqCFcyP5KWAw0ZiXie/RHdNLdLK1ijLNtFtSaksZjp 1B3w== X-Gm-Message-State: APjAAAWAcYtMm2f2CC4kcI9IdaKYZnxM8bf7+UjDb7dfEBV++97R3W8j Y1djCDSRqx93LADGMO7aW7qy8ua9 X-Google-Smtp-Source: APXvYqyFXwUqLogJpUThMajdoouGewR1XVB0rFswlWaAH4+nEb2Zrw+OsVCZLWB9Ylxbolfyc18KDA== X-Received: by 2002:adf:fc46:: with SMTP id e6mr26599225wrs.298.1558543365716; Wed, 22 May 2019 09:42:45 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id l18sm24576684wrv.38.2019.05.22.09.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 09:42:45 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/5] drm/vmwgfx: remove custom ioctl io encoding check Date: Wed, 22 May 2019 17:41:18 +0100 Message-Id: <20190522164119.24139-4-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522164119.24139-1-emil.l.velikov@gmail.com> References: <20190522164119.24139-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w/diVRkSY3GbsqvZKDkKB9JH05Fjty08jM7SF5zvRbk=; b=q+al59saRcBS1ExXpL6A6PoS40PBHRzQIzx5dS3rfse6DdYVzpZCBhj4syVU+QgRxd kA9mQ01yjertRrTOkg33IK3HVD/Cxyox7HQd4F+rHzRXf+U6zndyHY5KhOnZra1xmu0l jVXQ2aUXOQJ6qrKjXtKeonKrkEc0uA4EcVZbGy6qTh0LXt3rPJM6TZARdH12BDIL7n6o CwH3IGXSO3qbpteusqZ+E+FySEpkTdJla8fBN4MOoiw5K6flpwpvJAc1qx5fRS/V+m9C N9WU533aZo7UvmY7O/oFCC62MhlO9Z/i+w9xhkUs26HQT7Hz60Gvq6q0bysRgkxEJwYW YzZw== 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: , Cc: Thomas Hellstrom , kernel@collabora.com, VMware Graphics Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Drop the custom ioctl io encoding check - core drm does it for us. Cc: "VMware Graphics" Cc: Thomas Hellstrom Cc: Daniel Vetter Signed-off-by: Emil Velikov --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 2cb6ae219e43..f65542639b55 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1147,9 +1147,6 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd, return -EACCES; } - if (unlikely(ioctl->cmd != cmd)) - goto out_io_encoding; - flags = ioctl->flags; } else if (!drm_ioctl_flags(nr, &flags)) return -EINVAL; @@ -1169,12 +1166,6 @@ static long vmw_generic_ioctl(struct file *filp, unsigned int cmd, ttm_read_unlock(&vmaster->lock); return ret; - -out_io_encoding: - DRM_ERROR("Invalid command format, ioctl %d\n", - nr - DRM_COMMAND_BASE); - - return -EINVAL; } static long vmw_unlocked_ioctl(struct file *filp, unsigned int cmd, From patchwork Wed May 22 16:41:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10956351 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 4D3B31390 for ; Wed, 22 May 2019 16:42:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FFA428C9B for ; Wed, 22 May 2019 16:42:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 342AB28C9C; Wed, 22 May 2019 16:42:55 +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,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 D840126E69 for ; Wed, 22 May 2019 16:42:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A7E389C19; Wed, 22 May 2019 16:42:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by gabe.freedesktop.org (Postfix) with ESMTPS id 149A989C18 for ; Wed, 22 May 2019 16:42:48 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id r7so3034250wrr.13 for ; Wed, 22 May 2019 09:42:48 -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:mime-version:content-transfer-encoding; bh=FKVd6xhpYfv+ZT31yBVOx/hjmfuDpWSl0legPgI6N+0=; b=CHC5BmzYyR7pQTuLqof5zO/OhgBuesmnvO1M8s+Wqg/UF6xzjeK7Nt0qH4qI80IoXM B/w/l+VxcJ2ZCYXezA/rqyYyKumA35kBSyAwxa4CI410vwtYdNkvK+pqfrpirUx4T6g0 sD16H9YNr5QlLRnkFHPWHspnqaUpaLtsk04qBiYa4B81eK4UjIPz1alz3sMgCiepNan3 d5o3pkze7ZTkQaYXbQCljDsoN6fQL18nC+TnNT8S2z4558NVRROOQ9dwhLAX4NrX5p9K W943OpQK/BwM0Nwxq+pPLweChQDs9xQugPMQpTE7+XKxT5xGhKWKvAOnzdZj8HhgtWn7 ti7Q== X-Gm-Message-State: APjAAAV/T7QJ6VNSLtF98+7YVQ5kETxA5/BJnOdOUQMONLgPCp/FIVdG 0uDsxmul8C79q5KbIi4EHdW2arpO X-Google-Smtp-Source: APXvYqyHhTDtJjduPo0dH9P2lReJuJD//FrO5Bb8WzOdRG5o4pHomGt4avISjxxri3+osHv4H+5JNQ== X-Received: by 2002:adf:ce88:: with SMTP id r8mr33705053wrn.191.1558543366581; Wed, 22 May 2019 09:42:46 -0700 (PDT) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:5f00:102:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id l18sm24576684wrv.38.2019.05.22.09.42.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 May 2019 09:42:45 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/5] drm: make drm_ioctl_permit() internal Date: Wed, 22 May 2019 17:41:19 +0100 Message-Id: <20190522164119.24139-5-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190522164119.24139-1-emil.l.velikov@gmail.com> References: <20190522164119.24139-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FKVd6xhpYfv+ZT31yBVOx/hjmfuDpWSl0legPgI6N+0=; b=tFLbIoLdUZshS4NmVWVG0rZCkb2Z6byaRYuI9aU4hRiJ5Bze6DMlb38gd7yss0NYg2 HYpuyUE/M7qn64im5eokX0FPJrCerJu9om9pCYnhH/htzszMpvOoDs+Tvnlq6CPOCA+g ZEA4xu5KKYiwMXSwoWdKA2wZeuuz3uIyI4LD1whpLHSzceVFf4XkEU3Tr86BFB5N0CBd 2iwKa/pdk/ELVf8akh2+zGj/rGOuLc0qbErBSks9rpJjiJN6126MrcDdDOUXlmOMU7SA y03mlBdVEnxOTAqSOxKowJj/6SuUSizPRdyz3CNAr2aKJrJLV6O3PSVZjtXI4NncSGJQ F8Tw== 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: , Cc: kernel@collabora.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov As of earlier commit the function is used only within drm core. Cc: Daniel Vetter Signed-off-by: Emil Velikov --- drivers/gpu/drm/drm_ioctl.c | 3 +-- include/drm/drm_ioctl.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 2263e3ddd822..0646c0bd5535 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -523,7 +523,7 @@ int drm_version(struct drm_device *dev, void *data, * Returns: * Zero if allowed, -EACCES otherwise. */ -int drm_ioctl_permit(u32 flags, struct drm_file *file_priv) +static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv) { /* ROOT_ONLY is only for CAP_SYS_ADMIN */ if (unlikely((flags & DRM_ROOT_ONLY) && !capable(CAP_SYS_ADMIN))) @@ -546,7 +546,6 @@ int drm_ioctl_permit(u32 flags, struct drm_file *file_priv) return 0; } -EXPORT_SYMBOL(drm_ioctl_permit); #define DRM_IOCTL_DEF(ioctl, _func, _flags) \ [DRM_IOCTL_NR(ioctl)] = { \ diff --git a/include/drm/drm_ioctl.h b/include/drm/drm_ioctl.h index fafb6f592c4b..f3fba529cb1b 100644 --- a/include/drm/drm_ioctl.h +++ b/include/drm/drm_ioctl.h @@ -163,7 +163,6 @@ struct drm_ioctl_desc { .name = #ioctl \ } -int drm_ioctl_permit(u32 flags, struct drm_file *file_priv); long drm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); long drm_ioctl_kernel(struct file *, drm_ioctl_t, void *, u32); #ifdef CONFIG_COMPAT