From patchwork Tue Nov 21 09:32:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10067855 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 9F177602B7 for ; Tue, 21 Nov 2017 09:33:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 905B928C55 for ; Tue, 21 Nov 2017 09:33:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83CBA28C86; Tue, 21 Nov 2017 09:33:49 +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 0F66B28C55 for ; Tue, 21 Nov 2017 09:33:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C21F6E3B4; Tue, 21 Nov 2017 09:33:48 +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-cys01nam02on0067.outbound.protection.outlook.com [104.47.37.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id E6F4F6E3B2; Tue, 21 Nov 2017 09:33:46 +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=clqlrz9d9+wutTz6/9vrSbCY8djgVGeIuT7uJpVlisM=; b=0eBmFiCHaHHSftm+FMgnBb7YDj3rCeTmbdBL130pg7+Rb8MxydyAQWFp5t3G8fHALDOidB36ROeIneIpw2MY8y2Ar9VJZ8IsSa45ORR2p2Nf4dKHPM/BmXcjE/EOBx3h922X6LEc04StO+KeI5ON1Np5t28tmcEVagsVxNImP8g= Received: from CY4PR1201CA0008.namprd12.prod.outlook.com (10.172.75.18) by BN6PR1201MB0050.namprd12.prod.outlook.com (10.174.114.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Tue, 21 Nov 2017 09:33:43 +0000 Received: from CO1NAM03FT062.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::205) by CY4PR1201CA0008.outlook.office365.com (2603:10b6:910:16::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.239.5 via Frontend Transport; Tue, 21 Nov 2017 09:33:43 +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 CO1NAM03FT062.mail.protection.outlook.com (10.152.81.50) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.239.4 via Frontend Transport; Tue, 21 Nov 2017 09:33:42 +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, 21 Nov 2017 03:33:41 -0600 From: Roger He To: , Subject: [PATCH 3/4] drm/ttm: add page order support in ttm_pages_put Date: Tue, 21 Nov 2017 17:32:21 +0800 Message-ID: <1511256742-5601-4-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511256742-5601-1-git-send-email-Hongbo.He@amd.com> References: <1511256742-5601-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)(6009001)(39860400002)(346002)(376002)(2980300002)(428002)(189002)(199003)(478600001)(47776003)(2906002)(101416001)(97736004)(81166006)(81156014)(8676002)(53416004)(36756003)(50466002)(68736007)(76176999)(48376002)(5003940100001)(4326008)(72206003)(53936002)(356003)(50986999)(86362001)(106466001)(6666003)(2950100002)(5660300001)(104016004)(110136005)(305945005)(50226002)(16586007)(8936002)(316002)(77096006)(450100002)(189998001)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR1201MB0050; H:SATLEXCHOV02.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT062; 1:gsiefxG/crZiC1kYJhl/Vt4WulmNArToWYs1IFS8XWo7RPxYC1psI5gK+Jxz+dmiynnM1mVmyzPl423xGJ70XhUy0sFXrS9OHdZ0E3f9fM9BPao1NYDkkv9GD9qD+Bxd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ad67191-aef4-4d7c-839e-08d530c2f4b2 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:BN6PR1201MB0050; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0050; 3:BwJRHqeqOiXDmYXoyv+bU8oC5ZCluzp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dLXRdaBbSmbWH0BtosJN8Hw3z9+Jl3tdlI7gQTajrzQRUz/6N5m/GnQSeew/JRjcbHYQyi3FOinjt/yw+U3U+DoAtLZomHnqGiKwWIhQGyTkI8keaN3m4Srxr0NML4ydkXxfxQyGmcihi/1jpWj2ei36mpvNKGelixjPHNKD0/cq1AEsSrpeC77bsCR7g2Zp1K+DiN6/fXtGzz06VB92KHiNvoca/CvRWqSwk2rfUyI0/KkS32Mz3B3FkgXrh9JOA7mPkDh0EnMC8EV3ga3Fe65qQT6Z52ZHPSiV8dYWu0e+eLMrFchx8UWljcotVhUxDAwrSRpmJIa9bzGMGJrkjHDgQ6GdSBdBlvE5YMKkgdE5TeXjnMOAXjGjQSgw7AbJQTTv9N6gms3udKHFXXfTum3RJ8ZCMOvTM8XWMDqRCnysx2 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93003095)(3002001)(3231022)(100000703101)(100105400095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123555025)(20161123558100)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR1201MB0050; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR1201MB0050; X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0050; 4:Rwedbs6t0KxL359xfy3SN9Yjk4vvP2xx2z1zYZM7BwMjtPr1xON/+qgJYS4htn/OYZDGJjOMslm/HcVrhOJW61e1JLWH2PsKsd1iAGa1q33c84WbZMkA6/SMrJDFHLVSC3vmmrBT/PWGlaHQHwG1pJBAOrqc/JcespPozfrENvjoIL+4Yp9L2wlvlmepaCuT59HztO5ifoFlcPb9u+vyjOIIrrXUorOa1dHRMCvAGhDea+UtWKH7ZKKNB2ZjI4kuSl5LXadi2bel2HNgueNEtY9pCV6cwTE/582a7Ti7XtCF8EMXRxY/Z150CfsxiaGL X-Forefront-PRVS: 049897979A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR1201MB0050; 23:wZRUHAwLTT4blCOJNE7hqlBDxChSTNKMQfjYqbs?= =?us-ascii?Q?xO2yhb8u6Ofpfh9TiZ9HPqMI1WWgCIvu4jM9eJO+GtcgE5UpsyHDS5DG/1wg?= =?us-ascii?Q?dcTamaCjBITF7+A2SpOotohBHvHSIdW1Y1NqSL2q/FLgD6nhmP0ZbvyrETf/?= =?us-ascii?Q?8MLvWc0wtp1M9OseStIlSjHvqyqlVbGN1VUmMH+NuqW45zZHffChkVb/8whV?= =?us-ascii?Q?AcgmtgryVGk1AizIy2xkb/Oe+nF08zWnVIerpeOdZ+m4IXGaqsZnyInT6wNv?= =?us-ascii?Q?o9J4MkoTjtFIJNQTaipXTsvKOlwzDv/zXAQGKv5PWq6g8kylUIhcidIeyqAp?= =?us-ascii?Q?Vw+h8UHg8KY3S8sfv3T8evUI/RgRaOx97BoC9hyNqt5z7iCjazoz9AX/QFqj?= =?us-ascii?Q?UhaThiLonTTOkT8CkrKXoBilpZ1AavHpXpu36FaRn2haZEKYq/xCFAzr0g0M?= =?us-ascii?Q?dd0+1xevvgObbs977OrOekokEp84DYM4rZ0z74Jd6+RqDB+bXOhwqThULAUU?= =?us-ascii?Q?gjG3Y7DgyYeDEyuVDKBjFZkdRwZFV+GDyM06H07UuZX0rxro2a13IjtWhVVm?= =?us-ascii?Q?CNyqgoc7Fe+nSS5X5+PpJvOiqaVTSxs1BKbB9Gxi8n3EEplFIaPxzheRSK5k?= =?us-ascii?Q?ZAQfPcrcUyBTLBsQC8bUIgxmNF7wPvqlym99N2JD1AkSAsySx7S1Fe/woun0?= =?us-asc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EpX6JNi/dc6N2E8hB0SW9M9TJVz447WprP8Dz0pgl3lu14LSonIbhbLytDWu+zB0=; 7:ahnFM1veL+S/z6JCven3HNeKBg18Nddc60VxA3tSUga4FLIi02fI3RenWaH3LzaoFOrKsscFgeU4y3h5P17Xonl/EWO/O76Z43Qx2WDGUsIIlb/Hcn6yM+oYZavorol008UiP/5ur1SRLsUulx0PDCO5LN1iBqiXpc37Xhesq0ogzwh8xkR05blVFCkCSl2AIHaTc0mD9eTzpATyOnKLQU9lTFqiZXcH2mY4eb8zWP+dHHw+XlFh5i+mxWGKF3fe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR1201MB0050; 20:NXcUeA7C02Z+r6ARmeifT9B7a9HPlq9KiT/noKqE96iIXYy88gNvcs46c9EwMr+tdHwFJPN8J9rrZkycidjuhVsKtdgio662Wifp6o6IdUWSpfLt8TGPMOT1sI2SLXY0Cz0SUjPP/brqrQ9r1o3UaNc3zY1N+fPmTdq6UNGoQPJVbCNINyxdSd6j1I7zSQNrWb6MTWz0xajcYrjSftgdwQ5063vGn8eyXQE61N+PCFrz+tJMIB6KuhcdYHvKI1P/ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2017 09:33:42.8046 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ad67191-aef4-4d7c-839e-08d530c2f4b2 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: BN6PR1201MB0050 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 Change-Id: Ia55b206d95812c5afcfd6cec29f580758d1f50f0 Signed-off-by: Roger He --- drivers/gpu/drm/ttm/ttm_page_alloc.c | 42 +++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 27b2402..90546fd 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c @@ -285,13 +285,39 @@ static struct ttm_page_pool *ttm_get_pool(int flags, bool huge, } /* set memory back to wb and free the pages. */ -static void ttm_pages_put(struct page *pages[], unsigned npages) +static void ttm_pages_put(struct page *pages[], unsigned npages, + unsigned int order) { - unsigned i; - if (set_pages_array_wb(pages, npages)) - pr_err("Failed to set %d pages to wb!\n", npages); - for (i = 0; i < npages; ++i) - __free_page(pages[i]); + struct page **pages_to_free = NULL; + struct page **pages_array = NULL; + struct page *p = NULL; + unsigned int i, j, pages_nr = 1 << order; + + if (order > 0) { + pages_to_free = kmalloc_array(pages_nr, sizeof(struct page *), + GFP_KERNEL); + if (!pages_to_free) { + pr_err("Failed to allocate memory for ttm pages put operation\n"); + return; + } + } + + for (i = 0; i < npages; ++i) { + if (order) { + p = pages[i]; + for (j = 0; j < pages_nr; ++j) + pages_to_free[j] = p++; + + pages_array = pages_to_free; + } else + pages_array = pages; + + if (set_pages_array_wb(pages_array, pages_nr)) + pr_err("Failed to set %d pages to wb!\n", pages_nr); + __free_pages(pages[i], order); + } + + kfree(pages_to_free); } static void ttm_pool_update_free_locked(struct ttm_page_pool *pool, @@ -354,7 +380,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, */ spin_unlock_irqrestore(&pool->lock, irq_flags); - ttm_pages_put(pages_to_free, freed_pages); + ttm_pages_put(pages_to_free, freed_pages, pool->order); if (likely(nr_free != FREE_ALL_PAGES)) nr_free -= freed_pages; @@ -389,7 +415,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, spin_unlock_irqrestore(&pool->lock, irq_flags); if (freed_pages) - ttm_pages_put(pages_to_free, freed_pages); + ttm_pages_put(pages_to_free, freed_pages, pool->order); out: if (pages_to_free != static_buf) kfree(pages_to_free);