From patchwork Thu Mar 22 10:23:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Hellstrom X-Patchwork-Id: 10301195 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 EA61760385 for ; Thu, 22 Mar 2018 10:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC56529AA3 for ; Thu, 22 Mar 2018 10:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D142329B00; Thu, 22 Mar 2018 10:24:52 +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 69B3E29AA3 for ; Thu, 22 Mar 2018 10:24:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B7126EBD9; Thu, 22 Mar 2018 10:24:50 +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-co1nam03on0086.outbound.protection.outlook.com [104.47.40.86]) by gabe.freedesktop.org (Postfix) with ESMTPS id C89146EBD6 for ; Thu, 22 Mar 2018 10:24:47 +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=PHW/YLLzXy+vlR+BvEQcrSXqb2jMEJK2YYRXcKkH9SY=; b=iifmNpvIg+DsUvfzGv/DsXrnAEy6RFswDURiKGPNL2nlmlBxqWKU/5uL4sA5vX1jXMSbtHdG+RtJOISa55G+4Y8v3RCqarghQXOXKT8VA3mmAlc4dYo7e1096TwLHZLYG6MTCy5njX08AXsMRTZZF/9sVTjMi+wEWiqX+BfuwLs= 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:45 +0000 From: Thomas Hellstrom To: dri-devel@lists.freedesktop.org, linux-graphics-maintainer@vmware.com Subject: [PATCH -next 09/11] drm/vmwgfx: Unpin the screen object backup buffer when not used Date: Thu, 22 Mar 2018 11:23:50 +0100 Message-Id: <20180322102352.2881-9-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: c35f7ba4-ba57-40d7-3b80-08d58fdf225f 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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cqki7HrjDYYlnaZDjK9vbDRcD8I2BeyrJYDEu1Q0mJF9TvE8BI+aSE5iFn+nyqXNQTA/FKH0koLetYwFTV54fX1lUzfibTz0GfGjmz3Sc+4fdYQsZ6OeNxo7sW1gzYyx/h3PJQcA4BxBnYZ1MZwbpNqXD5e5U9QQaZM0UAKDWogAv/05vCdFeYzHASqbW8TBVxUowjfxRHXwcftCZEJU5MKQ05OwOOBAFELktDYPILGkD+7Yc6LtuXB+kPW2UTajPYVjqrmvTO7J2zBrFP2VChrhjavF9sLAZySPhBK/xABXeqYTIswwHqcMmF+W/+N9MPG0tAxxZEbpn5P0VgnlzQ0XS4ZAAxgqwz91nTSkxpF5Hr/mSc4g2ur6Sw/SRlO1zimhnL20zTwDvu6ZxD+TaUui9lxixcSYBFoF+rGIY901RUz; 4:Vvf0neDq/UtFK0D3d42Py9AszzQRTreo6s6p3pYaJFRBx5i7P8Q8qrdfnOKQSAswuYqglhTny8xYKqjKBxIca0WoQ3RRXwHW0ocx86ZDZyXp3U+EotLZrM01CpD8cSCTuID2M+5pYgJwWmJU2g7bcGmEcY0ofGwj9JKIs7yA05b1NLAOsMIftGr2v74KM5cZsTtnoUzymB6aI+3SvuaPT8PIUgIs0zbD+X8dmQUa/8NxaL4lGomc84PaLPtMwcUpbdmdiZbvKch+otLagpPCOeRtj7LCJ24clrhM7Tbd9rbIXkfjlaiLwM2W9E6fXFfx 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)(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:N9wZ6k7L5ItrDGoI/OS22kHK4AcS39AsDXBPQCrXrI?= =?us-ascii?Q?wNGj7JIAhrsnkZUvD1pT5IrogOVFqBtn7KZBPTz2Xb4ui5XOg3vsCHxJeRYg?= =?us-ascii?Q?CDOPHm6oTheT+IXey8ZRAWADoOTl0MH7vJHELMDZ1QyU5+xbpy+q2Arn79XY?= =?us-ascii?Q?PQqPhU81qipR+lomSRhNPMCWnPZPKN0KMiqfFuVI+mGgv+QG+n4qyTkd488q?= =?us-ascii?Q?wsF3WcVQ3BcLpBcWTtwo7PCxKyJz/ga2a8BAgX6cDLlf3XeOMLexylgSqQ96?= =?us-ascii?Q?bIV/l7KEoQjjszPgNfRnkjVWD7TfQmdyP24UWOGm//More2pjQTc87WS7GPu?= =?us-ascii?Q?dlGI1ie4WMr0MLXHNCxFAezhRkalPKB/fXM2tX84zolw9vMKlBb9Gsxn5Z90?= =?us-ascii?Q?04+1mmu/JSI0oJJGEJhWBmzkgmcOsWb16HWIXhtxcciDZWPAjbBcGf64T1PE?= =?us-ascii?Q?LD8rWGS+S++EsdNb51eiAOLTChfpOEewkIh2SM98UES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tvuQjbYPbXgX0y04216PHXgg0; 20:Pwf+Av3lQ3p2+dT6u/KBH8OoMCSqW/jK6XM0/zlJZls9TThSLKMfBr/UtKJj5tepT3kvut057dIQ1pGQnnaL4A47CJLXoMOpGUOQjGPAoV9QBF5RZh0Ond1at/o5asJCLUpEgSf2JV2cMyyoMMlZfIp2qpZZh0SjJz02d0SN/C4= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2018 10:24:45.3263 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c35f7ba4-ba57-40d7-3b80-08d58fdf225f 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 We were relying on the pinned screen object backup buffer to be destroyed when not used. But if we hold a copy of the atomic state, like when hibernating, the backup buffer might not be destroyed since it's refcounted by the atomic state. This causes us to hibernate with a buffer pinned in VRAM. Fix this by only having the buffer pinned when it is actually used by a screen object. Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c index 3b7bf7ca18b9..419185f60278 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c @@ -405,7 +405,11 @@ vmw_sou_primary_plane_cleanup_fb(struct drm_plane *plane, struct drm_plane_state *old_state) { struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); + struct drm_crtc *crtc = plane->state->crtc ? + plane->state->crtc : old_state->crtc; + if (vps->dmabuf) + vmw_dmabuf_unpin(vmw_priv(crtc->dev), vps->dmabuf, false); vmw_dmabuf_unreference(&vps->dmabuf); vps->dmabuf_size = 0; @@ -443,10 +447,17 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane, } size = new_state->crtc_w * new_state->crtc_h * 4; + dev_priv = vmw_priv(crtc->dev); if (vps->dmabuf) { - if (vps->dmabuf_size == size) - return 0; + if (vps->dmabuf_size == size) { + /* + * Note that this might temporarily up the pin-count + * to 2, until cleanup_fb() is called. + */ + return vmw_dmabuf_pin_in_vram(dev_priv, vps->dmabuf, + true); + } vmw_dmabuf_unreference(&vps->dmabuf); vps->dmabuf_size = 0; @@ -456,7 +467,6 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane, if (!vps->dmabuf) return -ENOMEM; - dev_priv = vmw_priv(crtc->dev); vmw_svga_enable(dev_priv); /* After we have alloced the backing store might not be able to @@ -467,13 +477,16 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane, &vmw_vram_ne_placement, false, &vmw_dmabuf_bo_free); vmw_overlay_resume_all(dev_priv); - - if (ret != 0) + if (ret) { vps->dmabuf = NULL; /* vmw_dmabuf_init frees on error */ - else - vps->dmabuf_size = size; + return ret; + } - return ret; + /* + * TTM already thinks the buffer is pinned, but make sure the + * pin_count is upped. + */ + return vmw_dmabuf_pin_in_vram(dev_priv, vps->dmabuf, true); }