From patchwork Fri Feb 9 07:30:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10208349 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 5C0E560247 for ; Fri, 9 Feb 2018 07:30:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44F14296F2 for ; Fri, 9 Feb 2018 07:30:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3994C29740; Fri, 9 Feb 2018 07:30:53 +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 60661296F2 for ; Fri, 9 Feb 2018 07:30:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFDEA6E673; Fri, 9 Feb 2018 07:30:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0044.outbound.protection.outlook.com [104.47.42.44]) by gabe.freedesktop.org (Postfix) with ESMTPS id 651FD6E673 for ; Fri, 9 Feb 2018 07:30:48 +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=ShP+mo7xl+YRlAAxd7sc9vp1+5qII0CIettkdCZ6WGs=; b=EJSdlQzkm3Kxn4e7VSAxCJk+cPuyXP8OMkPgOSk2wc6FWjIyfqy5J+mh+FiMT2bfsp8wfNtqyCm+QtU5UXziDHCAaJEo12aDHKo4+snc8eNO9+f+R7ywQ4boDz6PufGGZx6tfE9JmRl1xmn0aiVy06p2OXwmQ0KcMWyhsT1IVSo= Received: from DM5PR12CA0013.namprd12.prod.outlook.com (2603:10b6:4:1::23) by DM3PR1201MB0925.namprd12.prod.outlook.com (2a01:111:e400:5aaf::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.485.10; Fri, 9 Feb 2018 07:30:45 +0000 Received: from DM3NAM03FT024.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::209) by DM5PR12CA0013.outlook.office365.com (2603:10b6:4:1::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.485.10 via Frontend Transport; Fri, 9 Feb 2018 07:30:45 +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 SATLEXCHOV02.amd.com (165.204.84.17) by DM3NAM03FT024.mail.protection.outlook.com (10.152.82.182) 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; Fri, 9 Feb 2018 07:30:45 +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; Fri, 9 Feb 2018 01:30:44 -0600 From: Roger He To: Subject: [PATCH 2/3] drm/ttm: add input parameter force_alloc for ttm_bo_force_list_clean Date: Fri, 9 Feb 2018 15:30:18 +0800 Message-ID: <1518161419-27346-2-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518161419-27346-1-git-send-email-Hongbo.He@amd.com> References: <1518161419-27346-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)(39380400002)(346002)(2980300002)(428003)(189003)(199004)(316002)(48376002)(50466002)(76176011)(6666003)(104016004)(59450400001)(54906003)(36756003)(105586002)(51416003)(7696005)(47776003)(72206003)(68736007)(2906002)(53416004)(97736004)(478600001)(50226002)(81156014)(53936002)(8936002)(81166006)(2351001)(106466001)(4326008)(5660300001)(86362001)(16586007)(336011)(2950100002)(6916009)(77096007)(26005)(356003)(8676002)(186003)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR1201MB0925; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT024; 1:1efqI8lrAqM8/Il6937jiCnHdz5LIKeYCOXgnZbYbVi1daylNR704gf5xa7mSNRhgAPjrP8KXWe1nH/Zv2bWjn6Vm7Bg6ysrZJmJDp/sVXqA7I44DG07QEkhlGeF85Nn X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e50542ca-3b3e-4eba-2556-08d56f8f0897 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:DM3PR1201MB0925; X-Microsoft-Exchange-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k6xeScNDsdzC6WdA/3/3NBEd6CeDpxU53ZyNVY1Hxk+4h7wo10mTbbJtNyyOlz7+Qz/zJZcBrWUS+SXzw0rj3qZ2pevShpEb2U1ccNYXDl7nt5xHYB+lx4gb40nmbKolwdt1JW+iDxenZLinqeU0i9F2AAJEmCiymFvwVGUgySxdShfjdiyVa8gGpUHN+lb/OeWh77GraRlfzTcpxp3nMro9Kd8YeVFGSFbdVoG1Zf9BxPMF+YV//9rxtj9pVpS9ksi4M1d3QPia+Xn9oQB0cIg2MDZhcLcNHVeMWApoQZTiqW3B+Z86aPc9aE7O+PAwNQuMOZ7T0FvkWRxUI19zKSspjUKXe8UAPmDy8epBc8a8ZMrVl3xv1xpGGMLvTyeubkNdwZ1iZp2xbm0pmjLe0B+wfXQPJfKWfUX0NIRUBqkb/mFjmREoPur8b6LQ8+nodGOBtbkG7wFrRlqKeOV6v3kOpFe7q213/tcCE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93003095)(3231101)(2400082)(944501161)(3002001)(6055026)(6041288)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM3PR1201MB0925; BCL:0; PCL:0; RULEID:; SRVR:DM3PR1201MB0925; X-Microsoft-Exchange-Diagnostics: 1; DM3PR1201MB0925; 4:W4eaC3PKfmjHz8k473g3sr+IhEpBaxTrMAAiPEF+M9TInPhoZ1pHOu1HfL0yhjl4cXNUvGrtT+kW26kV9VfVIeFmCYPh544uGF2n+uUyOJFcoNM50M2l8Awq5hFEzxNly3UB8OwLINfgoz6lhj62AMlewQ6aEdi1eNoKC//E6BxEzqWi7oobTEPkjojHLSep1E6OUlHdsfbJxbe2ACWdaEFyjnXcUIKmjMJS3fhxb0PFeQGl3yDMWBMpGQh2G946sKflO9DfqZXcHrDIzAcZ/++eQaGRSyLLJFCLnaY2oQsBSOZ6PFic9riRTmzEk/TB X-Forefront-PRVS: 057859F9C5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM3PR1201MB0925; 23:OVxgaXahsShCb4Nd5U8ZTNZVcey7ostT+EvgVWq?= =?us-ascii?Q?LGOGKPVUK3yMy68XT9pr/vZ3WK40tc7BLlME6tl+4PhjcUxC+AtBaYX6qbgL?= =?us-ascii?Q?gHlnK6BASSGgiBhhw7iXlPy8jYx1tqoVbCHi37znbIPfAT0+UNeBJKFMucCb?= =?us-ascii?Q?PcecGIsLdQfz3TZFhAHFP8u9rkkB8NBQRaIPqD9tjQyTJDWUj6v6Ytuoqdlp?= =?us-ascii?Q?nuDMqisR0YyXxYeTNz8Lyf+dQMchZUgklOimLVUcNVBriLyYW8x38JEX399f?= =?us-ascii?Q?Q0p+FbJs2kfTgLLKdJCwZMYDYMJCrbfAFBZd3UqqbgyYzlDnootw7wX/PGXA?= =?us-ascii?Q?49g4kxXQ/KbKM97h24BsatgqZCeqP5jy37OntMAVm+aRVXcfAzQ8nm3WLN+y?= =?us-ascii?Q?bGd1Bpi3FcvwqyCLbs7CuZMmNF4qbSZQzerFhLKZh/AEXTxZnp0mUJ4p31o3?= =?us-ascii?Q?2NbjQQUWRm5dzcSt74dRhh7qNv9RyegeM2zBtwJO6Sbtc5/LwtufavynYPVT?= =?us-ascii?Q?qJmKQOH4jL/OXAaZBF8MCTCCUcuIvkjRwX2Owkf6sonq3xcxR239C0GnErOP?= =?us-ascii?Q?lMW2Z77ZRnnXjDj7Fj37rQ28oA+WIFsJRWrXf82EWcR+aPu7kBIFJgdmiu1K?= =?us-ascii?Q?ucShMyB11By7c06YlZvPHtZ/wQafi+/SrzJNzrIwRjsU2F7ykfvdBbKywLvH?= =?us-ascii?Q?eraifeB5XCczRfAwWPli63AuQS/YP5qEJzoHLMJkJjzH2gDawYd418PTQizW?= =?us-ascii?Q?y9jx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CCRFCme7i6mLRV+AyFD5sAMZNQMQ5O50vm+u3vb/MxsLO3qdmxYsJskq084lf5s06TStWs=; 7:vYc+lPUtLoJVAikuKgLvgMXV9V8C9CruIomYXp8KpskD08SctP8lpiJ7y6i89Gh9XBXOkjZia1WFvxzVR88pppbReB+8IEAXiUYOGPz6Tlb4lHOfkOhsSkxFkD5ibZ0WOqKl43Zihm3W7FjWnWvsTHa+afumqN/0u/xD+sqz2eLaZMpQjLJkmxBTA3+a0pKGaobx4hYUXW16sFhe6us7qKg6GDBVWzTofYqBfrb5w23V37I7gde3Xj5ldDe2eK3m SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM3PR1201MB0925; 20:z3KJpQAivI5NTb1wqnFv+Y25OWKzk7fIzw/UPAxYhRHnVLp0zVHPWxq+1molqZjBu1tpqK5U9f4jd9mM2NbtxEw5krDVzr+FWIurdnblvhWxDbhT3oKTrbMaXzFhOYNQRJUJASGOPKtEZTdm6ql1NnZu+sodFkaBho8xNtd43pwWpYj86NSOVoSnH8/0Ve9Qs1nKd6FChcl1vyMeEv32FVMIhfZl8VAd/D+F6n6qZgBD7eulx2biCE6G4akREgYn X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2018 07:30:45.5110 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e50542ca-3b3e-4eba-2556-08d56f8f0897 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: DM3PR1201MB0925 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 it is true, allocate TTM pages regardless of zone global memory account limit. For example suspend, We should avoid TTM memory allocate failure to lead to whole process fail. Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index a907311..685baad 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; @@ -1433,7 +1436,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, true); } EXPORT_SYMBOL(ttm_bo_evict_mm);