From patchwork Wed Sep 26 16:18:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10616157 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 C90FC175A 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 BCA2B2B3D2 for ; Wed, 26 Sep 2018 16:20:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB5652B42C; 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 A11352B3D2 for ; Wed, 26 Sep 2018 16:20:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 223956E4BB; Wed, 26 Sep 2018 16:19:46 +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 AE2746E4B8 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:25 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH -next 16/18] drm/vmwgfx: Don't refcount command-buffer managed resource lookups during command buffer validation Date: Wed, 26 Sep 2018 18:18:37 +0200 Message-Id: <20180926161839.4549-16-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: 6d39ab80-0830-414d-0121-08d623cbd412 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:3irfCVuq1GtjRJXx7mVlDwxNzK14TqVs5gIX1yedSkVVQmLg3UXepqJ5BYGfXk4Qt6qErgKp07RRxjRMighS8E6M/YV5m63lLCD115TATobD2JM1rLLKMdbPk/FPGfcQGvbsNfhNog1QLdlKPLbJznIExEgrSVOzwIiGv1VFXFxuz2BCOhP2T8tnZkqQoLxEM5BYpl84x8LV49y0JvMqwN2B6AMF2HlgI6KrZpYy/Q/dUTB5C5QQ34djcOXLU079; 25:gi8ry8oSSc+QYr5IqXPjKuywJ4ssrcUeeLDXkbZPm7Vfay3N+qBw0Md3iqY/lJ3WeXeufGXajp/xpOmm88kAhnMXV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9eKqPMr+HUAjXJPJ2YAihfTvioNKYFgnuHpidcYcUh/HSyLC3v0cYGkFpl/Co5SMzLY6JDJInm2Y3MhoKOwrKyZM6E2SLt3XI0fZrA6gsvD+zG74Stw=; 4:/3piIHWgFPnYgxw3Fr+0prBRPy6SDW1l46BEdY22h8xIfuYxOIgXdvRj21v8LGBEWK18SDi7hteMMZjAZWoHAbgPsojoa+i0FmtCnrtCGsqGixCzs9WFwTfZDg5G6Cx80xcLJwiLs8OV/QnMbDU1iTw/jkvswvnDKBr7D72IyUETPUQnV6Y1kJnnfymCW3K++eNeTJ5WccDphcrFdP9jbm/cdlDczrjmJktKcSDFf2qfqjxnY3uikzS/QUeo/oMmeDxE7Tl7Wx26hLG3UVfX2hQEiwrNjAIGFjwhExJCOrzX0HsgOydJIS/ofwTQ7+oH 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)(19627235002)(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:5FO7cZ+M6L3+ppE7vb9z1BkV8s0kn2ykSClswDrwL?= EGx+lwKsxbQJEa0QGKR12mV43j3J8/gPikLa/fmSUxdwPz8WL5sdXhoO/i+5cqOjcWweEt4tlGDx2Wes4Q/zxwwb/cX0GXNpuAa+pap4knuud46pEQ39c6V3Tr+zlWlplFEPUCeBjvE6yWDMtgoAgLlYvowmjWwQLsQXsibNiy9upOfH4q8bJgCYrspfCsdqJ/7iZMJMGOKnuvdh7zgQTEo4CI33ajjdoIucw5GPaf5pXBqwEZApFE2Udgp+NHIpxSql2owVZLN225SefN0FKyFYek81tULUP3v6AGy7r3UK6yMYLDyaTAPogk6g8IUCVaSuR86al0qQcEdwBAZkUtN+vgsDA9YLUkbYMVRsjOVGoQh2p2z8E01Wu+pKJjhNYleRPwnHeSpq50ElVmxOqgvsstZ6mUdUci0tO+Bpundb9oOJMhCLiRlZq43MFztHIP0qjJUx7fJILeyc3diKXXQV+m6DLdUjA34MqdA6UQKdlUn0vQS/RvfmtTIJrxlMJAUd83G5AJBLxLvm1fmbXRTT/l0+qM0/7wZDQqQ5jHgmooIzrJFM2vlrbLUba/3nQ7lFOtYv7b+UEDMCi2A0EswICjMfFjxbTSNYwDlVyA2PcdSa6I6FcODHmYi6tjJKSabd0nbp0BB05ByWv6r7eXTSDJL8YtigwnsHTmhw7oytqoP+klytRnZL6GHUbUN6iOOmkVGwLsT4V1SY9VNqGLydZXs1/3bIlHvfaItoN2W5kSZ/MRDF7em3VW4ZvMCciRQjgEu4r6fvfDSnlTGN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vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:19:25.4380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6d39ab80-0830-414d-0121-08d623cbd412 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. Signed-off-by: Thomas Hellstrom Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 3 +- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 69 +++++++++++------------------- 2 files changed, 27 insertions(+), 45 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c index 3b75af9bf85f..4ac55fc2bf97 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c @@ -89,8 +89,7 @@ vmw_cmdbuf_res_lookup(struct vmw_cmdbuf_res_manager *man, if (unlikely(ret != 0)) return ERR_PTR(ret); - return vmw_resource_reference - (drm_hash_entry(hash, struct vmw_cmdbuf_res, hash)->res); + return drm_hash_entry(hash, struct vmw_cmdbuf_res, hash)->res; } /** diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 15e83b39e26d..13db7efcb89c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c @@ -314,10 +314,14 @@ static int vmw_view_res_val_add(struct vmw_sw_context *sw_context, * * The view is represented by a view id and the DX context it's created on, * or scheduled for creation on. If there is no DX context set, the function - * will return -EINVAL. Otherwise returns 0 on success and -EINVAL on failure. + * will return an -EINVAL error pointer. + * + * Returns: Unreferenced pointer to the resource on success, negative error + * pointer on failure. */ -static int vmw_view_id_val_add(struct vmw_sw_context *sw_context, - enum vmw_view_type view_type, u32 id) +static struct vmw_resource * +vmw_view_id_val_add(struct vmw_sw_context *sw_context, + enum vmw_view_type view_type, u32 id) { struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; struct vmw_resource *view; @@ -325,17 +329,18 @@ static int vmw_view_id_val_add(struct vmw_sw_context *sw_context, if (!ctx_node) { DRM_ERROR("DX Context not set.\n"); - return -EINVAL; + return ERR_PTR(-EINVAL); } view = vmw_view_lookup(sw_context->man, view_type, id); if (IS_ERR(view)) - return PTR_ERR(view); + return view; ret = vmw_view_res_val_add(sw_context, view); - vmw_resource_unreference(&view); + if (ret) + return ERR_PTR(ret); - return ret; + return view; } /** @@ -740,34 +745,24 @@ static int vmw_view_bindings_add(struct vmw_sw_context *sw_context, u32 first_slot) { struct vmw_ctx_validation_info *ctx_node = sw_context->dx_ctx_node; - struct vmw_cmdbuf_res_manager *man; u32 i; - int ret; if (!ctx_node) { DRM_ERROR("DX Context not set.\n"); return -EINVAL; } - man = sw_context->man; for (i = 0; i < num_views; ++i) { struct vmw_ctx_bindinfo_view binding; struct vmw_resource *view = NULL; if (view_ids[i] != SVGA3D_INVALID_ID) { - view = vmw_view_lookup(man, view_type, view_ids[i]); + view = vmw_view_id_val_add(sw_context, view_type, + view_ids[i]); if (IS_ERR(view)) { DRM_ERROR("View not found.\n"); return PTR_ERR(view); } - - ret = vmw_view_res_val_add(sw_context, view); - if (ret) { - DRM_ERROR("Could not add view to " - "validation list.\n"); - vmw_resource_unreference(&view); - return ret; - } } binding.bi.ctx = ctx_node->ctx; binding.bi.res = view; @@ -776,8 +771,6 @@ static int vmw_view_bindings_add(struct vmw_sw_context *sw_context, binding.slot = first_slot + i; vmw_binding_add(ctx_node->staged, &binding.bi, shader_slot, binding.slot); - if (view) - vmw_resource_unreference(&view); } return 0; @@ -2136,11 +2129,8 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv, cmd->body.type); if (!IS_ERR(res)) { - struct vmw_resource *tmp_res = res; - ret = vmw_cmd_res_reloc_add(dev_priv, sw_context, &cmd->body.shid, res); - vmw_resource_unreference(&tmp_res); if (unlikely(ret != 0)) return ret; } @@ -2359,7 +2349,7 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv, ret = vmw_resource_val_add(sw_context, res); if (ret) - goto out_unref; + return ret; } binding.bi.ctx = ctx_node->ctx; @@ -2369,11 +2359,8 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv, vmw_binding_add(ctx_node->staged, &binding.bi, binding.shader_slot, 0); -out_unref: - if (res) - vmw_resource_unreference(&res); - return ret; + return 0; } /** @@ -2530,8 +2517,8 @@ static int vmw_cmd_dx_clear_rendertarget_view(struct vmw_private *dev_priv, SVGA3dCmdDXClearRenderTargetView body; } *cmd = container_of(header, typeof(*cmd), header); - return vmw_view_id_val_add(sw_context, vmw_view_rt, - cmd->body.renderTargetViewId); + return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_rt, + cmd->body.renderTargetViewId)); } /** @@ -2551,8 +2538,8 @@ static int vmw_cmd_dx_clear_depthstencil_view(struct vmw_private *dev_priv, SVGA3dCmdDXClearDepthStencilView body; } *cmd = container_of(header, typeof(*cmd), header); - return vmw_view_id_val_add(sw_context, vmw_view_ds, - cmd->body.depthStencilViewId); + return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_ds, + cmd->body.depthStencilViewId)); } static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, @@ -2904,17 +2891,13 @@ static int vmw_cmd_dx_bind_shader(struct vmw_private *dev_priv, ret = vmw_resource_val_add(sw_context, res); if (ret) { DRM_ERROR("Error creating resource validation node.\n"); - goto out_unref; + return ret; } - ret = vmw_cmd_res_switch_backup(dev_priv, sw_context, res, - &cmd->body.mobid, - cmd->body.offsetInBytes); -out_unref: - vmw_resource_unreference(&res); - - return ret; + return vmw_cmd_res_switch_backup(dev_priv, sw_context, res, + &cmd->body.mobid, + cmd->body.offsetInBytes); } /** @@ -2933,8 +2916,8 @@ static int vmw_cmd_dx_genmips(struct vmw_private *dev_priv, SVGA3dCmdDXGenMips body; } *cmd = container_of(header, typeof(*cmd), header); - return vmw_view_id_val_add(sw_context, vmw_view_sr, - cmd->body.shaderResourceViewId); + return PTR_RET(vmw_view_id_val_add(sw_context, vmw_view_sr, + cmd->body.shaderResourceViewId)); } /**