From patchwork Wed Nov 22 05:36:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "He, Hongbo" X-Patchwork-Id: 10069707 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 94C4C6038F for ; Wed, 22 Nov 2017 05:37:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FC0B286A8 for ; Wed, 22 Nov 2017 05:37:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8496F296C4; Wed, 22 Nov 2017 05:37:32 +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 68886286A8 for ; Wed, 22 Nov 2017 05:37:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB76989CD8; Wed, 22 Nov 2017 05:37:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0088.outbound.protection.outlook.com [104.47.33.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0776C89CD8; Wed, 22 Nov 2017 05:37:27 +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=uCVf7AIqI9Yyc7dAfrWqrodEfLinWzpixOKvmbTjfS4=; b=aESbJNB4cOGpzQyqYgwAl3+m5Fj4fiWOw4xrMai1G5f+Af//2fq/eaGTkgp0wQIMtdfc8lrn9xCkiXsOdkPMuuf3xISA9pczvmtflPQYHmzfumkrIck7/Q0E1FPCpzl/JIrC6R2K/mKerhFmZwMwW0DNqqRkDMulbsBCkCCMBLM= Received: from DM5PR12CA0069.namprd12.prod.outlook.com (10.175.83.159) 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.239.5; Wed, 22 Nov 2017 05:37:22 +0000 Received: from CO1NAM03FT024.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::208) by DM5PR12CA0069.outlook.office365.com (2603:10b6:3:103::31) 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, 22 Nov 2017 05:37:22 +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 CO1NAM03FT024.mail.protection.outlook.com (10.152.80.160) 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; Wed, 22 Nov 2017 05:37:22 +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; Tue, 21 Nov 2017 23:37:20 -0600 From: Roger He To: , Subject: [PATCH 2/4] drm/ttm: add page order support in ttm_pages_put Date: Wed, 22 Nov 2017 13:36:54 +0800 Message-ID: <1511329016-552-2-git-send-email-Hongbo.He@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511329016-552-1-git-send-email-Hongbo.He@amd.com> References: <1511329016-552-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)(346002)(376002)(39860400002)(2980300002)(428002)(189002)(199003)(48376002)(53936002)(2906002)(86362001)(575784001)(50226002)(4326008)(105586002)(5003940100001)(450100002)(106466001)(50466002)(8936002)(478600001)(101416001)(6666003)(72206003)(53416004)(104016004)(54906003)(110136005)(2950100002)(5660300001)(47776003)(50986999)(76176999)(316002)(16586007)(68736007)(97736004)(81156014)(81166006)(8676002)(189998001)(36756003)(356003)(305945005)(77096006); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR1201MB0063; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT024; 1:fmw96dYKv+cBFJSzaAch1W2oHfwG2gTap2B++E/WSL1ZMslY6ZsHft5NXWKBD1tdmjXaydQFurI6Imaf8c9YaKisqkoD1b9Z8XSFxwJK5Rw7MBPFTXOiwLaqCVcvwk/H X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2b59a5d9-c9bc-424a-51b9-08d5316b1ab4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600022)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603258); SRVR:MWHPR1201MB0063; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0063; 3:r6jQbcSb67fQyp/gZ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qgQxt9Wkw930mV+mjPbaJtOmGwyVI+Z81IVELEc/oobxx7wC+cYL1ZRbX6w3ATpshS/a+6lrW4JZrxReqCyOEeIRY9H6Z20jahBwrDCgham3vkwdfQqYqLjobxD6DyzPokxx/L92noqThRDowcnXeG+MZq5CVWne2hWjqeNfG0q3T8Ig2ZqJZUC6cEuUcPi0gYXJhm7DpTryhGJZsT2FcMxaH+nUqjPjUIZk/U/HJzBBNY1RBwPKgjJxc+lx6uQeE/jJ6aLmRZE3zBf35MsHm9Un9+l6nmQu8S0iSPJk9pFvWMX3PNseIMMqDLrxpPExW1qAz3ceOOlfz4L9CM9TOTeQHjo31B1Y4zPAlvy9x+DZiNAnG83QTQaPKN+zxkjItIXnfmS9kGqXRaHL/V/ijSXGp1iKlJyhKIeG0cNJat0B+0ON3Fag+ 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)(3002001)(10201501046)(93006095)(93003095)(3231022)(100000703101)(100105400095)(6055026)(6041248)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(20161123562025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR1201MB0063; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR1201MB0063; X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0063; 4:9/lnkJMXJYgOUKJBroCxODpXj/ZHxdYmJfarNuhtdDqCkF1L7Puuz3BRZy/HDkhg4vXjYn68YRHhXUxiyUi67hYttSrVCRwVWm9dPzSah6hbDoQ7SWsu9lc4D8DL+NRcaBLm8t0kPs5m7jBoZqGBYnUiXiouIE1fM1BRHERQBuWjGTASqCmY88WP4TfW96r3LcuSGSum+GMB3dyVKOpUOPehYfgUj+Ufro1z99KrqvPBjZ9RJf5dSxkCqCyfz+RFsC+oyIVsFI7+P2n2s3TD24T4s6Aq+X7ebtP+CHLcPhs2kl8XO1x+cWXAlIzO8T6K X-Forefront-PRVS: 0499DAF22A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR1201MB0063; 23:JiKkmytuU3NBlEaAU3XYElKhT6j+1GB6BMn0I/X?= =?us-ascii?Q?Mpwmhzuengjm781Teu0rQq4d4avlmRuHAjsAFgM5BCnc4U9e2R/DKPQyCuXI?= =?us-ascii?Q?y54PLy/EqPPc/cN3ycUcSuy5xoIhHqp1vwzFvaeM739KYPZw5MyQ7OGZH4Vb?= =?us-ascii?Q?mYATn4l62WiTLjpZ5NR2AENk4y1r8M5XjI8G6jGEYdBNVosSM1BijGnU2KoS?= =?us-ascii?Q?zfZspWpR3+7Jv6L6m1CBAB7Veefp4u/2xANQns+CnsQBhXQKDIfRS055ONhz?= =?us-ascii?Q?zO+3l9A6a+hrUgWORoXjz3juX+tWrUsHMuhpgN8qw5BbqkwmHjneMQ8YX+V2?= =?us-ascii?Q?H9PXoNQQufunkftrT4nxgci4iRXINQbMEWwY9DUHBz+xI9kO3Xz2Fhc9+a+X?= =?us-ascii?Q?DhdIEIuCWlAIqLynYVe9jDVGs0GvQ2EzXnbhcTjuY5UXsDc/0h6M/bHKKsy5?= =?us-ascii?Q?lCX+YBZZmZDD6Mxrj9pzor5VuBeyG8/9oGv9Fm7AIggWPKEwUb2Px4XOcuwO?= =?us-ascii?Q?WSKskl9SQWafUSqDpMAlOwE0751Q6a7RwyZKCCjhI+52xNtyPQEP+HMMvOmt?= =?us-ascii?Q?5uST25swk99/pSAqXJEYdaYO9/Z9hMif43KPWga48gUjfGMy9sFCSgRY1nDl?= =?us-ascii?Q?FVmABpr9kF7Uzr45bnW+OTNVmrWed8vLnjG/PDk652CMcmL1dZIdPYC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/mJ2nuJEKLG3/QC5iE=; 24:PQIZ/WAb11WkTAK5Imnajfw0OA59G56CZQZI33oDflfaoSxzYO5vcvO9ncFbwQFrr4M4+fn2yPl2BlheDkAvkXxe/CiD1rASvkGbZpGl13U=; 7:550l/Qt9L63KlEVAbgsnuA7SLLcql6nthizO/dYqInh4EdU/1gm3eYXdBpcj7appJKQTpTKPAU+dXZH5mTqcEQ2tGZjOeomCbnnS4ym4Y5pohsvjwT778jaKooli099GBTxOCFQQvLb+EwkXhHmeHhb5VLlLYeBi6cCOMt52N04GU967E8iC+2oQz2JaSa+K0luxSHj1inc1GfXbKNJQkcvtX0fHC8aWb/N057WyB3Qs0JjY1LI9s3MmagrrrHQy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR1201MB0063; 20:16VAAmku6CpDgKSOFXg812ONOW3QWLv2JxNQ5s6M5yP6bL4zGiOo0gaSgiEnsSeCKeI5jsI7T44NnRkyUykT+kK8fa/ovTdYJkn/YFspgjodZrOheAc1ovKy83+iCR8x1jN0yn5mVqTPzfmCMYQ2APzV8IMAmbWoek+pTO6Obim/6LalxVhNNpKMmrAU2nSPRU2A3P7Ta3bLDx6x6NRD0egt0pIJsc1LS5tP5j1TREQa7d2nUMqSKZNBO8vUlXOi X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Nov 2017 05:37:22.0204 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2b59a5d9-c9bc-424a-51b9-08d5316b1ab4 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 , Christian.Koenig@amd.com 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 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 0a0c653..de64209 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; + struct page *p; + 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 > 0) { + 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);