From patchwork Thu Feb 8 09:06:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10206777 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 A58AA60327 for ; Thu, 8 Feb 2018 09:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A2CE29359 for ; Thu, 8 Feb 2018 09:08:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E8E629424; Thu, 8 Feb 2018 09:08:41 +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 9F55629359 for ; Thu, 8 Feb 2018 09:08:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D5EF96E515; Thu, 8 Feb 2018 09:06:47 +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-co1nam03on0045.outbound.protection.outlook.com [104.47.40.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9493E6E4FC; Thu, 8 Feb 2018 09:06:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0huRWHUWUsl8SmQ/e+T8NfJJS7Tn+IL4EPyUZ4R81HI=; b=QIljKjFqVCkMdYYvy7XKVQU/GB9EhSgOkAycJlEIvGn4phjnMjBUo8vIStOKImIj0a5gHHu406P6xxwf/Xf3RRTt209hR7WZ3EqgkMIsVojCmC5D+1LV9h2rKfejWmD2JQO0MbDTt8EMG6raTlIKwSWiFbLof8gD0wZfoyTndvg= Received: from BN6PR1201CA0013.namprd12.prod.outlook.com (10.174.238.23) by BN6PR12MB1618.namprd12.prod.outlook.com (10.172.23.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Thu, 8 Feb 2018 09:06:37 +0000 Received: from CO1NAM03FT039.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by BN6PR1201CA0013.outlook.office365.com (2603:10b6:405:4c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.464.11 via Frontend Transport; Thu, 8 Feb 2018 09:06:37 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT039.mail.protection.outlook.com (10.152.81.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.485.12 via Frontend Transport; Thu, 8 Feb 2018 09:06:36 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server id 14.3.361.1; Thu, 8 Feb 2018 03:06:28 -0600 From: Roger He To: , Subject: [PATCH 3/4] drm/ttm: add input parameter force_alloc for ttm_bo_evict_mm Date: Thu, 8 Feb 2018 17:06:00 +0800 Message-ID: <1518080761-12952-3-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518080761-12952-1-git-send-email-Hongbo.He@amd.com> References: <1518080761-12952-1-git-send-email-Hongbo.He@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(396003)(39860400002)(346002)(39380400002)(2980300002)(428003)(199004)(189003)(47776003)(450100002)(6666003)(478600001)(5660300001)(316002)(2950100002)(72206003)(16586007)(86362001)(336011)(51416003)(104016004)(76176011)(77096007)(7696005)(186003)(53936002)(4326008)(50466002)(48376002)(59450400001)(50226002)(81166006)(81156014)(106466001)(26005)(305945005)(5890100001)(356003)(105586002)(8936002)(97736004)(68736007)(36756003)(2906002)(110136005)(54906003)(53416004)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1618; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT039; 1:C7iqqmQSBJzPWnpmyxSQ4JLNwc8jEQtXGmAhXilg3fZPVIbn1HwUvePJcAKYdMPzuQDcyLbYOHWqZqb+0br6JllaQDQLlxhcXqXTmd8Ek+7Wh5KngNLf4HxVHlAYYP8C X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30d6e27f-8fe5-4ff2-c740-08d56ed341fb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:BN6PR12MB1618; X-Microsoft-Exchange-Diagnostics: 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Y/SARphlx+QaKNe47rBFjSb7p4KZauoVCMrF5pMIKdriVX0krZRkEDaXwG1a0LBZ1zsvv95x5kTGtD20afy54DKeytn9BQB4dnkD6K0w8Wdcb1S/6o/crgEEQcrL72fAsrUQhf0J+uQvjTKm6yo4NLr+xsvTc/oq8/rCxdKDW9X1AupKK8vgjobe4O1zizEO/lreTt9CVm42D+yEi7xZIz4X1ViwJMJU2H2KMESxZnlIiw8ug5JoomcJOPvNXqy2BTcE2hqXnEU2O10GSbS5ByOrZYI1m8z5e5bJj/jGFg6ku+OTwyEPsnMjptlvwoFfrIdbuLNCG71ZCXSXQTfQLUheABeDaas4IgUFEBTV6blY1Eg8YvNLKqM4i/1u1gzuwp36RDaZHdHbbn7glkBjPGzH+YDAxHE73yGik1QteTTEbd68NQldHwHhFzxItU9lz2lPfo7waDD9+oq0F X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(3231101)(2400082)(944501161)(3002001)(10201501046)(93006095)(93003095)(6055026)(6041288)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(6072148)(201708071742011); SRVR:BN6PR12MB1618; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1618; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1618; 4:8LKc8wIDuZ69Dbvx0Rd1M+7csKNQAVpIHpbs3Rzulp0AZ2Li7pL9CDgBeJQ39XyByIi37DKx/JkgiI7C50Ju3nxCCxo+90ikqyuAmtW7q3sIO4a7qgntqCmsQiKUAHMWkl2MytI/fDkFOxIuwFlp6F4Bduo+yX2uYHzlJ8GuhXGxWVw09a0eilIxOBtYTp7Agyw7xwMfKZsD3tI2QpGyoYTCDkfbLxgHd5b+Y36TKXGthAyqDUrFDoyE1jpNRlUdGastNbNX/bxxFk7PzQHsvF1T0Tp2mVYcOxccr+GrwZbfCDbUnrVdXAJtzeGz1RBL X-Forefront-PRVS: 0577AD41D6 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1618; 23:bowAg4kLjI4Kj7hoQeiUsHWxfgfMn/jNSh7OfxUCP?= =?us-ascii?Q?2M/nr8oR/JGb9/EHBwzAB0xu9Utg5Rh6D8hm8gxxcDvKeR0+wpWL/jX5sKXz?= =?us-ascii?Q?fi/hvtOzGUqowUpYo/Vfqro0ooxSpDXjpzabtb9f9YCrXgLkJ+biRpRCzqQQ?= =?us-ascii?Q?qCEU+M5yHQXap3VGsbISYq0efMD3C2GwKiEwg47XCPa/08xFC5V4bLApYO66?= =?us-ascii?Q?lNzy4e0otV7Ga2sj/L2Gmq0p2RFtWi60RFhmj3yogZ/ilsddZ2/8+uEARyL7?= =?us-ascii?Q?8i7TqRD8WwMjuYVNLXrpWaOh/canH4q6kM/BC6ogwjqPuhPoaL8Yregiv4MP?= =?us-ascii?Q?33WIgT7ErKQg54t/g45jytyRZCd3ZndR78cx9uX8z2RoEaVQ6cnn6PFM0Q4f?= =?us-ascii?Q?CfgK6BLpRUSsE0xFiG3qtNMqiylXslsrrnVZPu0WzfqAjhfbfkE8UPoMjwUj?= =?us-ascii?Q?6ToXrn2d/7UcvGmZZB06No1qU5ojGe8F+/Hy9Kd+hQazajEWGHRSbo4YwvY4?= =?us-ascii?Q?XGtLfmdNwNhyT1nF8wWwoe2JPTr0J/ersGgOb4dZlNkavWhblBomkUBTi6rn?= =?us-ascii?Q?CXjL+gYbTNS8+0RGuZVqJPp3rABCvDdZLLIXWFE9z75Mla349C3Ah32pjG9J?= =?us-ascii?Q?Q/9kC9KjN9BgmvrFd7wktiipiD5MEKMHhUttS1Yz0gEvny15CrENhjGLPfjF?= =?us-ascii?Q?SS0hgOX06oncJzbJRZsdXSM5HPuVD/nmBka8B4WLwNhZukifxUINWV5Kwj8u?= =?us-ascii?Q?HHT2ZIy0q2I5/H7HNCjlFkw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rOiyY2kgxSrLhbpg/kRSAxLsp2VqIradaDXANwYRkp9vN8hx7Lz0go9o+RSwNF+0cMsBxIKWSZHDH7L+Dwg=; 7:t+1R1cUtCV2k1I8kblv/b8YjoeDa1dWmhp1VVQddK7zakysn/Iq07+Wor63GiXfqDT1bIGm5Nt2yMF1HcMaBbgXTlohUrMRdB5CHut4q6Po3ybWUVGfJajM5isR6B9RAgPMFfvV9RwTBDoTmOV5sfcF9FbQzg5qPxAI3JzxChOzow3XdOSxs3woYM5/UkcfxGnw0peJNwsekj9LwdUpG0a4hn6JQ1de3sQfmfcXPEw9uVLYOUVCHYRAHbxjzU1Qs SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1618; 20:tObk/Ykrta5AffKSbpDK6wkwRLTFFOhR90R+CuzCxk4ax2vMmezLBciIIfXAxufm+MOh/eW8VH26LNg7VwSepMe5SiOC6rW3sHiTYmEmi8eMfQY9Q0ld5xRy+UDHuOShHK26rTMI74S3yKlLDh9hswai1KrQkZ8PDrn7b7d3J4uqPyXQUiaJP5zD8vEsGSjEyZcbYvbWOjU/kt7Z84+qLTncXL2q2W05uv5QwMDF++Hn0uVZhTJM/gMwU+pUCEVJ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2018 09:06:36.4467 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 30d6e27f-8fe5-4ff2-c740-08d56ed341fb X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1618 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: Roger He , Christian.Koenig@amd.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP if true, allocate TTM pages regardless of zone global memory account limit. For suspend, We should avoid TTM memory allocate failure then result in suspend failure. Signed-off-by: Roger He --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 2 +- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- drivers/gpu/drm/qxl/qxl_object.c | 4 ++-- drivers/gpu/drm/radeon/radeon_device.c | 6 +++--- drivers/gpu/drm/radeon/radeon_object.c | 5 +++-- drivers/gpu/drm/radeon/radeon_object.h | 3 ++- drivers/gpu/drm/ttm/ttm_bo.c | 16 ++++++++++------ drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 6 +++--- include/drm/ttm/ttm_bo_api.h | 5 ++++- 12 files changed, 34 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index ee76b46..59ee12c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -763,7 +763,7 @@ static int amdgpu_debugfs_evict_vram(struct seq_file *m, void *data) struct drm_device *dev = node->minor->dev; struct amdgpu_device *adev = dev->dev_private; - seq_printf(m, "(%d)\n", amdgpu_bo_evict_vram(adev)); + seq_printf(m, "(%d)\n", amdgpu_bo_evict_vram(adev, true)); return 0; } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index e3fa3d7..3c5f9ca 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2168,7 +2168,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) } } /* evict vram memory */ - amdgpu_bo_evict_vram(adev); + amdgpu_bo_evict_vram(adev, true); amdgpu_fence_driver_suspend(adev); @@ -2178,7 +2178,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool suspend, bool fbcon) * This second call to evict vram is to evict the gart page table * using the CPU. */ - amdgpu_bo_evict_vram(adev); + amdgpu_bo_evict_vram(adev, true); pci_save_state(dev->pdev); if (suspend) { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 0338ef6..db813f9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -803,14 +803,14 @@ int amdgpu_bo_unpin(struct amdgpu_bo *bo) return r; } -int amdgpu_bo_evict_vram(struct amdgpu_device *adev) +int amdgpu_bo_evict_vram(struct amdgpu_device *adev, bool force_alloc) { /* late 2.6.33 fix IGP hibernate - we need pm ops to do this correct */ if (0 && (adev->flags & AMD_IS_APU)) { /* Useless to evict on IGP chips */ return 0; } - return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM); + return ttm_bo_evict_mm(&adev->mman.bdev, TTM_PL_VRAM, force_alloc); } static const char *amdgpu_vram_names[] = { diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h index c2b02f5..6724cdc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h @@ -227,7 +227,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, u64 min_offset, u64 max_offset, u64 *gpu_addr); int amdgpu_bo_unpin(struct amdgpu_bo *bo); -int amdgpu_bo_evict_vram(struct amdgpu_device *adev); +int amdgpu_bo_evict_vram(struct amdgpu_device *adev, bool force_alloc); int amdgpu_bo_init(struct amdgpu_device *adev); void amdgpu_bo_fini(struct amdgpu_device *adev); int amdgpu_bo_fbdev_mmap(struct amdgpu_bo *bo, diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 8d4a5be..c9627ef 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -702,7 +702,7 @@ nouveau_do_suspend(struct drm_device *dev, bool runtime) } NV_DEBUG(drm, "evicting buffers...\n"); - ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM); + ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM, true); NV_DEBUG(drm, "waiting for kernel channels to go idle...\n"); if (drm->cechan) { diff --git a/drivers/gpu/drm/qxl/qxl_object.c b/drivers/gpu/drm/qxl/qxl_object.c index f6b80fe..d8d26c8 100644 --- a/drivers/gpu/drm/qxl/qxl_object.c +++ b/drivers/gpu/drm/qxl/qxl_object.c @@ -350,10 +350,10 @@ int qxl_bo_check_id(struct qxl_device *qdev, struct qxl_bo *bo) int qxl_surf_evict(struct qxl_device *qdev) { - return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV); + return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_PRIV, true); } int qxl_vram_evict(struct qxl_device *qdev) { - return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_VRAM); + return ttm_bo_evict_mm(&qdev->mman.bdev, TTM_PL_VRAM, true); } diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 8d3e3d2..c11ee06 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c @@ -1522,7 +1522,7 @@ void radeon_device_fini(struct radeon_device *rdev) DRM_INFO("radeon: finishing device.\n"); rdev->shutdown = true; /* evict vram memory */ - radeon_bo_evict_vram(rdev); + radeon_bo_evict_vram(rdev, true); radeon_fini(rdev); if (!pci_is_thunderbolt_attached(rdev->pdev)) vga_switcheroo_unregister_client(rdev->pdev); @@ -1607,7 +1607,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, } } /* evict vram memory */ - radeon_bo_evict_vram(rdev); + radeon_bo_evict_vram(rdev, true); /* wait for gpu to finish processing current batch */ for (i = 0; i < RADEON_NUM_RINGS; i++) { @@ -1626,7 +1626,7 @@ int radeon_suspend_kms(struct drm_device *dev, bool suspend, * This second call to evict vram is to evict the gart page table * using the CPU. */ - radeon_bo_evict_vram(rdev); + radeon_bo_evict_vram(rdev, true); radeon_agp_suspend(rdev); diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 15404af..99a9a45 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -420,7 +420,8 @@ int radeon_bo_unpin(struct radeon_bo *bo) return r; } -int radeon_bo_evict_vram(struct radeon_device *rdev) +int +radeon_bo_evict_vram(struct radeon_device *rdev, bool force_alloc) { /* late 2.6.33 fix IGP hibernate - we need pm ops to do this correct */ if (0 && (rdev->flags & RADEON_IS_IGP)) { @@ -428,7 +429,7 @@ int radeon_bo_evict_vram(struct radeon_device *rdev) /* Useless to evict on IGP chips */ return 0; } - return ttm_bo_evict_mm(&rdev->mman.bdev, TTM_PL_VRAM); + return ttm_bo_evict_mm(&rdev->mman.bdev, TTM_PL_VRAM, force_alloc); } void radeon_bo_force_delete(struct radeon_device *rdev) diff --git a/drivers/gpu/drm/radeon/radeon_object.h b/drivers/gpu/drm/radeon/radeon_object.h index 9ffd821..757ba88 100644 --- a/drivers/gpu/drm/radeon/radeon_object.h +++ b/drivers/gpu/drm/radeon/radeon_object.h @@ -136,7 +136,8 @@ extern int radeon_bo_pin(struct radeon_bo *bo, u32 domain, u64 *gpu_addr); extern int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset, u64 *gpu_addr); extern int radeon_bo_unpin(struct radeon_bo *bo); -extern int radeon_bo_evict_vram(struct radeon_device *rdev); +extern int radeon_bo_evict_vram(struct radeon_device *rdev, + bool force_alloc); extern void radeon_bo_force_delete(struct radeon_device *rdev); extern int radeon_bo_init(struct radeon_device *rdev); extern void radeon_bo_fini(struct radeon_device *rdev); diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index a907311..31d10f1 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1342,15 +1342,17 @@ int ttm_bo_create(struct ttm_bo_device *bdev, EXPORT_SYMBOL(ttm_bo_create); static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, - unsigned mem_type) + unsigned mem_type, bool force_alloc) { - struct ttm_operation_ctx ctx = { false, false }; + struct ttm_operation_ctx ttm_opt_ctx = { false, false }; struct ttm_mem_type_manager *man = &bdev->man[mem_type]; struct ttm_bo_global *glob = bdev->glob; struct dma_fence *fence; int ret; unsigned i; + if (force_alloc) + ttm_opt_ctx.flags = TTM_OPT_FLAG_FORCE_ALLOC; /* * Can't use standard list traversal since we're unlocking. */ @@ -1359,7 +1361,8 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { while (!list_empty(&man->lru[i])) { spin_unlock(&glob->lru_lock); - ret = ttm_mem_evict_first(bdev, mem_type, NULL, &ctx); + ret = ttm_mem_evict_first(bdev, mem_type, NULL, + &ttm_opt_ctx); if (ret) return ret; spin_lock(&glob->lru_lock); @@ -1403,7 +1406,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = 0; if (mem_type > 0) { - ret = ttm_bo_force_list_clean(bdev, mem_type); + ret = ttm_bo_force_list_clean(bdev, mem_type, true); if (ret) { pr_err("Cleanup eviction failed\n"); return ret; @@ -1419,7 +1422,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) } EXPORT_SYMBOL(ttm_bo_clean_mm); -int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) +int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type, + bool force_alloc) { struct ttm_mem_type_manager *man = &bdev->man[mem_type]; @@ -1433,7 +1437,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) return 0; } - return ttm_bo_force_list_clean(bdev, mem_type); + return ttm_bo_force_list_clean(bdev, mem_type, force_alloc); } EXPORT_SYMBOL(ttm_bo_evict_mm); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 184340d..28f8e4f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -430,7 +430,7 @@ static int vmw_request_device(struct vmw_private *dev_priv) if (dev_priv->cman) vmw_cmdbuf_remove_pool(dev_priv->cman); if (dev_priv->has_mob) { - (void) ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB); + (void) ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB, true); vmw_otables_takedown(dev_priv); } if (dev_priv->cman) @@ -463,7 +463,7 @@ static void vmw_release_device_early(struct vmw_private *dev_priv) vmw_cmdbuf_remove_pool(dev_priv->cman); if (dev_priv->has_mob) { - ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB); + ttm_bo_evict_mm(&dev_priv->bdev, VMW_PL_MOB, true); vmw_otables_takedown(dev_priv); } } @@ -1342,7 +1342,7 @@ void vmw_svga_disable(struct vmw_private *dev_priv) if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) { dev_priv->bdev.man[TTM_PL_VRAM].use_type = false; spin_unlock(&dev_priv->svga_lock); - if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM)) + if (ttm_bo_evict_mm(&dev_priv->bdev, TTM_PL_VRAM, true)) DRM_ERROR("Failed evicting VRAM buffers.\n"); vmw_write(dev_priv, SVGA_REG_ENABLE, SVGA_REG_ENABLE_HIDE | diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 2142639..6b5db9c 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h @@ -636,6 +636,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type); * * @bdev: Pointer to a ttm_bo_device struct. * @mem_type: The memory type. + * @force_alloc: if true allow ttm pages allocation always + * regardless of zone memory account limit * * Evicts all buffers on the lru list of the memory type. * This is normally part of a VT switch or an @@ -649,7 +651,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type); * -ERESTARTSYS: The call was interrupted by a signal while waiting to * evict a buffer. */ -int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type); +int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type, + bool force_alloc); /** * ttm_kmap_obj_virtual