From patchwork Wed Sep 26 16:18:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10616163 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 6120346E4 for ; Wed, 26 Sep 2018 16:20:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 535122B435 for ; Wed, 26 Sep 2018 16:20:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 514202B46D; Wed, 26 Sep 2018 16:20:37 +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=BAD_ENC_HEADER,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 50A7F2B435 for ; Wed, 26 Sep 2018 16:20:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43F936E4C2; Wed, 26 Sep 2018 16:19:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::61b]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1322B6E4B7 for ; Wed, 26 Sep 2018 16:19:27 +0000 (UTC) Received: from localhost.localdomain (155.4.205.56) by DM6PR05MB4588.namprd05.prod.outlook.com (2603:10b6:5:9f::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.14; Wed, 26 Sep 2018 16:19:24 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH -next 15/18] drm/vmwgfx: Make buffer object lookups reference-free during validation Date: Wed, 26 Sep 2018 18:18:36 +0200 Message-Id: <20180926161839.4549-15-thellstrom@vmware.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180926161839.4549-1-thellstrom@vmware.com> References: <20180926161839.4549-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: VI1PR0601CA0020.eurprd06.prod.outlook.com (2603:10a6:800:1e::30) To DM6PR05MB4588.namprd05.prod.outlook.com (2603:10b6:5:9f::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 42af9a39-f376-4c47-1b07-08d623cbd357 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:DM6PR05MB4588; X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 3:3F9xrOIvpfu7qDHRztigrRYxvKm6TJNgauHWDU997gr1LiSBBGCr060tqUlpdC7BYcZVk17ZcCG2fZd62lTMMbQcmdLil3JqGJvQsBZwX8BXFU8MTwrYsPkrKHCLJa0Hgu1Vxxk+SkwiIzi6K9rzyoXWgupnjHQS6H8rH1OsWNIGIHgltuodtRJWZfRTqTb6yiz7d/CStEDKb6jMEuaX0ss0tRk3W8RXtguTzmI3UMwjGo19gvnYNdf9KZtyDmXB; 25:rCsOZ0CcVwuVxTVKXUUgfMp8/eCpsCkkKb8f9mOUTulq7kH7y+JfBB0d7YDmgvt1Nja34dLncSpjybQe71QXPXWtBoXZdD8u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aoRg5tKQ0UjFE1IrHaun1+BjaJYXNg3fVj49sZuUTiwJXtkQ4V0bBERBTqyTCayjXHjGMzD0gXgqRCGxzGm/IurnFgDA+4RObS1aNk/HzoxFt2Uf+ddqtE=; 4:Wc4p0w7f5aha7Xq5YJhKK/BgOkoNxeH7trPZfOFVA0o8YrZYQNYEqNDZ+qNWTHvHFiI+9kItv9RNftFzvHgQSE6rB3mk8f0DYJT616QsfK1Y0jzVh1AmSeVV10xjD+/meSNmUskqfgi9DUmD+CJ2E0wr9BCQS0s2tVq+5uDOZh/rP45R07F/tv1kNcu/RDDLPYqQxVsrRwh9O0wwWp0JyR8BixlgNLpnsHCsbVu4OmoS+mGXeQ6nck/5fO/X6+rmul0l4b8+sWRMQk2SsA+KtPuTzVTDhhGaqyIWsjx9zkc7994j9tobrP8fcFJ1GM1N X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3231355)(944501410)(52105095)(3002001)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201708071742011)(7699051)(76991041); SRVR:DM6PR05MB4588; BCL:0; PCL:0; RULEID:; SRVR:DM6PR05MB4588; X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(1496009)(346002)(376002)(366004)(396003)(136003)(39860400002)(199004)(189003)(11346002)(186003)(105586002)(36756003)(47776003)(26005)(66066001)(6512007)(2351001)(305945005)(14444005)(446003)(2361001)(486006)(16526019)(106356001)(7736002)(5660300001)(476003)(6666003)(53936002)(86362001)(6486002)(97736004)(69590400006)(478600001)(68736007)(50466002)(25786009)(8936002)(316002)(16586007)(48376002)(956004)(2616005)(386003)(76176011)(6506007)(3846002)(6916009)(51416003)(1076002)(4326008)(8676002)(81166006)(50226002)(6116002)(107886003)(2906002)(81156014)(52116002)(34290500001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM6PR05MB4588; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM6PR05MB4588; 23:SOlI00hgD1TrCXzSr+aBz6oq3+0U3vWdGfDGwJGKy?= tzg8NCKJosS+ETRFTK+XDd8Zhw4kgIFVclbjXa9M45kT9jipBuee3xwF5U54Xr8+QOoRaZvdHqKGLq7aKlI9n/c18LrLzQ8HlASaYySeXC7Scr7eJw2sO2tgsvXv9JD6VIO1iJogtJZJ4jZl8ZxPzedpZJntjqkfkMZihEYHSIHTlpuWKL/9FzZmLVVpmpLLWkEQTGh5V9GyoiDC+uBvpgKN/SWBopAQ+/Emg9YYiFcZ5DsnPvNx/CA4K6EpYfsnd55t+VNPgKrPcuxTmP0QUDfvRMYuAQQFl6VoqByzKFNcad1OtOPWSy393zxYxgmIuLh6MBPixI8OqNBUvSHgKVgNRSrjyoQgxIEu2bboZcfowClLm+CyqX7H5YNco0inXVtCj84ILHGSeyny235jlZjx10/sUkn3QQFLqdZBab8sbTXNA3koMn0bn5hW+LZLzVyqEN79EVzKg4w77Hsz0LgiGcv9Kyy4CZVDk1IhEkYstvz//F7zQyL1CBUi23gfft/cBFH+DMwIiDZOJxymW/Gd0nHH/ol4nmQ/ESvKMrLbvbOzbl+BJ5Evqd6pkMBW/4RTltinDAPIoLCdNNXYV5X5RPpi40ytlKuVleuWKpzFxSlpFs7oWSER4/I475E6/cAD1D38BtXSmc9qgL6bYfUoW/exQ0ajFzFz+Y9OzAaH6uGD/60mHU1BeNUqkfmGihpoO8jHOSpQDLoax0jwV7j7bOeNHo0EcmGQeP5YLeFsgTZFnURd4QEkihN4jMKl8rhq4NHxToP66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-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:19:24.2172 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 42af9a39-f376-4c47-1b07-08d623cbd357 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR05MB4588 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 , linux-graphics-maintainer@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make the process of looking up a buffer object and adding it to the validation list reference-free unless when it's actually added to the validation list where a single reference is taken. This saves two locked atomic operations per command stream buffer object handle lookup. Signed-off-by: Thomas Hellstrom Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 85 ++++++++++++--------------------- 1 file changed, 30 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 641b75110dc6..15e83b39e26d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -1137,7 +1137,7 @@ static void vmw_query_bo_switch_commit(struct vmw_private *dev_priv, * @sw_context: The software context used for this command batch validation. * @id: Pointer to the user-space handle to be translated. * @vmw_bo_p: Points to a location that, on successful return will carry - * a reference-counted pointer to the DMA buffer identified by the + * a non-reference-counted pointer to the buffer object identified by the * user-space handle in @id. * * This function saves information needed to translate a user-space buffer @@ -1152,38 +1152,34 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, SVGAMobId *id, struct vmw_buffer_object **vmw_bo_p) { - struct vmw_buffer_object *vmw_bo = NULL; + struct vmw_buffer_object *vmw_bo; uint32_t handle = *id; struct vmw_relocation *reloc; int ret; - ret = vmw_user_bo_lookup(sw_context->fp->tfile, handle, &vmw_bo, NULL); - if (unlikely(ret != 0)) { + vmw_validation_preload_bo(sw_context->ctx); + vmw_bo = vmw_user_bo_noref_lookup(sw_context->fp->tfile, handle); + if (IS_ERR(vmw_bo)) { DRM_ERROR("Could not find or use MOB buffer.\n"); - ret = -EINVAL; - goto out_no_reloc; + return PTR_ERR(vmw_bo); } + ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, true, false); + vmw_user_bo_noref_release(); + if (unlikely(ret != 0)) + return ret; + reloc = vmw_validation_mem_alloc(sw_context->ctx, sizeof(*reloc)); if (!reloc) - goto out_no_reloc; + return -ENOMEM; reloc->mob_loc = id; reloc->vbo = vmw_bo; - ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, true, false); - if (unlikely(ret != 0)) - goto out_no_reloc; - *vmw_bo_p = vmw_bo; list_add_tail(&reloc->head, &sw_context->bo_relocations); return 0; - -out_no_reloc: - vmw_bo_unreference(&vmw_bo); - *vmw_bo_p = NULL; - return ret; } /** @@ -1194,7 +1190,7 @@ static int vmw_translate_mob_ptr(struct vmw_private *dev_priv, * @sw_context: The software context used for this command batch validation. * @ptr: Pointer to the user-space handle to be translated. * @vmw_bo_p: Points to a location that, on successful return will carry - * a reference-counted pointer to the DMA buffer identified by the + * a non-reference-counted pointer to the DMA buffer identified by the * user-space handle in @id. * * This function saves information needed to translate a user-space buffer @@ -1210,38 +1206,33 @@ static int vmw_translate_guest_ptr(struct vmw_private *dev_priv, SVGAGuestPtr *ptr, struct vmw_buffer_object **vmw_bo_p) { - struct vmw_buffer_object *vmw_bo = NULL; + struct vmw_buffer_object *vmw_bo; uint32_t handle = ptr->gmrId; struct vmw_relocation *reloc; int ret; - ret = vmw_user_bo_lookup(sw_context->fp->tfile, handle, &vmw_bo, NULL); - if (unlikely(ret != 0)) { + vmw_validation_preload_bo(sw_context->ctx); + vmw_bo = vmw_user_bo_noref_lookup(sw_context->fp->tfile, handle); + if (IS_ERR(vmw_bo)) { DRM_ERROR("Could not find or use GMR region.\n"); - ret = -EINVAL; - goto out_no_reloc; + return PTR_ERR(vmw_bo); } + ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, false, false); + vmw_user_bo_noref_release(); + if (unlikely(ret != 0)) + return ret; + reloc = vmw_validation_mem_alloc(sw_context->ctx, sizeof(*reloc)); if (!reloc) - goto out_no_reloc; + return -ENOMEM; reloc->location = ptr; reloc->vbo = vmw_bo; - - ret = vmw_validation_add_bo(sw_context->ctx, vmw_bo, false, false); - if (unlikely(ret != 0)) - goto out_no_reloc; - *vmw_bo_p = vmw_bo; list_add_tail(&reloc->head, &sw_context->bo_relocations); return 0; - -out_no_reloc: - vmw_bo_unreference(&vmw_bo); - *vmw_bo_p = NULL; - return ret; } @@ -1328,10 +1319,7 @@ static int vmw_cmd_dx_bind_query(struct vmw_private *dev_priv, sw_context->dx_query_mob = vmw_bo; sw_context->dx_query_ctx = sw_context->dx_ctx_node->ctx; - - vmw_bo_unreference(&vmw_bo); - - return ret; + return 0; } @@ -1432,7 +1420,6 @@ static int vmw_cmd_end_gb_query(struct vmw_private *dev_priv, ret = vmw_query_bo_switch_prepare(dev_priv, vmw_bo, sw_context); - vmw_bo_unreference(&vmw_bo); return ret; } @@ -1486,7 +1473,6 @@ static int vmw_cmd_end_query(struct vmw_private *dev_priv, ret = vmw_query_bo_switch_prepare(dev_priv, vmw_bo, sw_context); - vmw_bo_unreference(&vmw_bo); return ret; } @@ -1519,7 +1505,6 @@ static int vmw_cmd_wait_gb_query(struct vmw_private *dev_priv, if (unlikely(ret != 0)) return ret; - vmw_bo_unreference(&vmw_bo); return 0; } @@ -1571,7 +1556,6 @@ static int vmw_cmd_wait_query(struct vmw_private *dev_priv, if (unlikely(ret != 0)) return ret; - vmw_bo_unreference(&vmw_bo); return 0; } @@ -1622,7 +1606,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv, if (unlikely(ret != 0)) { if (unlikely(ret != -ERESTARTSYS)) DRM_ERROR("could not find surface for DMA.\n"); - goto out_no_surface; + return ret; } srf = vmw_res_to_srf(sw_context->res_cache[vmw_res_surface].res); @@ -1630,9 +1614,7 @@ static int vmw_cmd_dma(struct vmw_private *dev_priv, vmw_kms_cursor_snoop(srf, sw_context->fp->tfile, &vmw_bo->base, header); -out_no_surface: - vmw_bo_unreference(&vmw_bo); - return ret; + return 0; } static int vmw_cmd_draw(struct vmw_private *dev_priv, @@ -1763,14 +1745,9 @@ static int vmw_cmd_check_define_gmrfb(struct vmw_private *dev_priv, SVGAFifoCmdDefineGMRFB body; } *cmd = buf; - ret = vmw_translate_guest_ptr(dev_priv, sw_context, - &cmd->body.ptr, - &vmw_bo); - if (unlikely(ret != 0)) - return ret; - - vmw_bo_unreference(&vmw_bo); - + return vmw_translate_guest_ptr(dev_priv, sw_context, + &cmd->body.ptr, + &vmw_bo); return ret; } @@ -1810,8 +1787,6 @@ static int vmw_cmd_res_switch_backup(struct vmw_private *dev_priv, vmw_validation_res_switch_backup(sw_context->ctx, info, vbo, backup_offset); - vmw_bo_unreference(&vbo); - return 0; }