From patchwork Thu Mar 22 10:23:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10301177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E75AE60386 for ; Thu, 22 Mar 2018 10:24:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7E57287CF for ; Thu, 22 Mar 2018 10:24:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC5FF29AA1; Thu, 22 Mar 2018 10:24: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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 EA947287DB for ; Thu, 22 Mar 2018 10:24:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 81FDC6EBBD; Thu, 22 Mar 2018 10:24:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0054.outbound.protection.outlook.com [104.47.40.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id E3DEA6EBC4 for ; Thu, 22 Mar 2018 10:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=onevmw.onmicrosoft.com; s=selector1-vmware-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=rv6lulNSZeAx919jfpYbRpSd1pwwNRUtLA9KAso2hfM=; b=nTtJEhoR/gxGXWVmEk4ZHHY9kP9ik1Y4QwiDvyo5kuitaKY3FlvhPX6pBE4s6WS0zN10UFc+mzxmzeFhsb75Kh/55M3pfWNVmkLIFPfUsWwIFkJHKs3IaWOJgowUApC/ifUnmPa2zBS1Xq+p6KO2FaBiR64LjmjGBGIrqEaeOMU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; Received: from localhost.localdomain (155.4.205.56) by DM2PR05MB767.namprd05.prod.outlook.com (2a01:111:e400:244d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.609.6; Thu, 22 Mar 2018 10:24:31 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org, linux-graphics-maintainer@vmware.com Subject: [PATCH -next 02/11] drm/vmwgfx: Use the cpu blit utility for framebuffer to screen target blits Date: Thu, 22 Mar 2018 11:23:43 +0100 Message-Id: <20180322102352.2881-2-thellstrom@vmware.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180322102352.2881-1-thellstrom@vmware.com> References: <20180322102352.2881-1-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: HE1PR0502CA0021.eurprd05.prod.outlook.com (2603:10a6:3:e3::31) To DM2PR05MB767.namprd05.prod.outlook.com (2a01:111:e400:244d::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 01fe92de-7a5c-4951-ecfb-08d58fdf1a16 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DM2PR05MB767; X-Microsoft-Exchange-Diagnostics: 1; DM2PR05MB767; 3:CevAjW9sg7Q43MZ5yrBKF2gCFJ+wRZErIGRpDlBYBgji1XmgnRfPpKmrCxaEzW8ZGjzMYe5818/3oRknglO1A1h4WziH45oMPPm6IawVNSRo7/mJKJbm0etTyvPpqv20R2wZFdWf5t9bhC2Roz+nBI2KioT3CoVLFabAOxXEwYmi8EpnjfLVGV/kHPk2n+hR+aTWv2L5V38deZp1SXiXjLX00/NGj9UaNe05WociRRP5MwM5YYOkxiYvgQPoFE5o; 25:/pFvZiw8YGzBLj4X0i/XUbPqAQROMzWefUjqKIbAjRoL/huu5EjV50eCDOLHVPtlDV32Sxg3gzDALuJWh5xCIfwhIbjoZsQxyrobMltRyD7GMtuYYryggJKqTySjkZcH9Iq90ooncE1oAycokmFZhI1cPuM2NLLHV1enWfySh9mLEHGPfsHQQLYAftWHFY6z+e8KL0oxZuTbYJ82h1orljiCdwg6hPIWIGg1OpgHZfhQ+kBIF4/vZ6eTwHfbiPkOIjUMvZ5Vff2ienJMcsBAKlrX2s6JJJK7LXXZ72B3gzL7YTpeEEMf7SiUo5D5/QpvoIzTDMTubMRNR/m7Lwesi1bFI1qrcpsRByWj2x3LUN0=; 31:v5MlECUrQ2h2HJeNBDk8hk0KbvthU5NrEe+fNaKNEYz0ZDoMKl31OxTwUxnYiNCwM/mqxna6VLqaoQXvXIej6ovjY6VkxNJxK2ie7R4w2zKTtHellTQuToUDgh1fDygz4Mb3or6sBLANxxp8KjeUw7KmygB1r8pebDN+1kNV3T3s1rs5Yo1PZi25KdkEmYYxbWGglSok5cxYTrnrDrUww1ITdEB0DVrPQ8BKpsLE8lY= X-MS-TrafficTypeDiagnostic: DM2PR05MB767: X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DM2PR05MB767; 20:/f0JwgqV+/HODalbLtTXf23Y46EvHMAOQR90FmK1PXz2vDFRC9bzhrDblWhnY8v/R0GNoRRREyw4QFjGh09LqNnwHTTl6HC5Oqv8wNqruwCVWTsV7ODO2wzNbXkcXw6BKfghDarBnu8wVlAvbzzOoA02JS0NPj/Th3pywdnqJBugTcrN/vTPCeWmrHHMFFq07N+PqdJC43nRxMvw9ZzeDKgxkV1yhqzYcNwYk/JHhjXm0UC6fDxR4AVGCEfnMA/qty0nB9CQwPqdU4WPRYn2UA6j3vBPJ4Xk0wTPynrMrwi2YkVPM40/1r0GgAJ8uczvDEaWiZkjuaAIqpcKXTZsE8vYH4Nvol6Xiz4SC/tlvY0CoLTtE3opowiYJL/gQGCtvNTu2IF7YeSicangBWO5ZYbbh066jbPG6ETyQEs4JbDJkM5zX1XxweaD6bvxw7u18qgIUh/hgL4UMMACp6lgPiFieT421uvzclq9R/+7k5Kbb/cAzY5bVIN9NhWP038L; 4:YBp19jAvCbsHwH7Vg5T55awPz7wu9XCDUzHtOLMxSj2G1wNvFH9DgYwwgu/gxl/WUBFqWY2HsnfdgHzKGNlPjm/XisvKxhzIb6OyWEWivpakpb6FLQvAhLEebiblP+Uu2ttT7M8Vz9F9EdAeHd0vbfSiycFoEs4DluF3mDslr5Jybaj1T6UeLxIKcl3aGEWFKgbtqhYbKRzdAufEldMhm8Qei9DeqLkjH3iP+eyImAUMB+bDac9Ssn/kIRqc4ZbsSCQ96kEjHZeOCDA0XcMP/pMlE05A51MKxlJrUnT5Cpy0Dg/LZvGxnmKmyeinVPW3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(10201501046)(3002001)(93006095)(93001095)(6041310)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(6072148)(201708071742011); SRVR:DM2PR05MB767; BCL:0; PCL:0; RULEID:; SRVR:DM2PR05MB767; X-Forefront-PRVS: 0619D53754 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(346002)(39380400002)(376002)(396003)(39860400002)(366004)(199004)(189003)(76176011)(59450400001)(8676002)(81156014)(316002)(68736007)(5660300001)(305945005)(8936002)(50226002)(16586007)(36756003)(81166006)(86362001)(50466002)(575784001)(6486002)(48376002)(186003)(16526019)(6512007)(53936002)(6666003)(6636002)(6506007)(386003)(2950100002)(25786009)(6116002)(52116002)(106356001)(105586002)(51416003)(47776003)(3846002)(26005)(1076002)(2906002)(97736004)(7736002)(66066001)(478600001)(446003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR05MB767; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR05MB767; 23:Zrwpjb9uXkA7rV0ZAxOL0wknqx6fB3NOjm6z0gufac?= =?us-ascii?Q?J7avrZHsFn6EnS5b8SlhFSFbdtdtYC/B82Luh1Wff+T68rMdQxtl1eaEL0W1?= =?us-ascii?Q?1JbP2Fb8zKbiq4w94MAhLU/LxgB4O/+CcXGMbnZw2Q6N+UuXLmg4U79pndVK?= =?us-ascii?Q?Enp89pLcjk75MEA+6CBlwQdMSbBAd8y1X2i4o1yWP/SAfLZ4RmrJX+3l6GlC?= =?us-ascii?Q?QeIoKNrPHm+PuIvI5S/6OqoSpQIrObI57Cqos1kS6DAm53eDMr+xhuMHSOlh?= =?us-ascii?Q?7pJjfKUpbAIcXsQ8w/anQ2wroUyX8vtT8XShjrkmq3rDPWYUxZ9yxhvRLfvn?= =?us-ascii?Q?QEytHpeo8SwdBzbYkDe5tE5X6WpMn+grcx9fG7oba3OnswjBt9uuOfNPqv5a?= =?us-ascii?Q?WaU/5fqsL5rMpjBhxUBuCEVwwXkQ5Cm+xYA9JCFwiSpy76d7uAev7/7AhJ0q?= =?us-ascii?Q?nJpI6/VemVc4xq0Eq6PCLSK+/Bje838ptbjiP2goJolbQSkXS22WlZ9+mFUO?= =?us-ascii?Q?hG4efAI8DpjwHRyCLMOPeIHZ/90QzR316mrfqNEFF1wnN3bK/jrO27n7ralL?= =?us-ascii?Q?DIKx3Y+09kWU9oYR3v/sUX3Ae7vbZuEXqsGHnyuJiEN5zMf6mZztHns71P0Q?= =?us-ascii?Q?nZaitHsU38NEfcJist7hyOGCAALQ9vCzHVob+3jmGwBnzmWHziDFiVHUoY9h?= =?us-ascii?Q?X9IJOZPfdYAhl9ZFU72gDmvtFAuRPUMJaRbAjkRz6paOStoXFkrmbH5afWsB?= =?us-ascii?Q?Z1W/OzF5LebFbuyTeResS2+853/EmnrkVCUQJygAljhlZjcGjuYIl04eaLMl?= =?us-ascii?Q?n8Gl7J/1v8J0m7XA2Wihv+HLJi81u20y/2lHJQvtrBrC80Wg8akOIRvt4YiD?= =?us-ascii?Q?UViOQzspVK4LE3NRhGHIHatvOFgDpefoLgkWNuw4eJQHan5G0vsEzK2uLPJD?= =?us-ascii?Q?eAJtPWAXoGhrK0KM+VLeFJDMiu+nR80+n24BhEKveJEWO8Q5l8DBP4jgbteE?= =?us-ascii?Q?T2Jf/ftD0oV2AkJ5kQwU+CgskIBO6xfYb795k66wlB9fFgpkW2sSjOvzrW/n?= =?us-ascii?Q?1Du7egZWOrCYb32i7EDmFJDEVDSUEOx6kQ6bV2xZI9sW7ng4nWHjuofCJIvx?= =?us-ascii?Q?7SCf1atv5XeBvzzoE5Z45L2biKIjST8wFuzBeyMkXzkqDO8K3KBqRE4VVV13?= =?us-ascii?Q?KUpRlvQ1AvNHM=3D?= X-Microsoft-Antispam-Message-Info: Yxqji41Pifb8iYJgX7ewv4AGOOa8afhJtW39Nw/91WD9XwDpSIY44MoMygF/NU/QoVweRU1U3yCvfPxhTMWGZd0W++1uZZEhYLuYEwkIffGUrm1RnCf0QCBHNpNe8ucpYlPwU0u5KCKuJPBEpdtrL7z7mEDDC1tV8x6Efbz2P0Us3tnA36XZxQXVY3tHMW6P X-Microsoft-Exchange-Diagnostics: 1; DM2PR05MB767; 6:c0qIsJMThhsBaKOhzgKj6Eltm4vIqXo/a0YxgIE2AMhvLvuCUvLSqJFjT6ssZ2WT4c2sdomUJMtKxt7XmFbA7XLuuBVpRapsWQ1AuaaNAZI0ivONGthgogAPu8D+C1fpGrRTHU2RzKljbYIwnGrb4oUsKbYThg+3MzHojhQ+4EvN9y4GOpLgZO2oHMvxsWHN9Pzg9OrQzqXq+PWAVLR1xtsywExjyIXP240rrcSWRj12v1A80XuXNbxzIM+ihq+E3yxL7tw+HeqIyxYvfhOnI4YRbiCMrJoU7XywoY0ttL5wTng6H0UN9XsoyOGbLnwhU6RdYGNq1YkVUywm8tgg+RfSqYquhMV8zRsBow3EM3TL77mXbCbAub8MKrOaaGE0C04+989yr2Dt2P+46MypycN2FGmIi4em9e0mdMomFUrWcU5aPH9j+ENuepgz6pZV7n4eccm0mwYAcPAtqSKjsg==; 5:hjJrNH2CM0OF+IxJM6CGSrPBKrbGLmECUBS0PRLN8RDt46N5+p0OcdzvmhV230fcC/FFnaUb+wHjCd5oe2rZxnhsAlRhC76Efd0M4dt0ZMKwDMtIBKsysIJ8sbylJiB08D1sHhywhXOSRYIfuMn9qmWc+0NA8/0m0w5t/YgDhXQ=; 24:/4GozYnRDayq7nY0ltaT9RZI5lUGncext3ygSQsE/Rt+wg8oCFfC7AdO1a2pJx53IZZUTkCUiqZ/L9U6YL9MoIJBOhtGK0KgbEEcJQKYnm4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR05MB767; 7:l5q6+foFz13ULdYhY8Qh9ZUcndMGzeMfTnc316zKdZqPU2iZdJYHcQau6SJdeVWNZhfK0Uy5BHiaR8zCR+yi72RHWjB/nLXl6iZCjdmq5AfNjab4BteSmdHl52Aolb6BT4nTQENBI8W4b6twAuYMN9lGFFEqMKeJNTutc7k0vpgcIc45bZzjoGEcMBSZT20bfFN5s4ZEMA8mVqBWnbLfg4LP4rOpXEbuMcEP3s/FS4qociyMJ1nY34tBdTctZfee; 20:012jsBwoNNXlQEgW1Go4Wrl5TbRiK8RQbr+6va+bs1sFyX8bxy/FtPnx74SOc9Lc2DObwRGnPrcxLbSJBbGzhaaJYCXzzXY3oJLICpZyrD5jmh2Wtxl3s3JAUxRJyP4omlCOr6ObfAxAdfdyrpHu/EATsCVl3qKfwMjQ4J8b8Sg= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2018 10:24:31.3826 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 01fe92de-7a5c-4951-ecfb-08d58fdf1a16 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR05MB767 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP This blit was previously performed using two large vmaps, one of which was teared down and remapped on each blit. Use the more resource- conserving TTM cpu blit instead. The blit is used in boundary-box computing mode which makes it possible to minimize the bounding box used in host operations. Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul --- drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 23 ++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 50 ++++++++++------ drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 4 +- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 5 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 105 +++++++++++---------------------- 6 files changed, 97 insertions(+), 91 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index 7177eecb8c9f..ddf71bef5359 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c @@ -185,6 +185,22 @@ static const struct ttm_place evictable_placement_flags[] = { } }; +static const struct ttm_place nonfixed_placement_flags[] = { + { + .fpfn = 0, + .lpfn = 0, + .flags = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED + }, { + .fpfn = 0, + .lpfn = 0, + .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED + }, { + .fpfn = 0, + .lpfn = 0, + .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED + } +}; + struct ttm_placement vmw_evictable_placement = { .num_placement = 4, .placement = evictable_placement_flags, @@ -213,6 +229,13 @@ struct ttm_placement vmw_mob_ne_placement = { .busy_placement = &mob_ne_placement_flags }; +struct ttm_placement vmw_nonfixed_placement = { + .num_placement = 3, + .placement = nonfixed_placement_flags, + .num_busy_placement = 1, + .busy_placement = &sys_placement_flags +}; + struct vmw_ttm_tt { struct ttm_dma_tt dma_ttm; struct vmw_private *dev_priv; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 15b22e56b8d1..9368bcb492aa 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -767,6 +767,7 @@ extern struct ttm_placement vmw_evictable_placement; extern struct ttm_placement vmw_srf_placement; extern struct ttm_placement vmw_mob_placement; extern struct ttm_placement vmw_mob_ne_placement; +extern struct ttm_placement vmw_nonfixed_placement; extern struct ttm_bo_driver vmw_bo_driver; extern int vmw_dma_quiescent(struct drm_device *dev); extern int vmw_bo_map_dma(struct ttm_buffer_object *bo); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 0f9c9cd78d83..63159674bf92 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -682,9 +682,6 @@ vmw_du_plane_duplicate_state(struct drm_plane *plane) return NULL; vps->pinned = 0; - - /* Mapping is managed by prepare_fb/cleanup_fb */ - memset(&vps->host_map, 0, sizeof(vps->host_map)); vps->cpp = 0; /* Each ref counted resource needs to be acquired again */ @@ -746,11 +743,6 @@ vmw_du_plane_destroy_state(struct drm_plane *plane, /* Should have been freed by cleanup_fb */ - if (vps->host_map.virtual) { - DRM_ERROR("Host mapping not freed\n"); - ttm_bo_kunmap(&vps->host_map); - } - if (vps->surf) vmw_surface_unreference(&vps->surf); @@ -1129,12 +1121,14 @@ static const struct drm_framebuffer_funcs vmw_framebuffer_dmabuf_funcs = { }; /** - * Pin the dmabuffer to the start of vram. + * Pin the dmabuffer in a location suitable for access by the + * display system. */ static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb) { struct vmw_private *dev_priv = vmw_priv(vfb->base.dev); struct vmw_dma_buffer *buf; + struct ttm_placement *placement; int ret; buf = vfb->dmabuf ? vmw_framebuffer_to_vfbd(&vfb->base)->buffer : @@ -1151,12 +1145,24 @@ static int vmw_framebuffer_pin(struct vmw_framebuffer *vfb) break; case vmw_du_screen_object: case vmw_du_screen_target: - if (vfb->dmabuf) - return vmw_dmabuf_pin_in_vram_or_gmr(dev_priv, buf, - false); + if (vfb->dmabuf) { + if (dev_priv->capabilities & SVGA_CAP_3D) { + /* + * Use surface DMA to get content to + * sreen target surface. + */ + placement = &vmw_vram_gmr_placement; + } else { + /* Use CPU blit. */ + placement = &vmw_sys_placement; + } + } else { + /* Use surface / image update */ + placement = &vmw_mob_placement; + } - return vmw_dmabuf_pin_in_placement(dev_priv, buf, - &vmw_mob_placement, false); + return vmw_dmabuf_pin_in_placement(dev_priv, buf, placement, + false); default: return -EINVAL; } @@ -2419,14 +2425,21 @@ int vmw_kms_helper_dirty(struct vmw_private *dev_priv, int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv, struct vmw_dma_buffer *buf, bool interruptible, - bool validate_as_mob) + 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); - ret = vmw_validate_single_buffer(dev_priv, bo, interruptible, - validate_as_mob); + if (for_cpu_blit) + ret = ttm_bo_validate(bo, &vmw_nonfixed_placement, &ctx); + else + ret = vmw_validate_single_buffer(dev_priv, bo, interruptible, + validate_as_mob); if (ret) ttm_bo_unreserve(bo); @@ -2538,7 +2551,8 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res, if (res->backup) { ret = vmw_kms_helper_buffer_prepare(res->dev_priv, res->backup, interruptible, - res->dev_priv->has_mob); + res->dev_priv->has_mob, + false); if (ret) goto out_unreserve; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h index 42b0f1589d3f..4e8749a8717e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h @@ -177,7 +177,6 @@ struct vmw_plane_state { int pinned; /* For CPU Blit */ - struct ttm_bo_kmap_obj host_map; unsigned int cpp; }; @@ -289,7 +288,8 @@ int vmw_kms_helper_dirty(struct vmw_private *dev_priv, int vmw_kms_helper_buffer_prepare(struct vmw_private *dev_priv, struct vmw_dma_buffer *buf, bool interruptible, - bool validate_as_mob); + bool validate_as_mob, + bool for_cpu_blit); void vmw_kms_helper_buffer_revert(struct vmw_dma_buffer *buf); void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, struct drm_file *file_priv, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c index 9f6deced4244..3b7bf7ca18b9 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c @@ -1032,7 +1032,7 @@ int vmw_kms_sou_do_dmabuf_dirty(struct vmw_private *dev_priv, int ret; ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, interruptible, - false); + false, false); if (ret) return ret; @@ -1130,7 +1130,8 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv, struct vmw_kms_dirty dirty; int ret; - ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, true, false); + ret = vmw_kms_helper_buffer_prepare(dev_priv, buf, true, false, + false); if (ret) return ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index 6de28746f6f7..8eec88920851 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -114,7 +114,6 @@ struct vmw_screen_target_display_unit { bool defined; /* For CPU Blit */ - struct ttm_bo_kmap_obj host_map; unsigned int cpp; }; @@ -639,10 +638,9 @@ static void vmw_stdu_dmabuf_cpu_commit(struct vmw_kms_dirty *dirty) container_of(dirty->unit, typeof(*stdu), base); s32 width, height; s32 src_pitch, dst_pitch; - u8 *src, *dst; - bool not_used; - struct ttm_bo_kmap_obj guest_map; - int ret; + struct ttm_buffer_object *src_bo, *dst_bo; + u32 src_offset, dst_offset; + struct vmw_diff_cpy diff = VMW_CPU_BLIT_DIFF_INITIALIZER(stdu->cpp); if (!dirty->num_hits) return; @@ -653,57 +651,38 @@ static void vmw_stdu_dmabuf_cpu_commit(struct vmw_kms_dirty *dirty) if (width == 0 || height == 0) return; - ret = ttm_bo_kmap(&ddirty->buf->base, 0, ddirty->buf->base.num_pages, - &guest_map); - if (ret) { - DRM_ERROR("Failed mapping framebuffer for blit: %d\n", - ret); - goto out_cleanup; - } - - /* Assume we are blitting from Host (display_srf) to Guest (dmabuf) */ - src_pitch = stdu->display_srf->base_size.width * stdu->cpp; - src = ttm_kmap_obj_virtual(&stdu->host_map, ¬_used); - src += ddirty->top * src_pitch + ddirty->left * stdu->cpp; - - dst_pitch = ddirty->pitch; - dst = ttm_kmap_obj_virtual(&guest_map, ¬_used); - dst += ddirty->fb_top * dst_pitch + ddirty->fb_left * stdu->cpp; + /* Assume we are blitting from Guest (dmabuf) to Host (display_srf) */ + dst_pitch = stdu->display_srf->base_size.width * stdu->cpp; + dst_bo = &stdu->display_srf->res.backup->base; + dst_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; + src_pitch = ddirty->pitch; + src_bo = &ddirty->buf->base; + src_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; - /* Figure out the real direction */ - if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM) { - u8 *tmp; - s32 tmp_pitch; - - tmp = src; - tmp_pitch = src_pitch; - - src = dst; - src_pitch = dst_pitch; - - dst = tmp; - dst_pitch = tmp_pitch; + /* Swap src and dst if the assumption was wrong. */ + if (ddirty->transfer != SVGA3D_WRITE_HOST_VRAM) { + swap(dst_pitch, src_pitch); + swap(dst_bo, src_bo); + swap(src_offset, dst_offset); } - /* CPU Blit */ - while (height-- > 0) { - memcpy(dst, src, width * stdu->cpp); - dst += dst_pitch; - src += src_pitch; - } + (void) vmw_bo_cpu_blit(dst_bo, dst_offset, dst_pitch, + src_bo, src_offset, src_pitch, + width * stdu->cpp, height, &diff); - if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM) { + if (ddirty->transfer == SVGA3D_WRITE_HOST_VRAM && + drm_rect_visible(&diff.rect)) { struct vmw_private *dev_priv; struct vmw_stdu_update *cmd; struct drm_clip_rect region; int ret; /* We are updating the actual surface, not a proxy */ - region.x1 = ddirty->left; - region.x2 = ddirty->right; - region.y1 = ddirty->top; - region.y2 = ddirty->bottom; + region.x1 = diff.rect.x1; + region.x2 = diff.rect.x2; + region.y1 = diff.rect.y1; + region.y2 = diff.rect.y2; ret = vmw_kms_update_proxy( (struct vmw_resource *) &stdu->display_srf->res, (const struct drm_clip_rect *) ®ion, 1, 1); @@ -720,13 +699,12 @@ static void vmw_stdu_dmabuf_cpu_commit(struct vmw_kms_dirty *dirty) } vmw_stdu_populate_update(cmd, stdu->base.unit, - ddirty->left, ddirty->right, - ddirty->top, ddirty->bottom); + region.x1, region.x2, + region.y1, region.y2); vmw_fifo_commit(dev_priv, sizeof(*cmd)); } - ttm_bo_kunmap(&guest_map); out_cleanup: ddirty->left = ddirty->top = ddirty->fb_left = ddirty->fb_top = S32_MAX; ddirty->right = ddirty->bottom = S32_MIN; @@ -772,9 +750,15 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv, container_of(vfb, struct vmw_framebuffer_dmabuf, base)->buffer; struct vmw_stdu_dirty ddirty; int ret; + bool cpu_blit = !(dev_priv->capabilities & SVGA_CAP_3D); + /* + * 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); + false, cpu_blit); if (ret) return ret; @@ -793,8 +777,8 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv, if (to_surface) ddirty.base.fifo_reserve_size += sizeof(struct vmw_stdu_update); - /* 2D VMs cannot use SVGA_3D_CMD_SURFACE_DMA so do CPU blit instead */ - if (!(dev_priv->capabilities & SVGA_CAP_3D)) { + + if (cpu_blit) { ddirty.base.fifo_commit = vmw_stdu_dmabuf_cpu_commit; ddirty.base.clip = vmw_stdu_dmabuf_cpu_clip; ddirty.base.fifo_reserve_size = 0; @@ -1071,9 +1055,6 @@ vmw_stdu_primary_plane_cleanup_fb(struct drm_plane *plane, { struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); - if (vps->host_map.virtual) - ttm_bo_kunmap(&vps->host_map); - if (vps->surf) WARN_ON(!vps->pinned); @@ -1235,24 +1216,11 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, * so cache these mappings */ if (vps->content_fb_type == SEPARATE_DMA && - !(dev_priv->capabilities & SVGA_CAP_3D)) { - ret = ttm_bo_kmap(&vps->surf->res.backup->base, 0, - vps->surf->res.backup->base.num_pages, - &vps->host_map); - if (ret) { - DRM_ERROR("Failed to map display buffer to CPU\n"); - goto out_srf_unpin; - } - + !(dev_priv->capabilities & SVGA_CAP_3D)) vps->cpp = new_fb->pitches[0] / new_fb->width; - } return 0; -out_srf_unpin: - vmw_resource_unpin(&vps->surf->res); - vps->pinned--; - out_srf_unref: vmw_surface_unreference(&vps->surf); return ret; @@ -1296,7 +1264,6 @@ vmw_stdu_primary_plane_atomic_update(struct drm_plane *plane, stdu->display_srf = vps->surf; stdu->content_fb_type = vps->content_fb_type; stdu->cpp = vps->cpp; - memcpy(&stdu->host_map, &vps->host_map, sizeof(vps->host_map)); vclips.x = crtc->x; vclips.y = crtc->y;