From patchwork Wed Sep 26 16:18:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10616161 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 53F27913 for ; Wed, 26 Sep 2018 16:20:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44A312B3D5 for ; Wed, 26 Sep 2018 16:20:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42CC62B401; Wed, 26 Sep 2018 16:20:36 +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 B19812B3D5 for ; Wed, 26 Sep 2018 16:20:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9CAD36E4B9; Wed, 26 Sep 2018 16:19:45 +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-dm3nam03on061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe49::61e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87DD56E4B7 for ; Wed, 26 Sep 2018 16:19:29 +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:26 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH -next 17/18] drm/vmwgfx: Don't refcount cotable lookups during command buffer validation Date: Wed, 26 Sep 2018 18:18:38 +0200 Message-Id: <20180926161839.4549-17-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: 8ca5c550-e7d0-47f5-5c5e-08d623cbd4cd 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:xkXINTgSkSfMt8BVuUQkgEKO8NC8dQlq/KesFAunCcYEnlgJVudtlRDamUNf1GskN2Kfb5lAeZMVShg+6rSKp9+ZHic/9i3o2rvUZeVuWWpIC0AXHvrBOo0kvvgOkE9YtX+hvA4s/yH1XhFAYVChWt9MkekpH3EL7Qd8aGfobHHCO3khT5il2hPddUpoWgMvVMYLyfZTBppqbSldekfK7OHIlCZNXMr7gzTNHP8PO6BgvcwGBo7KYSXorQSfBJLz; 25:JXR/gVRBDtqGuOV++gSus308xq/FLXC9HECslxQpPlEizrwWpl4n/8AyEjOJvbP1RnMF3iRCNOmxvg1/kJHkwfqTy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HxQaLi7lR1S5HWEdHutZZCv0MEMIkesfVempj36txPnw+5GGazJr2aLw5Gk1YJuKU80wFeAGZUXLveFn8egsGlehKeRi+e0p2s/5Jjk+YIQKB9BtAM=; 4:LpGkI7rfaMf3JVzgwecDVuw17fwjmYZGBevyomcsLw/y14eE/sQvdH0MrW7cYlsixFYlkYhvCVhFnFrNfJstlb8/iRh387iY4AoAUtarfeeiREjopGhQeUcGT4gAq2hgf1mWbltz7XKtkmhDiH9AouMJjl+N5a8NQEsyov/tH91auccN4oySpKmPInqRE4UISda6UU1f9Ig2fjofl73TfSHyNzuxd6NsXhGtbqb2djdbYbfqNWNMHFQGoKzzRSy3zJG005LuXzelKq13OYslxQCQHkFYirdYdfPUYr2Xu4Olx+ehhYbBlPdLcfyljy0B 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:rGiSjYU2sqZJWZvEmoaPnM7n519rpytBgWjGaoWZQ?= M1ix0PK8/fj/d1U//rwLRkTiq3FU9zL0kwDDMKnldHHk3Aga6hgZlr+CCobbkw4UfPVd+gTCpp99y0tRXtDugCljCMChqSJu8pM2bys8Nwp6R4a2u3Ewo78T/T5v/U1PftPwYJCxUJK9QuZxBq2K5fKHCs74M55MiycuN0o460Pc6FHp72ZfV1/D4Bw6GNAEKwLpFB5wODgzg4eE9Ofz/KnXyWyi459u36XbaqKHPxQKIW+yMkeZPOtYbOM253L1na1WrKA15kmyCusNZvARJTP3yQaSEefoStyZff/APkfqSZuf61yP4nHliHTgIVAGanAQQk6uhea93Nn1CJm5FLSFWfWRAqLdn/lnKHZxuOWwKkC7W7u6IApPmA02+UslFEAOl+N3yI9ZBnKba61jJ450M7fAAjlhR3BzHjaqen3GvQXo2LseZgax9SKFWpvTeV8HFyZ3HYnOONVgcjAzkztPKHV5sANH1LDkjuE+7/xkTAZlS4njKZoHsG/8kICxyKRFbjwW/QS+N5wEbfYoZSTZXymtCZVru5ytpmsk4R9kFhir7W1EcAKEoff5NvC0bVr3+fNyI3nDaFvYxyMVDuvNDnzaB8miguhvYL3Ih4YoeEONoOpVtdNMxafi6dWA76ERB4GafVNr22kBaA4fEfYN1th6xvvUxzu/XdScIfOjs+WwYXFsB7TmW5E7sDTLeZ+XY0cycI93VCHR0gl6BuU6eM+MEaezLmMIjG3GJkWzU+4bzretDJYAh1luc6vXHXxfpEevSOubCSeiwVRsOz5J7X6FzKYmrHnmI7Bdxw/gvlxlmtzEZOMS2X5fI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onRnRKMnUsJSlzsF3eMLjkEC2asq0urodYnB1hoW7kHSHRlIFa2dGNqJzAqEnvAa5CVAvM+1SCBNNB9s9UxOLs53ZiQaQlFxd5emoaRcH519qnGRdFBCur7O7prY+eeXWwpDUl/QxkAyVrwuEZW8pErlGemj8qbFXrFBzitGkPKh+MiIKjT4IMaEKZKEPc7zICblyahdK8TVqF2QkiV29E5lgeo8xNLZzt/LUNXQC+AMqurmp7wAtayR+oLc6/7rNbs+o90YWDeKhhspaWeMIEU5isSM6I8JYAFK3edMM1gsq9ACh0Nt6KX65AmH9vBCdxVjqg==; 5:WtmG/30A3f5MgFdQtUljj7bccRMiVkqfCQX98IkSWNZJkZ/gsRonI6XMy175p6gc2lUSq/ySCdKoiNk8LT8rY5DQFREmTMmH9Aov0sOOU6gZtxOTzUfxvpqWDDhVCat3AtoBtghem3ueWqWCVcH2mNIQmp9CUzawOJr4tHmHsnA=; 7:YQcRgKzOjvwXH4CjrNPnVR2qrgD0GPOfgzRk8fYEBI1NDqlEHb6o/p91oWxvgT5rMXYPcOxbNooYEjSrkOr/2v1QXMPKLu2M+0B9F8XnGSi0B75EtoNOAhX24tYbmd9vbl7eVIkb4WikQPQL8U3ZSZZK+QufsBvKZkv5NODrbcSPYk5FbUboQs02akO9P/dd27gqWwIt2kR61cp7+wKq5A+XXXuIRAdVZRo29rmSgHVT9RzJNMn9SbU2VJYjMaB6 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 20:eljM9mJfmIIroskpIdObGpWWIt+0Er5/YBEDqG2Fw1Sex7UiKzk8EGvITMpb1+L/N6CrSUTsUru/yFO7Uy7GBIAXg3lMUpPRIFp7o5BLQrH+7f5q3NWuCdeQMr6QwOPxZzgSDXYbNRZuYUKZEYLwWfe4jqbFu9Xp0jeBibDXZdc= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:19:26.6709 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ca5c550-e7d0-47f5-5c5e-08d623cbd4cd 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 The typical pattern of these lookups are -Lookup -Put on validate list if not already there. -Unreference And since we are the exclusive user of the context during lookup time, we can be sure that the resource will stay alive during the sequence. So avoid taking a reference during lookup, and also avoid unreferencing when done. There are two users outside of command buffer validation and those are refcounted explicitly. Signed-off-by: Thomas Hellstrom Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 5 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 5 ----- drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 3 ++- drivers/gpu/drm/vmwgfx/vmwgfx_so.c | 3 ++- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c index 24d7c81081ae..14bd760a62fd 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c @@ -861,9 +861,8 @@ struct vmw_resource *vmw_context_cotable(struct vmw_resource *ctx, if (cotable_type >= SVGA_COTABLE_DX10_MAX) return ERR_PTR(-EINVAL); - return vmw_resource_reference - (container_of(ctx, struct vmw_user_context, res)-> - cotables[cotable_type]); + return container_of(ctx, struct vmw_user_context, res)-> + cotables[cotable_type]; } /** diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 13db7efcb89c..dfa2d19274d5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -372,7 +372,6 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv, continue; ret = vmw_resource_val_add(sw_context, res); - vmw_resource_unreference(&res); if (unlikely(ret != 0)) return ret; } @@ -1266,7 +1265,6 @@ static int vmw_cmd_dx_define_query(struct vmw_private *dev_priv, cotable_res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXQUERY); ret = vmw_cotable_notify(cotable_res, cmd->q.queryId); - vmw_resource_unreference(&cotable_res); return ret; } @@ -2578,7 +2576,6 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, res = vmw_context_cotable(ctx_node->ctx, vmw_view_cotables[view_type]); ret = vmw_cotable_notify(res, cmd->defined_id); - vmw_resource_unreference(&res); if (unlikely(ret != 0)) return ret; @@ -2675,7 +2672,6 @@ static int vmw_cmd_dx_so_define(struct vmw_private *dev_priv, res = vmw_context_cotable(ctx_node->ctx, vmw_so_cotables[so_type]); cmd = container_of(header, typeof(*cmd), header); ret = vmw_cotable_notify(res, cmd->defined_id); - vmw_resource_unreference(&res); return ret; } @@ -2806,7 +2802,6 @@ static int vmw_cmd_dx_define_shader(struct vmw_private *dev_priv, res = vmw_context_cotable(ctx_node->ctx, SVGA_COTABLE_DXSHADER); ret = vmw_cotable_notify(res, cmd->body.shaderId); - vmw_resource_unreference(&res); if (ret) return ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c index 6915c8258e6b..bf32fe446219 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c @@ -636,7 +636,8 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man, res = &shader->res; shader->ctx = ctx; - shader->cotable = vmw_context_cotable(ctx, SVGA_COTABLE_DXSHADER); + shader->cotable = vmw_resource_reference + (vmw_context_cotable(ctx, SVGA_COTABLE_DXSHADER)); shader->id = user_key; shader->committed = false; INIT_LIST_HEAD(&shader->cotable_head); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c index aaabb87ac3af..bc8bb690f1ea 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c @@ -366,7 +366,8 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man, res = &view->res; view->ctx = ctx; view->srf = vmw_resource_reference(srf); - view->cotable = vmw_context_cotable(ctx, vmw_view_cotables[view_type]); + view->cotable = vmw_resource_reference + (vmw_context_cotable(ctx, vmw_view_cotables[view_type])); view->view_type = view_type; view->view_id = user_key; view->cmd_size = cmd_size;