From patchwork Tue Jan 16 13:56:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10167075 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 E6AC36055D for ; Tue, 16 Jan 2018 13:57:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8ECD2823D for ; Tue, 16 Jan 2018 13:57:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD88D28433; Tue, 16 Jan 2018 13:57:18 +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 5D6822823D for ; Tue, 16 Jan 2018 13:57:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB7696E22E; Tue, 16 Jan 2018 13:57:13 +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-co1nam03on0620.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe48::620]) by gabe.freedesktop.org (Postfix) with ESMTPS id 707026E22E for ; Tue, 16 Jan 2018 13:57:12 +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=QEScScHWG13OkeCsTaIejUwrPQUTTEmOrchMtpDbOfw=; b=LoSO7ntxbY5i/NG9Cuj7HOz46Om1Z0J0mrh53Zt/7kVzqjt/s+OO3zXbJgnehfhXeWmH7D1YqLNpe3Z9ZVig1aZELLl3EfonpwVYltX2FHjY3aVZ777R46lfs3UF7FnHXQU8cXOsCzA9eZpmvefn9pb0p33ln/qLSqe6X04aWfw= 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:10 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm/vmwgfx: Don't cache framebuffer maps Date: Tue, 16 Jan 2018 14:56:42 +0100 Message-Id: <1516111004-10247-4-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: 34fd08f1-dd64-45fc-54cd-08d55ce909f6 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:uPGZa6Au1adfikqgQFRTwqE0UhhkpogfoR7wa50rLLVLKbnRy8MZCwmDX/ulASUzli2xvkQwtPs+woHTXdtwOg8cKPj2zDW9BAeIO+NyxpAo/kvMMum64FZdewEYk2J2t2xOGeELbijFQ5QHULyaiuWwknPMENbiSJl6KS7iXm4a6Cg/k3lZva3E9q7uk9yd0922dqUkC2g2/6GvgEmIf5DXyLHV2j7Jef9eSUlEZBhHRjjNFBN0makalluy4Ih/; 25:ysVv2DAySDJHA4k9O7dtFKoC7f/A65+rZ5QJYEI7z8g3evW0iN0qmfC6U6UzwDVuULRAQDaG5cv/wM7v6cDWTBjRSrClhycvKY3upVT7B1xnGCFTpvDp9wkc6oym/+8J3LO6czIJSg/onT5ZqzYPgDeisRzeQfWmumAoHLrlVDFuhle9su5OyIe8UGa5Tvmy2XlgyCNsgkG51zFXavQD7WUIL2ZlGMQG1OCsJ3c/wR5Kx6qiyYBoRvFJoZcU16OleyvUjclJuaW88jnmL52XwyvXQgT4TkxT5NwrfB1dcJNASb8X/g4RFH4aWsHMhJ0AOP/f9E2tO2mRJaOsvaPtiw==; 31:RupII07zMrMbIXtkx7H2ox1A12f6/eWZ7aezupAklFKY2gduXiqb9rwD31hjL7mQwI+NbVrshr1fBsLrhuG+BD/6h9JAjkU6xz2prDneQCBKG+/WLeo4xxM0LjrTeSORcfPGYZ0oM8UCeiZGYEHZHsP+qb7VbiBfwqqUhsMVjrMK7jwVBdVuNEGxlgWaWPYzq9d/KX+gZp1y5Rmi0zHY6Kd1SWesFcVU3zEtf2pXJAE= X-MS-TrafficTypeDiagnostic: BLUPR05MB754: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=thellstrom@vmware.com; X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 20:qGxzN4H5BLos1I390ULt6pGfgQADVL8SRGEW71PwkoLUHFiIMzzh47qZA9wQdBCZwDLu6CaizqAdEYO4pjNpRM49+glIq5sCTCj049WByG0Pq31AdYapsK8loXUZ6afdRu1HJjWjU8CKx+0P1QDlKvIvL+FZqI8nEXIscUk/JXm6/JrH1ZOsyZx2A1AEUMB8wphBsZqOYVkmJWzgfFHPIRdOcCSrURTbyyNsCtPBbjIHC15F4VhrbrVTcRy9Vb7IVneGN8rZlyw6PQ01LVMw6Bkv4yAKeHIoSfj/T2KDrnlyeYaVvdmhxyR0KKdqnlIzqDRk/kWTT7Kla6Vez4gPplLUlvonlJ1Cts13nMJ9c0dwEdIsZCCM315YQlbLrMgQlGnLw/BaDADIBE3CZS6UZssJP7oT8L+ry9jyPgXneZvr9/+WUDfg9hbvrUFOEWGaGX+rzN9jonqpDQY4/dpItHQwB6TwtpAy0m/rdapvvsvQ7shLTsHBRWM2y1JyYQKl; 4:q7SQUiFI+zetVnh0zxQect6uwt0ZrgP05TzaA896kMscUylGD7XrwTGVdbkmgqRCDm3xYg67pLVVge4copOfutVHmDW7xmaIeXWpE8KCOsj3aslTaUhbnEaTBnfuDNI9B8bxqFJLvnuF0w6U6F1cFYrdP9tnobvJKVMWZ59E/agL0nY43i3HnSZXW8i7i1NCoGqeOdhDvGDg8I2Dc0h0tWVupqN3ZEDRjpnsPjIKrZ7CGRkBg+Lvw2W7y9v6d5tg5FZIScqiIJnUIMwsGAgOA+n3qEExlIcnRu4pDkLJBVM5LpMSxNmsbmuI+B9zuR3j 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)(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:0OiKjykehpcfBWpi9J1L+vUSKQRG2i+oKRTNmkBdxC?= =?us-ascii?Q?HPhdW05PrhqbWdKSG25enOSNCUBPeNb35vY8dTQlHv4b+TKrPXy3nFN3jkHW?= =?us-ascii?Q?CrsbX/4F8PW8MsqAHmM/0nsia+pPX17RB/ZDknGh/rYt9JM+CJPYhYXQIWUY?= =?us-ascii?Q?7QrpwhuA1/U7wCBJ/8G/02wIVEHFbT/DwTGIa7g6LxyPTAM35zXWGjevwS5A?= =?us-ascii?Q?1DxxuumlRi/PgpXxXkCVGsJCM+tKvxia/8d//XpFQiSF8II+IQ2RdfD6qsO4?= =?us-ascii?Q?IGX8RFRKOrHR3zobcZKizavMFQiyOH3j3si0l85Yvy/8Ntiiu8isYsl1gEcD?= =?us-ascii?Q?GSz7VrFrqTPQNfX4Brr2oaOk9JBbLP1hHXfkLeLiqqlzURjubagNlOC0ODCk?= =?us-ascii?Q?GWnQnniN6QmmAgrA2AbOpC0g7UoQWTDI74f2cvNrLnj+grtinzqLK520cQwq?= =?us-ascii?Q?A6clBtE3KI2wVHs/MmV+Fw+xD/JsK5OWuozgM9Ij1C3xsMTwn+2YyfQ9+3r6?= =?us-ascii?Q?SW+hC4NRuXBbfjJbi2ICn/XdeTIu22aFQKo9Gt5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jX6nooT8U78xiK74NqO2rsM5+zOpV6TdF6p0EbOcrimt0aSrwEXydjl5iep6ckEkPQGN8g4BNGNTa/acn1yclXKLiD30UGnjbY=; 5:jlset7ori5wR6z2CiEWdgrWyXXRV2GqHhrR75tICv7rkFo1CkemH9QkRAkrGmIBZOqoaiGLKLk3gTGOlVx6ShehhZ4BFJ5k5HmEQbe6fRN9cetwgETWsuF9PlXQWtKzIW5ZwrUl7OPwnAKw9SZXTeXair4RGTcLYSaIvg4QgP7g=; 24:ZLaecDdgBBgNy1G3/LRbju7aQhu5FqP6eaOzY0VFbLDNtxdBe33AkeMAry1Tu2UZt397OywleIBMAW5BXmRr2WL1mk6TlusnXY6L/j2RI7g=; 7:MEaZxWWEi0fJ7WJqhwfSCwhht2j64qRN7iErPI9vsnVZcX1cYebpic1+zdvDpDbgKVFUKllJ0jsk23ZDuW5R1PfTSRgl3UKIG1JusfqT+OCBIiJjb3s9stDi1XR9SfzOxLdl4fvvGJ2CrihNsM5V2qNShNL3q+J+Auy0As2HBMvz4FrVBQLpNHCtxV2eLUQY1CX/BYq73lMDyUIgvLjqj53AcWbVVSin9FYLlPQPKWjL/OrkkOpUD9/m6n+i4smp SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR05MB754; 20:oejxozIJ4F/vuQFGmc3BOda0gngu2ss1f2yMgGDRtvc8vn/306JqZh8rN0WWQxSR/1Uny1Rv1maGJBf1wAyAidRUqEvrca43S5rVoI3CO9+LMC/XZn8waVldKQE+1xMtXsDuCMfDKQBxOTKEPokNJ8jmOxwQBtxmp0C//WHlvH0= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2018 13:57:10.1598 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34fd08f1-dd64-45fc-54cd-08d55ce909f6 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 Buffer objects need to be either pinned or reserved while a map is active, that's not the case here, so avoid caching the framebuffer map. This will cause increasing mapping activity mainly when we don't do page flipping. This fixes occasional garbage filled screens when the framebuffer has been evicted after the map. Since in-kernel mapping of whole buffer objects is error-prone on 32-bit architectures and also quite inefficient, we will revisit this later. Signed-off-by: Thomas Hellstrom Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 6 ------ drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 40 +++++++++++------------------------- 3 files changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 34ee856..96737d5 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -694,7 +694,6 @@ vmw_du_plane_duplicate_state(struct drm_plane *plane) vps->pinned = 0; /* Mapping is managed by prepare_fb/cleanup_fb */ - memset(&vps->guest_map, 0, sizeof(vps->guest_map)); memset(&vps->host_map, 0, sizeof(vps->host_map)); vps->cpp = 0; @@ -757,11 +756,6 @@ vmw_du_plane_destroy_state(struct drm_plane *plane, /* Should have been freed by cleanup_fb */ - if (vps->guest_map.virtual) { - DRM_ERROR("Guest mapping not freed\n"); - ttm_bo_kunmap(&vps->guest_map); - } - if (vps->host_map.virtual) { DRM_ERROR("Host mapping not freed\n"); ttm_bo_kunmap(&vps->host_map); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h index 70a7be2..42b0f15 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h @@ -177,7 +177,7 @@ struct vmw_plane_state { int pinned; /* For CPU Blit */ - struct ttm_bo_kmap_obj host_map, guest_map; + struct ttm_bo_kmap_obj host_map; unsigned int cpp; }; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index 0e771d6..6de2874 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -114,7 +114,7 @@ struct vmw_screen_target_display_unit { bool defined; /* For CPU Blit */ - struct ttm_bo_kmap_obj host_map, guest_map; + struct ttm_bo_kmap_obj host_map; unsigned int cpp; }; @@ -641,7 +641,8 @@ static void vmw_stdu_dmabuf_cpu_commit(struct vmw_kms_dirty *dirty) s32 src_pitch, dst_pitch; u8 *src, *dst; bool not_used; - + struct ttm_bo_kmap_obj guest_map; + int ret; if (!dirty->num_hits) return; @@ -652,6 +653,13 @@ 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; @@ -659,7 +667,7 @@ static void vmw_stdu_dmabuf_cpu_commit(struct vmw_kms_dirty *dirty) src += ddirty->top * src_pitch + ddirty->left * stdu->cpp; dst_pitch = ddirty->pitch; - dst = ttm_kmap_obj_virtual(&stdu->guest_map, ¬_used); + dst = ttm_kmap_obj_virtual(&guest_map, ¬_used); dst += ddirty->fb_top * dst_pitch + ddirty->fb_left * stdu->cpp; @@ -718,6 +726,7 @@ static void vmw_stdu_dmabuf_cpu_commit(struct vmw_kms_dirty *dirty) 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; @@ -1062,9 +1071,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->guest_map.virtual) - ttm_bo_kunmap(&vps->guest_map); - if (vps->host_map.virtual) ttm_bo_kunmap(&vps->host_map); @@ -1230,33 +1236,11 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane, */ if (vps->content_fb_type == SEPARATE_DMA && !(dev_priv->capabilities & SVGA_CAP_3D)) { - - struct vmw_framebuffer_dmabuf *new_vfbd; - - new_vfbd = vmw_framebuffer_to_vfbd(new_fb); - - ret = ttm_bo_reserve(&new_vfbd->buffer->base, false, false, - NULL); - if (ret) - goto out_srf_unpin; - - ret = ttm_bo_kmap(&new_vfbd->buffer->base, 0, - new_vfbd->buffer->base.num_pages, - &vps->guest_map); - - ttm_bo_unreserve(&new_vfbd->buffer->base); - - if (ret) { - DRM_ERROR("Failed to map content buffer to CPU\n"); - goto out_srf_unpin; - } - 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"); - ttm_bo_kunmap(&vps->guest_map); goto out_srf_unpin; }