From patchwork Tue Feb 6 09:04:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10202513 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 9EDB6601A1 for ; Tue, 6 Feb 2018 09:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9762528ABB for ; Tue, 6 Feb 2018 09:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BA0A28AC4; Tue, 6 Feb 2018 09:06:54 +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 9FD1628ABB for ; Tue, 6 Feb 2018 09:06:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8AB8F89CA1; Tue, 6 Feb 2018 09:06:52 +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-co1nam03on0076.outbound.protection.outlook.com [104.47.40.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id 78DE86E08E; Tue, 6 Feb 2018 09:06:51 +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=QMS+tohJt6r0X4ezCXtMo+tqfcfYMzM6+//sB8TGWOM=; b=LYifvrWLEmiMAP07cLxfvEwqIwN6JS6B1JU8SBm4yVFOIceODvU5iBewZnO/9dp+1744cwd7bHxqmtv/UgJ1qqcZ7q9kHfcRJQz9Bje1OECoMYgz6rw9/O/AEqm4250B1xDuh55RI0GtTen9spOKX3nmxKhRpbj4pjHs9XQ/WJI= Received: from BN6PR1201CA0002.namprd12.prod.outlook.com (10.174.238.12) by BN6PR12MB1442.namprd12.prod.outlook.com (10.172.24.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.464.11; Tue, 6 Feb 2018 09:06:50 +0000 Received: from CO1NAM03FT040.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::200) by BN6PR1201CA0002.outlook.office365.com (2603:10b6:405:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.464.11 via Frontend Transport; Tue, 6 Feb 2018 09:06:49 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; shipmail.org; dkim=none (message not signed) header.d=none; shipmail.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 SATLEXCHOV02.amd.com (165.204.84.17) by CO1NAM03FT040.mail.protection.outlook.com (10.152.81.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.464.13 via Frontend Transport; Tue, 6 Feb 2018 09:06:49 +0000 Received: from roger-build-server.amd.com (10.34.1.3) by SATLEXCHOV02.amd.com (10.181.40.72) with Microsoft SMTP Server id 14.3.361.1; Tue, 6 Feb 2018 03:06:47 -0600 From: Roger He To: , Subject: [PATCH 5/5] drm/ttm: add input parameter allow_allo_anyway for ttm_bo_evict_mm Date: Tue, 6 Feb 2018 17:04:34 +0800 Message-ID: <1517907874-21248-6-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517907874-21248-1-git-send-email-Hongbo.He@amd.com> References: <1517907874-21248-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)(39860400002)(39380400002)(376002)(396003)(346002)(2980300002)(428003)(189003)(199004)(5890100001)(50226002)(72206003)(16586007)(8676002)(54906003)(81166006)(316002)(81156014)(478600001)(110136005)(8936002)(2906002)(53416004)(26005)(47776003)(356003)(77096007)(36756003)(50466002)(53936002)(105586002)(4326008)(48376002)(104016004)(305945005)(76176011)(68736007)(186003)(2950100002)(5660300001)(97736004)(6666003)(575784001)(86362001)(7696005)(106466001)(336011)(59450400001)(51416003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR12MB1442; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT040; 1:qQAKzxUWL1Cx/Oo/KLa9KDt0Z5q2jPqo3yOxGWQ1MQnJye/ezChLD+9iaCSfwiDd1xDdJE8mMAgOYqcsJ1qDMLN1UxRI746a5+28QG/4LcP5uWknvrbOzhU8+Si2SPPW X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc5e8061-dcaf-4dc1-99e2-08d56d40f4d0 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:BN6PR12MB1442; X-Microsoft-Exchange-Di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ef43ALLlsQsxcmJV3SxV6Vkwrq6tSz5iFimC4PH2ahpWUQDtVe+Qe4ef6tXehtdJ+QM+DnH8xIVdOfj1GH6HfO8MunEQjf76kOn6AsC8viZPuYEDP9uOByFhf83pUou418RK601ApUyJIW0aGu721NdtW8SsFzSp4Lk5HUx35qZBIAduXJglQppC5rvZ0II4/4uyMyyXtQu2tMGCVRnvb8EAlXoyEjI5gZhoI80rZCkEGMz3rPJhq8U3ygbTD/AOZv3wO+JiSTHUQcHBdGsSEZ0GMd87ppbwExAeVLq/2yAJo8WVfyxv5bH8nU0bOH/4kmBNwS2QciTn+RaM+kOh5n45O3EmV4tmRNtkqX9R/O9CWtxMu/+XQl3cKRMlOZYE1xkGNBAo2KfR76cBnxDsXtoXzVV4rZs6kIChAoZ5Ycfpng3KtCf9CZpYoxFbBQ1tp3dWV0WO1Vnk6VWlyHIPAJnIT+V96Tv+0H2C4 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)(93006095)(93003095)(10201501046)(3002001)(3231101)(2400082)(944501161)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:BN6PR12MB1442; BCL:0; PCL:0; RULEID:; SRVR:BN6PR12MB1442; X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1442; 4:YXz3gbAwBCFahhNJb+XnqWXeLE+jKz1g7CUZHzFPaj9wjwMaAdJ5L2yEqu4tcgEVO3k70wCshmBIhZAuYXuKb0i+sFqOkx99FuCtkzFZE+MDmalMbWDiQ6MZ7SaX8tJaMVeoJ3aPDSr/pfQ68+SqMPCWZnbJs7c6t5BrTjGr8phZ9XYgXTLzzJh7E6OlzZY2o4xqLUmyO7GkUUumZx6GqpdpKkBAks+l6mEjxbjfGVvQPHebPl2Mvzj8wp3wC62JTES913fyDCaP5PxHX1dljmYLQjgqeBGjVxpujEOno8XM6H/4i5oLQhN01YHCfl3q X-Forefront-PRVS: 0575F81B58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR12MB1442; 23:32NkzDqH761uKr+MxFh3S+Qa8e5nD35iTs+RHtNUw?= =?us-ascii?Q?TNYAPlj3ocAK9eZ5JfQiMCZhshzCkC7/89aAi4bbbWBBEEYXT99GALmYVI81?= =?us-ascii?Q?o9xm6uTL7cujKu+K7s49R4v/INcEI0T61FTcPMg/BaPJ9fqnSm8Db4woMaN1?= =?us-ascii?Q?2hg3Vj0tXs+kcKNaeM3Vua27gRORSHP315raaAvlPBfeeNuuvbe5ezFi8BGs?= =?us-ascii?Q?ZdNdeVlk5YXVnNYx0+u6taCw1jj2M8hRcbs684Ew67GNtmAhgcvIjPYI7vfR?= =?us-ascii?Q?1EkT0rdVWtmzHpws/oTCNlsMGazBdlUu36EKY9wOCxSIWGp34vPaSWW3qKGy?= =?us-ascii?Q?52UPPW0g/xfqyIfdKc8tCCPZsiqmD5dr8N8TYZm+Ilc5m+h/G/0waztHJrUY?= =?us-ascii?Q?+Iu5BFnQGaWYf0gD6vvBV6gQJz1diUUcwLKxXa1ByswEAzAhSvlR5nwq1T18?= =?us-ascii?Q?dvx//+tKzUepJcJR1CUbzYBtYiJChzUW2txw4t/qWnVeHgvxFw7tYumnlDaH?= =?us-ascii?Q?Wp27ztX7thdm5dRjwyQajJa+qrFu8WYbncrR9V6k5i+Ojl5hPIobZCxzph0a?= =?us-ascii?Q?6tPRDXIbfmYBie5tJ2PzF33Y0OWMQvj4MzeuDaChc7ug4B9eihVHw1AZH3FS?= =?us-ascii?Q?IUl1Nme3bMI4BSiReYg/kqgD01nwoZHZ22gbL80BXQI0AJxwqYNRY/ntAqtw?= =?us-ascii?Q?iEvOWqNJrU9NZmc08CvGaojKKORssTwnlSkX7S6Sl+FzV7AppEtSVKAjV5Zv?= =?us-ascii?Q?OA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Yq7eYfuk69oUZ4Ff6tbqTUEdUDIv5th2eMl9A3JMT9HUY+4oVd6b5zjoZ87iBSWW/L9XS7YH6rNLc=; 7:Q35gQFsb0Mbr1D/dK5w5TUTXFTM+yFcJrU2J8yXuxtwnV+hBKRp5KQfUpAzfTQ/UAlwVqKgA6B+Hhk8OdkFtAUl3kYJYOPYjW0CXacmP531cVFUi3mmNCMnky07hki0RO2pvo0bE7TuJDPsGVDm5nF4unELwo8ne+9nRxRdVcGmgGq14PL89ezsJNQsO1M+D2yRn5uLJvobjPGOWjkgpn4F1EB+xFBBK1kMQ57IpqsK6Eq9DTXyB45pc3fvxCy/f SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR12MB1442; 20:dl1zw9iSIGZaFJbm3DJG9KJ3DnSpJLNbSEdbebq+DeMICeOMXE/cGu64P1C/jzYykG4ssftydjPRNAuINdLx9kO6NKggKRgEF4RPneZ1pmv3kBFJSk8e08pLXKbZL3QVs4LzKUzXiSLiPVmwmlXnLX+e0I53UrHkV1cpA/0F06n4xKRuQltHbml3fJS4Gpwt0Un7TTVjoyePaRFcNltCY9gzOn/me0qa2dB0N4piVZeARel9912EpL1cj6X4sWg2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2018 09:06:49.2783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc5e8061-dcaf-4dc1-99e2-08d56d40f4d0 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=[SATLEXCHOV02.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1442 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 for it, allocate TTM pages regardless of zone global memory account limit. that is for another special case: suspend. doesn't care the zone global memory account limit for this case. 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 | 6 ++++-- 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 | 6 ++++-- 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, 37 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 850453e..44b0e2b 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..91f7b2f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -803,14 +803,16 @@ 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 allow_alloc_anyway) { /* 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, + allow_alloc_anyway); } 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..91d897e 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 allow_alloc_anyway); 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..aa1ece5 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 allow_alloc_anyway) { /* 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,8 @@ 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, + allow_alloc_anyway); } 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..1093112 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 allow_alloc_anyway); 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..1644505 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 allow_alloc_anyway) { - 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 (allow_alloc_anyway) + ttm_opt_ctx.flags = TTM_OPT_FLAG_ALLOW_ALLOC_ANYWAY; /* * 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 allow_allo_anyway) { 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, allow_allo_anyway); } 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 f7304c5..f97fb5f 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. + * @allow_alloc_anyway: 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 allow_alloc_anyway); /** * ttm_kmap_obj_virtual