From patchwork Tue Jan 16 13:56:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10167081 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 CCA3D60325 for ; Tue, 16 Jan 2018 13:57:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF07D2823D for ; Tue, 16 Jan 2018 13:57:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B367528433; Tue, 16 Jan 2018 13:57:26 +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 E39A82823D for ; Tue, 16 Jan 2018 13:57:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D7E176E24A; Tue, 16 Jan 2018 13:57:23 +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-co1nam03on0084.outbound.protection.outlook.com [104.47.40.84]) by gabe.freedesktop.org (Postfix) with ESMTPS id 248306E23A for ; Tue, 16 Jan 2018 13:57:16 +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=F0GlvBOUtEyRM717WvBMoemPtE/iT07hKFW1NtYSotM=; b=hfs0B78CKvC0TKVW5+lum4TLCUlWIMc8iIbtTQ2SbGB8K7xa2enZLWMXZGPk1cSAQQSuZPpaJ9cAxe8nkZy3o6FjDkSk44S153CPh8juPOxWCdnTRAJJZwWO+rODGaPGQXc7wImlMHUisa5YTfGdAwEdGMfTDT/81K5lapB1/Ww= Received: from ubuntu.localdomain (155.4.205.56) by BLUPR05MB754.namprd05.prod.outlook.com (10.141.208.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.9; Tue, 16 Jan 2018 13:57:12 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/5] drm/vmwgfx: Use the cpu blit utility for framebuffer to screen target blits Date: Tue, 16 Jan 2018 14:56:44 +0100 Message-Id: <1516111004-10247-6-git-send-email-thellstrom@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516111004-10247-1-git-send-email-thellstrom@vmware.com> References: <1516111004-10247-1-git-send-email-thellstrom@vmware.com> MIME-Version: 1.0 X-Originating-IP: [155.4.205.56] X-ClientProxiedBy: HE1PR0802CA0014.eurprd08.prod.outlook.com (10.172.123.152) To BLUPR05MB754.namprd05.prod.outlook.com (10.141.208.142) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82a2e7bb-c1e6-4310-a83a-08d55ce90b4d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534125)(4602075)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060)(7193020); SRVR:BLUPR05MB754; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 3:jm1MBF4k4/bR9cVrlDLSpxgJFgTz2ROSYR2Jo4ObX47f8GRL9BGWzBl+UPTTfG3nrIOBSM7kU67RVnMjYlgsfYU+Sy/RRS5m/Q/Kt1zfL4b9oIJsq700/hly758TjQ1dq5LuKc6qwA/hpyBbLNIK74NVcPRVNJ064QxjFxA1X8iQWc5Ohztz/3dtIKQmJaEJLRyrJwbMWoUnp+vm63k/NqJqlp8mWL5wS12iBA+Y8UBNzoZOE3fHRM7tsDla3Xm0; 25:VaHkrQdsXAwIDQxNcPGDWyswwBpodZ4O31xnh6PUsYKVoxz1pkU4vbpd+JJ4Y0em3wHLxOu7AOcfNvIdmTr9U/ABfxI1u7Kv7pSflS5kwVQaWLrstQVgoNevUBYOvuFOTw4ktlHpEDxf7TOEm6PL7Kv681Cxw2z/n2rfYJkxIKGfxAuji9zPwaNHDNRIkmXBPraDh+jQLfSOUmv5/BuboC6SSActL4dkaDdJ3fvklHoXIqMTtTBOmtA48njeeAH61JxFhykAxuPUVBlg4oah+m+9nJH4sTDZKmgazR1o/wJp72gGkOqcJtv1YMv3F0/dVNBdycxJmBTbYz1SPwGJSw==; 31:A8QJZ4GP1hIpywgmlSips06xIwtP5PXCNX/cbnTHEyv9uBVw0d59kVe4maBf8uMIMMSygwF9sfPmRXen43HdwMex0y7brpgZ/PJuq0FlmKg28J5hefxgRs4p83D5uK42XdsqU1+ToQIPZ7mYcsSjzBz5nBuUZsnyFzL1ivals7bmBLVexsVwSqnfJMfXHwlLPZgCGkXwDsMTDCNFp4NTfzlL/EQoAwBG/3LwBhtMrCs= X-MS-TrafficTypeDiagnostic: BLUPR05MB754: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 20:1eB5nA/qmWaydU/di4I7h99VkedOzp1I3S59e0jKIpkxsdFqyhl1UE3eEg2wa435Zb2CdkEEjabqVQiL+669gIcdkE4h8bXabUWcS7+b3MOx0hitnUoG02FvalU+K/LiFmQeKSsIKHA6BfwVE5pBq70NVAgoe0s5qXw/9hOaYvlGvyZIjB3er+uI+BXTt3hjYUuN0WYiS87EsUypgI0PAGvehsSUeGiMYPyMuNFIE7ArwUwwelsv0f5rz9VoHXUTMoD0JER/B6JDiuPrcZgyWsr8nnjMn3ELVTla6kmspneEqg4dS9j7EWVCVmI71fcIqiZQAz8q0Hc3XLSv2ljucmr01ZDLPVRVY1ouzwQDAQXQi4mQfnmRfY+UdUNHkoP5iS6MWvReyM083kSB/l1hYzLtBPpfjFjtveH7FhrNWHbdF447q0nCpN/bAFv0KpB/qMSB0Ku404sS+fjOioJWmD4tEm8fuy4wa6TMCFFhICxwUuuXnsP6hJjKpCA2Qky8; 4:SFvmB7LWaAqLH/6fTGIrEViauvnbiZrm2u9r2vRKNCO8ado0Da2rdWgMOaj8Nncsb/SKHZXfKmgVmrUuwIjJMIr3WvooKC8ReOmVqv5xvk2b9HG/W/8Zf6/jhunTSezUjZkAyhGTNsS5yU2LXlLRP42+ZSDHAcfiihilMSD/VtPaca2ViR/u0y6n4XBzmskbLkHtwj011anmrNgwVhMQqFGG9KXF6RFzhNVVpA4ZlesR9iN/6rD8ZZE21waxSwIX2TbJKNJxKpWLFke9eR2hUX1aQgkl0yiTePvhvwWw/zu7HC7wmjgC48w0dp3AufqJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(2400035)(944501161)(10201501046)(3002001)(93006095)(93001095)(6041268)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:BLUPR05MB754; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BLUPR05MB754; X-Forefront-PRVS: 0554B1F54F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(39860400002)(346002)(376002)(366004)(189003)(199004)(6116002)(2351001)(6506007)(386003)(5660300001)(3846002)(4326008)(305945005)(575784001)(8676002)(68736007)(16526018)(86362001)(59450400001)(2361001)(97736004)(81156014)(7736002)(50226002)(81166006)(16586007)(8936002)(2906002)(36756003)(6916009)(52116002)(6512007)(48376002)(6486002)(50466002)(76176011)(51416003)(66066001)(53936002)(47776003)(2950100002)(105586002)(106356001)(478600001)(107886003)(6666003)(316002)(25786009)(26005); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR05MB754; H:ubuntu.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BLUPR05MB754; 23:9nl8XANHtCvHiWnLZ2xWd7sjVztVhrsE07sfaNBn8c?= =?us-ascii?Q?Ckb4kyEckJ+UeEHUBMJ5Hm4tSKlQ8t30kMfM6QzpoPObDKFf3OWMD7Vd9UuO?= =?us-ascii?Q?Tpn14+Sp5e+zUFBbCx8bT2n4RadLAJxZyWvN5yPGvC+nS+1BpLponFdY8A3c?= =?us-ascii?Q?3zqoRHQiDTDFnVZl8Wy+cKORdHJmrd+J2gH5edQZa6yxRNCm2/FPMoD7Ibc4?= =?us-ascii?Q?4vizLIQmVJ242fPK3BFSinCcHlkCqUeGzicsWy6hspDp1tSltnWe0Hwt76/P?= =?us-ascii?Q?+m0g8jxt5F2zBRB3NYOMQYkpxz7985aMuvgBzmXb7pmnK8c5KClIfnRDvG9g?= =?us-ascii?Q?GCv9ACL9h55wlPjuAUgM+7zn+FOPOzimzm4QvWc1uE2fs0+fbSvDPm4g254I?= =?us-ascii?Q?Br93lBXMRoQrRZJ4aO4L3GtHWvUWXy6OBvRskeQ/qoBtJii1ZID60rDNJk7Y?= =?us-ascii?Q?6ixnYxGL0mvzY596ziFJB6H5UBelfbRz1qZgfTlblEL7uUMe+nLC5/6VbmwE?= =?us-ascii?Q?kAMP/ZW6B3DzhODwILTJXGDK0AdTNgIVGIG7NwnPwBiHoj4VdUtAn4kBOF9A?= =?us-ascii?Q?quFBFpCATyK10u5QKHUFGNpGusiE5NEhyfbe9E3fZQ0j/CB/AKiLhyLJ6Oue?= =?us-ascii?Q?Cib3e1vWvdIMuhQjVl6wtLzR+Kv+U8hcAYX7Y6RXQ+WgIF6K6EUAgY7ymm8l?= =?us-ascii?Q?eiEQRGelNHwBgALl0Y+/HlTLrskyg6IF4+BbY6knelheL7U9+OxgQ64CIlw7?= =?us-ascii?Q?o0Ma0ynuEHszjoDtBP3A01SHJ74t11gFC7paENqdlr2sztukAIAZWulfKbeZ?= =?us-ascii?Q?8am3bFAlxLwEk398IwEYGhHwHPs3lvwIvZsKoM1pufqi/rHbHhQhfsKvPrUP?= =?us-ascii?Q?vQ/bIzcKYinmgGgrHmreyZnpEPubxMiq8CR57cZ7j3Xd1f52pf5/BLm6qlfx?= =?us-ascii?Q?ukMeLddTW95glyhJnzcZwD1jqr0WV0LYvbJznybAU022F1QNzksSiUFOzx3V?= =?us-ascii?Q?wmKLWm/K+QGxMpAPv0lDQJTHSfs6ZAyXIT2BxDEgJ0NL2MO7/4LSsXDMbrOq?= =?us-ascii?Q?tOIk5GS0FEcjpuZf+f+CGlCGmoZ1qlLVDOW3TrNoa/mFbQjutbejUlwlhPXE?= =?us-ascii?Q?KNoEwbIl8jAIemhGTqc9Y7Y3KJrebkL0Q8aVFB14YLWjMVF3nt8V2ppjrNMs?= =?us-ascii?Q?vimA2rTqEN8zg=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 6:e9HK9vgh3aAfXFYjqL6LonGNJgmtcn7v1F5aJeGVcjOGTmg48uBMVPWRjlpC2kDxMH7zdl20HfeZma7kHdV3zS1PTDTH3IHevmVuwVHhBUiXLnhRNBytvimUA+WfKv6+DKK+cJPgXK88h30w8uN0V5Cug7Ip9Wu0QskciEUKAaP12ay2MUp2IWpklriRj/CnEutoqwsxb+Wib0NrCIf+re85Iy5BKK84ooAoL9e/21eZ06r6HPV4l4u8fMk19U2S7ff42xaVi4qZiLbsMZJpzU8opDlswPo1+mctXQGV9DCS4AcEbFu4J84KacmnGYX+ad1V8f5oL6OW0c269MDPvltxzKGO0IjYLJsc3Yth5gs=; 5:AMDGu++z/QpBNwc5LpiU1lt5F64eCdsy7tNbi/8OAatQ+7J2ZgTqK124SuLDZKXpZ01+PeVvWzuwS7ggLAvZo+LqaGqPWBxbCEQorgLVa+ocskvb2/wxOdCPYzxwwIGJgo46hTCOaBqgW7sKL1w25h1d2AwEK3G1E9LoHwkfL+k=; 24:q2A6h/u5xK4JKF6An+HLz2hN6eDBR+fVtmh5hhIkKZSeqeNFSISz3zKiGN6jL6USLf+iFviaHqeMyMXvvagdBm9Gui7Ir4E+0Bfm6Zz0b0c=; 7:I08yp6jz4N8CutaCDB4DuKJTsXthFB2lgD/SgsU6r27TV1l3XCVnyiRHIALAROSLg5sTF41oXAmnNaNuFnFQbUOHTTnQkcSMAmVkoUAv/cueCJtKuwpJsRGjr3Uw3Fq8Q81CrzxbkQanjO6D5WLvZnmLQmJEqKjBSn+rTLA4t8El7ZrEEzJJQrDiqhwLrYgW7HEun0QrrBYCFOh7kyCqrvRdmZWbmhVbLJ3qbUV02bhRcMc42VAps8uFTMbQaZlc SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 20:NIGeD0kowYMf4bbn0xqgv5PcAmwRpPBWu2lUWekRaSr8juaHmq34ZLW2dLek23TH8y5LMbPGLq/bSYk05fve1pinAHgcas3ok8lnGuANZAH/ZwX0fXCIGLNK2iJpLq8+wTu96qDgGbq+su3KqC9evyQ2SYiYIdaiZFLjtufdpQ4= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2018 13:57:12.4098 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82a2e7bb-c1e6-4310-a83a-08d55ce90b4d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR05MB754 Cc: Thomas Hellstrom X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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 22231bc..2fe099a 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 99e7e426..62e567a 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 96737d5..a62d0f8 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -692,9 +692,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 */ @@ -756,11 +753,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); @@ -1139,12 +1131,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 : @@ -1161,12 +1155,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; } @@ -2429,14 +2435,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); @@ -2548,7 +2561,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 42b0f15..4e8749a 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 7164724..8a43ba8 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 6de2874..8eec889 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;