From patchwork Wed Sep 26 16:18:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10616143 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 F163014BD for ; Wed, 26 Sep 2018 16:19:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4FBC2B3D2 for ; Wed, 26 Sep 2018 16:19:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8E632B3D9; Wed, 26 Sep 2018 16:19:30 +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 029DB2B3D2 for ; Wed, 26 Sep 2018 16:19:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1803B6E4A3; Wed, 26 Sep 2018 16:19:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-bn3nam04on0621.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4e::621]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8A8BB6E499 for ; Wed, 26 Sep 2018 16:19:12 +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:09 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH -next 04/18] drm/vmwgfx: Use new validation interface for the modesetting code v2 Date: Wed, 26 Sep 2018 18:18:25 +0200 Message-Id: <20180926161839.4549-4-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: ca31f883-cf3a-46c7-5a99-08d623cbca52 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:19b81oT9g8FaB4givx3GcryF2eaQQD2QcZMJ8KwTY49efHTAYawy5yuHDeWL+duEZSigEnM3VFMcwhdI4p8u0Y2BUytdI05EoIbEXyYbO/1biBsUMukKv+xoMoD9gvjV913LEmRxAyJWn/YR/Qhc5kRJWTseHtFaiN/W+uWkHTVnhaaBSmNdqhbjVbdAj2d5v7FINukWOJZ0qsawdS4YORr/5YZLcnemDgnCc+hAsWh3ROy0uG/vsX6d9HI6WGre; 25:+sj22RGQeNfTropOyKROxlsXo/TKmBwTX3U0ZzVXErPGnKr9eUk3KvWR0j+VosB2DwAt1ALwaTSa3UQJEkmiBHlz1lhYCD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nfkmLIekTQfaY61DD24/jVeUxpakq3m//AnuD58KmEz3JCu5Y7MpUpfdWvdlWJk+wy1cXXTUQFNQrXujUYqhCkawL0p4Q5GRwEoh1fEjH7wle/u2s=; 4:+Ru0vLs5j1/VIyalR3B/BHUZ2jBteN09/zbzN6oLaHI5EdbDVhwMqcblN+ZTarGzGtjm2cNFgbMxp3OC+4aKybnJOgiaLMh/49l4TABmMWLeGRMLLQQw6nJhDQpbiZ1/OjpIJZ8AFEZT2+7JKGYk2xXtMXs0QW1yNQ9dxYtV+zSDOu24lgySOyaLbvh2Re4BnIXfMVOQVQniCLHu22UFIc/t/HqDJa8AgZ4zg6FtKWezM1+CGANpr2kixiY1a+zsLav7ej8BFSlrjoSTR1UTmyAUUglVqppmw/ls1Xua4sfWoF4xum4IQrur0wvTqILh 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)(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)(575784001)(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:KBJOTeVgaxsYsKy77ONNgIytPwApMhIo7HromEHqS?= xk92UJwmxvIKB5pVwqlb2XaMn+rtAlsJ+W7/yK4d3DEGvFAdYw7nItMPY2Ha5kyFJyene3Lmiu3rG1eknjFVHWM9bsjHDmdAcUJxSPNv+pDdpnY6iE3Ue90lULiYcbXpZkZGNI2zFuDyPpzQfdy3QInISvcdObSuN9563+vJW+rirO1XNwHGHSXQn5cTZEFdecF6m33Gf4Zfw9EOTy+vmenZX5QHJ1dQbO+wHnicsLFUirqERmooZsq2JuSenkcn08Q5W+FHHcLBTNcfd7tACIpAfzVMloD299sqcgvKYYZJt+Faj4dVhdyA/smsVz7FWHn7t8OEdWXYtqOzX5RlozdolWBP0t6J++z5ulgeoYHD5oHAw695GgSgC6r6eXOgrvmXTJ7s+4Utho587GqCvUEpYNzRp4z2dVayk0IJaQKjPDJl9Ao8vEafFcyJodQxykFHxdzqMklsDn7o0VP3UAYFIX7w6BDTOPHEyJ8R/VYHmaF+oapi2DKNZ7jCCH2Ofoz0ZVg4Jhzqoydc5mH4/rk2JZ/iJEAnlr+gYkFAkQCuOgk71WTxvILt2/SOOSVmXJLudEzcdaGJWU6lyyLsnZPra7FxKY4AXATschCgL5nPypd7rUaXxyLCEXeAO9H8ROmDt6D4Hn63pYyjiOY2kwIv68oA64V87p34irUYEdvsanCHRe/HFYIuvcw8ugJmd1CsNl9FpS1UCC4aBPDSWtL9anrSVtqqbxEPx3bY9caWXpmOV7w/M10FtN1X8PiiETy86yx36Gga6pWynccKH4P5loG5sYTq873zse9dZ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WrOJtZwkyHWNmnHud4PNhPlGUdcoLmgsng1XbPfezSJZyDSWBN5m8BdbdwDZlW8WecL0QkusHdp92LtXPeV6TMiL2m7k1l2803ySL26c1KV6Y4mWw/T2barHyFUrwGZr6sb1DrTkhStVJ8lsRo/UrYN3V0Pc/Z4yvu1oZ2HRy7kYDAs28LgqnZUAWiVr3sxj97mUBsQpyqIrsxurKdrxpC367p1LhqdBU3Qw0E9BD0Km7/qXSWKtNUPkNaJldjlTzEtUwpjbyKbVoqNLiT9WEgnEwUDyQvP2Gll/xWzFIyXvXDjirzS8j93pZt/qWwUIRbwLUnNBoaQ==; 5:KtwHdYuNPHP3p18ds08uuzZh2b/D8cBYmVk6hCr64zpzw8vpLDVUAahQLQSZiRuQyEKrCwYa5PAZroT6k9MSFQj8IzQtU08Nc9SS0BuWbqE0XchbYV4/LGRlg+Ojy6hjyVXm8Y/+IpUtTMsazngjLiPBSnftLrguKMSrnqiycnw=; 7:QcFbdDsCyX0uiTGmjcyyAoBVPy5nYGl+nZTAKxDqH4L4hVhzuGlvhI+aiYgOMr7q7E5iHyPbpMblua/CPZQ+x+Clmyi6dtdo6zqtDoupMb4QgtQinRfCuD+ubjgApjUpXnkUN04aReb5j+PjcRpyS2sq7+oMv47wbMDUfwmSPAlYJKYf1ej+2zxdGqRiUdw+JA2jWn3Tr/gRIVWxnVBtqZIp02i/vsJ5EF5xawz4Gy1uUjJIVh/DLdlFFylrtdeu SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM6PR05MB4588; 20:8/OiSwwydf7wmuuC/pF/F+ZdOCFES9lZkTmEM82zHld4FW5Pg8ClKKjIUAc/ZeTyOV5Wl1YEXrfDEUY0QqJdRA+6oU+/S6k5hlFw6JvXS4INCLo5agOAr5kAsGQR3LbIqLHqPcmuhFNFSvTnLP54sPHIuCIzmAp+LNF46f048+I= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 16:19:09.0886 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ca31f883-cf3a-46c7-5a99-08d623cbca52 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 Strip the old KMS helpers and use the new validation interface also in the modesetting code. Signed-off-by: Thomas Hellstrom Reviewed-by: Deepak Rawat #v1 Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 199 ++++------------------------------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 24 ++--- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 48 ++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 31 ++++-- 4 files changed, 86 insertions(+), 216 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index ab424358b8cb..05fb16733c5c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2557,88 +2557,31 @@ int vmw_kms_helper_dirty(struct vmw_private *dev_priv, } /** - * vmw_kms_helper_buffer_prepare - Reserve and validate a buffer object before - * command submission. - * - * @dev_priv. Pointer to a device private structure. - * @buf: The buffer object - * @interruptible: Whether to perform waits as interruptible. - * @validate_as_mob: Whether the buffer should be validated as a MOB. If false, - * The buffer will be validated as a GMR. Already pinned buffers will not be - * validated. - * - * Returns 0 on success, negative error code on failure, -ERESTARTSYS if - * interrupted by a signal. + * vmw_kms_helper_validation_finish - Helper for post KMS command submission + * cleanup and fencing + * @dev_priv: Pointer to the device-private struct + * @file_priv: Pointer identifying the client when user-space fencing is used + * @ctx: Pointer to the validation context + * @out_fence: If non-NULL, returned refcounted fence-pointer + * @user_fence_rep: If non-NULL, pointer to user-space address area + * in which to copy user-space fence info */ -int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv, - struct vmw_buffer_object *buf, - bool interruptible, - bool validate_as_mob, - bool for_cpu_blit) -{ - struct ttm_operation_ctx ctx = { - .interruptible = interruptible, - .no_wait_gpu = false}; - struct ttm_buffer_object *bo = &buf->base; - int ret; - - ttm_bo_reserve(bo, false, false, NULL); - if (for_cpu_blit) - ret = ttm_bo_validate(bo, &vmw_nonfixed_placement, &ctx); - else - ret = vmw_validation_bo_validate_single(bo, interruptible, - validate_as_mob); - if (ret) - ttm_bo_unreserve(bo); - - return ret; -} - -/** - * vmw_kms_helper_buffer_revert - Undo the actions of - * vmw_kms_helper_buffer_prepare. - * - * @res: Pointer to the buffer object. - * - * Helper to be used if an error forces the caller to undo the actions of - * vmw_kms_helper_buffer_prepare. - */ -void vmw_kms_helper_buffer_revert(struct vmw_buffer_object *buf) -{ - if (buf) - ttm_bo_unreserve(&buf->base); -} - -/** - * vmw_kms_helper_buffer_finish - Unreserve and fence a buffer object after - * kms command submission. - * - * @dev_priv: Pointer to a device private structure. - * @file_priv: Pointer to a struct drm_file representing the caller's - * connection. Must be set to NULL if @user_fence_rep is NULL, and conversely - * if non-NULL, @user_fence_rep must be non-NULL. - * @buf: The buffer object. - * @out_fence: Optional pointer to a fence pointer. If non-NULL, a - * ref-counted fence pointer is returned here. - * @user_fence_rep: Optional pointer to a user-space provided struct - * drm_vmw_fence_rep. If provided, @file_priv must also be provided and the - * function copies fence data to user-space in a fail-safe manner. - */ -void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, - struct drm_file *file_priv, - struct vmw_buffer_object *buf, - struct vmw_fence_obj **out_fence, - struct drm_vmw_fence_rep __user * - user_fence_rep) -{ - struct vmw_fence_obj *fence; +void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv, + struct drm_file *file_priv, + struct vmw_validation_context *ctx, + struct vmw_fence_obj **out_fence, + struct drm_vmw_fence_rep __user * + user_fence_rep) +{ + struct vmw_fence_obj *fence = NULL; uint32_t handle; int ret; - ret = vmw_execbuf_fence_commands(file_priv, dev_priv, &fence, - file_priv ? &handle : NULL); - if (buf) - vmw_bo_fence_single(&buf->base, fence); + if (file_priv || user_fence_rep || vmw_validation_has_bos(ctx) || + out_fence) + ret = vmw_execbuf_fence_commands(file_priv, dev_priv, &fence, + file_priv ? &handle : NULL); + vmw_validation_done(ctx, fence); if (file_priv) vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret, user_fence_rep, fence, @@ -2647,106 +2590,6 @@ void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, *out_fence = fence; else vmw_fence_obj_unreference(&fence); - - vmw_kms_helper_buffer_revert(buf); -} - - -/** - * vmw_kms_helper_resource_revert - Undo the actions of - * vmw_kms_helper_resource_prepare. - * - * @res: Pointer to the resource. Typically a surface. - * - * Helper to be used if an error forces the caller to undo the actions of - * vmw_kms_helper_resource_prepare. - */ -void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx) -{ - struct vmw_resource *res = ctx->res; - - vmw_kms_helper_buffer_revert(ctx->buf); - vmw_bo_unreference(&ctx->buf); - vmw_resource_unreserve(res, false, NULL, 0); - mutex_unlock(&res->dev_priv->cmdbuf_mutex); -} - -/** - * vmw_kms_helper_resource_prepare - Reserve and validate a resource before - * command submission. - * - * @res: Pointer to the resource. Typically a surface. - * @interruptible: Whether to perform waits as interruptible. - * - * Reserves and validates also the backup buffer if a guest-backed resource. - * Returns 0 on success, negative error code on failure. -ERESTARTSYS if - * interrupted by a signal. - */ -int vmw_kms_helper_resource_prepare(struct vmw_resource *res, - bool interruptible, - struct vmw_validation_ctx *ctx) -{ - int ret = 0; - - ctx->buf = NULL; - ctx->res = res; - - if (interruptible) - ret = mutex_lock_interruptible(&res->dev_priv->cmdbuf_mutex); - else - mutex_lock(&res->dev_priv->cmdbuf_mutex); - - if (unlikely(ret != 0)) - return -ERESTARTSYS; - - ret = vmw_resource_reserve(res, interruptible, false); - if (ret) - goto out_unlock; - - if (res->backup) { - ret = vmw_kms_helper_buffer_prepare(res->dev_priv, res->backup, - interruptible, - res->dev_priv->has_mob, - false); - if (ret) - goto out_unreserve; - - ctx->buf = vmw_bo_reference(res->backup); - } - ret = vmw_resource_validate(res, interruptible); - if (ret) - goto out_revert; - return 0; - -out_revert: - vmw_kms_helper_buffer_revert(ctx->buf); -out_unreserve: - vmw_resource_unreserve(res, false, NULL, 0); -out_unlock: - mutex_unlock(&res->dev_priv->cmdbuf_mutex); - return ret; -} - -/** - * vmw_kms_helper_resource_finish - Unreserve and fence a resource after - * kms command submission. - * - * @res: Pointer to the resource. Typically a surface. - * @out_fence: Optional pointer to a fence pointer. If non-NULL, a - * ref-counted fence pointer is returned here. - */ -void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx, - struct vmw_fence_obj **out_fence) -{ - struct vmw_resource *res = ctx->res; - - if (ctx->buf || out_fence) - vmw_kms_helper_buffer_finish(res->dev_priv, NULL, ctx->buf, - out_fence, NULL); - - vmw_bo_unreference(&ctx->buf); - vmw_resource_unreserve(res, false, NULL, 0); - mutex_unlock(&res->dev_priv->cmdbuf_mutex); } /** diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h index 31311298ec0b..76ec570c0684 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h @@ -308,24 +308,12 @@ int vmw_kms_helper_dirty(struct vmw_private *dev_priv, int increment, struct vmw_kms_dirty *dirty); -int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv, - struct vmw_buffer_object *buf, - bool interruptible, - bool validate_as_mob, - bool for_cpu_blit); -void vmw_kms_helper_buffer_revert(struct vmw_buffer_object *buf); -void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, - struct drm_file *file_priv, - struct vmw_buffer_object *buf, - struct vmw_fence_obj **out_fence, - struct drm_vmw_fence_rep __user * - user_fence_rep); -int vmw_kms_helper_resource_prepare(struct vmw_resource *res, - bool interruptible, - struct vmw_validation_ctx *ctx); -void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx); -void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx, - struct vmw_fence_obj **out_fence); +void vmw_kms_helper_validation_finish(struct vmw_private *dev_priv, + struct drm_file *file_priv, + struct vmw_validation_context *ctx, + struct vmw_fence_obj **out_fence, + struct drm_vmw_fence_rep __user * + user_fence_rep); int vmw_kms_readback(struct vmw_private *dev_priv, struct drm_file *file_priv, struct vmw_framebuffer *vfb, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c index ad0de7f0cd60..53316b1bda3d 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c @@ -946,16 +946,20 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv, struct vmw_framebuffer_surface *vfbs = container_of(framebuffer, typeof(*vfbs), base); struct vmw_kms_sou_surface_dirty sdirty; - struct vmw_validation_ctx ctx; + DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); int ret; if (!srf) srf = &vfbs->surface->res; - ret = vmw_kms_helper_resource_prepare(srf, true, &ctx); + ret = vmw_validation_add_resource(&val_ctx, srf, 0, NULL, NULL); if (ret) return ret; + ret = vmw_validation_prepare(&val_ctx, &dev_priv->cmdbuf_mutex, true); + if (ret) + goto out_unref; + sdirty.base.fifo_commit = vmw_sou_surface_fifo_commit; sdirty.base.clip = vmw_sou_surface_clip; sdirty.base.dev_priv = dev_priv; @@ -972,9 +976,14 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv, ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips, dest_x, dest_y, num_clips, inc, &sdirty.base); - vmw_kms_helper_resource_finish(&ctx, out_fence); + vmw_kms_helper_validation_finish(dev_priv, NULL, &val_ctx, out_fence, + NULL); return ret; + +out_unref: + vmw_validation_unref_lists(&val_ctx); + return ret; } /** @@ -1051,13 +1060,17 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv, container_of(framebuffer, struct vmw_framebuffer_bo, base)->buffer; struct vmw_kms_dirty dirty; + DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); int ret; - ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, interruptible, - false, false); + ret = vmw_validation_add_bo(&val_ctx, buf, false, false); if (ret) return ret; + ret = vmw_validation_prepare(&val_ctx, NULL, interruptible); + if (ret) + goto out_unref; + ret = do_bo_define_gmrfb(dev_priv, framebuffer); if (unlikely(ret != 0)) goto out_revert; @@ -1069,12 +1082,15 @@ int vmw_kms_sou_do_bo_dirty(struct vmw_private *dev_priv, num_clips; ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips, 0, 0, num_clips, increment, &dirty); - vmw_kms_helper_buffer_finish(dev_priv, NULL, buf, out_fence, NULL); + vmw_kms_helper_validation_finish(dev_priv, NULL, &val_ctx, out_fence, + NULL); return ret; out_revert: - vmw_kms_helper_buffer_revert(buf); + vmw_validation_revert(&val_ctx); +out_unref: + vmw_validation_unref_lists(&val_ctx); return ret; } @@ -1150,13 +1166,17 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv, struct vmw_buffer_object *buf = container_of(vfb, struct vmw_framebuffer_bo, base)->buffer; struct vmw_kms_dirty dirty; + DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); int ret; - ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, true, false, - false); + ret = vmw_validation_add_bo(&val_ctx, buf, false, false); if (ret) return ret; + ret = vmw_validation_prepare(&val_ctx, NULL, true); + if (ret) + goto out_unref; + ret = do_bo_define_gmrfb(dev_priv, vfb); if (unlikely(ret != 0)) goto out_revert; @@ -1168,13 +1188,15 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv, num_clips; ret = vmw_kms_helper_dirty(dev_priv, vfb, NULL, vclips, 0, 0, num_clips, 1, &dirty); - vmw_kms_helper_buffer_finish(dev_priv, file_priv, buf, NULL, - user_fence_rep); + vmw_kms_helper_validation_finish(dev_priv, file_priv, &val_ctx, NULL, + user_fence_rep); return ret; out_revert: - vmw_kms_helper_buffer_revert(buf); - + vmw_validation_revert(&val_ctx); +out_unref: + vmw_validation_unref_lists(&val_ctx); + return ret; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index 93f6b96ca7bb..d3a9eba12b0e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -759,17 +759,21 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv, struct vmw_stdu_dirty ddirty; int ret; bool cpu_blit = !(dev_priv->capabilities & SVGA_CAP_3D); + DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); /* * VMs without 3D support don't have the surface DMA command and * we'll be using a CPU blit, and the framebuffer should be moved out * of VRAM. */ - ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, interruptible, - false, cpu_blit); + ret = vmw_validation_add_bo(&val_ctx, buf, false, cpu_blit); if (ret) return ret; + ret = vmw_validation_prepare(&val_ctx, NULL, interruptible); + if (ret) + goto out_unref; + ddirty.transfer = (to_surface) ? SVGA3D_WRITE_HOST_VRAM : SVGA3D_READ_HOST_VRAM; ddirty.left = ddirty.top = S32_MAX; @@ -796,9 +800,13 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv, ret = vmw_kms_helper_dirty(dev_priv, vfb, clips, vclips, 0, 0, num_clips, increment, &ddirty.base); - vmw_kms_helper_buffer_finish(dev_priv, file_priv, buf, NULL, - user_fence_rep); + vmw_kms_helper_validation_finish(dev_priv, file_priv, &val_ctx, NULL, + user_fence_rep); + return ret; + +out_unref: + vmw_validation_unref_lists(&val_ctx); return ret; } @@ -924,16 +932,20 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, struct vmw_framebuffer_surface *vfbs = container_of(framebuffer, typeof(*vfbs), base); struct vmw_stdu_dirty sdirty; - struct vmw_validation_ctx ctx; + DECLARE_VAL_CONTEXT(val_ctx, NULL, 0); int ret; if (!srf) srf = &vfbs->surface->res; - ret = vmw_kms_helper_resource_prepare(srf, true, &ctx); + ret = vmw_validation_add_resource(&val_ctx, srf, 0, NULL, NULL); if (ret) return ret; + ret = vmw_validation_prepare(&val_ctx, &dev_priv->cmdbuf_mutex, true); + if (ret) + goto out_unref; + if (vfbs->is_bo_proxy) { ret = vmw_kms_update_proxy(srf, clips, num_clips, inc); if (ret) @@ -954,8 +966,13 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, dest_x, dest_y, num_clips, inc, &sdirty.base); out_finish: - vmw_kms_helper_resource_finish(&ctx, out_fence); + vmw_kms_helper_validation_finish(dev_priv, NULL, &val_ctx, out_fence, + NULL); + + return ret; +out_unref: + vmw_validation_unref_lists(&val_ctx); return ret; }