From patchwork Wed Dec 20 10:35:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10125423 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 3A9516019C for ; Wed, 20 Dec 2017 10:36:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 242FA29612 for ; Wed, 20 Dec 2017 10:36:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19263296CA; Wed, 20 Dec 2017 10:36:48 +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 A035329612 for ; Wed, 20 Dec 2017 10:36:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 169076E3C8; Wed, 20 Dec 2017 10:36:47 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0064.outbound.protection.outlook.com [104.47.37.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id BFE996E3C8; Wed, 20 Dec 2017 10:36:45 +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=ShuSZ/oPl+X0VfH6wNU08mEhna30SiTDaxo0TAFN0Cw=; b=msJe7f8bUTD/INqzd6aV1xalYOc3yIiUHXlLZw0eAtkxnZxMk2CKiWJLz9t0sOPC4SyLkQRqz0wXCOauF3xapvlPxKgfGRvUIfjMqd1gBIcWmJOMXjQ4AAiF6aeyHBR0Goi40amO7Uk//Tze78sErpdOrSGCQLOE14D8Impy7EA= Received: from BN4PR12CA0002.namprd12.prod.outlook.com (10.164.241.12) by MWHPR1201MB0063.namprd12.prod.outlook.com (10.174.98.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.323.15; Wed, 20 Dec 2017 10:36:43 +0000 Received: from CO1NAM03FT020.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::206) by BN4PR12CA0002.outlook.office365.com (2603:10b6:403:2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.239.5 via Frontend Transport; Wed, 20 Dec 2017 10:36:42 +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 CO1NAM03FT020.mail.protection.outlook.com (10.152.80.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.302.6 via Frontend Transport; Wed, 20 Dec 2017 10:36:41 +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; Wed, 20 Dec 2017 04:36:40 -0600 From: Roger He To: , Subject: [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check bo is allowable to evict or swapout Date: Wed, 20 Dec 2017 18:35:00 +0800 Message-ID: <1513766101-15993-6-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513766101-15993-1-git-send-email-Hongbo.He@amd.com> References: <1513766101-15993-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)(305945005)(105586002)(106466001)(36756003)(478600001)(7696005)(72206003)(2906002)(53936002)(50226002)(450100002)(51416003)(81156014)(8676002)(8936002)(81166006)(76176011)(5660300001)(104016004)(316002)(4326008)(68736007)(86362001)(50466002)(48376002)(356003)(16586007)(77096006)(59450400001)(47776003)(6666003)(97736004)(110136005)(2950100002)(53416004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0063; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT020; 1:1yd3mi7yCJLecn1ASjeyUrKHF82j0b0X6bTuI6kVFVwmdOX0MdAj9YPpZJTMhLyNw7XLVdVzUYSFBeQKnIAUOWzLPZqDkiGOTV25ThXBkyaaZ3MhWDudgRfK7YMPxHNG X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29e9548a-10ad-4951-29b7-08d547958f3a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307)(7153060); SRVR:MWHPR1201MB0063; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0063; 3:hWfFf6MyK7u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/atGUC/iNsQqL1IuPVANoLEEeMT5bgJTJvFvL8fJkpmQNd9zxb5qneYT1FU6IPc7IZzeLDxm6VOFSwKm5LefC9Z2FTCEffClTnLcjlIPlv3pNZqSqDm9tfhutluE0Yq3aYvnawr0QzIDUZ8Gk8FoNczzzvnBJ7Elm/DDBUQVTsxkGPW6iTZZsiWUdBLfpUnIqbBefKfMcrFdaS3ep115nCTAUfIB/0uzsBZGhMBt+w1VTQgI0wz9ocU4G7fsOrz1Eskcjp36G5YNAOpS5dzgBwjt7S97AqV69UrgfLOg5ipaHmw8wI3CgN0j8puc+KZhkEd51g+SQRvdvmOfp2Lr1f6cvo5l6YPNyagQQCYXoykECKN/7eWp4iygA55GRoMV8coDTgjMrx2Dqa0VmdOfAuQwvQL3C/DTczLNbdsg+2rWraC6UQnLQy/iy0IuiwPLjUIRrJg5arNPdQeZ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231023)(93006095)(93003095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR1201MB0063; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR1201MB0063; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0063; 4:Ig7RPUje73TNW5iFAmXTYPVhMJLtbBewVUp4Br83+sakXFM1mGvPTiCzckeKBFojVV/T/rhkIVEJzigXq0MEtkFkRv0nnkv2VBqAtUFtHm5Z61IuZ3jtyRzmLn7CW6tWLwC62rKvdcPY4lV4MYHd1KnVJd3S5eERNu463WL5bZuemb0n26bL2pbWAUL/8jvWRR3Z5tB111X2ffgmYgS5iZpk8kOzhXU3xGyhPd25u8klwCwBe48a+ZrwRPEaoGJxn7nEGA2S2z9ccZz6Rp0APp17DmMOTXi+1+gwn9DiAIHXN6rVgj+VxCqyroJHkAo0 X-Forefront-PRVS: 0527DFA348 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR1201MB0063; 23:WH1tL8OIPEGLVifhKieBMoE39qntJuFHYjbKUys?= =?us-ascii?Q?WKCifN6clXZKuBD6HIwi/w7cXBI3D9YvILkA/iZASSiplNuhjThQcID75sMq?= =?us-ascii?Q?HksZVcSJTxI2Ex+6xzOtQziFvDSHABeW8hbL+K6PF5b2WF/mGK/OaNqFdzcq?= =?us-ascii?Q?oVdURE/oC5VnSNQyYjrJkMLiKx2/AiI1cUAt71BK4n4vKJI1yS4Liv069UJo?= =?us-ascii?Q?nuBpmAuzw2i6srYVxhk/jEC5mq1G0+6YFqaiDavs/iU25XHVxKQzeI6o1dKi?= =?us-ascii?Q?YTZZpU5LO7VSyXjODI1U3XQlWTZV5eCGXUKI/YcFb8FO8TcR3DSxToKAeZSu?= =?us-ascii?Q?yWs3+iT03uXm6zH3x3pIsGzy9riGurX9FmTubkoaTI3jUpBkf/Awm4XqpWVS?= =?us-ascii?Q?TrnCEgbj1+DVngC57AjYff57WFXKKHwdEifIthGeyll97rgARSfD9O8E0JKp?= =?us-ascii?Q?/gwh0a9iJbIYWXAYK0EZZPoX8h9vB7/xviVxY1uWnnJpa1HFxuAfLBfv+ONc?= =?us-ascii?Q?HL+xTUZD7Y9Z5KACgZI2uVWEP/HjkZrL9UKA0bs27yVgh5y8R8qVZDLL+xmo?= =?us-ascii?Q?pHUUg2UBQj57tif7HSdjWeREsxcJ/kfnGkEePVcYocugSAGiAvTfrFHMq/IX?= =?us-ascii?Q?1bp6sCVQEV4VGsTzZVAm1EtjinpMQYdQEuhPq0Ch5nmftQfFIdPONHYSiW8K?= =?us-ascii?Q?uPsv+tTmhuckL5cZYlhwR1+s9ixgHYjlkLXV+7dMO01zQQ4L1xwusuBODsQx?= =?us-ascii?Q?nQfIDKh0aRshO2XXPNYUzbLNWJx7yCS4M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Pi82M5ZAKHG1yQxoPCRKdLPjMBL4LRwSit6yscke8ZU9U/f2MizMiMa0ZPeOaTIEUv0DzMrYGuc0Rm7hhyU7p/HuZZRuYIZbCMYd1dvJuonFcNTEN+rAdCrmrxo0mCmX72d6ucjPKrvPFbO9f04VIb4llpQ2p+oA4cx1kbJg/JUnRVFGhuNOcg0QmKywIAXEsTqRy/fe6ECpVppuPX2QTgUzApgf2qeEsP+hAj SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0063; 20:IFdSLJ4rJwlL+rVvXokIFznnupMRpXiZS1KYb8cetU99uTYWBcL/QatauPG/ofPYtCrgxr+IXIBeJY2Jw3KY495WVwgGJRC8XGh0KLHTPPHTohhqmc8UWQqJLEkNRksiGiqLgt0uKFvex9fcPkzWhjW2O/1rEP0m2Z2lOBrEti83BrCixRtXSJAkkSJoqmHgqCP2hav3Bsh64UwHzZmIa4ukcx+6NJVRNbxGbljSdtafz6GFIzB8/8AKZVvgSR+2 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Dec 2017 10:36:41.9555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 29e9548a-10ad-4951-29b7-08d547958f3a 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: MWHPR1201MB0063 Cc: Roger He 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 extract this function since eviction and swapout share same logic Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_bo.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index e7595b4..313925c 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -706,6 +706,23 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo, } EXPORT_SYMBOL(ttm_bo_eviction_valuable); +static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo, + struct ttm_operation_ctx *ctx, bool *locked) +{ + bool ret = false; + + *locked = false; + if (bo->resv == ctx->resv) { + if (ctx->allow_reserved_eviction || !list_empty(&bo->ddestroy)) + ret = true; + } else { + *locked = reservation_object_trylock(bo->resv); + ret = *locked; + } + + return ret; +} + static int ttm_mem_evict_first(struct ttm_bo_device *bdev, uint32_t mem_type, const struct ttm_place *place, @@ -721,21 +738,13 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev, spin_lock(&glob->lru_lock); for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) { list_for_each_entry(bo, &man->lru[i], lru) { - if (bo->resv == ctx->resv) { - if (!ctx->allow_reserved_eviction && - list_empty(&bo->ddestroy)) - continue; - } else { - locked = reservation_object_trylock(bo->resv); - if (!locked) - continue; - } + if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked)) + continue; if (place && !bdev->driver->eviction_valuable(bo, place)) { if (locked) reservation_object_unlock(bo->resv); - locked = false; continue; } break;